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