[877cc6a] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
| 5 | ###################################
|
---|
| 6 | ### FUNCTIONS ###
|
---|
| 7 | ###################################
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | #----------------------------#
|
---|
| 12 | chapter4_Makefiles() {
|
---|
| 13 | #----------------------------#
|
---|
| 14 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4${R_arrow}"
|
---|
| 15 |
|
---|
| 16 | # If /home/lfs is already present in the host, we asume that the
|
---|
| 17 | # lfs user and group are also presents in the host, and a backup
|
---|
| 18 | # of their bash init files is made.
|
---|
| 19 | (
|
---|
| 20 | cat << EOF
|
---|
| 21 | 020-creatingtoolsdir:
|
---|
| 22 | @\$(call echo_message, Building)
|
---|
[cee9568] | 23 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
| 24 | rm -f /tools && \\
|
---|
| 25 | ln -s \$(MOUNT_PT)/tools / && \\
|
---|
[e2ef100] | 26 | touch \$@ && \\
|
---|
| 27 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK\$(WHITE) && \\
|
---|
| 28 | echo --------------------------------------------------------------------------------
|
---|
[877cc6a] | 29 |
|
---|
| 30 | 021-addinguser: 020-creatingtoolsdir
|
---|
| 31 | @\$(call echo_message, Building)
|
---|
| 32 | @if [ ! -d /home/lfs ]; then \\
|
---|
| 33 | groupadd lfs; \\
|
---|
| 34 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
| 35 | else \\
|
---|
| 36 | touch user-lfs-exist; \\
|
---|
| 37 | fi;
|
---|
| 38 | @chown lfs \$(MOUNT_PT)/tools && \\
|
---|
| 39 | chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
[e2ef100] | 40 | touch \$@ && \\
|
---|
| 41 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK\$(WHITE) && \\
|
---|
| 42 | echo --------------------------------------------------------------------------------
|
---|
[877cc6a] | 43 |
|
---|
| 44 | 022-settingenvironment: 021-addinguser
|
---|
| 45 | @\$(call echo_message, Building)
|
---|
| 46 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
[cee9568] | 47 | mv /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
[877cc6a] | 48 | fi;
|
---|
| 49 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
[cee9568] | 50 | mv /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
[877cc6a] | 51 | fi;
|
---|
| 52 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
| 53 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
[5a13801] | 54 | echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
---|
[877cc6a] | 55 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
| 56 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
| 57 | echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
| 58 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
---|
| 59 | chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
| 60 | touch envars && \\
|
---|
[e2ef100] | 61 | touch \$@ && \\
|
---|
| 62 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK\$(WHITE) && \\
|
---|
| 63 | echo --------------------------------------------------------------------------------
|
---|
[877cc6a] | 64 | EOF
|
---|
| 65 | ) >> $MKFILE.tmp
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | #----------------------------#
|
---|
| 69 | chapter5_Makefiles() {
|
---|
| 70 | #----------------------------#
|
---|
| 71 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
---|
| 72 |
|
---|
| 73 | for file in chapter05/* ; do
|
---|
| 74 | # Keep the script file name
|
---|
| 75 | this_script=`basename $file`
|
---|
| 76 |
|
---|
| 77 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
[a241c33] | 78 | # Fix also locales creation when running chapter05 testsuites (ugly)
|
---|
[877cc6a] | 79 | case "${this_script}" in
|
---|
| 80 | *tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 81 | *expect) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 82 | *dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 83 | *stripping) [[ "${STRIP}" = "0" ]] && continue ;;
|
---|
[a241c33] | 84 | *glibc) [[ "${TEST}" = "3" ]] && \
|
---|
[d46a46e] | 85 | sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
---|
[877cc6a] | 86 | esac
|
---|
| 87 |
|
---|
| 88 | # First append each name of the script files to a list (this will become
|
---|
| 89 | # the names of the targets in the Makefile
|
---|
| 90 | chapter5="$chapter5 ${this_script}"
|
---|
| 91 |
|
---|
| 92 | # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
---|
| 93 | # and binutils in chapter 5)
|
---|
| 94 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
---|
| 95 |
|
---|
| 96 | # Set the dependency for the first target.
|
---|
| 97 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
| 98 |
|
---|
| 99 | #--------------------------------------------------------------------#
|
---|
| 100 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 101 | #--------------------------------------------------------------------#
|
---|
| 102 | #
|
---|
| 103 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 104 | # as a dependency. Also call the echo_message function.
|
---|
| 105 | wrt_target "${this_script}" "$PREV"
|
---|
| 106 |
|
---|
| 107 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 108 | # a specific package
|
---|
| 109 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 110 |
|
---|
| 111 | # If $vrs isn't empty, we've got a package...
|
---|
| 112 | if [ "$vrs" != "" ] ; then
|
---|
| 113 | if [ "$name" = "tcl" ] ; then
|
---|
| 114 | FILE="$name$vrs-src.tar.*"
|
---|
| 115 | else
|
---|
| 116 | FILE="$name-$vrs.tar.*"
|
---|
| 117 | fi
|
---|
[b7faa5a] | 118 |
|
---|
[877cc6a] | 119 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
| 120 | wrt_unpack "$FILE"
|
---|
[a229600] | 121 | # If the testsuites must be run, initialize the log file
|
---|
| 122 | [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}"
|
---|
| 123 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 124 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 125 | fi
|
---|
| 126 |
|
---|
| 127 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 128 | # and date and disk usage again at the bottom of the log file.
|
---|
[a241c33] | 129 | # The changingowner script must be run as root.
|
---|
| 130 | case "${this_script}" in
|
---|
| 131 | *changingowner) wrt_run_as_root "${this_script}" "$file" ;;
|
---|
| 132 | *) wrt_run_as_su "${this_script}" "$file" ;;
|
---|
| 133 | esac
|
---|
[877cc6a] | 134 |
|
---|
| 135 | # Remove the build directory(ies) except if the package build fails
|
---|
| 136 | # (so we can review config.cache, config.log, etc.)
|
---|
| 137 | if [ "$vrs" != "" ] ; then
|
---|
| 138 | wrt_remove_build_dirs "$name"
|
---|
| 139 | fi
|
---|
| 140 |
|
---|
| 141 | # Include a touch of the target name so make can check
|
---|
| 142 | # if it's already been made.
|
---|
[e2ef100] | 143 | wrt_touch
|
---|
[877cc6a] | 144 | #
|
---|
| 145 | #--------------------------------------------------------------------#
|
---|
| 146 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 147 | #--------------------------------------------------------------------#
|
---|
| 148 |
|
---|
| 149 | # Keep the script file name for Makefile dependencies.
|
---|
| 150 | PREV=${this_script}
|
---|
| 151 | done # end for file in chapter05/*
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | #----------------------------#
|
---|
| 155 | chapter6_Makefiles() {
|
---|
| 156 | #----------------------------#
|
---|
[45f82718] | 157 | # Set envars and scripts for iteration targets
|
---|
| 158 | LOGS="" # Start with an empty global LOGS envar
|
---|
| 159 | if [[ -z "$1" ]] ; then
|
---|
| 160 | local N=""
|
---|
| 161 | else
|
---|
| 162 | local N=-build_$1
|
---|
| 163 | local chapter6=""
|
---|
| 164 | mkdir chapter06$N
|
---|
| 165 | cp chapter06/* chapter06$N
|
---|
| 166 | for script in chapter06$N/* ; do
|
---|
| 167 | # Overwrite existing symlinks, files, and dirs
|
---|
| 168 | sed -e 's/ln -sv/&f/g' \
|
---|
| 169 | -e 's/mv -v/&f/g' \
|
---|
| 170 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
| 171 | done
|
---|
| 172 | # Remove Bzip2 binaries before make install
|
---|
| 173 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
|
---|
| 174 | # Let some Udev pre-installation commands to fail
|
---|
| 175 | sed -e 's@/lib/udev/devices/fd@& || true@' \
|
---|
| 176 | -e 's/mknod -m.*/& || true/' -i chapter06$N/*-udev
|
---|
| 177 | fi
|
---|
| 178 |
|
---|
| 179 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
|
---|
| 180 |
|
---|
| 181 | for file in chapter06$N/* ; do
|
---|
[877cc6a] | 182 | # Keep the script file name
|
---|
| 183 | this_script=`basename $file`
|
---|
| 184 |
|
---|
| 185 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 186 | # dependencies and target creation.
|
---|
| 187 | case "${this_script}" in
|
---|
| 188 | *chroot) continue ;;
|
---|
| 189 | *stripping*) [[ "${STRIP}" = "0" ]] && continue ;;
|
---|
| 190 | esac
|
---|
| 191 |
|
---|
| 192 | # Grab the name of the target
|
---|
| 193 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 194 |
|
---|
[45f82718] | 195 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 196 | # a specific package. We need this here to can skip scripts not needed for
|
---|
| 197 | # iterations rebuilds
|
---|
| 198 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 199 |
|
---|
| 200 | if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
|
---|
| 201 | case "${this_script}" in
|
---|
| 202 | *stripping*) ;;
|
---|
| 203 | *) continue ;;
|
---|
| 204 | esac
|
---|
| 205 | fi
|
---|
| 206 |
|
---|
| 207 | # Append each name of the script files to a list (this will become
|
---|
| 208 | # the names of the targets in the Makefile)
|
---|
| 209 | chapter6="$chapter6 ${this_script}${N}"
|
---|
| 210 |
|
---|
| 211 | # Append each name of the script files to a list (this will become
|
---|
| 212 | # the names of the logs to be moved for each iteration)
|
---|
| 213 | LOGS="$LOGS ${this_script}"
|
---|
| 214 |
|
---|
[877cc6a] | 215 | #--------------------------------------------------------------------#
|
---|
| 216 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 217 | #--------------------------------------------------------------------#
|
---|
| 218 | #
|
---|
| 219 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 220 | # as a dependency. Also call the echo_message function.
|
---|
[45f82718] | 221 | wrt_target "${this_script}${N}" "$PREV"
|
---|
[877cc6a] | 222 |
|
---|
| 223 | # If $vrs isn't empty, we've got a package...
|
---|
| 224 | # Insert instructions for unpacking the package and changing directories
|
---|
| 225 | if [ "$vrs" != "" ] ; then
|
---|
| 226 | FILE="$name-$vrs.tar.*"
|
---|
| 227 | wrt_unpack2 "$FILE"
|
---|
[a229600] | 228 | # If the testsuites must be run, initialize the log file
|
---|
| 229 | case $name in
|
---|
| 230 | binutils | gcc | glibc )
|
---|
| 231 | [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
|
---|
| 232 | ;;
|
---|
| 233 | * )
|
---|
| 234 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
|
---|
| 235 | ;;
|
---|
| 236 | esac
|
---|
| 237 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 238 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 239 | fi
|
---|
| 240 |
|
---|
| 241 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 242 | # and not to use chroot.
|
---|
| 243 | case "${this_script}" in
|
---|
| 244 | *kernfs) wrt_run_as_root "${this_script}" "$file" ;;
|
---|
| 245 | *) wrt_run_as_chroot1 "${this_script}" "$file" ;;
|
---|
| 246 | esac
|
---|
| 247 |
|
---|
| 248 | # Remove the build directory(ies) except if the package build fails.
|
---|
| 249 | if [ "$vrs" != "" ] ; then
|
---|
| 250 | wrt_remove_build_dirs "$name"
|
---|
| 251 | fi
|
---|
| 252 |
|
---|
| 253 | # Include a touch of the target name so make can check
|
---|
| 254 | # if it's already been made.
|
---|
[e2ef100] | 255 | wrt_touch
|
---|
[877cc6a] | 256 | #
|
---|
| 257 | #--------------------------------------------------------------------#
|
---|
| 258 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 259 | #--------------------------------------------------------------------#
|
---|
| 260 |
|
---|
| 261 | # Keep the script file name for Makefile dependencies.
|
---|
[45f82718] | 262 | PREV=${this_script}${N}
|
---|
| 263 | # Set system_build envar for iteration targets
|
---|
| 264 | system_build=$chapter6
|
---|
[877cc6a] | 265 | done # end for file in chapter06/*
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | #----------------------------#
|
---|
| 269 | chapter789_Makefiles() {
|
---|
| 270 | #----------------------------#
|
---|
| 271 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9${R_arrow}"
|
---|
| 272 |
|
---|
| 273 | for file in chapter0{7,8,9}/* ; do
|
---|
| 274 | # Keep the script file name
|
---|
| 275 | this_script=`basename $file`
|
---|
| 276 |
|
---|
| 277 | # Grub must be configured manually.
|
---|
| 278 | # The filesystems can't be unmounted via Makefile and the user
|
---|
| 279 | # should enter the chroot environment to create the root
|
---|
| 280 | # password, edit several files and setup Grub.
|
---|
| 281 | #
|
---|
| 282 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 283 | #
|
---|
| 284 | case ${this_script} in
|
---|
| 285 | *grub) continue ;;
|
---|
| 286 | *reboot) continue ;;
|
---|
| 287 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
| 288 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 289 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
| 290 | esac
|
---|
| 291 |
|
---|
| 292 | # First append each name of the script files to a list (this will become
|
---|
| 293 | # the names of the targets in the Makefile
|
---|
| 294 | chapter789="$chapter789 ${this_script}"
|
---|
| 295 |
|
---|
| 296 | #--------------------------------------------------------------------#
|
---|
| 297 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 298 | #--------------------------------------------------------------------#
|
---|
| 299 | #
|
---|
| 300 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 301 | # as a dependency. Also call the echo_message function.
|
---|
| 302 | wrt_target "${this_script}" "$PREV"
|
---|
| 303 |
|
---|
| 304 | # Find the bootscripts and kernel package names
|
---|
| 305 | case "${this_script}" in
|
---|
| 306 | *bootscripts)
|
---|
| 307 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 308 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
| 309 | wrt_unpack2 "$FILE"
|
---|
| 310 | ;;
|
---|
| 311 | *kernel)
|
---|
| 312 | vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 313 | FILE="linux-$vrs.tar.*"
|
---|
| 314 | wrt_unpack2 "$FILE"
|
---|
| 315 | ;;
|
---|
| 316 | esac
|
---|
| 317 |
|
---|
| 318 | # Check if we have a real /etc/fstab file
|
---|
| 319 | case "${this_script}" in
|
---|
| 320 | *fstab) if [[ -n $FSTAB ]]; then
|
---|
| 321 | wrt_copy_fstab "${this_script}"
|
---|
| 322 | else
|
---|
| 323 | wrt_run_as_chroot2 "$this_script" "$file"
|
---|
| 324 | fi
|
---|
| 325 | ;;
|
---|
| 326 | *) wrt_run_as_chroot2 "$this_script" "$file"
|
---|
| 327 | ;;
|
---|
| 328 | esac
|
---|
| 329 |
|
---|
| 330 | case "${this_script}" in
|
---|
| 331 | *bootscripts) wrt_remove_build_dirs "dummy" ;;
|
---|
| 332 | *kernel) wrt_remove_build_dirs "dummy" ;;
|
---|
| 333 | esac
|
---|
| 334 |
|
---|
| 335 | # Include a touch of the target name so make can check
|
---|
| 336 | # if it's already been made.
|
---|
[e2ef100] | 337 | wrt_touch
|
---|
[877cc6a] | 338 | #
|
---|
| 339 | #--------------------------------------------------------------------#
|
---|
| 340 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 341 | #--------------------------------------------------------------------#
|
---|
| 342 |
|
---|
| 343 | # Keep the script file name for Makefile dependencies.
|
---|
| 344 | PREV=${this_script}
|
---|
| 345 | done # for file in chapter0{7,8,9}/*
|
---|
[453bef0] | 346 |
|
---|
| 347 | # Add SBU-disk_usage report target if required
|
---|
| 348 | if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
|
---|
[877cc6a] | 349 | }
|
---|
| 350 |
|
---|
| 351 |
|
---|
| 352 | #----------------------------#
|
---|
| 353 | build_Makefile() {
|
---|
| 354 | #----------------------------#
|
---|
[c7c5a53] | 355 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[877cc6a] | 356 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 357 |
|
---|
| 358 | # Start with a clean Makefile.tmp file
|
---|
| 359 | >$MKFILE.tmp
|
---|
| 360 |
|
---|
| 361 | chapter4_Makefiles
|
---|
| 362 | chapter5_Makefiles
|
---|
| 363 | chapter6_Makefiles
|
---|
[45f82718] | 364 | # Add the iterations targets, if needed
|
---|
| 365 | [[ "$COMPARE" != "0" ]] && wrt_compare_targets
|
---|
[877cc6a] | 366 | chapter789_Makefiles
|
---|
| 367 |
|
---|
| 368 |
|
---|
| 369 | # Add a header, some variables and include the function file
|
---|
| 370 | # to the top of the real Makefile.
|
---|
| 371 | (
|
---|
| 372 | cat << EOF
|
---|
| 373 | $HEADER
|
---|
| 374 |
|
---|
| 375 | SRC= /sources
|
---|
| 376 | MOUNT_PT= $BUILDDIR
|
---|
[82eb8c1] | 377 | PKG_LST= $PKG_LST
|
---|
[877cc6a] | 378 |
|
---|
| 379 | include makefile-functions
|
---|
| 380 |
|
---|
| 381 | EOF
|
---|
| 382 | ) > $MKFILE
|
---|
| 383 |
|
---|
| 384 |
|
---|
| 385 | # Add chroot commands
|
---|
| 386 | i=1
|
---|
| 387 | for file in chapter06/*chroot* ; do
|
---|
| 388 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
---|
| 389 | -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
|
---|
| 390 | -e 's|"$$LFS"|$(MOUNT_PT)|' -e 's|set -e||'`
|
---|
| 391 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 392 | i=`expr $i + 1`
|
---|
| 393 | done
|
---|
| 394 |
|
---|
| 395 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 396 | # as a dependency.
|
---|
| 397 | (
|
---|
| 398 | cat << EOF
|
---|
[7d9a82d] | 399 | all: chapter4 chapter5 chapter6 chapter789 do_housekeeping
|
---|
[877cc6a] | 400 | @\$(call echo_finished,$VERSION)
|
---|
| 401 |
|
---|
| 402 | chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
| 403 |
|
---|
| 404 | chapter5: chapter4 $chapter5 restore-lfs-env
|
---|
| 405 |
|
---|
| 406 | chapter6: chapter5 $chapter6
|
---|
| 407 |
|
---|
| 408 | chapter789: chapter6 $chapter789
|
---|
| 409 |
|
---|
| 410 | clean-all: clean
|
---|
| 411 | rm -rf ./{lfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
---|
| 412 |
|
---|
| 413 | clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
---|
| 414 |
|
---|
[fe24ca6] | 415 | restart: restart_code all
|
---|
| 416 |
|
---|
[877cc6a] | 417 | clean-chapter4:
|
---|
| 418 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 419 | userdel lfs; \\
|
---|
| 420 | rm -rf /home/lfs; \\
|
---|
| 421 | fi;
|
---|
| 422 | rm -rf \$(MOUNT_PT)/tools
|
---|
| 423 | rm -f /tools
|
---|
| 424 | rm -f envars user-lfs-exist
|
---|
| 425 | rm -f 02* logs/02*.log
|
---|
| 426 |
|
---|
| 427 | clean-chapter5:
|
---|
| 428 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
| 429 | rm -f $chapter5 restore-lfs-env sources-dir
|
---|
| 430 | cd logs && rm -f $chapter5 && cd ..
|
---|
| 431 |
|
---|
| 432 | clean-chapter6:
|
---|
| 433 | -umount \$(MOUNT_PT)/sys
|
---|
| 434 | -umount \$(MOUNT_PT)/proc
|
---|
| 435 | -umount \$(MOUNT_PT)/dev/shm
|
---|
| 436 | -umount \$(MOUNT_PT)/dev/pts
|
---|
| 437 | -umount \$(MOUNT_PT)/dev
|
---|
| 438 | rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
| 439 | rm -f $chapter6
|
---|
| 440 | cd logs && rm -f $chapter6 && cd ..
|
---|
| 441 |
|
---|
| 442 | clean-chapter789:
|
---|
| 443 | rm -f $chapter789
|
---|
| 444 | cd logs && rm -f $chapter789 && cd ..
|
---|
| 445 |
|
---|
| 446 | restore-lfs-env:
|
---|
| 447 | @\$(call echo_message, Building)
|
---|
| 448 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
[cee9568] | 449 | mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
[877cc6a] | 450 | fi;
|
---|
| 451 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
[e314f7e] | 452 | mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
[877cc6a] | 453 | fi;
|
---|
| 454 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
[e2ef100] | 455 | touch \$@ && \\
|
---|
| 456 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK\$(WHITE) && \\
|
---|
| 457 | echo --------------------------------------------------------------------------------
|
---|
[a858a78] | 458 |
|
---|
[7d9a82d] | 459 | do_housekeeping:
|
---|
| 460 | -umount \$(MOUNT_PT)/sys
|
---|
| 461 | -umount \$(MOUNT_PT)/proc
|
---|
| 462 | -umount \$(MOUNT_PT)/dev/shm
|
---|
| 463 | -umount \$(MOUNT_PT)/dev/pts
|
---|
| 464 | -umount \$(MOUNT_PT)/dev
|
---|
| 465 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 466 | userdel lfs; \\
|
---|
| 467 | rm -rf /home/lfs; \\
|
---|
| 468 | fi;
|
---|
[a858a78] | 469 |
|
---|
[fe24ca6] | 470 | restart_code:
|
---|
[aed6c72] | 471 | @echo ">>> This feature is experimental, BUGS may exist"
|
---|
| 472 |
|
---|
| 473 | @if [ ! -L /tools ]; then \\
|
---|
| 474 | echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
|
---|
| 475 | fi;
|
---|
| 476 |
|
---|
| 477 | @if [ ! -e /tools ]; then \\
|
---|
| 478 | echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
|
---|
| 479 | fi;
|
---|
| 480 |
|
---|
[fe24ca6] | 481 | @if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
|
---|
| 482 | echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
|
---|
| 483 | fi;
|
---|
[aed6c72] | 484 |
|
---|
[fe24ca6] | 485 | @if [ -f ???-kernfs ]; then \\
|
---|
| 486 | mkdir -pv \$(MOUNT_PT)/{dev,proc,sys};\\
|
---|
| 487 | if [ ! -e \$(MOUNT_PT)/dev/console ]; then \\
|
---|
| 488 | mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1;\\
|
---|
| 489 | fi;\\
|
---|
| 490 | if [ ! -e \$(MOUNT_PT)/dev/null ]; then \\
|
---|
| 491 | mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3;\\
|
---|
| 492 | fi;\\
|
---|
| 493 | if ! mount -l | grep bind >/dev/null ; then \\
|
---|
| 494 | mount --bind /dev \$(MOUNT_PT)/dev;\\
|
---|
| 495 | fi;\\
|
---|
| 496 | if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
|
---|
| 497 | mount -vt devpts devpts \$(MOUNT_PT)/dev/pts;\\
|
---|
| 498 | fi;\\
|
---|
| 499 | if ! mount -l | grep "\$(MOUNT_PT)/dev/shm" >/dev/null ; then \\
|
---|
| 500 | mount -vt tmpfs shm \$(MOUNT_PT)/dev/shm;\\
|
---|
| 501 | fi;\\
|
---|
| 502 | if ! mount -l | grep "\$(MOUNT_PT)/proc" >/dev/null ; then \\
|
---|
| 503 | mount -vt proc proc \$(MOUNT_PT)/proc;\\
|
---|
| 504 | fi;\\
|
---|
| 505 | if ! mount -l | grep "$\(MOUNT_PT)/sys" >/dev/null ; then \\
|
---|
| 506 | mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
|
---|
| 507 | fi;\\
|
---|
[e314f7e] | 508 | fi;
|
---|
[fe24ca6] | 509 |
|
---|
[877cc6a] | 510 | EOF
|
---|
| 511 | ) >> $MKFILE
|
---|
| 512 |
|
---|
| 513 | # Bring over the items from the Makefile.tmp
|
---|
| 514 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 515 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 516 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
[877cc6a] | 517 |
|
---|
[c7c5a53] | 518 | }
|
---|
[877cc6a] | 519 |
|
---|