source: common/libs/func_book_parser@ 2bd2fb8

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

Replace $PROGNAME-commands with $COMMANDS

This allows to remove some references to PROGNAME

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