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
10 #########################################################
11 # A few variables need to be set, here at the top.
12 # The script should not need any other customization.
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";
19 if [ -z "$EDITOR" ]; then EDITOR=vi; fi
22 #########################################################
25 # Options to make, when we compile
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";
39 while getopts ":Cm:Ph" opt; do
41 C ) COMPILE="";; # don't test compilation
42 m ) MAKEOPTS="$OPTARG";;
43 P ) PATCH="";; # don't build patch files
45 \? ) echo "Unknown option $opt"; usage; exit 1;;
48 shift $(($OPTIND - 1));
50 # Determine LyX version
52 VERSION=$(head configure.ac | grep AC_INIT | \
53 perl -e 'while (<>) {m/AC_INIT\(\[LyX\],\[([^,]+)\]/; print $1;}');
55 # Development release?
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";
70 echo "This is version $PKG_VERSION.";
71 echo -n "Ready to build source packages...";
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/";
79 $DEBUG rm -Rf "$BASE/lyx-build/";
80 $DEBUG mkdir "$BASE/lyx-build/";
81 $DEBUG cd "$BASE/lyx-build/";
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!";
90 echo "Packages created:";
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;
98 $DEBUG ln lyx-$PKG_VERSION.tar.{gz,xz} $BASE/ || exit 1;
100 echo -n "Ready to build signatures...";
103 $DEBUG gpg -b lyx-$VERSION.tar.gz
104 $DEBUG gpg -b lyx-$VERSION.tar.xz
106 echo "Signatures created:"
107 $DEBUG ln lyx-$VERSION.tar.*.sig $BASE;
109 if [ -n "$COMPILE" ]; then
110 echo -n "Ready to test compilation...";
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!";
122 $DEBUG ./configure --enable-build-type=rel --enable-qt5
124 if $DEBUG make $MAKEOPTS; then
125 echo "Compilation complete.";
126 echo -n "Ready to run LyX...";
128 $DEBUG src/lyx -userdir /tmp/lyx-test;
130 echo "Compilation errors!!";
135 if [ -z "$PATCH" ]; then
136 echo "Skipping patch files.";
140 LASTNUM=$(echo $PKG_VERSION | sed -e 's/.*\.//');
141 LAST=$((LASTNUM - 1));
142 FIRST=$(echo $PKG_VERSION | sed -e 's/[0-9]*$//');
146 if [ ! -d "$BASE/lyx-patch/" ]; then
147 $DEBUG mkdir "$BASE/lyx-patch/" || exit 1;
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.";
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!"
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.";
179 echo -n "Ready to make patch against $LAST...";
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...";
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;
196 if [ "$LASTNUM" = "1" ]; then
198 elif [ "$LASTNUM" = "2" ]; then
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...";
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
215 xz -zc $PATCH > $PATCH.xz
216 if [ -f $PATCH.xz.sig ]; then
219 $DEBUG gpg -b $PATCH.xz
221 echo -n "Patch and signatures created...";
222 ln $PATCH.gz $PATCH.gz.sig $PATCH.xz $PATCH.xz.sig $BASE;