]> git.lyx.org Git - lyx.git/blob - development/tools/lyx-build
Fix some issues found by the shellcheck script, and move an old
[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 # This has been checked with shellcheck. It complains about a lot
9 # of missing quotes, but we know, e.g., that $VERSION will not have
10 # spaces in it. RH chose not to fix that stuff.
11
12 # That said, the variables $BASE and $SRCDIR will cause problems if
13 # they have spaces in them, but RH did not fix that, either, since
14 # he thinks spaces in directory names are just a bad idea.
15
16 # A few variables need to be set, here at the top. 
17 #
18 # Where we will do our work
19 BASE="/cvs/lyx/lyx-release";
20 # Where our git repository lives
21 SRCDIR="/cvs/lyx/lyx-20";
22 # editor 
23 if [ -z "$EDITOR" ]; then EDITOR=vi; fi
24 # Options to make, when we compile
25 MAKEOPTS="-j4";
26
27 # Determine LyX version
28 cd $SRCDIR/
29 VERSION=$(head configure.ac | grep AC_INIT | perl -e 'while (<>) {m/AC_INIT\(LyX,([^,]+)/; print $1;}');
30
31 echo "This is version $VERSION.";
32 echo -n "Ready to build source packages...";
33 read
34
35 echo "Exporting clean tree...";
36 rm -Rf $BASE/lyx-export/
37 git checkout-index -a -f --prefix=$BASE/lyx-export/
38 cd $BASE/lyx-export/
39 ./autogen.sh
40 rm -Rf $BASE/lyx-build/
41 mkdir $BASE/lyx-build/
42 cd $BASE/lyx-build/
43
44 echo "Building distribution...";
45 $BASE/lyx-export/configure --enable-build-type=rel
46 if ! make lyxdist; then
47   echo "Couldn't make distribution!";
48   exit 1;
49 fi
50
51 echo "Packages created:";
52 cp -v lyx-$VERSION.tar.{gz,xz} $BASE;
53
54 echo -n "Ready to build signatures...";
55 read
56
57 gpg -b lyx-$VERSION.tar.gz
58 gpg -b lyx-$VERSION.tar.xz
59
60 echo "Signatures created:"
61 cp -v lyx-$VERSION.tar.*.sig $BASE;
62
63 echo -n "Ready to test compilation...";
64 read
65
66 rm -Rf $BASE/lyx-test/
67 mkdir $BASE/lyx-test/
68 cd $BASE/lyx-test/
69 tar -zxvf $BASE/lyx-build/lyx-$VERSION.tar.gz >/dev/null
70 if ! cd lyx-$VERSION; then
71   echo "Unable to enter build directory!";
72   exit 1;
73 fi
74
75 ./configure --enable-build-type=rel
76
77 if make $MAKEOPTS; then
78   echo "Compilation complete.";
79   echo -n "Ready to run LyX...";
80   read
81   src/lyx -userdir /tmp/lyx-test
82 else
83   echo "Compilation errors!!";
84   exit 1;
85 fi
86
87 LASTNUM=$(echo $VERSION | sed -e 's/.*\.//');
88 LAST=$((LASTNUM - 1));
89 FIRST=$(echo $VERSION | sed -e 's/[0-9]*$//');
90 ORIGINAL=${FIRST}0;
91 LAST=$FIRST$LAST;
92
93 if [ ! -d "$BASE/lyx-patch/" ]; then
94         mkdir "$BASE/lyx-patch/" || exit 1;
95 fi
96
97 if [ ! -d "$BASE/lyx-patch/lyx-$LAST" ]; then 
98   echo "Can't find directory for last version $LAST.";
99   echo "See if you can fix this in $BASE/lyx-patch/.";
100   echo "Try that, if you like, and then we'll continue.";
101   echo "We'll try to download from the LyX site if that does not work.";
102   read;
103
104   if [ ! -d "$BASE/lyx-patch/lyx-$LAST" ]; then 
105     echo "Will try to download from LyX site....";
106     pushd $BASE/lyx-patch/;
107     wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz;
108     tar -zxvf lyx-$LAST.tar.gz;
109     if [ ! -f lyx-$LAST.tar.gz ]; then
110       echo "Still unable to find directory for last version $LAST.";
111       exit 1;
112     fi
113     popd;
114   fi
115 fi
116
117 echo -n "Ready to make patch against $LAST...";
118 read
119
120 cd $BASE/lyx-patch/;
121 tar -zxvf $BASE/lyx-build/lyx-$VERSION.tar.gz >/dev/null;
122
123 diff -urN -x .svn -x version.cpp lyx-$LAST lyx-$VERSION > patch
124
125 echo -n "Please check the patch...";
126 read
127 $EDITOR patch;
128
129 NUMFIX="th";
130 if [ "$LASTNUM" = "1" ]; then
131   NUMFIX="st";
132 elif [ "$LASTNUM" = "2" ]; then
133   NUMFIX="nd";
134 fi
135 NUM="$LASTNUM$NUMFIX";
136 cat $BASE/lyx-export/development/tools/patch-preamble | \
137 sed -e "s/VERSION/$VERSION/; s/ORIGINAL/$ORIGINAL/; s/LAST/$LAST/; s/NUM/$NUM/;" >patch-preamble;
138 echo -n "Please verify the patch preamble...";
139 read
140 $EDITOR patch-preamble;
141
142 PATCH="patch-$VERSION";
143 cat patch-preamble $BASE/lyx-export/ANNOUNCE patch >$PATCH;
144 gzip -c $PATCH > $PATCH.gz
145 if [ -f $PATCH.gz.sig ]; then
146   rm $PATCH.gz.sig;
147 fi
148 gpg -b $PATCH.gz
149 xz -zc $PATCH > $PATCH.xz
150 if [ -f $PATCH.xz.sig ]; then
151         rm $PATCH.xz.sig;
152 fi
153 gpg -b $PATCH.xz
154
155 echo -n "Patch and signatures created...";
156 cp -v $PATCH.gz $PATCH.gz.sig $PATCH.xz $PATCH.xz.sig $BASE;
157
158