source: common/libs/func_book_parser@ fd4a798

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

Remove $Id$ comments, they are useless with git

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