source: common/libs/func_book_parser@ c412a07

ablfs-more trunk
Last change on this file since c412a07 was 0fa52f2, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove legacy: Remove almost all occurrences of CLFS/clfs

  • Property mode set to 100644
File size: 7.5 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" ;;
[fe30c61]17 *) echo "BOOK not defined in function <get_book>"
18 exit 1 ;;
19 esac
20 # Grab a fresh book if it's missing, otherwise, update it from the
21 # repo. If we've already extracted the commands, move on to getting the
22 # sources.
[de67016]23 if [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
[605ea36]24 git clone $GIT/$git_root ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
[92b7cb8]25 if [ ! $TREE == "development" ]; then
[de57ef4]26 pushd ${PROGNAME}-$LFSVRS > /dev/null
[92b7cb8]27 echo "Checking out $LFSVRS at $PWD in $TREE"
[ad4ff97]28 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
[de57ef4]29 popd > /dev/null
[92b7cb8]30 fi
[1cf621b]31 else
32 cd ${PROGNAME}-$LFSVRS
[de67016]33 # If the repo is in "detached head" state, git pull fails, so get
34 # back first to master:
35 git checkout trunk >>$LOGDIR/$LOG 2>&1
36 git pull >>$LOGDIR/$LOG 2>&1
37 if [ ! $TREE == "development" ]; then
38 git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
39 fi
[fe30c61]40 fi
[1cf621b]41 echo -ne "done\n"
[fe30c61]42
[de57ef4]43 else # Working copy
[fe30c61]44 echo -ne "Using $BOOK as book's sources ...\n"
45 fi
46}
47
48#----------------------------#
49extract_commands() { #
50#----------------------------#
51
52 cd $JHALFSDIR
[d68eb1b]53 # Clean
54 rm -rf ${PROGNAME}-commands
[fe30c61]55
[d68eb1b]56 # Extract the commands
57 echo -n "Extracting commands for"
[fe30c61]58 case ${PROGNAME} in
59
60 lfs)
[b11c10b]61 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
[13e52a5]62 # The scripts pages are xincluded by the book, so must
63 # be generated for running xsltproc
[f21dff8]64 pushd $BOOK > /dev/null
[66c09d0]65 if [ -f process-scripts.sh ]; then
[f0a31de]66 bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
67 fi
[97b270f]68 # Recent git versions need version.ent to be generated
69 if [ -f git-version.sh ]; then
[4c32ca8]70 bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
[97b270f]71 fi
[f21dff8]72 popd > /dev/null
[c9598f2]73
[13e52a5]74 # First profile the book, for revision and arch. Note that
75 # MULTIBLIB is set to "default" if pure 64 bit book. In this
76 # profiling on arch is useless, but does not hurt either.
[a4acb12]77 xsltproc --nonet \
78 --xinclude \
[13e52a5]79 --stringparam profile.revision "$INITSYS" \
80 --stringparam profile.arch "$MULTILIB" \
81 --output prbook.xml \
82 $BOOK/stylesheets/lfs-xsl/profile.xsl \
83 $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
84
85 # Use the profiled book for generating the scriptlets
86 xsltproc --nonet \
[a4acb12]87 --stringparam testsuite "$TEST" \
88 --stringparam bomb-testsuite "$BOMB_TEST" \
[085435e]89 --stringparam ncurses5 "$NCURSES5" \
[dc7fd7b]90 --stringparam strip "$STRIP" \
91 --stringparam del-la-files "$DEL_LA_FILES" \
[a4acb12]92 --stringparam full-locale "$FULL_LOCALE" \
93 --stringparam timezone "$TIMEZONE" \
94 --stringparam page "$PAGE" \
95 --stringparam lang "$LANG" \
96 --stringparam pkgmngt "$PKGMNGT" \
97 --stringparam wrap-install "$WRAP_INSTALL" \
98 --stringparam hostname "$HOSTNAME" \
99 --stringparam interface "$INTERFACE" \
100 --stringparam ip "$IP_ADDR" \
101 --stringparam gateway "$GATEWAY" \
102 --stringparam prefix "$PREFIX" \
103 --stringparam broadcast "$BROADCAST" \
104 --stringparam domain "$DOMAIN" \
105 --stringparam nameserver1 "$DNS1" \
106 --stringparam nameserver2 "$DNS2" \
[3b43e17b]107 --stringparam font "$FONT" \
108 --stringparam fontmap "$FONTMAP" \
109 --stringparam unicode "$UNICODE" \
110 --stringparam keymap "$KEYMAP" \
111 --stringparam local "$LOCAL" \
112 --stringparam log-level "$LOG_LEVEL" \
[2758d94]113 --stringparam script-root "$SCRIPT_ROOT" \
[a4acb12]114 --output ./${PROGNAME}-commands/ \
115 $XSL \
[13e52a5]116 prbook.xml >> $LOGDIR/$LOG 2>&1
[f168be1]117# Remove flags requesting user action in some cases. Much easier here than
118# in the stylesheet...
[ebe1ba6]119 sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
[fe30c61]120 ;;
[d68eb1b]121 *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
[fe30c61]122 exit 1 ;;
123 esac
124
[b11c10b]125 echo "done"
[fe30c61]126
127 # Make the scripts executable.
128 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
129
130 # Create the packages file. We need it for proper Makefile creation
[840b9ba]131 # lfs does not use this anymore, but this is taken care in the
132 # function body
[fe30c61]133 create_package_list
[706e5bf]134 # On the other hand, lfs needs two auxiliary files
[13c475b]135 if [ "${PROGNAME}" = lfs ]; then
136 create_chroot_scripts
137 create_kernfs_scripts
138 fi
[fe30c61]139
[840b9ba]140 # we create the VERSION variable here. Should maybe go into its own
141 # function. But at this point we can use the profiled xml to get
142 # version from lfs-release in the lfs case.
143 case $PROGNAME in
144 lfs)
145 VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
146 ;;
147 *)
148 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
149 esac
150
[fe30c61]151 # Done. Moving on...
152 get_sources
153}
154
155#----------------------------#
156create_package_list() { #
157#----------------------------#
158
159 # Create the packages file. We need it for proper Makefile creation
160 rm -f pkg_tarball_list
[b11c10b]161 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
[706e5bf]162 if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
[b11c10b]163 echo -n "... "
[fe30c61]164 case ${PROGNAME} in
165 lfs)
[706e5bf]166 # lfs does not use the package list anymore
[fe30c61]167 ;;
[92b7cb8]168 *)
[fe30c61]169 esac
170
[b11c10b]171 echo "done"
[fe30c61]172
173}
174
[d68eb1b]175#----------------------------#
[13c475b]176create_chroot_scripts() { #
[d68eb1b]177#----------------------------#
178
[13c475b]179 rm -rf chroot-scripts
[d68eb1b]180 echo -n "Creating chroot commands scripts from $BOOK"
181 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
182 echo -n "... "
183 case ${PROGNAME} in
184 lfs)
185 xsltproc --nonet --xinclude \
186 -o chroot-scripts/ chroot.xsl \
[04de9bc]187 $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
[d68eb1b]188 ;;
189 *)
190 esac
191 echo "done"
192
193}
[13c475b]194
195#----------------------------#
196create_kernfs_scripts() { #
197#----------------------------#
198
199 rm -rf kernfs-scripts
200 mkdir kernfs-scripts
201 echo -n "Creating virtual kernel FS commands scripts from $BOOK"
202 if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
203 echo -n "... "
204 case ${PROGNAME} in
205 lfs)
206 xsltproc --nonet \
207 -o kernfs-scripts/devices.sh kernfs.xsl \
[04de9bc]208 $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
[13c475b]209 xsltproc --nonet \
210 -o kernfs-scripts/teardown.sh kernfs.xsl \
[ebe1ba6]211 $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
[13c475b]212 ;;
213 *)
214 esac
215 echo "done"
216
217}
Note: See TracBrowser for help on using the repository browser.