source: common/libs/func_book_parser@ 4c36783

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

Remove legacy: remove everything about HLFS

  • Property mode set to 100644
File size: 10.2 KB
RevLine 
[fe30c61]1#!/bin/bash
2
3#----------------------------#
4get_book() { #
5#----------------------------#
6 cd $JHALFSDIR
7
8 if [ -z $WORKING_COPY ] ; then
[de57ef4]9# Check for Subversion or git instead of just letting the script fail.
[de67016]10 test `type -p git` || eval "echo \"This feature requires Git.\"
11 exit 1"
[de57ef4]12
[fe30c61]13 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
14
15 case $PROGNAME in
[de67016]16 lfs) git_root="lfs.git" ;;
[d68eb1b]17 clfs*) ;;
[fe30c61]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.
[de67016]24 if [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
[605ea36]25 git clone $GIT/$git_root ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
[92b7cb8]26 if [ ! $TREE == "development" ]; then
[de57ef4]27 pushd ${PROGNAME}-$LFSVRS > /dev/null
[92b7cb8]28 echo "Checking out $LFSVRS at $PWD in $TREE"
[ad4ff97]29 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
[de57ef4]30 popd > /dev/null
[92b7cb8]31 fi
[1cf621b]32 else
33 cd ${PROGNAME}-$LFSVRS
[de67016]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
[fe30c61]41 fi
[1cf621b]42 echo -ne "done\n"
[fe30c61]43
[de57ef4]44 else # Working copy
[fe30c61]45 echo -ne "Using $BOOK as book's sources ...\n"
46 fi
47}
48
49#----------------------------#
50extract_commands() { #
51#----------------------------#
52
53 cd $JHALFSDIR
[d68eb1b]54 # Clean
55 rm -rf ${PROGNAME}-commands
[fe30c61]56
[d68eb1b]57 # Extract the commands
58 echo -n "Extracting commands for"
[fe30c61]59 case ${PROGNAME} in
60 clfs)
[b11c10b]61 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]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 \
[c9598f2]75 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]76 ;;
77
78 clfs2)
[b11c10b]79 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]80 xsltproc --nonet \
81 --xinclude \
82 --stringparam timezone "$TIMEZONE" \
83 --stringparam page "$PAGE" \
84 --stringparam lang "$LANG" \
85 --output ./${PROGNAME}-commands/ \
86 $XSL \
[c9598f2]87 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]88 ;;
89
90 clfs3)
[b11c10b]91 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
[a4acb12]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 \
[c9598f2]100 $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]101 ;;
102
103 lfs)
[b11c10b]104 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
[13e52a5]105 # The scripts pages are xincluded by the book, so must
106 # be generated for running xsltproc
[f21dff8]107 pushd $BOOK > /dev/null
[66c09d0]108 if [ -f process-scripts.sh ]; then
[f0a31de]109 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
110 fi
[97b270f]111 # Recent git versions need version.ent to be generated
112 if [ -f git-version.sh ]; then
[4c32ca8]113 bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
[97b270f]114 fi
[f21dff8]115 popd > /dev/null
[c9598f2]116
[13e52a5]117 # First profile the book, for revision and arch. Note that
118 # MULTIBLIB is set to "default" if pure 64 bit book. In this
119 # profiling on arch is useless, but does not hurt either.
[a4acb12]120 xsltproc --nonet \
121 --xinclude \
[13e52a5]122 --stringparam profile.revision "$INITSYS" \
123 --stringparam profile.arch "$MULTILIB" \
124 --output prbook.xml \
125 $BOOK/stylesheets/lfs-xsl/profile.xsl \
126 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
127
128 # Use the profiled book for generating the scriptlets
129 xsltproc --nonet \
[a4acb12]130 --stringparam testsuite "$TEST" \
131 --stringparam bomb-testsuite "$BOMB_TEST" \
[085435e]132 --stringparam ncurses5 "$NCURSES5" \
[dc7fd7b]133 --stringparam strip "$STRIP" \
134 --stringparam del-la-files "$DEL_LA_FILES" \
[a4acb12]135 --stringparam full-locale "$FULL_LOCALE" \
136 --stringparam timezone "$TIMEZONE" \
137 --stringparam page "$PAGE" \
138 --stringparam lang "$LANG" \
139 --stringparam pkgmngt "$PKGMNGT" \
140 --stringparam wrap-install "$WRAP_INSTALL" \
141 --stringparam hostname "$HOSTNAME" \
142 --stringparam interface "$INTERFACE" \
143 --stringparam ip "$IP_ADDR" \
144 --stringparam gateway "$GATEWAY" \
145 --stringparam prefix "$PREFIX" \
146 --stringparam broadcast "$BROADCAST" \
147 --stringparam domain "$DOMAIN" \
148 --stringparam nameserver1 "$DNS1" \
149 --stringparam nameserver2 "$DNS2" \
[3b43e17b]150 --stringparam font "$FONT" \
151 --stringparam fontmap "$FONTMAP" \
152 --stringparam unicode "$UNICODE" \
153 --stringparam keymap "$KEYMAP" \
154 --stringparam local "$LOCAL" \
155 --stringparam log-level "$LOG_LEVEL" \
[2758d94]156 --stringparam script-root "$SCRIPT_ROOT" \
[a4acb12]157 --output ./${PROGNAME}-commands/ \
158 $XSL \
[13e52a5]159 prbook.xml >> $LOGDIR/$LOG 2>&1
[f168be1]160# Remove flags requesting user action in some cases. Much easier here than
161# in the stylesheet...
[ebe1ba6]162 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
[fe30c61]163 ;;
[d68eb1b]164 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
[fe30c61]165 exit 1 ;;
166 esac
167
[b11c10b]168 echo "done"
[fe30c61]169
170 # Make the scripts executable.
171 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
172
173 # Create the packages file. We need it for proper Makefile creation
[840b9ba]174 # lfs does not use this anymore, but this is taken care in the
175 # function body
[fe30c61]176 create_package_list
[706e5bf]177 # On the other hand, lfs needs two auxiliary files
[13c475b]178 if [ "${PROGNAME}" = lfs ]; then
179 create_chroot_scripts
180 create_kernfs_scripts
181 fi
[fe30c61]182
[840b9ba]183 # we create the VERSION variable here. Should maybe go into its own
184 # function. But at this point we can use the profiled xml to get
185 # version from lfs-release in the lfs case.
186 case $PROGNAME in
187 clfs*)
188 VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
189 lfs)
190 VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
191 ;;
192 *)
193 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
194 esac
195
[fe30c61]196 # Done. Moving on...
197 get_sources
198}
199
200#----------------------------#
201create_package_list() { #
202#----------------------------#
203
204 # Create the packages file. We need it for proper Makefile creation
205 rm -f pkg_tarball_list
[b11c10b]206 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
[706e5bf]207 if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
[b11c10b]208 echo -n "... "
[fe30c61]209 case ${PROGNAME} in
[92b7cb8]210 clfs*)
[c9598f2]211 xsltproc --nonet --xinclude \
212 -o pkg_tarball_list \
213 packages.xsl \
[92b7cb8]214 $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
[fe30c61]215 ;;
216 lfs)
[706e5bf]217 # lfs does not use the package list anymore
[fe30c61]218 ;;
[92b7cb8]219 *)
[fe30c61]220 esac
221
[b11c10b]222 echo "done"
[fe30c61]223
224}
225
[d68eb1b]226#----------------------------#
[13c475b]227create_chroot_scripts() { #
[d68eb1b]228#----------------------------#
229
[13c475b]230 rm -rf chroot-scripts
[d68eb1b]231 echo -n "Creating chroot commands scripts from $BOOK"
232 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
233 echo -n "... "
234 case ${PROGNAME} in
235 clfs*)
236 xsltproc --nonet --xinclude \
237 -o chroot-scripts/ chroot.xsl \
238 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
239 ;;
240 lfs)
241 xsltproc --nonet --xinclude \
242 -o chroot-scripts/ chroot.xsl \
[04de9bc]243 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
[d68eb1b]244 ;;
245 *)
246 esac
247 echo "done"
248
249}
[13c475b]250
251#----------------------------#
252create_kernfs_scripts() { #
253#----------------------------#
254
255 rm -rf kernfs-scripts
256 mkdir kernfs-scripts
257 echo -n "Creating virtual kernel FS 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 kernfs-scripts/ kernfs.xsl \
264 $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
265 ;;
266 lfs)
267 xsltproc --nonet \
268 -o kernfs-scripts/devices.sh kernfs.xsl \
[04de9bc]269 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
[13c475b]270 xsltproc --nonet \
271 -o kernfs-scripts/teardown.sh kernfs.xsl \
[ebe1ba6]272 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
[13c475b]273 ;;
274 *)
275 esac
276 echo "done"
277
278}
Note: See TracBrowser for help on using the repository browser.