-
Notifications
You must be signed in to change notification settings - Fork 0
/
python2deb.sh
60 lines (47 loc) · 1.41 KB
/
python2deb.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
#!/bin/bash
# This file is copied from
# https://github.com/jordansissel/python-packaging/blob/master/python2deb.sh
if [ "$1" = "-h" ] ; then
echo "Usage: $0 [package]"
echo "If no package is given, 'setup.py' is searched for in $PWD."
echo "If package given, we download with easy_install then build a package."
exit 0
fi
# debuild requires package names be lowercase.
if [ "0$#" -ne 0 ] ; then
easy_install --editable --build-directory . "$@"
cd $(ls -td */ | sed -ne '1p')
fi
if [ ! -r "setup.py" ] ; then
echo "No setup.py found in current directory ($PWD)"
exit 1
fi
if [ ! -z "$PATCHES" ] ; then
sh $PATCHES
fi
# I know, this is pretty crappy, but it's quicker than monkeypatching or
# extending distutils.
ed setup.py << ED_IS_AWESOME
/^ *setup *(/i
import pipes
def setup(**kwds):
for k in kwds:
print "%s=%s" % (k, pipes.quote(str(kwds[k])))
if "requires" in kwds:
print "requires=%s" % pipes.quote((", ".join(["python-%s" % x for x in kwds["requires"]])))
.
w hacked_setup.py
q
ED_IS_AWESOME
eval "$(python hacked_setup.py)"
if [ -z "$name" -o -z "$version" ] ; then
echo "Unable to find name, version, etc..."
exit 1
fi
set -e
set -x
name=$(echo "$name" | tr A-Z a-z)
release="$(date +%Y%m%d.%H%M%S)"
dh_make -s -n -c blank -e $USER -p "python-${name}_${version}-${release}" < /dev/null
sed -i -e "/Depends:.*$requires/! { s/^Depends: .*/&, $requires/ }" debian/control
debuild -us -uc