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