source: common/libs/func_book_parser@ 59a1e1a

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

Adapt to condxml branch: func_book_parser

When running git-version.sh, unconditionally add a $INITSYS
argument, which is needed for the new condxml, and
is harmless if this argument is not needed.

  • Property mode set to 100644
File size: 12.0 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5#----------------------------#
6get_book() { #
7#----------------------------#
8 cd $JHALFSDIR
9
10 if [ -z $WORKING_COPY ] ; then
11# Check for Subversion or git instead of just letting the script fail.
12 test `type -p git` || eval "echo \"This feature requires Git.\"
13 exit 1"
14
15 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
16
17 case $PROGNAME in
18 lfs) git_root="lfs.git" ;;
19 clfs*) ;;
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.
26 if [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
27 git clone $GIT/$git_root ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
28 if [ ! $TREE == "development" ]; then
29 pushd ${PROGNAME}-$LFSVRS > /dev/null
30 echo "Checking out $LFSVRS at $PWD in $TREE"
31 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
32 popd > /dev/null
33 fi
34 else
35 cd ${PROGNAME}-$LFSVRS
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
43 fi
44 echo -ne "done\n"
45
46 else # Working copy
47 echo -ne "Using $BOOK as book's sources ...\n"
48 fi
49}
50
51#----------------------------#
52extract_commands() { #
53#----------------------------#
54
55 cd $JHALFSDIR
56 # Clean
57 rm -rf ${PROGNAME}-commands
58
59 # Extract the commands
60 echo -n "Extracting commands for"
61 case ${PROGNAME} in
62 clfs)
63 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
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 \
77 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
78 ;;
79
80 clfs2)
81 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
82 xsltproc --nonet \
83 --xinclude \
84 --stringparam timezone "$TIMEZONE" \
85 --stringparam page "$PAGE" \
86 --stringparam lang "$LANG" \
87 --output ./${PROGNAME}-commands/ \
88 $XSL \
89 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
90 ;;
91
92 clfs3)
93 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
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 \
102 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
103 ;;
104
105 hlfs)
106 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
107 xsltproc --nonet \
108 --xinclude \
109 --stringparam model "$MODEL" \
110 --stringparam kernel "$KERNEL" \
111 --stringparam testsuite "$TEST" \
112 --stringparam bomb-testsuite "$BOMB_TEST" \
113 --stringparam features \
114 x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
115 --stringparam timezone "$TIMEZONE" \
116 --stringparam page "$PAGE" \
117 --stringparam lang "$LANG" \
118 --stringparam grsecurity_host "$GRSECURITY_HOST" \
119 --output ./${PROGNAME}-commands/ \
120 $XSL \
121 $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
122 ;;
123 lfs)
124 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
125 # The scripts pages are xincluded by the book, so must
126 # be generated for running xsltproc
127 pushd $BOOK > /dev/null
128 if [ -f process-scripts.sh ]; then
129 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
130 fi
131 # Recent git versions need version.ent to be generated
132 if [ -f git-version.sh ]; then
133 bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
134 fi
135 popd > /dev/null
136
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.
140 xsltproc --nonet \
141 --xinclude \
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 \
150 --stringparam testsuite "$TEST" \
151 --stringparam bomb-testsuite "$BOMB_TEST" \
152 --stringparam ncurses5 "$NCURSES5" \
153 --stringparam strip "$STRIP" \
154 --stringparam del-la-files "$DEL_LA_FILES" \
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" \
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" \
176 --stringparam script-root "$SCRIPT_ROOT" \
177 --output ./${PROGNAME}-commands/ \
178 $XSL \
179 prbook.xml >> $LOGDIR/$LOG 2>&1
180# Remove flags requesting user action in some cases. Much easier here than
181# in the stylesheet...
182 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
183 ;;
184 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
185 exit 1 ;;
186 esac
187
188 echo "done"
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
194 # lfs does not use this anymore, but this is taken care in the
195 # function body
196 create_package_list
197 # On the other hand, lfs needs two auxiliary files
198 if [ "${PROGNAME}" = lfs ]; then
199 create_chroot_scripts
200 create_kernfs_scripts
201 fi
202
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
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
226 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
227 if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
228 echo -n "... "
229 case ${PROGNAME} in
230 clfs*)
231 xsltproc --nonet --xinclude \
232 -o pkg_tarball_list \
233 packages.xsl \
234 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
235 ;;
236 hlfs)
237 xsltproc --nonet --xinclude \
238 --stringparam model "$MODEL" \
239 --stringparam kernel "$KERNEL" \
240 --output pkg_tarball_list \
241 packages.xsl \
242 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
243 ;;
244 lfs)
245 # lfs does not use the package list anymore
246 ;;
247 *)
248 esac
249
250 echo "done"
251
252}
253
254#----------------------------#
255create_chroot_scripts() { #
256#----------------------------#
257
258 rm -rf chroot-scripts
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 \
276 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
277 ;;
278 *)
279 esac
280 echo "done"
281
282}
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 \
307 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
308 xsltproc --nonet \
309 -o kernfs-scripts/teardown.sh kernfs.xsl \
310 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
311 ;;
312 *)
313 esac
314 echo "done"
315
316}
Note: See TracBrowser for help on using the repository browser.