]> git.lyx.org Git - features.git/blob - development/tools/lyx-build
typo
[features.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 package
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 | \
53         perl -e 'while (<>) {m/AC_INIT\(\[LyX\],\[([^,]+)\]/; print $1;}');
54
55 # Development release?
56 DEVEL_RELEASE="";
57
58 # If the version in configure.ac is e.g. "2.3.4dev", then we are building
59 # a development release.
60 PKG_VERSION=${VERSION%dev};
61 if [ "$VERSION" != "$PKG_VERSION" ]; then
62         CURHASH=$(git rev-parse HEAD);
63         # Eight chars should be enough
64         CURHASH=${CURHASH:0:8};
65         # New version is e.g. 2.3.4dev-12649348
66         PKG_VERSION="$VERSION-$CURHASH";
67         PATCH="";
68 fi
69
70 echo "This is version $PKG_VERSION.";
71 echo -n "Ready to build source packages...";
72 read
73
74 echo "Exporting clean tree...";
75 $DEBUG rm -Rf "$BASE/lyx-export/";
76 $DEBUG git checkout-index -a -f --prefix="$BASE/lyx-export/";
77 $DEBUG cd "$BASE/lyx-export/";
78 $DEBUG ./autogen.sh
79 $DEBUG rm -Rf "$BASE/lyx-build/";
80 $DEBUG mkdir "$BASE/lyx-build/";
81 $DEBUG cd "$BASE/lyx-build/";
82
83 echo "Building distribution...";
84 $DEBUG "$BASE/lyx-export/configure" --enable-build-type=rel --enable-qt5
85 if ! $DEBUG make dist; then
86   echo "Couldn't make distribution!";
87   exit 1;
88 fi
89
90 echo "Packages created:";
91
92 # This will happen with development releases
93 if [ ! -f "lyx-$PKG_VERSION.tar.gz" ]; then
94         $DEBUG mv "lyx-$VERSION.tar.gz" "lyx-$PKG_VERSION.tar.gz" || exit 1;
95         $DEBUG mv "lyx-$VERSION.tar.xz" "lyx-$PKG_VERSION.tar.xz" || exit 1;
96 fi
97
98 $DEBUG ln lyx-$PKG_VERSION.tar.{gz,xz} $BASE/ || exit 1;
99
100 echo -n "Ready to build signatures...";
101 read
102
103 $DEBUG gpg -b lyx-$VERSION.tar.gz
104 $DEBUG gpg -b lyx-$VERSION.tar.xz
105
106 echo "Signatures created:"
107 $DEBUG ln lyx-$VERSION.tar.*.sig $BASE;
108
109 if [ -n "$COMPILE" ]; then
110         echo -n "Ready to test compilation...";
111         read
112
113         $DEBUG rm -Rf "$BASE/lyx-test/";
114         $DEBUG mkdir "$BASE/lyx-test/";
115         $DEBUG cd "$BASE/lyx-test/";
116         $DEBUG tar -zxvf "$BASE/lyx-build/lyx-$VERSION.tar.gz";
117         if ! $DEBUG cd lyx-$PKG_VERSION; then
118                 echo "Unable to enter build directory!";
119                 exit 1;
120         fi
121
122         $DEBUG ./configure --enable-build-type=rel --enable-qt5
123
124         if $DEBUG make $MAKEOPTS; then
125                 echo "Compilation complete.";
126                 echo -n "Ready to run LyX...";
127                 read;
128                 $DEBUG src/lyx -userdir /tmp/lyx-test;
129         else
130                 echo "Compilation errors!!";
131                 exit 1;
132         fi
133 fi
134
135 if [ -z "$PATCH" ]; then 
136         echo "Skipping patch files.";
137         exit 0; 
138 fi
139
140 LASTNUM=$(echo $PKG_VERSION | sed -e 's/.*\.//');
141 LAST=$((LASTNUM - 1));
142 FIRST=$(echo $PKG_VERSION | sed -e 's/[0-9]*$//');
143 ORIGINAL=${FIRST}0;
144 LAST=$FIRST$LAST;
145
146 if [ ! -d "$BASE/lyx-patch/" ]; then
147         $DEBUG mkdir "$BASE/lyx-patch/" || exit 1;
148 fi
149
150 if [ ! -d "$BASE/lyx-patch/lyx-$LAST" ]; then 
151     echo "Can't find directory for last version $LAST.";
152     echo "See if you can fix this in $BASE/lyx-patch/.";
153     echo "Try that, if you like, and then we'll continue.";
154     echo "We'll try to download from the LyX site if that does not work.";
155     read;
156
157     if [ -z "$DEBUG" ]; then
158         if [ ! -d $BASE/lyx-patch/lyx-$LAST ]; then 
159             echo "Will try to download from LyX site....";
160             pushd "$BASE/lyx-patch/";
161             wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz;
162             wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz.sig
163             gpg -q --verify lyx-$LAST.tar.gz.sig
164             if ! [ $? == 0 ]; then
165                 echo "Signature wrong!"
166                 exit 1;
167             fi
168             rm lyx-$LAST.tar.gz.sig
169             tar -zxvf lyx-$LAST.tar.gz;
170             if [ ! -f lyx-$LAST.tar.gz ]; then
171                 echo "Still unable to find directory for last version $LAST.";
172                 exit 1;
173             fi
174             $DEBUG popd;
175         fi
176     fi
177 fi
178
179 echo -n "Ready to make patch against $LAST...";
180 read
181
182 $DEBUG cd "$BASE/lyx-patch/";
183 if [ -z "$DEBUG" ]; then
184     tar -zxvf "$BASE/lyx-build/lyx-$VERSION.tar.gz" >/dev/null;
185     diff -urN -x .svn -x version.cpp lyx-$LAST lyx-$PKG_VERSION > patch;
186     echo -n "Please check the patch...";
187     read;
188     $EDITOR patch;
189 else
190     $DEBUG tar -zxvf "$BASE/lyx-build/lyx-$VERSION.tar.gz";
191     $DEBUG diff -urN -x .svn -x version.cpp lyx-$LAST lyx-$PKG_VERSION;
192 fi
193
194
195 NUMFIX="th";
196 if [ "$LASTNUM" = "1" ]; then
197   NUMFIX="st";
198 elif [ "$LASTNUM" = "2" ]; then
199   NUMFIX="nd";
200 fi
201 NUM="$LASTNUM$NUMFIX";
202 if [ -z "$DEBUG" ]; then
203     cat "$BASE/lyx-export/development/tools/patch-preamble" | \
204     sed -e "s/VERSION/$PKG_VERSION/; s/ORIGINAL/$ORIGINAL/; s/LAST/$LAST/; s/NUM/$NUM/;" >patch-preamble;
205     echo -n "Please verify the patch preamble...";
206     read
207     $EDITOR patch-preamble;
208     PATCH="patch-$VERSION";
209     cat patch-preamble "$BASE/lyx-export/ANNOUNCE" patch >$PATCH;
210     gzip -c $PATCH > $PATCH.gz
211     if [ -f $PATCH.gz.sig ]; then
212         rm $PATCH.gz.sig;
213     fi
214     gpg -b $PATCH.gz
215     xz -zc $PATCH > $PATCH.xz
216     if [ -f $PATCH.xz.sig ]; then
217         rm $PATCH.xz.sig;
218     fi
219     $DEBUG gpg -b $PATCH.xz
220
221     echo -n "Patch and signatures created...";
222     ln $PATCH.gz $PATCH.gz.sig $PATCH.xz $PATCH.xz.sig $BASE;
223 fi