source: CLFS/master.sh@ cbfba99

2.4 ablfs-more legacy new_features trunk
Last change on this file since cbfba99 was b4df9e1, checked in by Pierre Labastie <pierre@…>, 11 years ago

Add network scripts for CLFS systemd branch

  • Property mode set to 100644
File size: 39.4 KB
Line 
1#!/bin/bash
2# $Id$
3
4
5orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
6
7
8#--------------------------------------#
9host_prep_Makefiles() { #
10#--------------------------------------#
11 local CLFS_HOST
12
13 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
14
15 # defined here, only for ease of reading
16 CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
17(
18cat << EOF
19023-creatingtoolsdir:
20 @\$(call echo_message, Building)
21 @install -dv \$(MOUNT_PT)/tools && \\
22 rm -f /tools && \\
23 ln -s \$(MOUNT_PT)/tools /
24 @\$(call housekeeping)
25
26024-creatingcrossdir: 023-creatingtoolsdir
27 @\$(call echo_message, Building)
28 @install -dv \$(MOUNT_PT)/cross-tools && \\
29 rm -f /cross-tools && \\
30 ln -s \$(MOUNT_PT)/cross-tools /
31 @\$(call housekeeping)
32
33025-addinguser: 024-creatingcrossdir
34 @\$(call echo_message, Building)
35 @if [ ! -d \$(LUSER_HOME) ]; then \\
36 groupadd \$(LGROUP); \\
37 useradd -s /bin/bash -g \$(LGROUP) -d \$(LUSER_HOME) \$(LUSER); \\
38 mkdir -pv \$(LUSER_HOME); \\
39 chown -v \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
40 else \\
41 touch luser-exist; \\
42 fi
43 @chown -v \$(LUSER) \$(MOUNT_PT)/tools && \\
44 chown -v \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
45 chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
46 chmod a+wt \$(SRCSDIR)
47 @\$(call housekeeping)
48
49026-settingenvironment: 025-addinguser
50 @\$(call echo_message, Building)
51 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
52 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
53 fi
54 @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
55 mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
56 fi;
57 @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
58 echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
59 echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
60 echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
61 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
62 echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
63 echo "" >> \$(LUSER_HOME)/.bashrc && \\
64 echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
65 echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
66 echo "" >> \$(LUSER_HOME)/.bashrc && \\
67 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
68 echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
69 echo "export CLFS_TARGET32=\"${TARGET32}\"" >> \$(LUSER_HOME)/.bashrc && \\
70 echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
71 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
72 chmod a+wt \$(MOUNT_PT) && \\
73 if [ -d \$(MOUNT_PT)/var ]; then \\
74 chown -R \$(LUSER) \$(MOUNT_PT)/var; \\
75 fi && \\
76 touch envars && \\
77 chown \$(LUSER):\$(LGROUP) envars
78 @\$(call housekeeping)
79EOF
80) >> $MKFILE.tmp
81 host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
82
83}
84
85#--------------------------------------#
86cross_tools_Makefiles() { #
87#--------------------------------------#
88 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
89
90 for file in cross-tools/* ; do
91 # Keep the script file name
92 this_script=`basename $file`
93 #
94 # Skip this script...
95 case $this_script in
96 *cflags* | *variables* ) # work done in host_prep_Makefiles
97 continue; ;;
98 *) ;;
99 esac
100 #
101 # Set the dependency for the first target.
102 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
103
104 # First append each name of the script files to a list (this will become
105 # the names of the targets in the Makefile
106 cross_tools="$cross_tools $this_script"
107
108 # Grab the name of the target (minus the -headers or -cross in the case of gcc
109 # and binutils in chapter 5)
110 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
111 -e 's@-static@@' \
112 -e 's@-final@@' \
113 -e 's@-64@@' \
114 -e 's@-n32@@'`
115 pkg_tarball=$(get_package_tarball_name $name)
116
117 #--------------------------------------------------------------------#
118 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
119 #--------------------------------------------------------------------#
120 #
121 # Drop in the name of the target on a new line, and the previous target
122 # as a dependency. Also call the echo_message function.
123 LUSER_wrt_target "${this_script}" "$PREV"
124 #
125 # If $pkg_tarball isn't empty, we've got a package...
126 #
127 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
128 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = 3 ]] && wrt_makeflags "${name}"
129 #
130 LUSER_wrt_RunAsUser "${file}"
131 #
132 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
133 #
134 # Include a touch of the target name so make can check if it's already been made.
135 wrt_touch
136 #
137 #--------------------------------------------------------------------#
138 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
139 #--------------------------------------------------------------------#
140 #
141 # Keep the script file name for Makefile dependencies.
142 PREV=$this_script
143
144 done # for file in ....
145}
146
147#--------------------------------------#
148temptools_Makefiles() { #
149#--------------------------------------#
150 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
151
152 for file in temp-system/* ; do
153 # Keep the script file name
154 this_script=`basename $file`
155 #
156 # Deal with any odd scripts..
157 case $this_script in
158 *choose) # The choose script will fail if you cannot enter the new environment
159 # If the 'boot' build method was chosen don't run the script
160 [[ $METHOD = "boot" ]] && continue; ;;
161 *) ;;
162 esac
163
164 #
165 # First append each name of the script files to a list (this will become
166 # the names of the targets in the Makefile
167 temptools="$temptools $this_script"
168
169 #
170 # Grab the name of the target, strip id number, XXX-script
171 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
172 #
173 pkg_tarball=$(get_package_tarball_name $name)
174
175 #--------------------------------------------------------------------#
176 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
177 #--------------------------------------------------------------------#
178 #
179 # Drop in the name of the target on a new line, and the previous target
180 # as a dependency. Also call the echo_message function.
181 LUSER_wrt_target "${this_script}" "$PREV"
182 #
183 # If $pkg_tarball isn't empty, we've got a package...
184 # Insert instructions for unpacking the package and to set the PKGDIR variable.
185 #
186 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
187 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
188 #
189 LUSER_wrt_RunAsUser "${file}"
190 #
191 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
192 #
193 # Include a touch of the target name so make can check if it's already been made.
194 wrt_touch
195 #
196 #--------------------------------------------------------------------#
197 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
198 #--------------------------------------------------------------------#
199 #
200 # Keep the script file name for Makefile dependencies.
201 PREV=$this_script
202 done # for file in ....
203}
204
205
206#--------------------------------------#
207chroot_Makefiles() { #
208#--------------------------------------#
209 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
210
211 for file in chroot/* ; do
212 # Keep the script file name
213 this_script=`basename $file`
214 #
215 # Skipping scripts is done now and not included in the build tree.
216 case $this_script in
217 *chroot*) continue ;;
218 esac
219
220 #
221 # First append each name of the script files to a list (this will become
222 # the names of the targets in the Makefile
223 case "${this_script}" in
224 *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
225 *) chroottools="$chroottools $this_script" ;;
226 esac
227
228 # Grab the name of the target, strip id number, XXX-script
229 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
230
231 pkg_tarball=$(get_package_tarball_name $name)
232
233 # This is very ugly:: util-linux is in /chroot but must be run under LUSER
234 # Same for e2fsprogs (in CLFS 1.1.0)
235 # .. Customized makefile entry
236 case "${this_script}" in
237 *util-linux)
238 LUSER_wrt_target "${this_script}" "$PREV"
239 LUSER_wrt_unpack "$pkg_tarball"
240 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
241 LUSER_wrt_RunAsUser "${file}"
242 LUSER_RemoveBuildDirs "${name}"
243 wrt_touch
244 temptools="$temptools $this_script"
245 continue ;;
246 *util-linux-ng)
247 LUSER_wrt_target "${this_script}" "$PREV"
248 LUSER_wrt_unpack "$pkg_tarball"
249 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
250 LUSER_wrt_RunAsUser "${file}"
251 LUSER_RemoveBuildDirs "${name}"
252 wrt_touch
253 temptools="$temptools $this_script"
254 continue ;;
255 *util-linux-libs)
256 LUSER_wrt_target "${this_script}" "$PREV"
257 LUSER_wrt_unpack "$pkg_tarball"
258 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
259 LUSER_wrt_RunAsUser "${file}"
260 LUSER_RemoveBuildDirs "${name}"
261 wrt_touch
262 temptools="$temptools $this_script"
263 continue ;;
264 *e2fsprogs)
265 LUSER_wrt_target "${this_script}" "$PREV"
266 LUSER_wrt_unpack "$pkg_tarball"
267 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
268 LUSER_wrt_RunAsUser "${file}"
269 LUSER_RemoveBuildDirs "${name}"
270 wrt_touch
271 temptools="$temptools $this_script"
272 continue ;;
273 *e2fsprogs-libs)
274 LUSER_wrt_target "${this_script}" "$PREV"
275 LUSER_wrt_unpack "$pkg_tarball"
276 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
277 LUSER_wrt_RunAsUser "${file}"
278 LUSER_RemoveBuildDirs "${name}"
279 wrt_touch
280 temptools="$temptools $this_script"
281 continue ;;
282 esac
283
284
285 #--------------------------------------------------------------------#
286 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
287 #--------------------------------------------------------------------#
288 #
289 # Drop in the name of the target on a new line, and the previous target
290 # as a dependency. Also call the echo_message function.
291 CHROOT_wrt_target "${this_script}" "$PREV"
292 #
293 # If $pkg_tarball isn't empty, we've got a package...
294 # Insert instructions for unpacking the package and changing directories
295 #
296 if [ "$pkg_tarball" != "" ] ; then
297 CHROOT_Unpack "$pkg_tarball"
298 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
299 fi
300 #
301 # Select a script execution method
302 case $this_script in
303 *kernfs) wrt_RunAsRoot "${file}" ;;
304 *) CHROOT_wrt_RunAsRoot "${file}" ;;
305 esac
306 #
307 # Housekeeping...remove the build directory(ies), except if the package build fails.
308 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
309 #
310 # Include a touch of the target name so make can check if it's already been made.
311 wrt_touch
312 #
313 #--------------------------------------------------------------------#
314 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
315 #--------------------------------------------------------------------#
316 #
317 # Keep the script file name for Makefile dependencies.
318 PREV=$this_script
319
320 done # for file in...
321}
322
323
324#--------------------------------------#
325boot_Makefiles() { #
326#--------------------------------------#
327
328 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
329 #
330 # Create a target bootable partition containing a compile environment. Later
331 # on we boot into this environment and contine the build.
332 #
333 for file in boot/* ; do
334 # Keep the script file name
335 this_script=`basename $file`
336
337 # A little housekeeping on the scripts
338 case $this_script in
339 *grub | *aboot | *colo | *silo | *arcload | *lilo | *introduction ) continue ;;
340 *whatnext*) continue ;;
341 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
342 *kernel) # if there is no kernel config file do not build the kernel
343 [[ -z $CONFIG ]] && continue
344 # Copy the config file to /sources with a standardized name
345 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
346 ;;
347 esac
348 #
349 # First append each name of the script files to a list (this will become
350 # the names of the targets in the Makefile
351 case "${this_script}" in
352 *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
353 *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
354 *) boottools="$boottools $this_script" ;;
355 esac
356 #
357 # Grab the name of the target, strip id number and misc words.
358 case $this_script in
359 *kernel) name=linux ;;
360 *bootscripts) name="bootscripts-cross-lfs" ;;
361 *udev-rules) name="udev-cross-lfs" ;;
362 *grub-build) name=grub ;;
363 *-aboot-build) name=aboot ;;
364 *yaboot-build) name=yaboot ;;
365 *colo-build) name=colo ;;
366 *silo-build) name=silo ;;
367 *arcload-build) name=arcload ;;
368 *lilo-build) name=lilo ;;
369 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
370 esac
371 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
372 pkg_tarball=$(get_package_tarball_name $name)
373
374 #--------------------------------------------------------------------#
375 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
376 #--------------------------------------------------------------------#
377 #
378 # Drop in the name of the target on a new line, and the previous target
379 # as a dependency. Also call the echo_message function.
380 LUSER_wrt_target "${this_script}" "$PREV"
381 #
382 # If $pkg_tarball isn't empty, we've got a package...
383 # Insert instructions for unpacking the package and changing directories
384 #
385 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
386 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
387 #
388 # Select a script execution method
389 case $this_script in
390 # The following 2 scripts are defined in the /boot directory but need
391 # to be run as a root user. Set them up here but run them in another phase
392 *changingowner*) wrt_RunAsRoot "${file}" ;;
393 *devices*) wrt_RunAsRoot "${file}" ;;
394 *fstab*) if [[ -n "$FSTAB" ]]; then
395 LUSER_wrt_CopyFstab
396 else
397 LUSER_wrt_RunAsUser "${file}"
398 fi
399 ;;
400 *) LUSER_wrt_RunAsUser "${file}" ;;
401 esac
402 #
403 # Housekeeping...remove any build directory(ies) except if the package build fails.
404 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
405 #
406 # Include a touch of the target name so make can check if it's already been made.
407 wrt_touch
408 #
409 #--------------------------------------------------------------------#
410 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
411 #--------------------------------------------------------------------#
412 #
413 # Keep the script file name for Makefile dependencies.
414 PREV=$this_script
415
416 done
417}
418
419
420#--------------------------------------#
421testsuite_tools_Makefiles() { #
422#--------------------------------------#
423
424 if [[ "${METHOD}" = "chroot" ]]; then
425 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
426 else
427 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
428 PREV=""
429 fi
430
431 for file in testsuite-tools/* ; do
432 # Keep the script file name
433 this_script=`basename $file`
434
435 # First append each name of the script files to a list (this will become
436 # the names of the targets in the Makefile
437 testsuitetools="$testsuitetools $this_script"
438
439 # Grab the name of the target, strip id number, XXX-script
440 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
441 -e 's@-64bit@@' \
442 -e 's@-64@@' \
443 -e 's@64@@' \
444 -e 's@n32@@'`
445
446 pkg_tarball=$(get_package_tarball_name $name)
447
448 #--------------------------------------------------------------------#
449 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
450 #--------------------------------------------------------------------#
451 #
452 # Drop in the name of the target on a new line, and the previous target
453 # as a dependency. Also call the echo_message function.
454 CHROOT_wrt_target "${this_script}" "$PREV"
455 #
456 CHROOT_Unpack "$pkg_tarball"
457 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
458 #
459 CHROOT_wrt_RunAsRoot "${file}"
460 #
461 CHROOT_wrt_RemoveBuildDirs "${name}"
462 #
463 # Include a touch of the target name so make can check if it's already been made.
464 wrt_touch
465 #
466 #--------------------------------------------------------------------#
467 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
468 #--------------------------------------------------------------------#
469 #
470 # Keep the script file name for Makefile dependencies.
471 PREV=$this_script
472
473 done
474}
475
476
477#--------------------------------------#
478final_system_Makefiles() { #
479#--------------------------------------#
480 # Set envars and scripts for iteration targets
481 if [[ -z "$1" ]] ; then
482 local N=""
483 # In boot method the makesys phase was initiated in testsuite_tools_makefile
484 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
485 else
486 local N=-build_$1
487 local basicsystem=""
488 mkdir final-system$N
489 cp final-system/* final-system$N
490 for script in final-system$N/* ; do
491 # Overwrite existing symlinks, files, and dirs
492 sed -e 's/ln -sv/&f/g' \
493 -e 's/mv -v/&f/g' \
494 -e 's/mkdir -v/&p/g' -i ${script}
495 # Rename the scripts
496 mv ${script} ${script}$N
497 done
498 # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
499 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
500 # Delete *old Readline libraries just after make install
501 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
502 fi
503
504 if [[ "${METHOD}" = "chroot" ]]; then
505 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
506 else
507 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
508 fi
509
510 for file in final-system$N/* ; do
511 # Keep the script file name
512 this_script=`basename $file`
513
514 # Test if the stripping phase must be skipped.
515 # Skip also temp-perl for iterative runs
516 case $this_script in
517 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
518 *temp-perl*) [[ -n "$N" ]] && continue ;;
519 esac
520
521 # Grab the name of the target, strip id number, XXX-script.
522 # name1 is partially stripped and should be used for logging files.
523 # name is completely stripped and is used for grabbing
524 # the package name.
525 name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
526 -e 's,'$N',,'`
527 name=`echo $name1 | sed -e 's@temp-@@' \
528 -e 's@-64bit@@' \
529 -e 's@-64@@' \
530 -e 's@64@@' \
531 -e 's@n32@@'`
532
533 # Find the version of the command files, if it corresponds with the building of
534 # a specific package. We need this here to can skip scripts not needed for
535 # iterations rebuilds
536 pkg_tarball=$(get_package_tarball_name $name)
537
538 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
539 case "${this_script}" in
540 *stripping*) ;;
541 *) continue ;;
542 esac
543 fi
544
545 # Append each name of the script files to a list (this will become
546 # the names of the targets in the Makefile
547 basicsystem="$basicsystem ${this_script}"
548
549 #--------------------------------------------------------------------#
550 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
551 #--------------------------------------------------------------------#
552 #
553 # Drop in the name of the target on a new line, and the previous target
554 # as a dependency. Also call the echo_message function.
555 CHROOT_wrt_target "${this_script}" "$PREV"
556
557 # If $pkg_tarball isn't empty, we've got a package...
558 if [ "$pkg_tarball" != "" ] ; then
559 # Touch timestamp file if installed files logs will be created.
560 # But only for the firt build when running iterative builds.
561 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
562 CHROOT_wrt_TouchTimestamp
563 fi
564 CHROOT_Unpack "$pkg_tarball"
565 # If the testsuites must be run, initialize the log file
566 case $name in
567 binutils | gcc | glibc | eglibc | gmp | mpfr | mpc | isl | cloog )
568 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
569 ;;
570 * )
571 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
572 ;;
573 esac
574 # If using optimizations, write the instructions
575 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
576 fi
577 #
578 CHROOT_wrt_RunAsRoot "${file}"
579 #
580 # Write installed files log and remove the build directory(ies)
581 # except if the package build fails.
582 if [ "$pkg_tarball" != "" ] ; then
583 CHROOT_wrt_RemoveBuildDirs "$name"
584 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
585 CHROOT_wrt_LogNewFiles "$name1"
586 fi
587 fi
588 #
589 # Include a touch of the target name so make can check
590 # if it's already been made.
591 wrt_touch
592 #
593 #--------------------------------------------------------------------#
594 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
595 #--------------------------------------------------------------------#
596 #
597 # Keep the script file name for Makefile dependencies.
598 PREV=${this_script}
599 # Set system_build envar for iteration targets
600 system_build=$basicsystem
601 done # for file in final-system/* ...
602}
603
604#--------------------------------------#
605bootscripts_Makefiles() { #
606#--------------------------------------#
607
608 if [[ "${METHOD}" = "chroot" ]]; then
609 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
610 else
611 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
612 fi
613
614 for file in bootscripts/* ; do
615 # Keep the script file name
616 this_script=`basename $file`
617
618 case $this_script in
619 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
620 *console*) continue ;; # Use the files that came with the bootscripts
621 *) ;;
622 esac
623
624 # First append each name of the script files to a list (this will become
625 # the names of the targets in the Makefile
626 bootscripttools="$bootscripttools $this_script"
627
628 # Grab the name of the target, strip id number, XXX-script.
629 # name1 is partially stripped and should be used for logging files.
630 # name is completely stripped and is used for grabbing
631 # the package name.
632 name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
633 name=`echo $name1 | sed -e 's@-64bit@@' \
634 -e 's@-64@@' \
635 -e 's@64@@' \
636 -e 's@n32@@'`
637 case $name in
638 *bootscripts*) name=bootscripts-cross-lfs ;;
639 *udev-rules) name=udev-cross-lfs ;;
640 esac
641
642 pkg_tarball=$(get_package_tarball_name $name)
643
644 #--------------------------------------------------------------------#
645 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
646 #--------------------------------------------------------------------#
647 #
648 # Drop in the name of the target on a new line, and the previous target
649 # as a dependency. Also call the echo_message function.
650 CHROOT_wrt_target "${this_script}" "$PREV"
651 #
652 # If $pkg_tarball isn't empty, we've got a package...
653 #
654 if [ "$pkg_tarball" != "" ] ; then
655 if [ "${INSTALL_LOG}" = "y" ] ; then
656 CHROOT_wrt_TouchTimestamp
657 fi
658 CHROOT_Unpack "$pkg_tarball"
659 fi
660 #
661 CHROOT_wrt_RunAsRoot "${file}"
662 #
663 # Write installed files log and remove the build directory(ies)
664 # except if the package build fails.
665 if [ "$pkg_tarball" != "" ] ; then
666 CHROOT_wrt_RemoveBuildDirs "$name"
667 if [ "${INSTALL_LOG}" = "y" ] ; then
668 CHROOT_wrt_LogNewFiles "$name1"
669 fi
670 fi
671 #
672 # Include a touch of the target name so make can check if it's already been made.
673 wrt_touch
674 #
675 #--------------------------------------------------------------------#
676 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
677 #--------------------------------------------------------------------#
678 #
679 # Keep the script file name for Makefile dependencies.
680 PREV=$this_script
681
682 done # for file in bootscripts/* ...
683}
684
685#--------------------------------------#
686network_Makefiles() { #
687#--------------------------------------#
688
689 if [[ "${METHOD}" = "chroot" ]]; then
690 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) network ( CHROOT ) ${R_arrow}"
691 else
692 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) network ( ROOT ) ${R_arrow}"
693 fi
694
695 for file in network/* ; do
696 # Keep the script file name
697 this_script=`basename $file`
698
699 case $this_script in
700 *choose) continue ;; # This is not a script but a commentary.
701 *dhcp) continue ;; # Assume static networking.
702 *dhcpcd) continue ;; # Assume static networking.
703 *) ;;
704 esac
705
706 # First append each name of the script files to a list (this will become
707 # the names of the targets in the Makefile
708 networktools="$networktools $this_script"
709
710 # Grab the name of the target, strip id number, XXX-script
711 # name1 is partially stripped and should be used for logging files.
712 # name is completely stripped and is used for grabbing
713 # the package name.
714 name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
715 name=`echo $name1 | sed -e 's@-64bit@@' \
716 -e 's@-64@@' \
717 -e 's@64@@' \
718 -e 's@n32@@'`
719 case $name in
720 network-scripts) name=clfs-network-scripts ;;
721 esac
722
723 pkg_tarball=$(get_package_tarball_name $name)
724
725 #--------------------------------------------------------------------#
726 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
727 #--------------------------------------------------------------------#
728 #
729 # Drop in the name of the target on a new line, and the previous target
730 # as a dependency. Also call the echo_message function.
731 CHROOT_wrt_target "${this_script}" "$PREV"
732 #
733 # If $pkg_tarball isn't empty, we've got a package...
734 #
735 if [ "$pkg_tarball" != "" ] ; then
736 if [ "${INSTALL_LOG}" = "y" ] ; then
737 CHROOT_wrt_TouchTimestamp
738 fi
739 CHROOT_Unpack "$pkg_tarball"
740 fi
741 #
742 CHROOT_wrt_RunAsRoot "${file}"
743 #
744 # Write installed files log and remove the build directory(ies)
745 # except if the package build fails.
746 if [ "$pkg_tarball" != "" ] ; then
747 CHROOT_wrt_RemoveBuildDirs "$name"
748 if [ "${INSTALL_LOG}" = "y" ] ; then
749 CHROOT_wrt_LogNewFiles "$name1"
750 fi
751 fi
752 #
753 # Include a touch of the target name so make can check if it's already been made.
754 wrt_touch
755 #
756 #--------------------------------------------------------------------#
757 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
758 #--------------------------------------------------------------------#
759 #
760 # Keep the script file name for Makefile dependencies.
761 PREV=$this_script
762
763 done # for file in network/* ...
764}
765
766#--------------------------------------#
767bootable_Makefiles() { #
768#--------------------------------------#
769
770 if [[ "${METHOD}" = "chroot" ]]; then
771 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
772 else
773 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
774 fi
775
776
777 for file in bootable/* ; do
778 # Keep the script file name
779 this_script=`basename $file`
780
781 # A little housekeeping on the scripts
782 case $this_script in
783 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
784 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
785 *kernel) # if there is no kernel config file do not build the kernel
786 [[ -z $CONFIG ]] && continue
787 # Copy the config file to /sources with a standardized name
788 cp $CONFIG $BUILDDIR/sources/kernel-config
789 ;;
790 esac
791 #
792 # First append each name of the script files to a list (this will become
793 # the names of the targets in the Makefile
794 bootabletools="$bootabletools $this_script"
795 #
796 # Grab the name of the target, strip id number and misc words.
797 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
798 case $this_script in
799 *kernel*) name=linux
800 ;;
801 esac
802
803 pkg_tarball=$(get_package_tarball_name $name)
804
805 #--------------------------------------------------------------------#
806 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
807 #--------------------------------------------------------------------#
808 #
809 # Drop in the name of the target on a new line, and the previous target
810 # as a dependency. Also call the echo_message function.
811 CHROOT_wrt_target "${this_script}" "$PREV"
812 #
813 # If $pkg_tarball isn't empty, we've got a package...
814 # Insert instructions for unpacking the package and changing directories
815 #
816 if [ "$pkg_tarball" != "" ] ; then
817 if [ "${INSTALL_LOG}" = "y" ] ; then
818 CHROOT_wrt_TouchTimestamp
819 fi
820 CHROOT_Unpack "$pkg_tarball"
821 fi
822 #
823 # Select a script execution method
824 case $this_script in
825 *fstab*) if [[ -n "$FSTAB" ]]; then
826 CHROOT_wrt_CopyFstab
827 else
828 CHROOT_wrt_RunAsRoot "${file}"
829 fi
830 ;;
831 *) CHROOT_wrt_RunAsRoot "${file}"
832 ;;
833 esac
834 #
835 # Write installed files log and remove the build directory(ies)
836 # except if the package build fails.
837 if [ "$pkg_tarball" != "" ] ; then
838 CHROOT_wrt_RemoveBuildDirs "$name"
839 if [ "${INSTALL_LOG}" = "y" ] ; then
840 CHROOT_wrt_LogNewFiles "$name"
841 fi
842 fi
843 #
844 # Include a touch of the target name so make can check if it's already been made.
845 wrt_touch
846 #
847 #--------------------------------------------------------------------#
848 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
849 #--------------------------------------------------------------------#
850 #
851 # Keep the script file name for Makefile dependencies.
852 PREV=$this_script
853
854 done
855
856}
857
858
859#--------------------------------------#
860build_Makefile() { # Construct a Makefile from the book scripts
861#--------------------------------------#
862
863 echo "...Creating Makefile... ${BOLD}START${OFF}"
864
865 cd $JHALFSDIR/${PROGNAME}-commands
866 # Start with clean files
867 >$MKFILE
868 >$MKFILE.tmp
869
870 method_cmds=${METHOD}_Makefiles
871
872 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
873 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
874 temptools_Makefiles # mk_TEMP (LUSER) $temptools
875 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
876 if [[ ! $TEST = "0" ]]; then
877 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
878 fi
879 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
880 # Add the iterations targets, if needed
881 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
882 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
883 if [ -d network ]; then
884 network_Makefiles # If present, process network setup.
885 fi
886 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
887
888 # Add the CUSTOM_TOOLS targets, if needed
889 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
890
891 # Add a header, some variables and include the function file
892 # to the top of the real Makefile.
893 wrt_Makefile_header
894
895 # Add chroot commands
896 if [ "$METHOD" = "chroot" ] ; then
897 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
898 chroot=`cat chroot/???-chroot | \
899 sed -e "s@chroot@$CHROOT_LOC@" \
900 -e '/#!\/bin\/bash/d' \
901 -e '/^export/d' \
902 -e '/^logout/d' \
903 -e 's@ \\\@ @g' | \
904 tr -d '\n' | \
905 sed -e 's/ */ /g' \
906 -e 's|\\$|&&|g' \
907 -e 's|exit||g' \
908 -e 's|$| -c|' \
909 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
910 -e 's|set -e||' \
911 -e 's|set +h||'`
912 echo -e "CHROOT1= $chroot\n" >> $MKFILE
913 fi
914
915################## CHROOT ####################
916
917if [[ "${METHOD}" = "chroot" ]]; then
918(
919cat << EOF
920
921all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
922 @sudo make do-housekeeping
923 @echo "$VERSION - jhalfs build" > clfs-release && \\
924 sudo mv clfs-release \$(MOUNT_PT)/etc && \\
925 sudo chown root:root \$(MOUNT_PT)/etc/clfs-release
926 @\$(call echo_finished,$VERSION)
927
928ck_UID:
929 @if [ \`id -u\` = "0" ]; then \\
930 echo "+--------------------------------------------------+"; \\
931 echo "|You cannot run this makefile from the root account|"; \\
932 echo "+--------------------------------------------------+"; \\
933 exit 1; \\
934 fi
935
936#---------------AS ROOT
937mk_SETUP:
938 @\$(call echo_SU_request)
939 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
940 @touch \$@
941
942#---------------AS LUSER
943mk_CROSS: mk_SETUP
944 @\$(call echo_PHASE,Cross and Temporary Tools)
945 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
946 @sudo make restore-luser-env
947 @touch \$@
948
949mk_SUDO: mk_CROSS
950 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
951 @touch \$@
952
953#---------------CHROOT JAIL
954mk_SYSTOOLS: mk_SUDO
955 @\$(call echo_CHROOT_request)
956 @\$(call echo_PHASE, CHROOT JAIL )
957 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
958 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
959 @touch \$@
960
961mk_BLFS_TOOL: create-sbu_du-report
962 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
963 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
964 (sudo \$(CHROOT1) "make -C $BLFS_ROOT/work"); \\
965 fi;
966 @touch \$@
967
968mk_CUSTOM_TOOLS: mk_BLFS_TOOL
969 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
970 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
971 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
972 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
973 fi;
974 @touch \$@
975
976SETUP: $host_prep
977AS_LUSER: $cross_tools $temptools
978SUDO: $orphan_scripts
979PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
980PREP_CHROOT_JAIL: ${chroottools}
981CHROOT_JAIL: SHELL=/tools/bin/bash
982CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
983CUSTOM_TOOLS: $custom_list
984
985
986create-sbu_du-report: mk_SYSTOOLS
987 @\$(call echo_message, Building)
988 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
989 ./create-sbu_du-report.sh logs $VERSION; \\
990 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
991 fi;
992 @touch \$@
993
994do-housekeeping:
995 @-umount \$(MOUNT_PT)/dev/pts
996 @-if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
997 link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
998 umount \$(MOUNT_PT)/\$\$link; \\
999 unset link; \\
1000 else \\
1001 umount \$(MOUNT_PT)/dev/shm; \\
1002 fi
1003 @-umount \$(MOUNT_PT)/dev
1004 @-umount \$(MOUNT_PT)/sys
1005 @-umount \$(MOUNT_PT)/proc
1006 @-rm /tools /cross-tools
1007 @-if [ ! -f luser-exist ]; then \\
1008 userdel \$(LUSER); \\
1009 rm -rf \$(LUSER_HOME); \\
1010 fi;
1011
1012EOF
1013) >> $MKFILE
1014
1015fi
1016
1017################### BOOT #####################
1018
1019if [[ "${METHOD}" = "boot" ]]; then
1020(
1021cat << EOF
1022
1023all: ck_UID mk_SETUP mk_CROSS mk_SUDO
1024 @sudo make restore-luser-env
1025 @sudo make do-housekeeping
1026 @\$(call echo_boot_finished,$VERSION)
1027
1028makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
1029 @echo "$VERSION - jhalfs build" > /etc/clfs-release
1030 @\$(call echo_finished,$VERSION)
1031
1032
1033ck_UID:
1034 @if [ \`id -u\` = "0" ]; then \\
1035 echo "+--------------------------------------------------+"; \\
1036 echo "|You cannot run this makefile from the root account|"; \\
1037 echo "|However, if this is the boot environment |"; \\
1038 echo "| the command you are looking for is |"; \\
1039 echo "| make makesys |"; \\
1040 echo "| to complete the build |"; \\
1041 echo "+--------------------------------------------------+"; \\
1042 exit 1; \\
1043 fi
1044
1045#---------------AS ROOT
1046
1047mk_SETUP:
1048 @\$(call echo_SU_request)
1049 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
1050 @touch \$@
1051
1052#---------------AS LUSER
1053
1054mk_CROSS: mk_SETUP
1055 @\$(call echo_PHASE,Cross Tool)
1056 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
1057 @touch \$@
1058
1059mk_SUDO: mk_CROSS
1060 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
1061 @touch \$@
1062
1063#---------------AS ROOT
1064
1065mk_FINAL:
1066 @\$(call echo_PHASE,Final System)
1067 @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
1068 @touch \$@
1069
1070mk_BLFS_TOOL: mk_FINAL
1071 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
1072 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
1073 ( make -C $BLFS_ROOT/work ); \\
1074 fi;
1075 @touch \$@
1076
1077mk_CUSTOM_TOOLS: mk_BLFS_TOOL
1078 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
1079 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
1080 mkdir -p ${TRACKING_DIR}; \\
1081 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
1082 fi;
1083 @touch \$@
1084
1085SETUP: $host_prep
1086AS_LUSER: $cross_tools $temptools ${boottools}
1087SUDO: $orphan_scripts
1088AS_ROOT: SHELL=/tools/bin/bash
1089AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
1090CUSTOM_TOOLS: $custom_list
1091
1092do-housekeeping:
1093 @-rm /tools /cross-tools
1094 @-if [ ! -f luser-exist ]; then \\
1095 userdel \$(LUSER); \\
1096 rm -rf \$(LUSER_HOME); \\
1097 fi;
1098
1099EOF
1100) >> $MKFILE
1101fi
1102
1103(
1104 cat << EOF
1105
1106restore-luser-env:
1107 @\$(call echo_message, Building)
1108 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
1109 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
1110 fi;
1111 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
1112 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
1113 fi;
1114 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
1115 touch \$@ && \\
1116 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1117 echo --------------------------------------------------------------------------------\$(WHITE)
1118
1119########################################################
1120
1121
1122EOF
1123) >> $MKFILE
1124
1125 # Bring over the items from the Makefile.tmp
1126 cat $MKFILE.tmp >> $MKFILE
1127 rm $MKFILE.tmp
1128
1129 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1130}
Note: See TracBrowser for help on using the repository browser.