source: common/libs/func_book_parser@ de67016

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

Adapt func_book_parser to git

The variable name "TREE" makes no sense now. It is rather a branch or a tag.
So more work is needed here.

  • Property mode set to 100644
File size: 11.8 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 ${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 popd > /dev/null
146
147 # First profile the book, for revision and arch. Note that
148 # MULTIBLIB is set to "default" if pure 64 bit book. In this
149 # profiling on arch is useless, but does not hurt either.
150 xsltproc --nonet \
151 --xinclude \
152 --stringparam profile.revision "$INITSYS" \
153 --stringparam profile.arch "$MULTILIB" \
154 --output prbook.xml \
155 $BOOK/stylesheets/lfs-xsl/profile.xsl \
156 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
157
158 # Use the profiled book for generating the scriptlets
159 xsltproc --nonet \
160 --stringparam testsuite "$TEST" \
161 --stringparam bomb-testsuite "$BOMB_TEST" \
162 --stringparam ncurses5 "$NCURSES5" \
163 --stringparam strip "$STRIP" \
164 --stringparam del-la-files "$DEL_LA_FILES" \
165 --stringparam full-locale "$FULL_LOCALE" \
166 --stringparam timezone "$TIMEZONE" \
167 --stringparam page "$PAGE" \
168 --stringparam lang "$LANG" \
169 --stringparam pkgmngt "$PKGMNGT" \
170 --stringparam wrap-install "$WRAP_INSTALL" \
171 --stringparam hostname "$HOSTNAME" \
172 --stringparam interface "$INTERFACE" \
173 --stringparam ip "$IP_ADDR" \
174 --stringparam gateway "$GATEWAY" \
175 --stringparam prefix "$PREFIX" \
176 --stringparam broadcast "$BROADCAST" \
177 --stringparam domain "$DOMAIN" \
178 --stringparam nameserver1 "$DNS1" \
179 --stringparam nameserver2 "$DNS2" \
180 --stringparam font "$FONT" \
181 --stringparam fontmap "$FONTMAP" \
182 --stringparam unicode "$UNICODE" \
183 --stringparam keymap "$KEYMAP" \
184 --stringparam local "$LOCAL" \
185 --stringparam log-level "$LOG_LEVEL" \
186 --stringparam script-root "$SCRIPT_ROOT" \
187 --output ./${PROGNAME}-commands/ \
188 $XSL \
189 prbook.xml >> $LOGDIR/$LOG 2>&1
190# Remove flags requesting user action in some cases. Much easier here than
191# in the stylesheet...
192 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
193 ;;
194 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
195 exit 1 ;;
196 esac
197
198 echo "done"
199
200 # Make the scripts executable.
201 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
202
203 # Create the packages file. We need it for proper Makefile creation
204 # lfs does not use this anymore, but thei is taken care in the
205 # funtion body
206 create_package_list
207 # On the other hand, lfs needs two auxiliary files
208 if [ "${PROGNAME}" = lfs ]; then
209 create_chroot_scripts
210 create_kernfs_scripts
211 fi
212
213 # Done. Moving on...
214 get_sources
215
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.