1 |
#!/bin/bash |
2 |
|
3 |
#This script produced with the aid of "The Debian System concepts and techniques" By Martin F. Krafft |
4 |
# Its purpose is to produce a .deb for escript |
5 |
|
6 |
|
7 |
#A ~ in front of the version number indicates a pre-release and will sort earlier than versions without ~ |
8 |
SRCDIR=`pwd` |
9 |
WRAPPERNAME=escript |
10 |
#ALTWRAPPERNAME=finleypython |
11 |
OUTPUTROOT=$SRCDIR/build/package/lenny/escript |
12 |
LIBOUT=$OUTPUTROOT/usr/lib/escript |
13 |
BINOUT=$OUTPUTROOT/usr/bin |
14 |
PKGFILES=$SRCDIR/packaging/lenny |
15 |
|
16 |
# check to be sure we are running from the project root and that we look like the root user |
17 |
|
18 |
if [ `whoami` != 'root' ] |
19 |
then |
20 |
echo "Please execute this script under fakeroot." |
21 |
echo "fakeroot $0" |
22 |
exit 1 |
23 |
fi |
24 |
|
25 |
if [ ! -d escript/src ] |
26 |
then |
27 |
echo "Please execute this script from the root of the project" |
28 |
exit 3 |
29 |
fi |
30 |
|
31 |
if [ $# -lt 1 ] |
32 |
then |
33 |
echo "Usage: builddeb distro" |
34 |
exit 4 |
35 |
fi |
36 |
|
37 |
distro=$1 |
38 |
|
39 |
case "$distro" in |
40 |
"lenny" ) echo "" ;; |
41 |
"jaunty" ) echo "";; |
42 |
*) echo "Unknown distro $distro"; exit 4;; |
43 |
esac |
44 |
|
45 |
if [ -d $OUTPUTROOT ] |
46 |
then |
47 |
rm -rf $OUTPUTROOT || (echo "Error could not clean build area";exit 2) |
48 |
fi |
49 |
|
50 |
ARCHV=`uname -m` |
51 |
|
52 |
|
53 |
case "$ARCHV" in |
54 |
"i686" ) ARCH="i386";; |
55 |
"x86_64" ) ARCH="amd64";; |
56 |
*) echo "Unknown architecture $ARCHV. Unable to build package";exit 3;; |
57 |
esac |
58 |
|
59 |
#Check to ensure people are only building from clean checkouts |
60 |
#(Or at least a single consistent version). |
61 |
SVNREV=`svnversion` || (echo "Error - can't determine svn version"; exit 5) |
62 |
SVNERR=`echo $SVNREV | grep '[^[:digit:]]'` |
63 |
|
64 |
if [ -n "$SVNERR" ] |
65 |
then |
66 |
echo "Please build packages using a clean checkout." |
67 |
echo "Your version string shows $SVNREV" |
68 |
exit 6 |
69 |
fi |
70 |
|
71 |
echo "Reading package version from $PKGFILES/escript/DEBIAN/control" |
72 |
#Now get the package version |
73 |
VERSION=`grep "Version:" $PKGFILES/escript/DEBIAN/control | cut -f2 -d\ ` |
74 |
|
75 |
read -p "Build package with version $VERSION?(Y/N)" DOBUILD |
76 |
|
77 |
if [ "$DOBUILD" != 'Y' ] |
78 |
then |
79 |
echo "Aborting" |
80 |
exit 7 |
81 |
fi |
82 |
|
83 |
mkdir -p $OUTPUTROOT |
84 |
|
85 |
#First copy debian skeleton |
86 |
cp -r $PKGFILES/escript/* $OUTPUTROOT |
87 |
|
88 |
|
89 |
mkdir -p $OUTPUTROOT/usr/share/man/man1 |
90 |
|
91 |
#copy the man page |
92 |
cp $SRCDIR/doc/manpage/man1/$WRAPPERNAME.1 $OUTPUTROOT/usr/share/man/man1 |
93 |
#cp $SRCDIR/doc/manpage/man1/$WRAPPERNAME.1 $OUTPUTROOT/usr/share/man/man1/$ALTWRAPPERNAME.1 |
94 |
gzip $OUTPUTROOT/usr/share/man/man1/$WRAPPERNAME.1 |
95 |
#gzip $OUTPUTROOT/usr/share/man/man1/$ALTWRAPPERNAME.1 |
96 |
|
97 |
#copy the documentation |
98 |
cp $SRCDIR/release/doc/escript_examples.tar.gz $OUTPUTROOT/usr/share/doc/escript/ |
99 |
cp $SRCDIR/release/doc/install/install.pdf $OUTPUTROOT/usr/share/doc/escript |
100 |
cp $SRCDIR/release/doc/user/guide.pdf $OUTPUTROOT/usr/share/doc/escript |
101 |
cp -r $SRCDIR/release/doc/epydoc $OUTPUTROOT/usr/share/doc/escript/python_html |
102 |
|
103 |
mkdir -p $LIBOUT/lib |
104 |
mkdir -p $BINOUT |
105 |
#Should be using install here? |
106 |
cp $SRCDIR/lib/* $LIBOUT/lib |
107 |
cp -r $SRCDIR/esys $LIBOUT |
108 |
|
109 |
# We should be using the standard python |
110 |
export ESCRIPT_ROOT=/usr/lib/escript |
111 |
|
112 |
sed -e "s%STDLOCATION=0%STDLOCATION=1%" \ |
113 |
< $SRCDIR/bin/escript > $BINOUT/$WRAPPERNAME |
114 |
|
115 |
#end content from finley_wrapper_writer.sh |
116 |
|
117 |
cd $BINOUT |
118 |
#ln -s $WRAPPERNAME $ALTWRAPPERNAME |
119 |
cd $SRCDIR |
120 |
|
121 |
#Nuke any svn stuff that made it in |
122 |
find $OUTPUTROOT -name ".svn" | xargs rm -rf |
123 |
|
124 |
|
125 |
#Say what version of the debian packaging format we are using: |
126 |
#This is NOT the package version |
127 |
echo 2.0 > $OUTPUTROOT/../debian-binary |
128 |
|
129 |
#Check some permissions |
130 |
chmod og=rx $BINOUT/$WRAPPERNAME |
131 |
if [ -f $LIBOUT/pythonMPI ] |
132 |
then |
133 |
chmod og=rx $LIBOUT/pythonMPI |
134 |
fi |
135 |
|
136 |
cd $OUTPUTROOT |
137 |
|
138 |
cd usr/share/doc/escript/ |
139 |
gzip changelog.Debian |
140 |
|
141 |
cd $OUTPUTROOT |
142 |
#Fix directory perms |
143 |
chmod -R og-w . |
144 |
|
145 |
cd DEBIAN |
146 |
|
147 |
#Now we need to update the architecture |
148 |
mv control control.old |
149 |
sed -e "s%Architecture: i386%Architecture: $ARCH%" < control.old > control |
150 |
if [ $distro == "jaunty" ] |
151 |
then |
152 |
echo "Replacing python2.5 dependency with python2.6 for jaunty" |
153 |
rm control.old |
154 |
mv control control.old |
155 |
sed -e "s%Depends: python2.5%Depends: python2.6%" < control.old > control |
156 |
fi |
157 |
rm control.old |
158 |
|
159 |
tar czf ../../control.tar.gz . |
160 |
cd .. |
161 |
tar czf ../data.tar.gz usr |
162 |
cd .. |
163 |
|
164 |
ar rcu escript-$VERSION-$distro\_$ARCH.deb debian-binary control.tar.gz data.tar.gz |
165 |
|
166 |
|
167 |
|
168 |
|