summaryrefslogtreecommitdiff
path: root/packages/bddeb
blob: 7493298547065427e06f2367ad15a90980de5da2 (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
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh 

# Ensure we can find the setup.py file which
# should be at the root of the cloud-init tree
PKG_DIR=`pwd`
ROOT="$PKG_DIR/../"
if [ ! -e "$ROOT/setup.py" ]; then
    echo "No setup.py found at $ROOT"
    exit 1
fi
echo "Using root directory $ROOT for building your debian package"

# Ensure tempdir is cleaned and ready to go
TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXXX")
echo "With $TEMP_D as a temporary workspace"
rm -Rf "${TEMP_D}"; mkdir "${TEMP_D}"
set -e

# Ensure tempdir removed if breaks...
trap "rm -Rf '${TEMP_D}'" EXIT SIGINT SIGTERM

# Go to the root and start making a package!
cd $ROOT
files=$(bzr ls --versioned)
revno=$(bzr revno)
version=$(awk -F: \
   '$1 ~ /[0-9][.][0-9]+[.][0-9]+/ { print $1 ; exit(0); }' ChangeLog )

# Ensure that the version found in 'Changelog' is the same in the python 
# cloud-init version directory
py_version=$(python -c 'from cloudinit import version; import sys; \
sys.stdout.write(version.version_string())')

# Canonicalize the changelog version
ch_version=$(python -c "from distutils import version; import sys; \
sys.stdout.write(str(version.StrictVersion('$version')));")

if [ "$py_version" != "$ch_version" ]; then
    echo "Cloud-init python version $py_version" \
         " != changelog version $ch_version"
    echo "Please ensure they are the same!"
    exit 1
fi

mkdir "${TEMP_D}/cloud-init"
otar="$TEMP_D/cloud-init_$version~bzr${revno}.orig.tar.gz"
tar -czf - ${files} > "$otar"
tar -C "${TEMP_D}/cloud-init" -xzf - < "$otar"

if [ ! -d "${TEMP_D}/cloud-init/debian" ]; then
   rsync -a $PKG_DIR/debian.trunk/ "${TEMP_D}/cloud-init/debian"
fi

sed -i -e "s,VERSION,$version," -e "s,REVNO,bzr$revno," \
          "$TEMP_D/cloud-init/debian/changelog"

cd "${TEMP_D}/cloud-init"
debuild "$@"
debname="cloud-init_${version}~bzr${revno}-1_all.deb"
mv "../$debname" "$PKG_DIR"
echo "Wrote $debname to $PKG_DIR"