1 | #!/bin/bash
|
---|
2 |
|
---|
3 | #----------------------------#
|
---|
4 | get_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 | #----------------------------#
|
---|
50 | extract_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 | lfs)
|
---|
104 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
|
---|
105 | # The scripts pages are xincluded by the book, so must
|
---|
106 | # be generated for running xsltproc
|
---|
107 | pushd $BOOK > /dev/null
|
---|
108 | if [ -f process-scripts.sh ]; then
|
---|
109 | bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
|
---|
110 | fi
|
---|
111 | # Recent git versions need version.ent to be generated
|
---|
112 | if [ -f git-version.sh ]; then
|
---|
113 | bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
|
---|
114 | fi
|
---|
115 | popd > /dev/null
|
---|
116 |
|
---|
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.
|
---|
120 | xsltproc --nonet \
|
---|
121 | --xinclude \
|
---|
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 \
|
---|
130 | --stringparam testsuite "$TEST" \
|
---|
131 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
132 | --stringparam ncurses5 "$NCURSES5" \
|
---|
133 | --stringparam strip "$STRIP" \
|
---|
134 | --stringparam del-la-files "$DEL_LA_FILES" \
|
---|
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" \
|
---|
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" \
|
---|
156 | --stringparam script-root "$SCRIPT_ROOT" \
|
---|
157 | --output ./${PROGNAME}-commands/ \
|
---|
158 | $XSL \
|
---|
159 | prbook.xml >> $LOGDIR/$LOG 2>&1
|
---|
160 | # Remove flags requesting user action in some cases. Much easier here than
|
---|
161 | # in the stylesheet...
|
---|
162 | sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
|
---|
163 | ;;
|
---|
164 | *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
|
---|
165 | exit 1 ;;
|
---|
166 | esac
|
---|
167 |
|
---|
168 | echo "done"
|
---|
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
|
---|
174 | # lfs does not use this anymore, but this is taken care in the
|
---|
175 | # function body
|
---|
176 | create_package_list
|
---|
177 | # On the other hand, lfs needs two auxiliary files
|
---|
178 | if [ "${PROGNAME}" = lfs ]; then
|
---|
179 | create_chroot_scripts
|
---|
180 | create_kernfs_scripts
|
---|
181 | fi
|
---|
182 |
|
---|
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 |
|
---|
196 | # Done. Moving on...
|
---|
197 | get_sources
|
---|
198 | }
|
---|
199 |
|
---|
200 | #----------------------------#
|
---|
201 | create_package_list() { #
|
---|
202 | #----------------------------#
|
---|
203 |
|
---|
204 | # Create the packages file. We need it for proper Makefile creation
|
---|
205 | rm -f pkg_tarball_list
|
---|
206 | echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
|
---|
207 | if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
|
---|
208 | echo -n "... "
|
---|
209 | case ${PROGNAME} in
|
---|
210 | clfs*)
|
---|
211 | xsltproc --nonet --xinclude \
|
---|
212 | -o pkg_tarball_list \
|
---|
213 | packages.xsl \
|
---|
214 | $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
215 | ;;
|
---|
216 | lfs)
|
---|
217 | # lfs does not use the package list anymore
|
---|
218 | ;;
|
---|
219 | *)
|
---|
220 | esac
|
---|
221 |
|
---|
222 | echo "done"
|
---|
223 |
|
---|
224 | }
|
---|
225 |
|
---|
226 | #----------------------------#
|
---|
227 | create_chroot_scripts() { #
|
---|
228 | #----------------------------#
|
---|
229 |
|
---|
230 | rm -rf chroot-scripts
|
---|
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 \
|
---|
243 | $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
|
---|
244 | ;;
|
---|
245 | *)
|
---|
246 | esac
|
---|
247 | echo "done"
|
---|
248 |
|
---|
249 | }
|
---|
250 |
|
---|
251 | #----------------------------#
|
---|
252 | create_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 \
|
---|
269 | $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
|
---|
270 | xsltproc --nonet \
|
---|
271 | -o kernfs-scripts/teardown.sh kernfs.xsl \
|
---|
272 | $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
|
---|
273 | ;;
|
---|
274 | *)
|
---|
275 | esac
|
---|
276 | echo "done"
|
---|
277 |
|
---|
278 | }
|
---|