source: HLFS/master.sh@ 00f4966

experimental
Last change on this file since 00f4966 was 47fddc8, checked in by George Boudreau <georgeb@…>, 18 years ago

Change bool parameter definitions from 0/1 to y/n to match the new menu app

  • Property mode set to 100755
File size: 21.3 KB
RevLine 
[0170229]1#!/bin/sh
2set -e # Enable error trapping
3
[57ca090]4# $Id$
[0170229]5
6###################################
7### FUNCTIONS ###
8###################################
9
[65a2be6]10#----------------------------#
11process_toolchain() { # embryo,cocoon and butterfly need special handling
12#----------------------------#
13 local toolchain=$1
14 local this_script=$2
15 local tc_phase
[398a037]16 local binutil_tarball
17 local gcc_core_tarball
18
[65a2be6]19 echo "${tab_}${tab_}${GREEN}toolchain ${L_arrow}${toolchain}${R_arrow}"
20
[89ddac0]21 #
22 # Safe method to remove existing toolchain dirs
[398a037]23 binutil_tarball=$(get_package_tarball_name "binutils")
24 gcc_core_tarball=$(get_package_tarball_name "gcc-core")
25(
26cat << EOF
27 @\$(call remove_existing_dirs,$binutil_tarball)
28 @\$(call remove_existing_dirs,$gcc_core_tarball)
29EOF
30) >> $MKFILE.tmp
31
[89ddac0]32 #
33 # Manually remove the toolchain directories..
34 tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'`
35(
36cat << EOF
37 @rm -rf \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\
38 rm -rf \$(MOUNT_PT)\$(SRC)/${tc_phase}-build
39EOF
40) >> $MKFILE.tmp
41
[21dab83]42 case ${toolchain} in
43 *butterfly*)
44(
45cat << EOF
46 @echo "export PKGDIR=\$(SRC)" > envars
47EOF
48) >> $MKFILE.tmp
[89ddac0]49 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
[21dab83]50 wrt_run_as_chroot1 "$toolchain" "$this_script"
51 ;;
[a82bbc0]52
[21dab83]53 *)
[65a2be6]54(
55cat << EOF
56 @echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars
57EOF
58) >> $MKFILE.tmp
[9485eba]59 wrt_RunAsUser "$toolchain" "$this_script"
[21dab83]60 ;;
61 esac
[a82bbc0]62 #
[398a037]63(
64cat << EOF
65 @\$(call remove_existing_dirs,$binutil_tarball)
66 @\$(call remove_existing_dirs,$gcc_core_tarball)
67EOF
68) >> $MKFILE.tmp
69
[21dab83]70 #
[65a2be6]71 # Manually remove the toolchain directories..
72 tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'`
73(
74cat << EOF
75 @rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\
76 rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-build
77EOF
78) >> $MKFILE.tmp
79
80}
81
[0170229]82
83#----------------------------#
[389fe2a]84chapter3_Makefiles() { # Initialization of the system
[0170229]85#----------------------------#
86
[e10232b]87 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
[0170229]88
[e840d27]89 # Define a few model dependant variables
90 if [[ ${MODEL} = "uclibc" ]]; then
91 TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0"
92 else
93 TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
94 fi
[0170229]95
[30737ea8]96 # If /home/$LUSER is already present in the host, we asume that the
[65a2be6]97 # hlfs user and group are also presents in the host, and a backup
[0170229]98 # of their bash init files is made.
99(
100cat << EOF
101020-creatingtoolsdir:
102 @\$(call echo_message, Building)
[9199a13]103 @mkdir \$(MOUNT_PT)/tools && \\
104 rm -f /tools && \\
105 ln -s \$(MOUNT_PT)/tools /
[0170229]106 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
107 mkdir \$(MOUNT_PT)/sources; \\
108 fi;
109 @chmod a+wt \$(MOUNT_PT)/sources && \\
[9199a13]110 touch \$@ && \\
111 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
112 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]113
114021-addinguser: 020-creatingtoolsdir
115 @\$(call echo_message, Building)
[9485eba]116 @if [ ! -d /home/\$(LUSER) ]; then \\
117 groupadd \$(LGROUP); \\
118 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
[0170229]119 else \\
[30737ea8]120 touch luser-exist; \\
[0170229]121 fi;
[9485eba]122 @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
123 chown \$(LUSER) \$(MOUNT_PT)/sources && \\
[9199a13]124 touch \$@ && \\
125 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
126 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]127
128022-settingenvironment: 021-addinguser
129 @\$(call echo_message, Building)
[9485eba]130 @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
131 mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
[0170229]132 fi;
[9485eba]133 @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
134 mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
[0170229]135 fi;
[9485eba]136 @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
137 echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
138 echo "HLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
139 echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
140 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
141 echo "export HLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
142 echo "" >> /home/\$(LUSER)/.bashrc && \\
143 echo "target=$(uname -m)-${TARGET}" >> /home/\$(LUSER)/.bashrc && \\
144 echo "ldso=/tools/lib/${LOADER}" >> /home/\$(LUSER)/.bashrc && \\
145 echo "export target ldso" >> /home/\$(LUSER)/.bashrc && \\
146 echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\
147 chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
[0170229]148 touch envars && \\
[9199a13]149 touch \$@ && \\
150 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
151 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]152EOF
153) >> $MKFILE.tmp
154
155}
156
157#----------------------------#
158chapter5_Makefiles() { # Bootstrap or temptools phase
159#----------------------------#
160 local file
161 local this_script
[57ca090]162
[e10232b]163 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
[0170229]164
165 for file in chapter05/* ; do
166 # Keep the script file name
167 this_script=`basename $file`
168
169 # Skip this script depending on jhalfs.conf flags set.
170 case $this_script in
171 # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
[821a2c6]172 *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
173 *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
174 *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
[7d018d1]175 # Nothing interestin in this script
176 *introduction* ) continue ;;
[0170229]177 # Test if the stripping phase must be skipped
[47fddc8]178 *stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
[0170229]179 *) ;;
180 esac
181
182 # First append each name of the script files to a list (this will become
183 # the names of the targets in the Makefile
184 chapter5="$chapter5 $this_script"
185
[9272545]186 # Grab the name of the target
187 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
[0170229]188
[5c5a010]189 # Adjust 'name'
[0170229]190 case $name in
[3b63c8c]191 uclibc) name="uClibc" ;;
[0170229]192 esac
193
194 # Set the dependency for the first target.
195 if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
196
197 #--------------------------------------------------------------------#
198 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
199 #--------------------------------------------------------------------#
200 #
201 # Drop in the name of the target on a new line, and the previous target
202 # as a dependency. Also call the echo_message function.
[9272545]203
[65a2be6]204 # This is a very special script and requires manual processing
205 # NO Optimization allowed
206 if [[ ${name} = "embryo-toolchain" ]] || \
207 [[ ${name} = "cocoon-toolchain" ]]; then
208 wrt_target "$this_script" "$PREV"
209 process_toolchain "${this_script}" "${file}"
210 wrt_touch
211 PREV=$this_script
212 continue
213 fi
214 #
[0170229]215 wrt_target "$this_script" "$PREV"
216 # Find the version of the command files, if it corresponds with the building of
217 # a specific package
[3b63c8c]218 pkg_tarball=$(get_package_tarball_name $name)
219 # If $pkg_tarball isn't empty, we've got a package...
220 if [ "$pkg_tarball" != "" ] ; then
[29f9ec8]221 # Insert instructions for unpacking the package and to set the PKGDIR variable.
[9485eba]222 wrt_unpack "$pkg_tarball"
[e35e794]223 # If using optimizations, write the instructions
[c205656]224 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[29f9ec8]225 fi
[0170229]226 # Insert date and disk usage at the top of the log file, the script run
227 # and date and disk usage again at the bottom of the log file.
[9485eba]228 wrt_RunAsUser "$this_script" "${file}"
[0170229]229
230 # Remove the build directory(ies) except if the package build fails
231 # (so we can review config.cache, config.log, etc.)
[3b63c8c]232 if [ "$pkg_tarball" != "" ] ; then
[65a2be6]233 wrt_remove_build_dirs "$name"
[0170229]234 fi
235
236 # Include a touch of the target name so make can check if it's already been made.
[9199a13]237 wrt_touch
[0170229]238 #
239 #--------------------------------------------------------------------#
240 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
241 #--------------------------------------------------------------------#
242
243 # Keep the script file name for Makefile dependencies.
244 PREV=$this_script
245 done # end for file in chapter05/*
246}
247
248
249#----------------------------#
250chapter6_Makefiles() { # sysroot or chroot build phase
251#----------------------------#
252 local file
253 local this_script
[c483858]254 # Set envars and scripts for iteration targets
255 LOGS="" # Start with an empty global LOGS envar
256 if [[ -z "$1" ]] ; then
257 local N=""
258 else
259 local N=-build_$1
260 local chapter6=""
261 mkdir chapter06$N
262 cp chapter06/* chapter06$N
263 for script in chapter06$N/* ; do
264 # Overwrite existing symlinks, files, and dirs
265 sed -e 's/ln -s /ln -sf /g' \
266 -e 's/^mv /&-f/g' -i ${script}
267 done
268 # Remove Bzip2 binaries before make install
269 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
270 # Fix how Module-Init-Tools do the install target
271 sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
272 # Delete *old Readline libraries just after make install
273 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
274 # Don't readd already existing groups
275 sed -e '/groupadd/d' -i chapter06$N/*-udev
276 fi
[0170229]277
[c483858]278 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
[0170229]279
[c483858]280 for file in chapter06$N/* ; do
[0170229]281 # Keep the script file name
282 this_script=`basename $file`
283
284 # Skip this script depending on jhalfs.conf flags set.
285 case $this_script in
286 # We'll run the chroot commands differently than the others, so skip them in the
287 # dependencies and target creation.
288 *chroot* ) continue ;;
289 # Test if the stripping phase must be skipped
[47fddc8]290 *-stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
[0170229]291 esac
292
293 # Grab the name of the target
294 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
295
[3b63c8c]296 case $name in
297 uclibc) name="uClibc" ;;
298 esac
299
[c483858]300 # Find the version of the command files, if it corresponds with the building of
301 # a specific package
[3b63c8c]302 pkg_tarball=$(get_package_tarball_name $name)
[c483858]303
[3b63c8c]304 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[c483858]305 case "${this_script}" in
306 *stripping*) ;;
307 *) continue ;;
308 esac
309 fi
310
311 # Append each name of the script files to a list (this will become
312 # the names of the targets in the Makefile
313 chapter6="$chapter6 ${this_script}${N}"
314
315 # Append each name of the script files to a list (this will become
[7635367]316 # the names of the logs to be moved for each iteration)
317 LOGS="$LOGS ${this_script}"
[c483858]318
[0170229]319
320 #--------------------------------------------------------------------#
321 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
322 #--------------------------------------------------------------------#
323 #
324 # Drop in the name of the target on a new line, and the previous target
[65a2be6]325 # as a dependency. Also call the echo_message function.
326 if [[ ${name} = "butterfly-toolchain" ]]; then
[7cd9186]327 wrt_target "${this_script}${N}" "$PREV"
[65a2be6]328 process_toolchain "${this_script}" "${file}"
329 wrt_touch
330 PREV=$this_script
331 continue
332 fi
333
[c483858]334 wrt_target "${this_script}${N}" "$PREV"
[0170229]335
[3b63c8c]336 # If $pkg_tarball isn't empty, we've got a package...
[0170229]337 # Insert instructions for unpacking the package and changing directories
[3b63c8c]338 if [ "$pkg_tarball" != "" ] ; then
339 wrt_unpack2 "$pkg_tarball"
[e35e794]340 # If the testsuites must be run, initialize the log file
[7cd9186]341 # butterfly-toolchain tests are enabled in 'process_tookchain' function
[e35e794]342 case $name in
[7cd9186]343 glibc ) [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
[e35e794]344 ;;
[89ddac0]345 * ) [[ "$TEST" > "1" ]] && wrt_test_log2 "${this_script}"
[e35e794]346 ;;
347 esac
348 # If using optimizations, write the instructions
[c205656]349 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]350 fi
351
[9272545]352 # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
[5f4d08f]353 case "${this_script}" in
354 *kernfs*)
[9485eba]355 wrt_RunAsRoot "${this_script}" "${file}"
[5f4d08f]356 ;;
357 *) # The rest of Chapter06
358 wrt_run_as_chroot1 "${this_script}" "${file}"
359 ;;
360 esac
[0170229]361 #
362 # Remove the build directory(ies) except if the package build fails.
[3b63c8c]363 if [ "$pkg_tarball" != "" ] ; then
[0170229]364 wrt_remove_build_dirs "$name"
365 fi
366 #
367 # Include a touch of the target name so make can check if it's already been made.
[9199a13]368 wrt_touch
[0170229]369 #
370 #--------------------------------------------------------------------#
371 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
372 #--------------------------------------------------------------------#
373
374 # Keep the script file name for Makefile dependencies.
[c483858]375 PREV=${this_script}${N}
376 # Set system_build envar for iteration targets
377 system_build=$chapter6
[0170229]378 done # end for file in chapter06/*
379
380}
381
382#----------------------------#
383chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
384#----------------------------#
385 local file
386 local this_script
[57ca090]387
[e10232b]388 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
[0170229]389 for file in chapter07/*; do
390 # Keep the script file name
391 this_script=`basename $file`
392
393 # Grub must be configured manually.
394 # The filesystems can't be unmounted via Makefile and the user
395 # should enter the chroot environment to create the root
396 # password, edit several files and setup Grub.
397 case $this_script in
[0ac273e]398 *usage) continue ;; # Contains example commands
[0170229]399 *grub) continue ;;
400 *console) continue ;; # Use the file generated by lfs-bootscripts
401
[57ca090]402 *kernel)
[821a2c6]403 # If no .config file is supplied, the kernel build is skipped
404 [[ -z $CONFIG ]] && continue
[1d756b0]405 cp $CONFIG $BUILDDIR/sources/kernel-config
[0170229]406 ;;
407 esac
408
409 # First append then name of the script file to a list (this will become
410 # the names of the targets in the Makefile
411 chapter7="$chapter7 $this_script"
412
413 #--------------------------------------------------------------------#
414 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
415 #--------------------------------------------------------------------#
416 #
417 # Drop in the name of the target on a new line, and the previous target
418 # as a dependency. Also call the echo_message function.
419 wrt_target "$this_script" "$PREV"
420
[5f4d08f]421 case "${this_script}" in
[db187c74]422 *bootscripts*)
[3b63c8c]423 wrt_unpack2 $(get_package_tarball_name "lfs-bootscripts")
424 blfs_bootscripts=$(get_package_tarball_name "blfs-bootscripts" | sed -e 's/.tar.*//' )
425 echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/$blfs_bootscripts\" >> sources-dir" >> $MKFILE.tmp
[5f4d08f]426 ;;
427 esac
[0170229]428
[db187c74]429 case "${this_script}" in
[5f4d08f]430 *fstab*) # Check if we have a real /etc/fstab file
431 if [[ -n "$FSTAB" ]] ; then
432 wrt_copy_fstab "$this_script"
433 else # Initialize the log and run the script
434 wrt_run_as_chroot2 "${this_script}" "${file}"
435 fi
436 ;;
437 *) # All other scripts
438 wrt_run_as_chroot2 "${this_script}" "${file}"
439 ;;
440 esac
[0170229]441
442 # Remove the build directory except if the package build fails.
[5f4d08f]443 case "${this_script}" in
444 *bootscripts*)
[0170229]445(
446cat << EOF
[460ea63]447 @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
[0170229]448 rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
449 @rm -r \`cat sources-dir\` && \\
450 rm sources-dir
451EOF
452) >> $MKFILE.tmp
[5f4d08f]453 ;;
454 esac
[0170229]455
456 # Include a touch of the target name so make can check if it's already been made.
[9199a13]457 wrt_touch
[0170229]458 #
459 #--------------------------------------------------------------------#
460 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
461 #--------------------------------------------------------------------#
462
463 # Keep the script file name for Makefile dependencies.
464 PREV=$this_script
465 done # for file in chapter07/*
[9e4b9a1]466
467 # Add SBU-disk_usage report target if required
[47fddc8]468 if [[ "$REPORT" = "y" ]] ; then wrt_report ; fi
[0170229]469}
470
471
472#----------------------------#
473build_Makefile() { # Construct a Makefile from the book scripts
474#----------------------------#
[a702b4d]475 echo "Creating Makefile... ${BOLD}START${OFF}"
[0170229]476
477 cd $JHALFSDIR/${PROGNAME}-commands
478 # Start with a clean Makefile.tmp file
479 >$MKFILE.tmp
480
[389fe2a]481 chapter3_Makefiles
[0170229]482 chapter5_Makefiles
483 chapter6_Makefiles
[c483858]484 # Add the iterations targets, if needed
[47fddc8]485 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
[0170229]486 chapter7_Makefiles
487
488 # Add a header, some variables and include the function file
489 # to the top of the real Makefile.
490(
491 cat << EOF
492$HEADER
493
[398a037]494SRC = /sources
495MOUNT_PT = $BUILDDIR
496PKG_LST = $PKG_LST
497LUSER = $LUSER
498LGROUP = $LGROUP
499SCRIPT_ROOT = $SCRIPT_ROOT
500
501BASEDIR = \$(MOUNT_PT)
502SRCSDIR = \$(BASEDIR)/sources
503CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
504LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs
505TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs
506
507crSRCSDIR = /sources
508crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
509crLOGDIR = /\$(SCRIPT_ROOT)/logs
510crTESTLOGDIR = /\$(SCRIPT_ROOT)/test-logs
511
512SU_LUSER = su - \$(LUSER) -c
513LUSER_HOME = /home/\$(LUSER)
514PRT_DU = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n"
515PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT)\`\n"
[0170229]516
517include makefile-functions
518
519EOF
520) > $MKFILE
521
522
523 # Add chroot commands
[8381f6e]524 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
[0170229]525 i=1
526 for file in chapter06/*chroot* ; do
[8381f6e]527 chroot=`cat $file | \
528 sed -e "s@chroot@$CHROOT_LOC@" \
529 -e '/#!\/bin\/sh/d' \
530 -e '/^export/d' \
531 -e '/^logout/d' \
532 -e 's@ \\\@ @g' | \
533 tr -d '\n' | \
534 sed -e 's/ */ /g' \
535 -e 's|\\$|&&|g' \
536 -e 's|exit||g' \
537 -e 's|$| -c|' \
538 -e 's|"$$HLFS"|$(MOUNT_PT)|'\
539 -e 's|set -e||'`
[0170229]540 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
541 i=`expr $i + 1`
542 done
543
544 # Drop in the main target 'all:' and the chapter targets with each sub-target
545 # as a dependency.
546(
547 cat << EOF
[3a27393]548all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
[0170229]549 @\$(call echo_finished,$VERSION)
550
[0ac273e]551chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
[0170229]552
[30737ea8]553chapter5: chapter3 $chapter5 restore-luser-env
[0170229]554
555chapter6: chapter5 $chapter6
556
557chapter7: chapter6 $chapter7
558
559clean-all: clean
[bc097cd]560 rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
[0170229]561
[0ac273e]562clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
[0170229]563
[3b63c8c]564restart: restart_code all
565
[0ac273e]566clean-chapter3:
[30737ea8]567 -if [ ! -f luser-exist ]; then \\
[9485eba]568 userdel \$(LUSER); \\
569 rm -rf /home/\$(LUSER); \\
[0170229]570 fi;
571 rm -rf \$(MOUNT_PT)/tools
572 rm -f /tools
[30737ea8]573 rm -f envars luser-exist
[0170229]574 rm -f 02* logs/02*.log
575
576clean-chapter5:
577 rm -rf \$(MOUNT_PT)/tools/*
[30737ea8]578 rm -f $chapter5 restore-luser-env sources-dir
[0170229]579 cd logs && rm -f $chapter5 && cd ..
580
581clean-chapter6:
582 -umount \$(MOUNT_PT)/sys
583 -umount \$(MOUNT_PT)/proc
584 -umount \$(MOUNT_PT)/dev/shm
585 -umount \$(MOUNT_PT)/dev/pts
586 -umount \$(MOUNT_PT)/dev
587 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
588 rm -f $chapter6
589 cd logs && rm -f $chapter6 && cd ..
590
591clean-chapter7:
592 rm -f $chapter7
593 cd logs && rm -f $chapter7 && cd ..
594
[30737ea8]595restore-luser-env:
[0170229]596 @\$(call echo_message, Building)
[9485eba]597 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
598 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
[0170229]599 fi;
[9485eba]600 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
601 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
[0170229]602 fi;
[9485eba]603 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
[9199a13]604 touch \$@ && \\
605 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
606 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]607
[3a27393]608do-housekeeping:
[9199a13]609 @-umount \$(MOUNT_PT)/dev/pts
610 @-umount \$(MOUNT_PT)/dev/shm
611 @-umount \$(MOUNT_PT)/dev
612 @-umount \$(MOUNT_PT)/sys
613 @-umount \$(MOUNT_PT)/proc
[30737ea8]614 @-if [ ! -f luser-exist ]; then \\
[9485eba]615 userdel \$(LUSER); \\
616 rm -rf /home/\$(LUSER); \\
[3a27393]617 fi;
[460ea63]618
[3b63c8c]619restart_code:
[9272545]620 @echo ">>> This feature is experimental, BUGS may exist"
621
[3b63c8c]622 @if [ ! -L /tools ]; then \\
623 echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
624 fi;
[9272545]625
[3b63c8c]626 @if [ ! -e /tools ]; then \\
627 echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
628 fi;
[9272545]629
[3b63c8c]630 @if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
631 echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
[9272545]632 fi;
[3b63c8c]633
634 @if [ -f ???-kernfs ]; then \\
635 mkdir -pv \$(MOUNT_PT)/{proc,sys};\\
636 if ! mount -l | "\$(MOUNT_PT)/dev" >/dev/null ; then \\
637 mount -vt ramfs ramfs \$(MOUNT_PT)/dev;\\
638 fi;\\
639 if [ ! -e \$(MOUNT_PT)/dev/console ]; then \\
640 mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1;\\
641 fi;\\
642 if [ ! -e \$(MOUNT_PT)/dev/null ]; then \\
643 mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3;\\
644 fi;\\
645 if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
646 mount -vt devpts -o gid=4,mode=620 devpts \$(MOUNT_PT)/dev/pts;\\
647 fi;\\
648 if ! mount -l | grep "\$(MOUNT_PT)/dev/shm" >/dev/null ; then \\
649 mount -vt tmpfs shm \$(MOUNT_PT)/dev/shm;\\
650 fi;\\
651 if ! mount -l | grep "\$(MOUNT_PT)/proc" >/dev/null ; then \\
652 mount -vt proc proc \$(MOUNT_PT)/proc;\\
653 fi;\\
654 if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
655 mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
656 fi;\\
657 fi;
658
659
[0170229]660EOF
661) >> $MKFILE
662
663 # Bring over the items from the Makefile.tmp
664 cat $MKFILE.tmp >> $MKFILE
665 rm $MKFILE.tmp
[a702b4d]666 echo "Creating Makefile... ${BOLD}DONE${OFF}"
667
[0170229]668}
Note: See TracBrowser for help on using the repository browser.