-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmake-deb.sh
executable file
·88 lines (65 loc) · 2.17 KB
/
make-deb.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash -e
unset CDPATH
if [ -d debian ]; then
rm -rf debian
fi
mkdir debian
VERSION="$(cat version)"
if ! (echo "$VERSION" | egrep -q '^[0-9]+\.[0-9]+$'); then
echo "Invalid version number $VERSION" 1>&2
exit 1
fi
if [ "$(hg branch)" = 'default' ]; then
REVISION="$(hg id -n)"
VERSION="${VERSION}-tip"
elif [ "$(hg branch)" = "$VERSION" ]; then
REVISION="$(hg id -n)"
fi
mkdir -p debian/DEBIAN
cat <<EOF > debian/DEBIAN/control
Package: hanzo-warc-tools
Version: ${VERSION}-${REVISION}
Maintainer: Stephen Jones <[email protected]>
Section: admin
Priority: optional
Architecture: all
Depends: python (>= 2.7)
Description: Suite of tools and libraries for manipulating warc files.
Provides commands for listing the contents of warc files and libraries for
manipulating warc files and http.
EOF
python setup.py install -q --no-compile --root "$PWD/debian" --install-layout=deb
mkdir -p debian/usr/share/doc/hanzo-warc-tools
echo "Copyright Hanzo Archives $(date +%Y)" > debian/usr/share/doc/hanzo-warc-tools/copyright
cp README debian/usr/share/doc/hanzo-warc-tools/
hg log --style=changelog | gzip -9 > debian/usr/share/doc/hanzo-warc-tools/changelog.gz
cat <<EOF | gzip -9 > debian/usr/share/doc/hanzo-warc-tools/changelog.Debian.gz
hanzo-warc-tools ($VERSION) Hanzo;
* Made debian style package
-- Stephen Jones <[email protected]> $(date +'%a, %d %h %Y %T %z')
EOF
cat <<EOF > debian/DEBIAN/postinst
#!/bin/bash -e
if which pycompile >/dev/null 2>&1; then
pycompile -p hanzo-warc-tools
fi
EOF
pushd debian
find usr/bin -type f -name '*.py' | (
while read SCRIPT; do
mv "$SCRIPT" "${SCRIPT%.py}"
chmod 755 "${SCRIPT%.py}"
done
)
md5sum $(find . -path ./DEBIAN -prune -o -type f -print) > DEBIAN/md5sums
find usr/lib -type f -exec chmod 644 '{}' ';'
find usr/share -type f -exec chmod 644 '{}' ';'
find DEBIAN -type f -exec chmod 644 '{}' ';'
find . -type d -exec chmod 755 '{}' ';'
chmod 755 DEBIAN/postinst
popd
fakeroot dpkg-deb --build debian .
lintian "hanzo-warc-tools_${VERSION}-${REVISION}_all.deb"
if [ -n "$1" ] && [ -d "$1" ] && [ -w "$1" ]; then
mv "hanzo-warc-tools_${VERSION}-${REVISION}_all.deb" "$1"
fi