source: common/libs/func_book_parser@ 8b85dae

ablfs-more legacy trunk
Last change on this file since 8b85dae was 13e52a5, checked in by Pierre Labastie <pierre@…>, 4 years ago

Add the multilib book: fixes ticket #1722

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