summaryrefslogtreecommitdiffstats
path: root/debian/get-orig-source.sh
blob: 0a48accd3cf254c891bb90a395faa712f26fc434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh

set -ex

if [ $# -ne 2 ]; then
  echo "Error: 2 parameters are required."
  exit 1
fi

if [ "$1" != "--upstream-version" ]; then
  echo "Error: First parameter needs to be --upstream-version."
  exit 1
fi

UPSTREAM_VERSION=$2
ORIG_TARBALL=`readlink -e ../`/VBoxGuestAdditions_${UPSTREAM_VERSION}.iso

ORGDIR=`pwd`

cd `dirname ${ORIG_TARBALL}`
if ! wget -O - http://download.virtualbox.org/virtualbox/${UPSTREAM_VERSION}/SHA256SUMS | grep iso | sha256sum -c --strict -; then
  echo "Error: checksum doesn't match."
  exit 1
fi
cd ${ORGDIR}

PACKAGE_NAME=`awk '/^Source: / { print $2 }' debian/control`

if [ -z "${PACKAGE_NAME}" ]; then
  echo "Error: couldn't determine package name."
  exit 1
fi

TMP=`mktemp -d`

if [ -z "${TMP}" ]; then
  echo "Error: couldn't create a tmp dir."
  exit 1
fi

trap 'rm -r ${TMP}' EXIT

mkdir ${TMP}/${PACKAGE_NAME}-${UPSTREAM_VERSION}
mv ${ORIG_TARBALL} ${TMP}/${PACKAGE_NAME}-${UPSTREAM_VERSION}/
cd ${TMP}
tar cJf ${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.xz ${PACKAGE_NAME}-${UPSTREAM_VERSION}
mv ${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.xz ${ORGDIR}/../
cd ${ORGDIR}

echo "Done, now you can run:"
echo "gbp import-orig ../${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.xz"