1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # $Id$
|
---|
4 |
|
---|
5 | #----------------------------#
|
---|
6 | get_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 | case $PROGNAME in
|
---|
13 | lfs | hlfs)
|
---|
14 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
15 | exit 1"
|
---|
16 | ;;
|
---|
17 | clfs*)
|
---|
18 | test `type -p git` || eval "echo \"This feature requires Git.\"
|
---|
19 | exit 1"
|
---|
20 | ;;
|
---|
21 | esac
|
---|
22 |
|
---|
23 | echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
|
---|
24 |
|
---|
25 | case $PROGNAME in
|
---|
26 | lfs) svn_root="LFS" ;;
|
---|
27 | hlfs) svn_root="HLFS" ;;
|
---|
28 | clfs*) ;;
|
---|
29 | *) echo "BOOK not defined in function <get_book>"
|
---|
30 | exit 1 ;;
|
---|
31 | esac
|
---|
32 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
33 | # repo. If we've already extracted the commands, move on to getting the
|
---|
34 | # sources.
|
---|
35 | if [ $PROGNAME == "lfs" ] || [ $PROGNAME == "hlfs" ] &&
|
---|
36 | [ ! -d ${PROGNAME}-${LFSVRS}/.svn ]; then
|
---|
37 | svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
38 | elif [ $PROGNAME == "clfs" ] || [ $PROGNAME == "clfs2" ] ||
|
---|
39 | [ $PROGNAME == "clfs3" ] && [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
|
---|
40 | echo $TREE
|
---|
41 | git clone $GIT ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
42 | if [ ! $TREE == "development" ]; then
|
---|
43 | pushd ${PROGNAME}-$LFSVRS > /dev/null
|
---|
44 | echo "Checking out $LFSVRS at $PWD in $TREE"
|
---|
45 | git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
|
---|
46 | popd > /dev/null
|
---|
47 | fi
|
---|
48 | else
|
---|
49 | cd ${PROGNAME}-$LFSVRS
|
---|
50 | case $PROGNAME in
|
---|
51 | clfs*)
|
---|
52 | # If the repo is in "detached head" state, git pull fails, so get
|
---|
53 | # back first to master:
|
---|
54 | git checkout master >>$LOGDIR/$LOG 2>&1
|
---|
55 | git pull >>$LOGDIR/$LOG 2>&1
|
---|
56 | if [ ! $TREE == "development" ]; then
|
---|
57 | git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
|
---|
58 | fi
|
---|
59 | ;;
|
---|
60 | lfs | hlfs) svn up >>$LOGDIR/$LOG 2>&1 ;;
|
---|
61 | *) ;;
|
---|
62 | esac
|
---|
63 | fi
|
---|
64 | echo -ne "done\n"
|
---|
65 |
|
---|
66 | else # Working copy
|
---|
67 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
68 | fi
|
---|
69 | }
|
---|
70 |
|
---|
71 | #----------------------------#
|
---|
72 | extract_commands() { #
|
---|
73 | #----------------------------#
|
---|
74 |
|
---|
75 | cd $JHALFSDIR
|
---|
76 | case $PROGNAME in
|
---|
77 | clfs*)
|
---|
78 | VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
79 | lfs)
|
---|
80 | if [ "$INITSYS" = "sysv" ] ; then
|
---|
81 | VERSION=$(grep 'ENTITY version ' $BOOK/general.ent| cut -d\" -f2)
|
---|
82 | else
|
---|
83 | VERSION=$(grep 'ENTITY versiond' $BOOK/general.ent| cut -d\" -f2)
|
---|
84 | fi
|
---|
85 | ;;
|
---|
86 | *)
|
---|
87 | VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
88 | esac
|
---|
89 |
|
---|
90 | # Clean
|
---|
91 | rm -rf ${PROGNAME}-commands
|
---|
92 |
|
---|
93 | # Extract the commands
|
---|
94 | echo -n "Extracting commands for"
|
---|
95 | case ${PROGNAME} in
|
---|
96 | clfs)
|
---|
97 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
98 | xsltproc --nonet \
|
---|
99 | --xinclude \
|
---|
100 | --stringparam method "$METHOD" \
|
---|
101 | --stringparam testsuite "$TEST" \
|
---|
102 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
103 | --stringparam vim-lang "$VIMLANG" \
|
---|
104 | --stringparam timezone "$TIMEZONE" \
|
---|
105 | --stringparam page "$PAGE" \
|
---|
106 | --stringparam lang "$LANG" \
|
---|
107 | --stringparam sparc "$SPARC64_PROC" \
|
---|
108 | --stringparam x86 "$TARGET" \
|
---|
109 | --stringparam mips "$TARGET" \
|
---|
110 | -o ./${PROGNAME}-commands/ \
|
---|
111 | $XSL \
|
---|
112 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
113 | ;;
|
---|
114 |
|
---|
115 | clfs2)
|
---|
116 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
117 | xsltproc --nonet \
|
---|
118 | --xinclude \
|
---|
119 | --stringparam vim-lang "$VIMLANG" \
|
---|
120 | --stringparam timezone "$TIMEZONE" \
|
---|
121 | --stringparam page "$PAGE" \
|
---|
122 | --stringparam lang "$LANG" \
|
---|
123 | --output ./${PROGNAME}-commands/ \
|
---|
124 | $XSL \
|
---|
125 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
126 | ;;
|
---|
127 |
|
---|
128 | clfs3)
|
---|
129 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
|
---|
130 | xsltproc --nonet \
|
---|
131 | --xinclude \
|
---|
132 | --stringparam endian x$ENDIAN \
|
---|
133 | --stringparam timezone "$TIMEZONE" \
|
---|
134 | --stringparam page "$PAGE" \
|
---|
135 | --stringparam lang "$LANG" \
|
---|
136 | --output ./${PROGNAME}-commands/ \
|
---|
137 | $XSL \
|
---|
138 | $BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
139 | ;;
|
---|
140 |
|
---|
141 | hlfs)
|
---|
142 | echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
|
---|
143 | xsltproc --nonet \
|
---|
144 | --xinclude \
|
---|
145 | --stringparam model "$MODEL" \
|
---|
146 | --stringparam kernel "$KERNEL" \
|
---|
147 | --stringparam testsuite "$TEST" \
|
---|
148 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
149 | --stringparam features \
|
---|
150 | x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
|
---|
151 | --stringparam timezone "$TIMEZONE" \
|
---|
152 | --stringparam page "$PAGE" \
|
---|
153 | --stringparam lang "$LANG" \
|
---|
154 | --stringparam grsecurity_host "$GRSECURITY_HOST" \
|
---|
155 | --output ./${PROGNAME}-commands/ \
|
---|
156 | $XSL \
|
---|
157 | $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
158 | ;;
|
---|
159 | lfs)
|
---|
160 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
|
---|
161 | pushd $BOOK > /dev/null
|
---|
162 | if [ -f process-scripts.sh ]; then
|
---|
163 | bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
|
---|
164 | fi
|
---|
165 | popd > /dev/null
|
---|
166 |
|
---|
167 | xsltproc --nonet \
|
---|
168 | --xinclude \
|
---|
169 | --stringparam revision "$INITSYS" \
|
---|
170 | --stringparam testsuite "$TEST" \
|
---|
171 | --stringparam bomb-testsuite "$BOMB_TEST" \
|
---|
172 | --stringparam vim-lang "$VIMLANG" \
|
---|
173 | --stringparam strip "$STRIP" \
|
---|
174 | --stringparam del-la-files "$DEL_LA_FILES" \
|
---|
175 | --stringparam full-locale "$FULL_LOCALE" \
|
---|
176 | --stringparam timezone "$TIMEZONE" \
|
---|
177 | --stringparam page "$PAGE" \
|
---|
178 | --stringparam lang "$LANG" \
|
---|
179 | --stringparam pkgmngt "$PKGMNGT" \
|
---|
180 | --stringparam wrap-install "$WRAP_INSTALL" \
|
---|
181 | --stringparam hostname "$HOSTNAME" \
|
---|
182 | --stringparam interface "$INTERFACE" \
|
---|
183 | --stringparam ip "$IP_ADDR" \
|
---|
184 | --stringparam gateway "$GATEWAY" \
|
---|
185 | --stringparam prefix "$PREFIX" \
|
---|
186 | --stringparam broadcast "$BROADCAST" \
|
---|
187 | --stringparam domain "$DOMAIN" \
|
---|
188 | --stringparam nameserver1 "$DNS1" \
|
---|
189 | --stringparam nameserver2 "$DNS2" \
|
---|
190 | --stringparam font "$FONT" \
|
---|
191 | --stringparam fontmap "$FONTMAP" \
|
---|
192 | --stringparam unicode "$UNICODE" \
|
---|
193 | --stringparam keymap "$KEYMAP" \
|
---|
194 | --stringparam local "$LOCAL" \
|
---|
195 | --stringparam log-level "$LOG_LEVEL" \
|
---|
196 | --output ./${PROGNAME}-commands/ \
|
---|
197 | $XSL \
|
---|
198 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
199 | # Remove flags requesting user action in some cases. Much easier here than
|
---|
200 | # in the stylesheet...
|
---|
201 | sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter08/*kernel*
|
---|
202 | ;;
|
---|
203 | *) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
|
---|
204 | exit 1 ;;
|
---|
205 | esac
|
---|
206 |
|
---|
207 | echo "done"
|
---|
208 |
|
---|
209 | # Make the scripts executable.
|
---|
210 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
211 |
|
---|
212 | # Create the packages file. We need it for proper Makefile creation
|
---|
213 | create_package_list
|
---|
214 | if [ "${PROGNAME}" = lfs ]; then
|
---|
215 | create_chroot_scripts
|
---|
216 | create_kernfs_scripts
|
---|
217 | fi
|
---|
218 |
|
---|
219 | # Done. Moving on...
|
---|
220 | get_sources
|
---|
221 |
|
---|
222 | }
|
---|
223 |
|
---|
224 | #----------------------------#
|
---|
225 | create_package_list() { #
|
---|
226 | #----------------------------#
|
---|
227 |
|
---|
228 | # Create the packages file. We need it for proper Makefile creation
|
---|
229 | rm -f pkg_tarball_list
|
---|
230 | echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
|
---|
231 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
232 | echo -n "... "
|
---|
233 | case ${PROGNAME} in
|
---|
234 | clfs*)
|
---|
235 | xsltproc --nonet --xinclude \
|
---|
236 | -o pkg_tarball_list \
|
---|
237 | packages.xsl \
|
---|
238 | $BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
239 | ;;
|
---|
240 | hlfs)
|
---|
241 | xsltproc --nonet --xinclude \
|
---|
242 | --stringparam model "$MODEL" \
|
---|
243 | --stringparam kernel "$KERNEL" \
|
---|
244 | --output pkg_tarball_list \
|
---|
245 | packages.xsl \
|
---|
246 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
247 | ;;
|
---|
248 | lfs)
|
---|
249 | xsltproc --nonet --xinclude \
|
---|
250 | --stringparam pkgmngt "$PKGMNGT" \
|
---|
251 | --stringparam revision "$INITSYS" \
|
---|
252 | --output pkg_tarball_list \
|
---|
253 | packages.xsl \
|
---|
254 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
255 | ;;
|
---|
256 | *)
|
---|
257 | esac
|
---|
258 |
|
---|
259 | echo "done"
|
---|
260 |
|
---|
261 | }
|
---|
262 |
|
---|
263 | #----------------------------#
|
---|
264 | create_chroot_scripts() { #
|
---|
265 | #----------------------------#
|
---|
266 |
|
---|
267 | rm -rf chroot-scripts
|
---|
268 | echo -n "Creating chroot commands scripts from $BOOK"
|
---|
269 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
270 | echo -n "... "
|
---|
271 | case ${PROGNAME} in
|
---|
272 | clfs*)
|
---|
273 | xsltproc --nonet --xinclude \
|
---|
274 | -o chroot-scripts/ chroot.xsl \
|
---|
275 | $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
|
---|
276 | ;;
|
---|
277 | hlfs)
|
---|
278 | xsltproc --nonet --xinclude \
|
---|
279 | -o chroot-scripts/ chroot.xsl \
|
---|
280 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
281 | ;;
|
---|
282 | lfs)
|
---|
283 | xsltproc --nonet --xinclude \
|
---|
284 | -o chroot-scripts/ chroot.xsl \
|
---|
285 | $BOOK/chapter06/chapter06.xml >> $LOGDIR/$LOG 2>&1
|
---|
286 | ;;
|
---|
287 | *)
|
---|
288 | esac
|
---|
289 | echo "done"
|
---|
290 |
|
---|
291 | }
|
---|
292 |
|
---|
293 | #----------------------------#
|
---|
294 | create_kernfs_scripts() { #
|
---|
295 | #----------------------------#
|
---|
296 |
|
---|
297 | rm -rf kernfs-scripts
|
---|
298 | mkdir kernfs-scripts
|
---|
299 | echo -n "Creating virtual kernel FS commands scripts from $BOOK"
|
---|
300 | if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
---|
301 | echo -n "... "
|
---|
302 | case ${PROGNAME} in
|
---|
303 | clfs*)
|
---|
304 | xsltproc --nonet --xinclude \
|
---|
305 | -o kernfs-scripts/ kernfs.xsl \
|
---|
306 | $BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
|
---|
307 | ;;
|
---|
308 | hlfs)
|
---|
309 | xsltproc --nonet --xinclude \
|
---|
310 | -o kernfs-scripts/ kernfs.xsl \
|
---|
311 | $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
---|
312 | ;;
|
---|
313 | lfs)
|
---|
314 | xsltproc --nonet \
|
---|
315 | -o kernfs-scripts/devices.sh kernfs.xsl \
|
---|
316 | $BOOK/chapter06/kernfs.xml >> $LOGDIR/$LOG 2>&1
|
---|
317 | xsltproc --nonet \
|
---|
318 | -o kernfs-scripts/teardown.sh kernfs.xsl \
|
---|
319 | $BOOK/chapter09/reboot.xml >> $LOGDIR/$LOG 2>&1
|
---|
320 | ;;
|
---|
321 | *)
|
---|
322 | esac
|
---|
323 | echo "done"
|
---|
324 |
|
---|
325 | }
|
---|