source: common/libs/func_book_parser@ 2718053

ablfs-more legacy trunk
Last change on this file since 2718053 was 840b9ba, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Fix wrong VERSION variable for dev book

Using version from the ENTITY version line in gneral.ent is not
good anymore, since version is in version.ent for the dev book.
But it _is_ in general.ent for releases...
Use a different approach: take the profiled .xml, and use the
version in lsb-release.

  • Property mode set to 100644
File size: 12.0 KB
RevLine 
[fe30c61]1#!/bin/bash
2
3# $Id$
4
5#----------------------------#
6get_book() { #
7#----------------------------#
8 cd $JHALFSDIR
9
10 if [ -z $WORKING_COPY ] ; then
[de57ef4]11# Check for Subversion or git instead of just letting the script fail.
[de67016]12 test `type -p git` || eval "echo \"This feature requires Git.\"
13 exit 1"
[de57ef4]14
[fe30c61]15 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
16
17 case $PROGNAME in
[de67016]18 lfs) git_root="lfs.git" ;;
[d68eb1b]19 clfs*) ;;
[fe30c61]20 *) echo "BOOK not defined in function <get_book>"
21 exit 1 ;;
22 esac
23 # Grab a fresh book if it's missing, otherwise, update it from the
24 # repo. If we've already extracted the commands, move on to getting the
25 # sources.
[de67016]26 if [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
[605ea36]27 git clone $GIT/$git_root ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
[92b7cb8]28 if [ ! $TREE == "development" ]; then
[de57ef4]29 pushd ${PROGNAME}-$LFSVRS > /dev/null
[92b7cb8]30 echo "Checking out $LFSVRS at $PWD in $TREE"
[ad4ff97]31 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
[de57ef4]32 popd > /dev/null
[92b7cb8]33 fi
[1cf621b]34 else
35 cd ${PROGNAME}-$LFSVRS
[de67016]36 # If the repo is in "detached head" state, git pull fails, so get
37 # back first to master:
38 git checkout trunk >>$LOGDIR/$LOG 2>&1
39 git pull >>$LOGDIR/$LOG 2>&1
40 if [ ! $TREE == "development" ]; then
41 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
42 fi
[fe30c61]43 fi
[1cf621b]44 echo -ne "done\n"
[fe30c61]45
[de57ef4]46 else # Working copy
[fe30c61]47 echo -ne "Using $BOOK as book's sources ...\n"
48 fi
49}
50
51#----------------------------#
52extract_commands() { #
53#----------------------------#
54
55 cd $JHALFSDIR
[d68eb1b]56 # Clean
57 rm -rf ${PROGNAME}-commands
[fe30c61]58
[d68eb1b]59 # Extract the commands
60 echo -n "Extracting commands for"
[fe30c61]61 case ${PROGNAME} in
62 clfs)
[b11c10b]63 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]64 xsltproc --nonet \
65 --xinclude \
66 --stringparam method "$METHOD" \
67 --stringparam testsuite "$TEST" \
68 --stringparam bomb-testsuite "$BOMB_TEST" \
69 --stringparam timezone "$TIMEZONE" \
70 --stringparam page "$PAGE" \
71 --stringparam lang "$LANG" \
72 --stringparam sparc "$SPARC64_PROC" \
73 --stringparam x86 "$TARGET" \
74 --stringparam mips "$TARGET" \
75 -o ./${PROGNAME}-commands/ \
76 $XSL \
[c9598f2]77 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]78 ;;
79
80 clfs2)
[b11c10b]81 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]82 xsltproc --nonet \
83 --xinclude \
84 --stringparam timezone "$TIMEZONE" \
85 --stringparam page "$PAGE" \
86 --stringparam lang "$LANG" \
87 --output ./${PROGNAME}-commands/ \
88 $XSL \
[c9598f2]89 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]90 ;;
91
92 clfs3)
[b11c10b]93 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]94 xsltproc --nonet \
95 --xinclude \
96 --stringparam endian x$ENDIAN \
97 --stringparam timezone "$TIMEZONE" \
98 --stringparam page "$PAGE" \
99 --stringparam lang "$LANG" \
100 --output ./${PROGNAME}-commands/ \
101 $XSL \
[c9598f2]102 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]103 ;;
104
105 hlfs)
[139c34e]106 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
[c9598f2]107 xsltproc --nonet \
108 --xinclude \
[45f8a9c8]109 --stringparam model "$MODEL" \
110 --stringparam kernel "$KERNEL" \
111 --stringparam testsuite "$TEST" \
112 --stringparam bomb-testsuite "$BOMB_TEST" \
[c9598f2]113 --stringparam features \
114 x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
[45f8a9c8]115 --stringparam timezone "$TIMEZONE" \
116 --stringparam page "$PAGE" \
117 --stringparam lang "$LANG" \
118 --stringparam grsecurity_host "$GRSECURITY_HOST" \
[c9598f2]119 --output ./${PROGNAME}-commands/ \
120 $XSL \
121 $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]122 ;;
123 lfs)
[b11c10b]124 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
[13e52a5]125 # The scripts pages are xincluded by the book, so must
126 # be generated for running xsltproc
[f21dff8]127 pushd $BOOK > /dev/null
[66c09d0]128 if [ -f process-scripts.sh ]; then
[f0a31de]129 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
130 fi
[97b270f]131 # Recent git versions need version.ent to be generated
132 if [ -f git-version.sh ]; then
133 bash git-version.sh >> $LOGDIR/$LOG 2>&1
134 fi
[f21dff8]135 popd > /dev/null
[c9598f2]136
[13e52a5]137 # First profile the book, for revision and arch. Note that
138 # MULTIBLIB is set to "default" if pure 64 bit book. In this
139 # profiling on arch is useless, but does not hurt either.
[a4acb12]140 xsltproc --nonet \
141 --xinclude \
[13e52a5]142 --stringparam profile.revision "$INITSYS" \
143 --stringparam profile.arch "$MULTILIB" \
144 --output prbook.xml \
145 $BOOK/stylesheets/lfs-xsl/profile.xsl \
146 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
147
148 # Use the profiled book for generating the scriptlets
149 xsltproc --nonet \
[a4acb12]150 --stringparam testsuite "$TEST" \
151 --stringparam bomb-testsuite "$BOMB_TEST" \
[085435e]152 --stringparam ncurses5 "$NCURSES5" \
[dc7fd7b]153 --stringparam strip "$STRIP" \
154 --stringparam del-la-files "$DEL_LA_FILES" \
[a4acb12]155 --stringparam full-locale "$FULL_LOCALE" \
156 --stringparam timezone "$TIMEZONE" \
157 --stringparam page "$PAGE" \
158 --stringparam lang "$LANG" \
159 --stringparam pkgmngt "$PKGMNGT" \
160 --stringparam wrap-install "$WRAP_INSTALL" \
161 --stringparam hostname "$HOSTNAME" \
162 --stringparam interface "$INTERFACE" \
163 --stringparam ip "$IP_ADDR" \
164 --stringparam gateway "$GATEWAY" \
165 --stringparam prefix "$PREFIX" \
166 --stringparam broadcast "$BROADCAST" \
167 --stringparam domain "$DOMAIN" \
168 --stringparam nameserver1 "$DNS1" \
169 --stringparam nameserver2 "$DNS2" \
[3b43e17b]170 --stringparam font "$FONT" \
171 --stringparam fontmap "$FONTMAP" \
172 --stringparam unicode "$UNICODE" \
173 --stringparam keymap "$KEYMAP" \
174 --stringparam local "$LOCAL" \
175 --stringparam log-level "$LOG_LEVEL" \
[2758d94]176 --stringparam script-root "$SCRIPT_ROOT" \
[a4acb12]177 --output ./${PROGNAME}-commands/ \
178 $XSL \
[13e52a5]179 prbook.xml >> $LOGDIR/$LOG 2>&1
[f168be1]180# Remove flags requesting user action in some cases. Much easier here than
181# in the stylesheet...
[ebe1ba6]182 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
[fe30c61]183 ;;
[d68eb1b]184 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
[fe30c61]185 exit 1 ;;
186 esac
187
[b11c10b]188 echo "done"
[fe30c61]189
190 # Make the scripts executable.
191 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
192
193 # Create the packages file. We need it for proper Makefile creation
[840b9ba]194 # lfs does not use this anymore, but this is taken care in the
195 # function body
[fe30c61]196 create_package_list
[706e5bf]197 # On the other hand, lfs needs two auxiliary files
[13c475b]198 if [ "${PROGNAME}" = lfs ]; then
199 create_chroot_scripts
200 create_kernfs_scripts
201 fi
[fe30c61]202
[840b9ba]203 # we create the VERSION variable here. Should maybe go into its own
204 # function. But at this point we can use the profiled xml to get
205 # version from lfs-release in the lfs case.
206 case $PROGNAME in
207 clfs*)
208 VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
209 lfs)
210 VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
211 ;;
212 *)
213 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
214 esac
215
[fe30c61]216 # Done. Moving on...
217 get_sources
218}
219
220#----------------------------#
221create_package_list() { #
222#----------------------------#
223
224 # Create the packages file. We need it for proper Makefile creation
225 rm -f pkg_tarball_list
[b11c10b]226 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
[706e5bf]227 if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
[b11c10b]228 echo -n "... "
[fe30c61]229 case ${PROGNAME} in
[92b7cb8]230 clfs*)
[c9598f2]231 xsltproc --nonet --xinclude \
232 -o pkg_tarball_list \
233 packages.xsl \
[92b7cb8]234 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]235 ;;
236 hlfs)
[a4acb12]237 xsltproc --nonet --xinclude \
238 --stringparam model "$MODEL" \
239 --stringparam kernel "$KERNEL" \
240 --output pkg_tarball_list \
241 packages.xsl \
[fe30c61]242 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
243 ;;
244 lfs)
[706e5bf]245 # lfs does not use the package list anymore
[fe30c61]246 ;;
[92b7cb8]247 *)
[fe30c61]248 esac
249
[b11c10b]250 echo "done"
[fe30c61]251
252}
253
[d68eb1b]254#----------------------------#
[13c475b]255create_chroot_scripts() { #
[d68eb1b]256#----------------------------#
257
[13c475b]258 rm -rf chroot-scripts
[d68eb1b]259 echo -n "Creating chroot commands scripts from $BOOK"
260 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
261 echo -n "... "
262 case ${PROGNAME} in
263 clfs*)
264 xsltproc --nonet --xinclude \
265 -o chroot-scripts/ chroot.xsl \
266 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
267 ;;
268 hlfs)
269 xsltproc --nonet --xinclude \
270 -o chroot-scripts/ chroot.xsl \
271 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
272 ;;
273 lfs)
274 xsltproc --nonet --xinclude \
275 -o chroot-scripts/ chroot.xsl \
[04de9bc]276 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
[d68eb1b]277 ;;
278 *)
279 esac
280 echo "done"
281
282}
[13c475b]283
284#----------------------------#
285create_kernfs_scripts() { #
286#----------------------------#
287
288 rm -rf kernfs-scripts
289 mkdir kernfs-scripts
290 echo -n "Creating virtual kernel FS commands scripts from $BOOK"
291 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
292 echo -n "... "
293 case ${PROGNAME} in
294 clfs*)
295 xsltproc --nonet --xinclude \
296 -o kernfs-scripts/ kernfs.xsl \
297 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
298 ;;
299 hlfs)
300 xsltproc --nonet --xinclude \
301 -o kernfs-scripts/ kernfs.xsl \
302 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
303 ;;
304 lfs)
305 xsltproc --nonet \
306 -o kernfs-scripts/devices.sh kernfs.xsl \
[04de9bc]307 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
[13c475b]308 xsltproc --nonet \
309 -o kernfs-scripts/teardown.sh kernfs.xsl \
[ebe1ba6]310 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
[13c475b]311 ;;
312 *)
313 esac
314 echo "done"
315
316}
Note: See TracBrowser for help on using the repository browser.