source: common/libs/func_book_parser@ 756863b

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

LFS: Generate version.ent before profiling the book

  • Property mode set to 100644
File size: 11.9 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
56 case $PROGNAME in
[92b7cb8]57 clfs*)
[a1dd968]58 VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
[c9598f2]59 lfs)
60 if [ "$INITSYS" = "sysv" ] ; then
61 VERSION=$(grep 'ENTITY version ' $BOOK/general.ent| cut -d\" -f2)
62 else
63 VERSION=$(grep 'ENTITY versiond' $BOOK/general.ent| cut -d\" -f2)
64 fi
65 ;;
[fe30c61]66 *)
67 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
68 esac
69
[d68eb1b]70 # Clean
71 rm -rf ${PROGNAME}-commands
[fe30c61]72
[d68eb1b]73 # Extract the commands
74 echo -n "Extracting commands for"
[fe30c61]75 case ${PROGNAME} in
76 clfs)
[b11c10b]77 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]78 xsltproc --nonet \
79 --xinclude \
80 --stringparam method "$METHOD" \
81 --stringparam testsuite "$TEST" \
82 --stringparam bomb-testsuite "$BOMB_TEST" \
83 --stringparam timezone "$TIMEZONE" \
84 --stringparam page "$PAGE" \
85 --stringparam lang "$LANG" \
86 --stringparam sparc "$SPARC64_PROC" \
87 --stringparam x86 "$TARGET" \
88 --stringparam mips "$TARGET" \
89 -o ./${PROGNAME}-commands/ \
90 $XSL \
[c9598f2]91 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]92 ;;
93
94 clfs2)
[b11c10b]95 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]96 xsltproc --nonet \
97 --xinclude \
98 --stringparam timezone "$TIMEZONE" \
99 --stringparam page "$PAGE" \
100 --stringparam lang "$LANG" \
101 --output ./${PROGNAME}-commands/ \
102 $XSL \
[c9598f2]103 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]104 ;;
105
106 clfs3)
[b11c10b]107 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]108 xsltproc --nonet \
109 --xinclude \
110 --stringparam endian x$ENDIAN \
111 --stringparam timezone "$TIMEZONE" \
112 --stringparam page "$PAGE" \
113 --stringparam lang "$LANG" \
114 --output ./${PROGNAME}-commands/ \
115 $XSL \
[c9598f2]116 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]117 ;;
118
119 hlfs)
[139c34e]120 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
[c9598f2]121 xsltproc --nonet \
122 --xinclude \
[45f8a9c8]123 --stringparam model "$MODEL" \
124 --stringparam kernel "$KERNEL" \
125 --stringparam testsuite "$TEST" \
126 --stringparam bomb-testsuite "$BOMB_TEST" \
[c9598f2]127 --stringparam features \
128 x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
[45f8a9c8]129 --stringparam timezone "$TIMEZONE" \
130 --stringparam page "$PAGE" \
131 --stringparam lang "$LANG" \
132 --stringparam grsecurity_host "$GRSECURITY_HOST" \
[c9598f2]133 --output ./${PROGNAME}-commands/ \
134 $XSL \
135 $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]136 ;;
137 lfs)
[b11c10b]138 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
[13e52a5]139 # The scripts pages are xincluded by the book, so must
140 # be generated for running xsltproc
[f21dff8]141 pushd $BOOK > /dev/null
[66c09d0]142 if [ -f process-scripts.sh ]; then
[f0a31de]143 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
144 fi
[97b270f]145 # Recent git versions need version.ent to be generated
146 if [ -f git-version.sh ]; then
147 bash git-version.sh >> $LOGDIR/$LOG 2>&1
148 fi
[f21dff8]149 popd > /dev/null
[c9598f2]150
[13e52a5]151 # First profile the book, for revision and arch. Note that
152 # MULTIBLIB is set to "default" if pure 64 bit book. In this
153 # profiling on arch is useless, but does not hurt either.
[a4acb12]154 xsltproc --nonet \
155 --xinclude \
[13e52a5]156 --stringparam profile.revision "$INITSYS" \
157 --stringparam profile.arch "$MULTILIB" \
158 --output prbook.xml \
159 $BOOK/stylesheets/lfs-xsl/profile.xsl \
160 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
161
162 # Use the profiled book for generating the scriptlets
163 xsltproc --nonet \
[a4acb12]164 --stringparam testsuite "$TEST" \
165 --stringparam bomb-testsuite "$BOMB_TEST" \
[085435e]166 --stringparam ncurses5 "$NCURSES5" \
[dc7fd7b]167 --stringparam strip "$STRIP" \
168 --stringparam del-la-files "$DEL_LA_FILES" \
[a4acb12]169 --stringparam full-locale "$FULL_LOCALE" \
170 --stringparam timezone "$TIMEZONE" \
171 --stringparam page "$PAGE" \
172 --stringparam lang "$LANG" \
173 --stringparam pkgmngt "$PKGMNGT" \
174 --stringparam wrap-install "$WRAP_INSTALL" \
175 --stringparam hostname "$HOSTNAME" \
176 --stringparam interface "$INTERFACE" \
177 --stringparam ip "$IP_ADDR" \
178 --stringparam gateway "$GATEWAY" \
179 --stringparam prefix "$PREFIX" \
180 --stringparam broadcast "$BROADCAST" \
181 --stringparam domain "$DOMAIN" \
182 --stringparam nameserver1 "$DNS1" \
183 --stringparam nameserver2 "$DNS2" \
[3b43e17b]184 --stringparam font "$FONT" \
185 --stringparam fontmap "$FONTMAP" \
186 --stringparam unicode "$UNICODE" \
187 --stringparam keymap "$KEYMAP" \
188 --stringparam local "$LOCAL" \
189 --stringparam log-level "$LOG_LEVEL" \
[2758d94]190 --stringparam script-root "$SCRIPT_ROOT" \
[a4acb12]191 --output ./${PROGNAME}-commands/ \
192 $XSL \
[13e52a5]193 prbook.xml >> $LOGDIR/$LOG 2>&1
[f168be1]194# Remove flags requesting user action in some cases. Much easier here than
195# in the stylesheet...
[ebe1ba6]196 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
[fe30c61]197 ;;
[d68eb1b]198 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
[fe30c61]199 exit 1 ;;
200 esac
201
[b11c10b]202 echo "done"
[fe30c61]203
204 # Make the scripts executable.
205 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
206
207 # Create the packages file. We need it for proper Makefile creation
[706e5bf]208 # lfs does not use this anymore, but thei is taken care in the
209 # funtion body
[fe30c61]210 create_package_list
[706e5bf]211 # On the other hand, lfs needs two auxiliary files
[13c475b]212 if [ "${PROGNAME}" = lfs ]; then
213 create_chroot_scripts
214 create_kernfs_scripts
215 fi
[fe30c61]216
217 # Done. Moving on...
218 get_sources
219
220}
221
222#----------------------------#
223create_package_list() { #
224#----------------------------#
225
226 # Create the packages file. We need it for proper Makefile creation
227 rm -f pkg_tarball_list
[b11c10b]228 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
[706e5bf]229 if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
[b11c10b]230 echo -n "... "
[fe30c61]231 case ${PROGNAME} in
[92b7cb8]232 clfs*)
[c9598f2]233 xsltproc --nonet --xinclude \
234 -o pkg_tarball_list \
235 packages.xsl \
[92b7cb8]236 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]237 ;;
238 hlfs)
[a4acb12]239 xsltproc --nonet --xinclude \
240 --stringparam model "$MODEL" \
241 --stringparam kernel "$KERNEL" \
242 --output pkg_tarball_list \
243 packages.xsl \
[fe30c61]244 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
245 ;;
246 lfs)
[706e5bf]247 # lfs does not use the package list anymore
[fe30c61]248 ;;
[92b7cb8]249 *)
[fe30c61]250 esac
251
[b11c10b]252 echo "done"
[fe30c61]253
254}
255
[d68eb1b]256#----------------------------#
[13c475b]257create_chroot_scripts() { #
[d68eb1b]258#----------------------------#
259
[13c475b]260 rm -rf chroot-scripts
[d68eb1b]261 echo -n "Creating chroot commands scripts from $BOOK"
262 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
263 echo -n "... "
264 case ${PROGNAME} in
265 clfs*)
266 xsltproc --nonet --xinclude \
267 -o chroot-scripts/ chroot.xsl \
268 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
269 ;;
270 hlfs)
271 xsltproc --nonet --xinclude \
272 -o chroot-scripts/ chroot.xsl \
273 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
274 ;;
275 lfs)
276 xsltproc --nonet --xinclude \
277 -o chroot-scripts/ chroot.xsl \
[04de9bc]278 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
[d68eb1b]279 ;;
280 *)
281 esac
282 echo "done"
283
284}
[13c475b]285
286#----------------------------#
287create_kernfs_scripts() { #
288#----------------------------#
289
290 rm -rf kernfs-scripts
291 mkdir kernfs-scripts
292 echo -n "Creating virtual kernel FS commands scripts from $BOOK"
293 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
294 echo -n "... "
295 case ${PROGNAME} in
296 clfs*)
297 xsltproc --nonet --xinclude \
298 -o kernfs-scripts/ kernfs.xsl \
299 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
300 ;;
301 hlfs)
302 xsltproc --nonet --xinclude \
303 -o kernfs-scripts/ kernfs.xsl \
304 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
305 ;;
306 lfs)
307 xsltproc --nonet \
308 -o kernfs-scripts/devices.sh kernfs.xsl \
[04de9bc]309 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
[13c475b]310 xsltproc --nonet \
311 -o kernfs-scripts/teardown.sh kernfs.xsl \
[ebe1ba6]312 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
[13c475b]313 ;;
314 *)
315 esac
316 echo "done"
317
318}
Note: See TracBrowser for help on using the repository browser.