]> git.lyx.org Git - lyx.git/blob - development/tools/lyx-build
0dd9088763eeefefa4be5093400848ea01e1c666
[lyx.git] / development / tools / lyx-build
1 #!/bin/bash
2 # This script builds a maintainance LyX distribution according to 
3 # the procedure outlined at:
4 #   http://wiki.lyx.org/Devel/ReleaseProcedure
5 # It also includes several other tests, to make sure the packages
6 # works as it should.
7
8 #DEBUG=echo;
9
10 #########################################################
11 # A few variables need to be set, here at the top. 
12 # The script should not need any other customization.
13 #
14 # Where we will do our work
15 BASE="/cvs/lyx/lyx-release";
16 # Where our git repository lives
17 SRCDIR="/cvs/lyx/lyx-stable";
18 # editor 
19 if [ -z "$EDITOR" ]; then EDITOR=vi; fi
20
21
22 #########################################################
23 # Option variables
24
25 # Options to make, when we compile
26 MAKEOPTS="-j8";
27 # Compile?
28 COMPILE="YES";
29 # Make patch file?
30 PATCH="YES";
31
32 function usage() {
33 echo "lyx-build [-C] [-m MAKEARGS[ [-P]";
34 echo " -C: Do not test compilation";
35 echo " -m MAKEARGS: Arguments for make";
36 echo " -P: Do not build patch files";
37 }
38
39 while getopts ":Cm:Ph" opt; do
40   case $opt in
41     C )   COMPILE="";; # don't test compilation
42     m )   MAKEOPTS="$OPTARG";;
43     P )   PATCH="";; # don't build patch files
44     h )   usage; exit 0;;
45     \? )  echo "Unknown option $opt"; usage; exit 1;;
46   esac
47 done
48 shift $(($OPTIND - 1));
49
50 # Determine LyX version
51 cd $SRCDIR/
52 VERSION=$(head configure.ac | grep AC_INIT | perl -e 'while (<>) {m/AC_INIT\(LyX,([^,]+)/; print $1;}');
53
54 # Development release?
55 DEVEL_RELEASE="";
56
57 # If the version in configure.ac is e.g. "2.3.4dev", then we are building
58 # a development release.
59 PKG_VERSION=${VERSION%dev};
60 if [ "$VERSION" != "$PKG_VERSION" ]; then
61         CURHASH=$(git rev-parse HEAD);
62         # Eight chars should be enough
63         CURHASH=${CURHASH:0:8};
64         # New version is e.g. 2.3.4-12649348
65         PKG_VERSION="$VERSION-$CURHASH";
66         PATCH="";
67 fi
68
69 echo "This is version $PKG_VERSION.";
70 echo -n "Ready to build source packages...";
71 read
72
73 echo "Exporting clean tree...";
74 $DEBUG rm -Rf $BASE/lyx-export/
75 $DEBUG git checkout-index -a -f --prefix=$BASE/lyx-export/
76 $DEBUG cd $BASE/lyx-export/
77 $DEBUG ./autogen.sh
78 $DEBUG rm -Rf $BASE/lyx-build/
79 $DEBUG mkdir $BASE/lyx-build/
80 $DEBUG cd $BASE/lyx-build/
81
82 echo "Building distribution...";
83 $DEBUG $BASE/lyx-export/configure --enable-build-type=rel --enable-qt5
84 if ! $DEBUG make lyxdist; then
85   echo "Couldn't make distribution!";
86   exit 1;
87 fi
88
89 echo "Packages created:";
90
91 # This will happen with development releases
92 if [ ! -f "lyx-$PKG_VERSION.tar.gz" ]; then
93         $DEBUG mv "lyx-$VERSION.tar.gz" "lyx-$PKG_VERSION.tar.gz" || exit 1;
94         $DEBUG mv "lyx-$VERSION.tar.xz" "lyx-$PKG_VERSION.tar.xz" || exit 1;
95 fi
96
97 $DEBUG ln lyx-$PKG_VERSION.tar.{gz,xz} $BASE/ || exit 1;
98
99 echo -n "Ready to build signatures...";
100 read
101
102 $DEBUG gpg -b lyx-$VERSION.tar.gz
103 $DEBUG gpg -b lyx-$VERSION.tar.xz
104
105 echo "Signatures created:"
106 $DEBUG ln lyx-$VERSION.tar.*.sig $BASE;
107
108 if [ -n "$COMPILE" ]; then
109         echo -n "Ready to test compilation...";
110         read
111
112         $DEBUG rm -Rf $BASE/lyx-test/
113         $DEBUG mkdir $BASE/lyx-test/
114         $DEBUG cd $BASE/lyx-test/
115         $DEBUG tar -zxvf $BASE/lyx-build/lyx-$VERSION.tar.gz
116         if ! $DEBUG cd lyx-$PKG_VERSION; then
117                 echo "Unable to enter build directory!";
118                 exit 1;
119         fi
120
121         $DEBUG ./configure --enable-build-type=rel --enable-qt5
122
123         if $DEBUG make $MAKEOPTS; then
124                 echo "Compilation complete.";
125                 echo -n "Ready to run LyX...";
126                 read;
127                 $DEBUG src/lyx -userdir /tmp/lyx-test;
128         else
129                 echo "Compilation errors!!";
130                 exit 1;
131         fi
132 fi
133
134 if [ -z "$PATCH" ]; then 
135         echo "Skipping patch files.";
136         exit 0; 
137 fi
138
139 LASTNUM=$(echo $PKG_VERSION | sed -e 's/.*\.//');
140 LAST=$((LASTNUM - 1));
141 FIRST=$(echo $PKG_VERSION | sed -e 's/[0-9]*$//');
142 ORIGINAL=${FIRST}0;
143 LAST=$FIRST$LAST;
144
145 if [ ! -d "$BASE/lyx-patch/" ]; then
146         $DEBUG mkdir "$BASE/lyx-patch/" || exit 1;
147 fi
148
149 if [ ! -d $BASE/lyx-patch/lyx-$LAST ]; then 
150     echo "Can't find directory for last version $LAST.";
151     echo "See if you can fix this in $BASE/lyx-patch/.";
152     echo "Try that, if you like, and then we'll continue.";
153     echo "We'll try to download from the LyX site if that does not work.";
154     read;
155
156     if [ -z "$DEBUG" ]; then
157         if [ ! -d $BASE/lyx-patch/lyx-$LAST ]; then 
158             echo "Will try to download from LyX site....";
159             pushd $BASE/lyx-patch/;
160             wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz;
161             wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz.sig
162             gpg -q --verify lyx-$LAST.tar.gz.sig
163             if ! [ $? == 0 ]; then
164                 echo "Signature wrong!"
165                 exit 1;
166             fi
167             rm lyx-$LAST.tar.gz.sig
168             tar -zxvf lyx-$LAST.tar.gz;
169             if [ ! -f lyx-$LAST.tar.gz ]; then
170                 echo "Still unable to find directory for last version $LAST.";
171                 exit 1;
172             fi
173             $DEBUG popd;
174         fi
175     fi
176 fi
177
178 echo -n "Ready to make patch against $LAST...";
179 read
180
181 $DEBUG cd $BASE/lyx-patch/;
182 if [ -z "$DEBUG" ]; then
183     tar -zxvf $BASE/lyx-build/lyx-$VERSION.tar.gz >/dev/null;
184     diff -urN -x .svn -x version.cpp lyx-$LAST lyx-$PKG_VERSION > patch;
185     echo -n "Please check the patch...";
186     read;
187     $EDITOR patch;
188 else
189     $DEBUG tar -zxvf $BASE/lyx-build/lyx-$VERSION.tar.gz;
190     $DEBUG diff -urN -x .svn -x version.cpp lyx-$LAST lyx-$PKG_VERSION;
191 fi
192
193
194 NUMFIX="th";
195 if [ "$LASTNUM" = "1" ]; then
196   NUMFIX="st";
197 elif [ "$LASTNUM" = "2" ]; then
198   NUMFIX="nd";
199 fi
200 NUM="$LASTNUM$NUMFIX";
201 if [ -z "$DEBUG" ]; then
202     cat $BASE/lyx-export/development/tools/patch-preamble | \
203     sed -e "s/VERSION/$PKG_VERSION/; s/ORIGINAL/$ORIGINAL/; s/LAST/$LAST/; s/NUM/$NUM/;" >patch-preamble;
204     echo -n "Please verify the patch preamble...";
205     read
206     $EDITOR patch-preamble;
207     PATCH="patch-$VERSION";
208     cat patch-preamble $BASE/lyx-export/ANNOUNCE patch >$PATCH;
209     gzip -c $PATCH > $PATCH.gz
210     if [ -f $PATCH.gz.sig ]; then
211         rm $PATCH.gz.sig;
212     fi
213     gpg -b $PATCH.gz
214     xz -zc $PATCH > $PATCH.xz
215     if [ -f $PATCH.xz.sig ]; then
216         rm $PATCH.xz.sig;
217     fi
218     $DEBUG gpg -b $PATCH.xz
219
220     echo -n "Patch and signatures created...";
221     ln $PATCH.gz $PATCH.gz.sig $PATCH.xz $PATCH.xz.sig $BASE;
222 fi