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