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 | perl -e 'while (<>) {m/AC_INIT\(\[LyX\],\[([^,]+)\]/; print $1;}');
54 # Development release?
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";
69 echo "This is version $PKG_VERSION.";
70 echo -n "Ready to build source packages...";
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/
78 $DEBUG rm -Rf $BASE/lyx-build/
79 $DEBUG mkdir $BASE/lyx-build/
80 $DEBUG cd $BASE/lyx-build/
82 echo "Building distribution...";
83 $DEBUG $BASE/lyx-export/configure --enable-build-type=rel --enable-qt5
84 if ! $DEBUG make dist; then
85 echo "Couldn't make distribution!";
89 echo "Packages created:";
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;
97 $DEBUG ln lyx-$PKG_VERSION.tar.{gz,xz} $BASE/ || exit 1;
99 echo -n "Ready to build signatures...";
102 $DEBUG gpg -b lyx-$VERSION.tar.gz
103 $DEBUG gpg -b lyx-$VERSION.tar.xz
105 echo "Signatures created:"
106 $DEBUG ln lyx-$VERSION.tar.*.sig $BASE;
108 if [ -n "$COMPILE" ]; then
109 echo -n "Ready to test compilation...";
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!";
121 $DEBUG ./configure --enable-build-type=rel --enable-qt5
123 if $DEBUG make $MAKEOPTS; then
124 echo "Compilation complete.";
125 echo -n "Ready to run LyX...";
127 $DEBUG src/lyx -userdir /tmp/lyx-test;
129 echo "Compilation errors!!";
134 if [ -z "$PATCH" ]; then
135 echo "Skipping patch files.";
139 LASTNUM=$(echo $PKG_VERSION | sed -e 's/.*\.//');
140 LAST=$((LASTNUM - 1));
141 FIRST=$(echo $PKG_VERSION | sed -e 's/[0-9]*$//');
145 if [ ! -d "$BASE/lyx-patch/" ]; then
146 $DEBUG mkdir "$BASE/lyx-patch/" || exit 1;
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.";
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!"
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.";
178 echo -n "Ready to make patch against $LAST...";
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...";
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;
195 if [ "$LASTNUM" = "1" ]; then
197 elif [ "$LASTNUM" = "2" ]; then
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...";
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
214 xz -zc $PATCH > $PATCH.xz
215 if [ -f $PATCH.xz.sig ]; then
218 $DEBUG gpg -b $PATCH.xz
220 echo -n "Patch and signatures created...";
221 ln $PATCH.gz $PATCH.gz.sig $PATCH.xz $PATCH.xz.sig $BASE;