source: common/libs/func_book_parser@ bcae37d

ablfs-more legacy trunk
Last change on this file since bcae37d 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
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 case $PROGNAME in
57 clfs*)
58 VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
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 ;;
66 *)
67 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
68 esac
69
70 # Clean
71 rm -rf ${PROGNAME}-commands
72
73 # Extract the commands
74 echo -n "Extracting commands for"
75 case ${PROGNAME} in
76 clfs)
77 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
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 \
91 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
92 ;;
93
94 clfs2)
95 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
96 xsltproc --nonet \
97 --xinclude \
98 --stringparam timezone "$TIMEZONE" \
99 --stringparam page "$PAGE" \
100 --stringparam lang "$LANG" \
101 --output ./${PROGNAME}-commands/ \
102 $XSL \
103 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
104 ;;
105
106 clfs3)
107 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
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 \
116 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
117 ;;
118
119 hlfs)
120 echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
121 xsltproc --nonet \
122 --xinclude \
123 --stringparam model "$MODEL" \
124 --stringparam kernel "$KERNEL" \
125 --stringparam testsuite "$TEST" \
126 --stringparam bomb-testsuite "$BOMB_TEST" \
127 --stringparam features \
128 x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
129 --stringparam timezone "$TIMEZONE" \
130 --stringparam page "$PAGE" \
131 --stringparam lang "$LANG" \
132 --stringparam grsecurity_host "$GRSECURITY_HOST" \
133 --output ./${PROGNAME}-commands/ \
134 $XSL \
135 $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
136 ;;
137 lfs)
138 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
139 # The scripts pages are xincluded by the book, so must
140 # be generated for running xsltproc
141 pushd $BOOK > /dev/null
142 if [ -f process-scripts.sh ]; then
143 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
144 fi
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
149 popd > /dev/null
150
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.
154 xsltproc --nonet \
155 --xinclude \
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 \
164 --stringparam testsuite "$TEST" \
165 --stringparam bomb-testsuite "$BOMB_TEST" \
166 --stringparam ncurses5 "$NCURSES5" \
167 --stringparam strip "$STRIP" \
168 --stringparam del-la-files "$DEL_LA_FILES" \
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" \
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" \
190 --stringparam script-root "$SCRIPT_ROOT" \
191 --output ./${PROGNAME}-commands/ \
192 $XSL \
193 prbook.xml >> $LOGDIR/$LOG 2>&1
194# Remove flags requesting user action in some cases. Much easier here than
195# in the stylesheet...
196 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
197 ;;
198 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
199 exit 1 ;;
200 esac
201
202 echo "done"
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
208 # lfs does not use this anymore, but thei is taken care in the
209 # funtion body
210 create_package_list
211 # On the other hand, lfs needs two auxiliary files
212 if [ "${PROGNAME}" = lfs ]; then
213 create_chroot_scripts
214 create_kernfs_scripts
215 fi
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
228 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
229 if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
230 echo -n "... "
231 case ${PROGNAME} in
232 clfs*)
233 xsltproc --nonet --xinclude \
234 -o pkg_tarball_list \
235 packages.xsl \
236 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
237 ;;
238 hlfs)
239 xsltproc --nonet --xinclude \
240 --stringparam model "$MODEL" \
241 --stringparam kernel "$KERNEL" \
242 --output pkg_tarball_list \
243 packages.xsl \
244 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
245 ;;
246 lfs)
247 # lfs does not use the package list anymore
248 ;;
249 *)
250 esac
251
252 echo "done"
253
254}
255
256#----------------------------#
257create_chroot_scripts() { #
258#----------------------------#
259
260 rm -rf chroot-scripts
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 \
278 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
279 ;;
280 *)
281 esac
282 echo "done"
283
284}
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 \
309 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
310 xsltproc --nonet \
311 -o kernfs-scripts/teardown.sh kernfs.xsl \
312 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
313 ;;
314 *)
315 esac
316 echo "done"
317
318}
Note: See TracBrowser for help on using the repository browser.