Update to linux-4.17.13 to fix a network stack bug.
[linux_from_scratch.git] / editor-manual / release-script.sh
blob4e74d90d92bc73d33a8a5a46b6bd1c8208597ec1
1 #!/bin/bash
3 # This script is used to help prepare a release of the LFS Book.
4 # Original concept by Matt Burgess <matthew AT linuxfromscratch D0T org>
5 # Written by Archaic <archaic AT linuxfromscratch D0T org>
7 # To keep this script simple, assumptions were made that require this script to
8 # be run on belgarath.
10 # Exit Codes: 9 - make failed
11 # 19 - tar failed
12 # 29 - bzip2 failed
13 # 39 - xsltproc failed
15 # First setup a sane environment
17 set -e # Die on all errors
18 umask 022 # Set a sane environment
19 host=`hostname -s` # Ensure we are building on belg
20 date=`date +%s` # Used only for a unique identifier
21 norm="\e[0;39m" # Color codes are just for eye candy :)
22 grn="\e[01;32m"
23 white="\e[1;37m"
24 red="\e[01;31m"
25 yel="\e[1;33m"
27 export JAVA_HOME=/usr/jdk
28 export FOP_HOME=/usr/fop
29 export PATH=$PATH:$JAVA_HOME/bin:$FOP_HOME
31 #######################
32 # These are the biggies
33 stable=n # Is this the final release? 'y' or 'n' only
34 version=6.6-rc2 # x.y[.z-preX]
35 #######################
37 workarea=~/RELEASE-${version} # This is where you will do all your work
38 testarea=~/public_html/test # This is where you will view the product
39 book=LFS-BOOK-${version} # I'm lazy, hence the shorthand :)
40 group=lfswww # Which group will own the files after copying
42 # Where the books are to be copied to
43 view=/srv/www/www.linuxfromscratch.org/lfs/view
44 downloads=/srv/www/www.linuxfromscratch.org/lfs/downloads
45 archives=/srv/www/archives.linuxfromscratch.org/lfs-museum
47 if [ "$host" != "quantum" ]; then
48 echo -e "\n${red}*${white} This script must be run on ${red}quantum${white}."
49 exit 1
52 # Now prep the $workarea and $testarea
54 if [ -d "$workarea" ]; then
55 echo -e "\n${red}*${grn} $workarea${white} ${red}already exists${white}."
56 echo -e "${red}*${white} Moving to ${grn}$workarea-$date${white}...${norm}"
57 mv $workarea $workarea-$date
59 if [ -d "$testarea" ]; then
60 echo -e "\n${red}*${grn} $testarea${white} ${red}already exists${white}."
61 echo -e "${red}*${white} Moving to ${grn}$testarea-$date${white}...${norm}"
62 mv $testarea $testarea-$date
65 echo -e "\n${grn}*${white} Creating directory ${grn}$workarea${white}...${norm}"
66 install -d $workarea
67 cd $workarea
68 echo -e "${grn}*${white} Checking out the sources...${norm}"
69 svn export svn://svn.linuxfromscratch.org/LFS/tags/$version/BOOK original >/dev/null
70 cd $workarea/original
72 ##############
73 # BIG NOTE!!!!
74 ##############
76 # A bug in libxml2 (http://bugs.gnome.org/show_bug.cgi?id=309616) causes certain
77 # failures to still exit with a value of 0. To work around this, stderr must be
78 # allowed to output to screen and the person running this script must _WATCH_
79 # for errors. At this stage of the release cycle, there is no excuse for
80 # validation errors, but never assume they aren't there.
82 echo -e "${grn}*${white} Validating the sources...${norm}\n"
83 make validate > $workarea/validate.log || exit 9
85 # XML is the easiest, so let's do it first.
87 echo -e "${grn}*${white} Preparing ${grn}$book-XML${white}...${norm}"
88 cd $workarea
89 cp -a original $book-XML
90 tar cWf $book-XML.tar $book-XML || exit 19
91 bzip2 $book-XML.tar || exit 29
92 rm -rf $book-XML
93 echo -e "${grn}*${yel} Successful!${norm}\n"
95 # Next is regular HTML
97 echo -e "${grn}*${white} Preparing ${grn}$book-HTML${white}...${norm}"
98 cd $workarea/original
99 make BASEDIR=$workarea/$book-HTML >$workarea/html.log 2>&1 || exit 9
100 cp lfs-bootscripts-* udev-config-* ../
101 cd $workarea
102 tar cWf $book-HTML.tar $book-HTML || exit 19
103 bzip2 $book-HTML.tar || exit 29
104 rm -rf $book-HTML
105 echo -e "${grn}*${yel} Successful!${norm}\n"
107 # Next is NOCHUNKS
109 echo -e "${grn}*${white} Preparing ${grn}$book-NOCHUNKS${white}...${norm}"
110 cd $workarea/original
111 make BASEDIR=$workarea NOCHUNKS_OUTPUT=$book-NOCHUNKS.html nochunks \
112 >$workarea/nochunks.log 2>&1 || exit 9
113 cd $workarea
114 # Before bzipping the NOCHUNKS, create a text dump
115 #lynx -dump $book-NOCHUNKS.html >$book.txt
116 #sed -i.bak -e "/^ [0-9]\. /d" -e "/^ [0-9][0-9]\. /d" \
117 # -e "/^ [0-9][0-9][0-9]\. /d" -e "/^[0-9][0-9][0-9][0-9]\. /d" \
118 # $book.txt
119 #bzip2 $book.txt
120 bzip2 $book-NOCHUNKS.html || exit 29
121 rm -rf images
122 echo -e "${grn}*${yel} Successful!${norm}\n"
124 # Finally, the PDF
126 echo -e "${grn}*${white} Preparing ${grn}$book.pdf${white}...${norm}"
127 cd $workarea/original
128 make BASEDIR=$workarea PDF_OUTPUT=$book.pdf pdf >$workarea/pdf.log 2>&1 || exit 9
129 echo -e "${grn}*${yel} Successful!${norm}\n"
131 # Now that the books are finished, create the script that will copy all patches
132 # to their proper location.
134 echo -e "${grn}*${white} Creating ${grn}copy-lfs-patches.sh ${white}...${norm}"
135 cd $workarea/original
136 chmod u+x process-scripts.sh
137 ./process-scripts.sh
138 xsltproc --xinclude stylesheets/patcheslist.xsl index.xml \
139 >$workarea/copy-lfs-patches.sh || exit 39
141 # Now to create a temporary area inside the $workarea to inspect the compressed
142 # files
144 echo -e "${grn}*${white} Unpacking compressed files into ${grn}$testarea${white}...${norm}"
145 install -d -m 0755 $testarea
146 cd $testarea
147 tar jxf $workarea/$book-XML.tar.bz2
148 tar jxf $workarea/$book-HTML.tar.bz2
149 bzcat $workarea/$book-NOCHUNKS.html.bz2 >$book-NOCHUNKS.html
150 #bzcat $workarea/$book.txt.bz2 >$book.txt
151 cp $workarea/$book.pdf .
153 # Now to cleanup
154 echo -e "\n${grn}*${white} Cleaning up...${norm}"
155 cd $workarea
156 rm -rf original
158 cat >copy-book.sh << EOF
159 #!/bin/bash
161 ############################################
162 # DO NOT EDIT!! THIS IS A GENERATED SCRIPT!!
163 ############################################
165 # This script is used to copy already prepared LFS Books into their proper
166 # website locations. It is assumed the script and the books are in the current
167 # directory.
169 set -e # Die on all errors
170 umask 002 # Set a sane environment
171 stable=$stable # Don't touch this! It is set in release-script.sh
173 # First make sure everything is as it should be
175 groups | grep $group >/dev/null || { echo "You need to be a member of the lfswww group to run this script"; exit 1; }
177 if [ -d "$view/$version" ]; then
178 echo "The $view/$version directory already exists. Halting."
179 exit 1
182 if [ -d "$downloads/$version" ]; then
183 echo "The $downloads/$version directory already exists. Halting."
184 exit 1
187 if [ -d "$archives/$version" ]; then
188 echo "The $archives/$version directory already exists. Halting."
189 exit 1
192 # Create the new directories
194 install -dv -m 0775 -g $group $downloads/$version
195 echo
196 install -dv -m 0775 -g $group $archives/$version
197 echo
198 install -dv -m 0775 -g $group $view/$version
199 echo
201 # If this is a final release, recreate the needed symlinks
203 if [ "\$stable" = "y" ]; then
204 # The archive's stable link is fixed. Don't recreate it.
205 rm -f $view/stable
206 rm -f $downloads/stable
207 ln -sv $version $view/stable
208 echo
209 ln -sv $version $downloads/stable
210 echo
211 chgrp $group $view/stable $downloads/stable
214 # Copy the books
216 for dir in $downloads $archives; do
217 install -v -m 0664 -g $group $book-XML.tar.bz2 \$dir/$version
218 echo
219 install -v -m 0664 -g $group $book-HTML.tar.bz2 \$dir/$version
220 echo
221 install -v -m 0664 -g $group $book-NOCHUNKS.html.bz2 \$dir/$version
222 # echo
223 # install -v -m 0664 -g $group $book.txt.bz2 \$dir/$version
224 echo
225 install -v -m 0664 -g $group $book.pdf \$dir/$version
226 echo
227 install -v -m 0664 -g $group lfs-bootscripts-* udev-config-* \$dir/$version
228 done
230 # Now untar a copy in both archives and in view
232 # NOTE: Tar sucks. They change the names of arguments and I can't be arsed to
233 # put in code to check for the installed version. Therefore, this script will
234 # remain agnostic and do things the old-fashioned (and very inefficient) way.
235 # But hey, it works.
237 cd $archives/$version
238 tar jxf $book-HTML.tar.bz2
239 chmod -R g+w $book-HTML
240 chgrp -R $group $book-HTML
242 cd $view/$version
243 tar -xjf $downloads/$version/$book-HTML.tar.bz2 --strip-components=1
244 cd ..
245 chmod -R g+w $version
246 chgrp -R $group $version
248 exit 0
251 echo -e "\n${grn}*${white} All Finished!${norm}"
252 echo -e "\n${grn}* *${white} Please verify ${yel}all${white} log files in ${grn}$workarea${white}."
253 echo -e "\n${grn}* *${white} and ${yel}all${white} files in ${grn}$testarea${white}."
254 echo -e "\n${grn}* *${white} The ${yel}text ${white}version of the book specifically \
255 needs to be inspected to ensure that"
256 echo -e "${grn}* * ${yel}all${white} and ${yel}only${white} the desired stuff was removed (references).${norm}"
258 exit 0