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
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"; # stable
18 DEVDIR="/cvs/lyx/lyx-devel"; # devel
20 BRANCH=$(git status | head -n1 | sed -e 's/On branch //');
21 if [ $BRANCH == "master" ]; then
26 if [ -z "$EDITOR" ]; then EDITOR=vi; fi
29 #########################################################
32 # Options to make, when we compile
40 echo "lyx-build [-C] [-m MAKEARGS[ [-P]";
41 echo " -C: Do not test compilation";
42 echo " -m MAKEARGS: Arguments for make";
43 echo " -P: Do not build patch files";
46 while getopts ":Cm:Ph" opt; do
48 C ) COMPILE="";; # don't test compilation
49 m ) MAKEOPTS="$OPTARG";;
50 P ) PATCH="";; # don't build patch files
52 \? ) echo "Unknown option $opt"; usage; exit 1;;
55 shift $(($OPTIND - 1));
57 # Determine LyX version
59 VERSION=$(head configure.ac | grep AC_INIT | \
60 perl -e 'while (<>) {m/AC_INIT\(\[LyX\],\[([^,]+)\]/; print $1;}');
62 # Development release?
65 # If the version in configure.ac is e.g. "2.3.4dev", then we are building
66 # a development release.
67 PKG_VERSION=${VERSION%dev};
68 if [ "$VERSION" != "$PKG_VERSION" ]; then
69 CURHASH=$(git rev-parse HEAD);
70 # Eight chars should be enough
71 CURHASH=${CURHASH:0:8};
72 # New version is e.g. 2.3.4dev-12649348
73 PKG_VERSION="$VERSION-$CURHASH";
77 echo "This is version $PKG_VERSION.";
78 echo -n "Ready to build source packages...";
81 echo "Exporting clean tree...";
82 $DEBUG rm -Rf "$BASE/lyx-export/";
83 $DEBUG git checkout-index -a -f --prefix="$BASE/lyx-export/";
84 $DEBUG cd "$BASE/lyx-export/";
86 $DEBUG rm -Rf "$BASE/lyx-build/";
87 $DEBUG mkdir "$BASE/lyx-build/";
88 $DEBUG cd "$BASE/lyx-build/";
90 echo "Building distribution...";
91 $DEBUG "$BASE/lyx-export/configure" --enable-build-type=rel
92 if ! $DEBUG make dist; then
93 echo "Couldn't make distribution!";
97 echo "Packages created:";
99 # This will happen with development releases
100 if [ ! -f "lyx-$PKG_VERSION.tar.gz" ]; then
101 $DEBUG mv "lyx-$VERSION.tar.gz" "lyx-$PKG_VERSION.tar.gz" || exit 1;
102 $DEBUG mv "lyx-$VERSION.tar.xz" "lyx-$PKG_VERSION.tar.xz" || exit 1;
105 $DEBUG ln lyx-$PKG_VERSION.tar.{gz,xz} $BASE/ || exit 1;
107 echo -n "Ready to build signatures...";
110 $DEBUG gpg -b lyx-$PKG_VERSION.tar.gz
111 $DEBUG gpg -b lyx-$PKG_VERSION.tar.xz
113 echo "Signatures created:"
114 $DEBUG ln lyx-$VERSION.tar.*.sig $BASE;
116 if [ -n "$COMPILE" ]; then
117 echo -n "Ready to test compilation...";
120 $DEBUG rm -Rf "$BASE/lyx-test/";
121 $DEBUG mkdir "$BASE/lyx-test/";
122 $DEBUG cd "$BASE/lyx-test/";
123 $DEBUG tar -zxvf "$BASE/lyx-build/lyx-$VERSION.tar.gz";
124 if ! $DEBUG cd lyx-$PKG_VERSION; then
125 echo "Unable to enter build directory!";
129 $DEBUG ./configure --enable-build-type=rel --enable-qt5
131 if $DEBUG make $MAKEOPTS; then
132 echo "Compilation complete.";
133 echo -n "Ready to run LyX...";
135 $DEBUG src/lyx -userdir /tmp/lyx-test;
137 echo "Compilation errors!!";
142 if [ -z "$PATCH" ]; then
143 echo "Skipping patch files.";
147 LASTNUM=$(echo $PKG_VERSION | sed -e 's/.*\.//');
148 LAST=$((LASTNUM - 1));
149 FIRST=$(echo $PKG_VERSION | sed -e 's/[0-9]*$//');
153 if [ ! -d "$BASE/lyx-patch/" ]; then
154 $DEBUG mkdir "$BASE/lyx-patch/" || exit 1;
157 if [ ! -d "$BASE/lyx-patch/lyx-$LAST" ]; then
158 echo "Can't find directory for last version $LAST.";
159 echo "See if you can fix this in $BASE/lyx-patch/.";
160 echo "Try that, if you like, and then we'll continue.";
161 echo "We'll try to download from the LyX site if that does not work.";
164 if [ -z "$DEBUG" ]; then
165 if [ ! -d $BASE/lyx-patch/lyx-$LAST ]; then
166 echo "Will try to download from LyX site....";
167 pushd "$BASE/lyx-patch/";
168 wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz;
169 wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz.sig
170 gpg -q --verify lyx-$LAST.tar.gz.sig
171 if ! [ $? == 0 ]; then
172 echo "Signature wrong!"
175 rm lyx-$LAST.tar.gz.sig
176 tar -zxvf lyx-$LAST.tar.gz;
177 if [ ! -f lyx-$LAST.tar.gz ]; then
178 echo "Still unable to find directory for last version $LAST.";
186 echo -n "Ready to make patch against $LAST...";
189 $DEBUG cd "$BASE/lyx-patch/";
190 if [ -z "$DEBUG" ]; then
191 tar -zxvf "$BASE/lyx-build/lyx-$VERSION.tar.gz" >/dev/null;
192 diff -urN -x .svn -x version.cpp lyx-$LAST lyx-$PKG_VERSION > patch;
193 echo -n "Please check the patch...";
197 $DEBUG tar -zxvf "$BASE/lyx-build/lyx-$VERSION.tar.gz";
198 $DEBUG diff -urN -x .svn -x version.cpp lyx-$LAST lyx-$PKG_VERSION;
203 if [ "$LASTNUM" = "1" ]; then
205 elif [ "$LASTNUM" = "2" ]; then
208 NUM="$LASTNUM$NUMFIX";
209 if [ -z "$DEBUG" ]; then
210 cat "$BASE/lyx-export/development/tools/patch-preamble" | \
211 sed -e "s/VERSION/$PKG_VERSION/; s/ORIGINAL/$ORIGINAL/; s/LAST/$LAST/; s/NUM/$NUM/;" >patch-preamble;
212 echo -n "Please verify the patch preamble...";
214 $EDITOR patch-preamble;
215 PATCH="patch-$VERSION";
216 cat patch-preamble "$BASE/lyx-export/ANNOUNCE" patch >$PATCH;
217 gzip -c $PATCH > $PATCH.gz
218 if [ -f $PATCH.gz.sig ]; then
222 xz -zc $PATCH > $PATCH.xz
223 if [ -f $PATCH.xz.sig ]; then
226 $DEBUG gpg -b $PATCH.xz
228 echo -n "Patch and signatures created...";
229 ln $PATCH.gz $PATCH.gz.sig $PATCH.xz $PATCH.xz.sig $BASE;