1 | #!/bin/sh
|
---|
2 | set -e # Enable error trapping
|
---|
3 |
|
---|
4 | # $Id$
|
---|
5 |
|
---|
6 | ###################################
|
---|
7 | ### FUNCTIONS ###
|
---|
8 | ###################################
|
---|
9 |
|
---|
10 |
|
---|
11 | #----------------------------#
|
---|
12 | get_sources() { #
|
---|
13 | #----------------------------#
|
---|
14 | local IFS
|
---|
15 |
|
---|
16 | # Test if the packages must be downloaded
|
---|
17 | if [ ! "$HPKG" = "1" ] ; then
|
---|
18 | return
|
---|
19 | fi
|
---|
20 |
|
---|
21 | # Modify the 'internal field separator' to break on 'LF' only
|
---|
22 | IFS=$'\x0A'
|
---|
23 |
|
---|
24 | if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
---|
25 | cd $BUILDDIR/sources
|
---|
26 |
|
---|
27 | > MISSING_FILES.DMP # Files not in md5sum end up here
|
---|
28 |
|
---|
29 | if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
---|
30 | if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
---|
31 |
|
---|
32 | # Retrieve the master md5sum file
|
---|
33 | download "" MD5SUMS
|
---|
34 |
|
---|
35 | # Iterate through each package and grab it, along with any patches it needs.
|
---|
36 | for i in `cat $JHALFSDIR/packages` ; do
|
---|
37 | PKG=`echo $i | sed -e 's/-version.*//' \
|
---|
38 | -e 's/-file.*//' \
|
---|
39 | -e 's/uclibc/uClibc/' `
|
---|
40 |
|
---|
41 | # Needed for Groff patchlevel patch on UTF-8 branch
|
---|
42 | GROFFLEVEL=`grep "groff-patchlevel" $JHALFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
|
---|
43 |
|
---|
44 | #
|
---|
45 | # How to deal with orphan packages..??
|
---|
46 | #
|
---|
47 | VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
---|
48 | case "$PKG" in
|
---|
49 | "uClibc-patch" ) continue ;;
|
---|
50 |
|
---|
51 | "tcl" ) FILE="$PKG$VRS-src.tar.bz2" ; download $PKG $FILE ;;
|
---|
52 |
|
---|
53 | "uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc"
|
---|
54 | download $PKG $FILE
|
---|
55 | # There can be no patches for this file
|
---|
56 | continue ;;
|
---|
57 |
|
---|
58 | "gcc" ) download $PKG "gcc-core-$VRS.tar.bz2"
|
---|
59 | download $PKG "gcc-g++-$VRS.tar.bz2"
|
---|
60 | if [ ! "$TEST" = "0" ] ; then
|
---|
61 | download $PKG "gcc-testsuite-$VRS.tar.bz2" ;
|
---|
62 | fi
|
---|
63 | ;;
|
---|
64 | "glibc") download $PKG "$PKG-$VRS.tar.bz2"
|
---|
65 | download $PKG "$PKG-libidn-$VRS.tar.bz2"
|
---|
66 | ;;
|
---|
67 | * ) FILE="$PKG-$VRS.tar.bz2"
|
---|
68 | download $PKG $FILE
|
---|
69 | ;;
|
---|
70 | esac
|
---|
71 |
|
---|
72 | for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
|
---|
73 | PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
---|
74 | download $PKG $PATCH
|
---|
75 | done
|
---|
76 |
|
---|
77 | done
|
---|
78 |
|
---|
79 | # .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
---|
80 | download grsecurity `grep grsecurity $JHALFSDIR/patches`
|
---|
81 |
|
---|
82 | # .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue.
|
---|
83 | bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz
|
---|
84 |
|
---|
85 | if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
|
---|
86 | echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check <MISSING_FILES.DMP> for names ${OFF}\n\n"
|
---|
87 | fi
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | #----------------------------#
|
---|
92 | chapter4_Makefiles() { # Initialization of the system
|
---|
93 | #----------------------------#
|
---|
94 | local TARGET LOADER
|
---|
95 |
|
---|
96 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
|
---|
97 |
|
---|
98 | # Define a few model dependant variables
|
---|
99 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
100 | TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
101 | else
|
---|
102 | TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
103 | fi
|
---|
104 |
|
---|
105 | # 022-
|
---|
106 | # If /home/hlfs is already present in the host, we asume that the
|
---|
107 | # hlfs user and group are also presents in the host, and a backup
|
---|
108 | # of their bash init files is made.
|
---|
109 | (
|
---|
110 | cat << EOF
|
---|
111 | 020-creatingtoolsdir:
|
---|
112 | @\$(call echo_message, Building)
|
---|
113 | @mkdir -v \$(MOUNT_PT)/tools && \\
|
---|
114 | rm -fv /tools && \\
|
---|
115 | ln -sv \$(MOUNT_PT)/tools /
|
---|
116 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
117 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
118 | fi;
|
---|
119 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
120 | touch \$@
|
---|
121 |
|
---|
122 | 021-addinguser: 020-creatingtoolsdir
|
---|
123 | @\$(call echo_message, Building)
|
---|
124 | @if [ ! -d /home/lfs ]; then \\
|
---|
125 | groupadd lfs; \\
|
---|
126 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
127 | else \\
|
---|
128 | touch user-lfs-exist; \\
|
---|
129 | fi;
|
---|
130 | @chown lfs \$(MOUNT_PT)/tools && \\
|
---|
131 | chown lfs \$(MOUNT_PT)/sources && \\
|
---|
132 | touch \$@
|
---|
133 |
|
---|
134 | 022-settingenvironment: 021-addinguser
|
---|
135 | @\$(call echo_message, Building)
|
---|
136 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
137 | mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
138 | fi;
|
---|
139 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
140 | mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
141 | fi;
|
---|
142 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
143 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
144 | echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
---|
145 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
146 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
147 | echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
148 | echo "" >> /home/lfs/.bashrc && \\
|
---|
149 | echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
|
---|
150 | echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
|
---|
151 | echo "export target ldso" >> /home/lfs/.bashrc && \\
|
---|
152 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
---|
153 | chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
154 | touch envars && \\
|
---|
155 | touch \$@
|
---|
156 | EOF
|
---|
157 | ) >> $MKFILE.tmp
|
---|
158 |
|
---|
159 | }
|
---|
160 |
|
---|
161 | #----------------------------#
|
---|
162 | chapter5_Makefiles() { # Bootstrap or temptools phase
|
---|
163 | #----------------------------#
|
---|
164 | local file
|
---|
165 | local this_script
|
---|
166 |
|
---|
167 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
---|
168 |
|
---|
169 | for file in chapter05/* ; do
|
---|
170 | # Keep the script file name
|
---|
171 | this_script=`basename $file`
|
---|
172 |
|
---|
173 | # Skip this script depending on jhalfs.conf flags set.
|
---|
174 | case $this_script in
|
---|
175 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
176 | *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
177 | *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
178 | *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
179 | # Test if the stripping phase must be skipped
|
---|
180 | *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
181 | # Select the appropriate library
|
---|
182 | *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
|
---|
183 | *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
|
---|
184 | *) ;;
|
---|
185 | esac
|
---|
186 |
|
---|
187 | # First append each name of the script files to a list (this will become
|
---|
188 | # the names of the targets in the Makefile
|
---|
189 | chapter5="$chapter5 $this_script"
|
---|
190 |
|
---|
191 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
192 | # and binutils in chapter 5)
|
---|
193 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
|
---|
194 |
|
---|
195 | # >>>>>>>>>> U G L Y <<<<<<<<<
|
---|
196 | # Adjust 'name' and patch a few scripts on the fly..
|
---|
197 | case $name in
|
---|
198 | linux-libc) name=linux-libc-headers
|
---|
199 | ;;
|
---|
200 | uclibc) # this sucks as method to deal with gettext/libint inside uClibc
|
---|
201 | sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter05/$this_script
|
---|
202 | ;;
|
---|
203 | gcc) # to compensate for the compiler test inside gcc (which fails), disable error trap
|
---|
204 | sed 's@^gcc -o test test.c@set +e; gcc -o test test.c@' -i chapter05/$this_script
|
---|
205 | ;;
|
---|
206 | esac
|
---|
207 |
|
---|
208 | # Set the dependency for the first target.
|
---|
209 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
210 |
|
---|
211 |
|
---|
212 | #--------------------------------------------------------------------#
|
---|
213 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
214 | #--------------------------------------------------------------------#
|
---|
215 | #
|
---|
216 | # Drop in the name of the target on a new line, and the previous target
|
---|
217 | # as a dependency. Also call the echo_message function.
|
---|
218 | wrt_target "$this_script" "$PREV"
|
---|
219 |
|
---|
220 | # Find the version of the command files, if it corresponds with the building of
|
---|
221 | # a specific package
|
---|
222 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
223 | # If $vrs isn't empty, we've got a package...
|
---|
224 | if [ "$vrs" != "" ] ; then
|
---|
225 | # Deal with non-standard names
|
---|
226 | case $name in
|
---|
227 | tcl) FILE="$name$vrs-src.tar" ;;
|
---|
228 | uclibc) FILE="uClibc-$vrs.tar" ;;
|
---|
229 | gcc) FILE="gcc-core-$vrs.tar" ;;
|
---|
230 | *) FILE="$name-$vrs.tar" ;;
|
---|
231 | esac
|
---|
232 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
233 | wrt_unpack "$FILE"
|
---|
234 | fi
|
---|
235 |
|
---|
236 | case $this_script in
|
---|
237 | *binutils* ) # Dump the path to sources directory for later removal
|
---|
238 | echo -e '\techo "$(MOUNT_PT)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp
|
---|
239 | ;;
|
---|
240 | *adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
241 | echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
242 | ;;
|
---|
243 | * ) # Everything else, add a true statment so we don't confuse make
|
---|
244 | echo -e '\ttrue' >> $MKFILE.tmp
|
---|
245 | ;;
|
---|
246 | esac
|
---|
247 |
|
---|
248 | # Insert date and disk usage at the top of the log file, the script run
|
---|
249 | # and date and disk usage again at the bottom of the log file.
|
---|
250 | wrt_run_as_su "${this_script}" "${file}"
|
---|
251 |
|
---|
252 | # Remove the build directory(ies) except if the package build fails
|
---|
253 | # (so we can review config.cache, config.log, etc.)
|
---|
254 | # For Binutils the sources must be retained for some time.
|
---|
255 | if [ "$vrs" != "" ] ; then
|
---|
256 | if [[ ! `_IS_ $this_script binutils` ]]; then
|
---|
257 | wrt_remove_build_dirs "$name"
|
---|
258 | fi
|
---|
259 | fi
|
---|
260 |
|
---|
261 | # Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
---|
262 | if [[ `_IS_ $this_script adjusting` ]] ; then
|
---|
263 | (
|
---|
264 | cat << EOF
|
---|
265 | @rm -r \`cat sources-dir\` && \\
|
---|
266 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
267 | rm sources-dir
|
---|
268 | EOF
|
---|
269 | ) >> $MKFILE.tmp
|
---|
270 | fi
|
---|
271 |
|
---|
272 | # Include a touch of the target name so make can check if it's already been made.
|
---|
273 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
274 | #
|
---|
275 | #--------------------------------------------------------------------#
|
---|
276 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
277 | #--------------------------------------------------------------------#
|
---|
278 |
|
---|
279 | # Keep the script file name for Makefile dependencies.
|
---|
280 | PREV=$this_script
|
---|
281 | done # end for file in chapter05/*
|
---|
282 | }
|
---|
283 |
|
---|
284 |
|
---|
285 | #----------------------------#
|
---|
286 | chapter6_Makefiles() { # sysroot or chroot build phase
|
---|
287 | #----------------------------#
|
---|
288 | local TARGET LOADER
|
---|
289 | local file
|
---|
290 | local this_script
|
---|
291 |
|
---|
292 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6${R_arrow}"
|
---|
293 | #
|
---|
294 | # Set these definitions early and only once
|
---|
295 | #
|
---|
296 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
297 | TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
298 | else
|
---|
299 | TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
300 | fi
|
---|
301 |
|
---|
302 | for file in chapter06/* ; do
|
---|
303 | # Keep the script file name
|
---|
304 | this_script=`basename $file`
|
---|
305 |
|
---|
306 | # Skip this script depending on jhalfs.conf flags set.
|
---|
307 | case $this_script in
|
---|
308 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
309 | # dependencies and target creation.
|
---|
310 | *chroot* ) continue ;;
|
---|
311 | # Test if the stripping phase must be skipped
|
---|
312 | *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
313 | # Select the appropriate library
|
---|
314 | *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
|
---|
315 | *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
|
---|
316 | *) ;;
|
---|
317 | esac
|
---|
318 |
|
---|
319 | # First append each name of the script files to a list (this will become
|
---|
320 | # the names of the targets in the Makefile
|
---|
321 | chapter6="$chapter6 $this_script"
|
---|
322 |
|
---|
323 | # Grab the name of the target
|
---|
324 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
325 |
|
---|
326 | #
|
---|
327 | # Sed replacement for 'nodump' tag in xml scripts until Manuel has a chance to fix them
|
---|
328 | #
|
---|
329 | case $name in
|
---|
330 | kernfs)
|
---|
331 | # We are using LFS instead of HLFS..
|
---|
332 | sed 's/HLFS/LFS/' -i chapter06/$this_script
|
---|
333 | # Remove sysctl code if host does not have grsecurity enabled
|
---|
334 | if [[ "$GRSECURITY_HOST" = "0" ]]; then
|
---|
335 | sed '/sysctl/d' -i chapter06/$this_script
|
---|
336 | fi
|
---|
337 | ;;
|
---|
338 | module-init-tools)
|
---|
339 | if [[ "$TEST" = "0" ]]; then # This needs rework....
|
---|
340 | sed '/make distclean/d' -i chapter06/$this_script
|
---|
341 | fi
|
---|
342 | ;;
|
---|
343 | glibc) # PATCH.. Turn off error trapping for the remainder of the script.
|
---|
344 | sed 's|^make install|make install; set +e|' -i chapter06/$this_script
|
---|
345 | ;;
|
---|
346 | uclibc) # PATCH..
|
---|
347 | sed 's/EST5EDT/${TIMEZONE}/' -i chapter06/$this_script
|
---|
348 | # PATCH.. Cannot use interactive programs/scripts.
|
---|
349 | sed 's/make menuconfig/make oldconfig/' -i chapter06/$this_script
|
---|
350 | sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter06/$this_script
|
---|
351 | ;;
|
---|
352 | gcc) # PATCH..
|
---|
353 | sed 's/rm /rm -f /' -i chapter06/$this_script
|
---|
354 | ;;
|
---|
355 | esac
|
---|
356 |
|
---|
357 | #--------------------------------------------------------------------#
|
---|
358 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
359 | #--------------------------------------------------------------------#
|
---|
360 | #
|
---|
361 | # Drop in the name of the target on a new line, and the previous target
|
---|
362 | # as a dependency. Also call the echo_message function.
|
---|
363 | wrt_target "$this_script" "$PREV"
|
---|
364 |
|
---|
365 | # Find the version of the command files, if it corresponds with the building of
|
---|
366 | # a specific package
|
---|
367 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
368 |
|
---|
369 | # If $vrs isn't empty, we've got a package...
|
---|
370 | # Insert instructions for unpacking the package and changing directories
|
---|
371 | if [ "$vrs" != "" ] ; then
|
---|
372 | # Deal with non-standard names
|
---|
373 | case $name in
|
---|
374 | tcl) FILE="$name$vrs-src.tar.*" ;;
|
---|
375 | uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
---|
376 | gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
---|
377 | *) FILE="$name-$vrs.tar.*" ;;
|
---|
378 | esac
|
---|
379 | wrt_unpack2 "$FILE"
|
---|
380 | wrt_target_vars
|
---|
381 | fi
|
---|
382 |
|
---|
383 | case $this_script in
|
---|
384 | *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
---|
385 | echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
386 | ;;
|
---|
387 | *glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar.
|
---|
388 | wrt_export_timezone
|
---|
389 | ;;
|
---|
390 | *groff* ) # For Groff we need to set PAGE envar.
|
---|
391 | wrt_export_pagesize
|
---|
392 | ;;
|
---|
393 | esac
|
---|
394 |
|
---|
395 | # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
|
---|
396 | if [[ `_IS_ $this_script kernfs` ]] ; then
|
---|
397 | wrt_run_as_root "${this_script}" "${file}"
|
---|
398 | #
|
---|
399 | # The rest of Chapter06
|
---|
400 | else
|
---|
401 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
402 | fi
|
---|
403 | #
|
---|
404 | # Remove the build directory(ies) except if the package build fails.
|
---|
405 | if [ "$vrs" != "" ] ; then
|
---|
406 | wrt_remove_build_dirs "$name"
|
---|
407 | fi
|
---|
408 | #
|
---|
409 | # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
---|
410 | if [[ `_IS_ $this_script readjusting` ]] ; then
|
---|
411 | (
|
---|
412 | cat << EOF
|
---|
413 | @rm -r \`cat sources-dir\` && \\
|
---|
414 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
415 | rm sources-dir
|
---|
416 | EOF
|
---|
417 | ) >> $MKFILE.tmp
|
---|
418 | fi
|
---|
419 |
|
---|
420 | # Include a touch of the target name so make can check if it's already been made.
|
---|
421 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
422 | #
|
---|
423 | #--------------------------------------------------------------------#
|
---|
424 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
425 | #--------------------------------------------------------------------#
|
---|
426 |
|
---|
427 | # Keep the script file name for Makefile dependencies.
|
---|
428 | PREV=$this_script
|
---|
429 | done # end for file in chapter06/*
|
---|
430 |
|
---|
431 | }
|
---|
432 |
|
---|
433 | #----------------------------#
|
---|
434 | chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
---|
435 | #----------------------------#
|
---|
436 | local file
|
---|
437 | local this_script
|
---|
438 |
|
---|
439 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
|
---|
440 | for file in chapter07/*; do
|
---|
441 | # Keep the script file name
|
---|
442 | this_script=`basename $file`
|
---|
443 |
|
---|
444 | # Grub must be configured manually.
|
---|
445 | # The filesystems can't be unmounted via Makefile and the user
|
---|
446 | # should enter the chroot environment to create the root
|
---|
447 | # password, edit several files and setup Grub.
|
---|
448 | case $this_script in
|
---|
449 | *grub) continue ;;
|
---|
450 | *reboot) continue ;;
|
---|
451 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
452 |
|
---|
453 | *kernel)
|
---|
454 | # If no .config file is supplied, the kernel build is skipped
|
---|
455 | [[ -z $CONFIG ]] && continue
|
---|
456 | # How does Manuel add this string to the file..
|
---|
457 | sed 's|cd \$PKGDIR.*||' -i chapter07/$this_script
|
---|
458 | # You cannot run menuconfig from within the makefile
|
---|
459 | sed 's|make menuconfig|make oldconfig|' -i chapter07/$this_script
|
---|
460 | # The files in the conglomeration dir are xxx.bz2
|
---|
461 | sed 's|.patch.gz|.patch.bz2|' -i chapter07/$this_script
|
---|
462 | sed 's|gunzip|bunzip2|' -i chapter07/$this_script
|
---|
463 | # If defined include the keymap in the kernel
|
---|
464 | if [[ -n "$KEYMAP" ]]; then
|
---|
465 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i chapter07/$this_script
|
---|
466 | else
|
---|
467 | sed '/loadkeys -m/d' -i chapter07/$this_script
|
---|
468 | sed '/drivers\/char/d' -i chapter07/$this_script
|
---|
469 | fi
|
---|
470 | ;;
|
---|
471 | *usage) # The script bombs, disable error trapping
|
---|
472 | sed 's|set -e|set +e|' -i chapter07/$this_script
|
---|
473 | ;;
|
---|
474 | *profile) # Add the config values to the script
|
---|
475 | sed "s|LC_ALL=\*\*EDITME.*EDITME\*\*|LC_ALL=$LC_ALL|" -i chapter07/$this_script
|
---|
476 | sed "s|LANG=\*\*EDITME.*EDITME\*\*|LANG=$LANG|" -i chapter07/$this_script
|
---|
477 | ;;
|
---|
478 | esac
|
---|
479 |
|
---|
480 | # First append then name of the script file to a list (this will become
|
---|
481 | # the names of the targets in the Makefile
|
---|
482 | chapter7="$chapter7 $this_script"
|
---|
483 |
|
---|
484 | #--------------------------------------------------------------------#
|
---|
485 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
486 | #--------------------------------------------------------------------#
|
---|
487 | #
|
---|
488 | # Drop in the name of the target on a new line, and the previous target
|
---|
489 | # as a dependency. Also call the echo_message function.
|
---|
490 | wrt_target "$this_script" "$PREV"
|
---|
491 |
|
---|
492 | if [[ `_IS_ $this_script bootscripts` ]] ; then
|
---|
493 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
494 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
495 | # The bootscript pkg references both lfs AND blfs bootscripts...
|
---|
496 | # see XML script for other additions to bootscripts file
|
---|
497 | # PATCH
|
---|
498 | vrs=`grep "^blfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
499 | sed "s|make install$|make install; cd ../blfs-bootscripts-$vrs|" -i chapter07/$this_script
|
---|
500 | wrt_unpack2 "$FILE"
|
---|
501 | (
|
---|
502 | cat << EOF
|
---|
503 | echo "\$(MOUNT_PT)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir
|
---|
504 | EOF
|
---|
505 | ) >> $MKFILE.tmp
|
---|
506 | fi
|
---|
507 |
|
---|
508 | if [[ `_IS_ $this_script kernel` ]] ; then
|
---|
509 | # not much really, script does everything..
|
---|
510 | echo -e "\t@cp -f $CONFIG \$(MOUNT_PT)/sources/kernel-config" >> $MKFILE.tmp
|
---|
511 | fi
|
---|
512 |
|
---|
513 | case "${this_script}" in
|
---|
514 | *profile* ) wrt_export_lang2 ;; # For /etc/profile we need to set LANG envar.
|
---|
515 | esac
|
---|
516 |
|
---|
517 | # Check if we have a real /etc/fstab file
|
---|
518 | if [[ `_IS_ $this_script fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
---|
519 | wrt_copy_fstab "$this_script"
|
---|
520 | else
|
---|
521 | # Initialize the log and run the script
|
---|
522 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
523 | fi
|
---|
524 |
|
---|
525 | # Remove the build directory except if the package build fails.
|
---|
526 | if [[ `_IS_ $this_script bootscripts` ]]; then
|
---|
527 | (
|
---|
528 | cat << EOF
|
---|
529 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
530 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
531 | @rm -r \`cat sources-dir\` && \\
|
---|
532 | rm sources-dir
|
---|
533 | EOF
|
---|
534 | ) >> $MKFILE.tmp
|
---|
535 | fi
|
---|
536 |
|
---|
537 | # Include a touch of the target name so make can check if it's already been made.
|
---|
538 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
539 | #
|
---|
540 | #--------------------------------------------------------------------#
|
---|
541 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
542 | #--------------------------------------------------------------------#
|
---|
543 |
|
---|
544 | # Keep the script file name for Makefile dependencies.
|
---|
545 | PREV=$this_script
|
---|
546 | done # for file in chapter07/*
|
---|
547 | }
|
---|
548 |
|
---|
549 |
|
---|
550 | #----------------------------#
|
---|
551 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
552 | #----------------------------#
|
---|
553 | echo "Creating Makefile... "
|
---|
554 |
|
---|
555 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
556 | # Start with a clean Makefile.tmp file
|
---|
557 | >$MKFILE.tmp
|
---|
558 |
|
---|
559 | chapter4_Makefiles
|
---|
560 | chapter5_Makefiles
|
---|
561 | chapter6_Makefiles
|
---|
562 | chapter7_Makefiles
|
---|
563 |
|
---|
564 | # Add a header, some variables and include the function file
|
---|
565 | # to the top of the real Makefile.
|
---|
566 | (
|
---|
567 | cat << EOF
|
---|
568 | $HEADER
|
---|
569 |
|
---|
570 | SRC= /sources
|
---|
571 | MOUNT_PT= $BUILDDIR
|
---|
572 | PAGE= $PAGE
|
---|
573 | TIMEZONE= $TIMEZONE
|
---|
574 | LC_ALL= $LC_ALL
|
---|
575 | LANG= $LANG
|
---|
576 |
|
---|
577 | include makefile-functions
|
---|
578 |
|
---|
579 | EOF
|
---|
580 | ) > $MKFILE
|
---|
581 |
|
---|
582 |
|
---|
583 | # Add chroot commands
|
---|
584 | i=1
|
---|
585 | for file in chapter06/*chroot* ; do
|
---|
586 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
587 | -e '/^export/d' \
|
---|
588 | -e '/^logout/d' \
|
---|
589 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
590 | -e 's|\\$|&&|g' \
|
---|
591 | -e 's|exit||g' \
|
---|
592 | -e 's|$| -c|' \
|
---|
593 | -e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
---|
594 | -e 's|set -e||'`
|
---|
595 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
596 | i=`expr $i + 1`
|
---|
597 | done
|
---|
598 |
|
---|
599 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
600 | # as a dependency.
|
---|
601 | (
|
---|
602 | cat << EOF
|
---|
603 | all: chapter4 chapter5 chapter6 chapter7
|
---|
604 | @\$(call echo_finished,$VERSION)
|
---|
605 |
|
---|
606 | chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
607 |
|
---|
608 | chapter5: chapter4 $chapter5 restore-hlfs-env
|
---|
609 |
|
---|
610 | chapter6: chapter5 $chapter6
|
---|
611 |
|
---|
612 | chapter7: chapter6 $chapter7
|
---|
613 |
|
---|
614 | clean-all: clean
|
---|
615 | rm -rf ./{hlfs-commands,logs,Makefile,dump-hlfs-scripts.xsl,functions,packages,patches}
|
---|
616 |
|
---|
617 | clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter4
|
---|
618 |
|
---|
619 | clean-chapter4:
|
---|
620 | -if [ ! -f user-hlfs-exist ]; then \\
|
---|
621 | userdel hlfs; \\
|
---|
622 | rm -rf /home/hlfs; \\
|
---|
623 | fi;
|
---|
624 | rm -rf \$(MOUNT_PT)/tools
|
---|
625 | rm -f /tools
|
---|
626 | rm -f envars user-hlfs-exist
|
---|
627 | rm -f 02* logs/02*.log
|
---|
628 |
|
---|
629 | clean-chapter5:
|
---|
630 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
631 | rm -f $chapter5 restore-hlfs-env sources-dir
|
---|
632 | cd logs && rm -f $chapter5 && cd ..
|
---|
633 |
|
---|
634 | clean-chapter6:
|
---|
635 | -umount \$(MOUNT_PT)/sys
|
---|
636 | -umount \$(MOUNT_PT)/proc
|
---|
637 | -umount \$(MOUNT_PT)/dev/shm
|
---|
638 | -umount \$(MOUNT_PT)/dev/pts
|
---|
639 | -umount \$(MOUNT_PT)/dev
|
---|
640 | rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
641 | rm -f $chapter6
|
---|
642 | cd logs && rm -f $chapter6 && cd ..
|
---|
643 |
|
---|
644 | clean-chapter7:
|
---|
645 | rm -f $chapter7
|
---|
646 | cd logs && rm -f $chapter7 && cd ..
|
---|
647 |
|
---|
648 | restore-hlfs-env:
|
---|
649 | @\$(call echo_message, Building)
|
---|
650 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
651 | mv -fv /home/lfs/.bashrc.XXX /home/hlfs/.bashrc; \\
|
---|
652 | fi;
|
---|
653 | @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
|
---|
654 | mv -v /home/lfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
|
---|
655 | fi;
|
---|
656 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
657 | touch \$@
|
---|
658 |
|
---|
659 | EOF
|
---|
660 | ) >> $MKFILE
|
---|
661 |
|
---|
662 | # Bring over the items from the Makefile.tmp
|
---|
663 | cat $MKFILE.tmp >> $MKFILE
|
---|
664 | rm $MKFILE.tmp
|
---|
665 | echo "done"
|
---|
666 | }
|
---|
667 |
|
---|
668 |
|
---|