[0170229] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
[a46ada0] | 3 | # $Id$
|
---|
[0170229] | 4 |
|
---|
| 5 | ###################################
|
---|
| 6 | ### FUNCTIONS ###
|
---|
| 7 | ###################################
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | #----------------------------#
|
---|
| 11 | chapter4_Makefiles() {
|
---|
| 12 | #----------------------------#
|
---|
[e10232b] | 13 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4${R_arrow}"
|
---|
[0170229] | 14 |
|
---|
[30737ea8] | 15 | # If /home/$LUSER is already present in the host, we asume that the
|
---|
[0170229] | 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)
|
---|
[9199a13] | 22 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
| 23 | rm -f /tools && \\
|
---|
| 24 | ln -s \$(MOUNT_PT)/tools / && \\
|
---|
| 25 | touch \$@ && \\
|
---|
| 26 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 27 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[0170229] | 28 |
|
---|
| 29 | 021-addinguser: 020-creatingtoolsdir
|
---|
| 30 | @\$(call echo_message, Building)
|
---|
[9485eba] | 31 | @if [ ! -d /home/\$(LUSER) ]; then \\
|
---|
| 32 | groupadd \$(LGROUP); \\
|
---|
| 33 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
[0170229] | 34 | else \\
|
---|
[30737ea8] | 35 | touch luser-exist; \\
|
---|
[0170229] | 36 | fi;
|
---|
[9485eba] | 37 | @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
---|
[dacaa85] | 38 | chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
[9199a13] | 39 | touch \$@ && \\
|
---|
| 40 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 41 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[0170229] | 42 |
|
---|
| 43 | 022-settingenvironment: 021-addinguser
|
---|
| 44 | @\$(call echo_message, Building)
|
---|
[9485eba] | 45 | @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
| 46 | mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
---|
[0170229] | 47 | fi;
|
---|
[9485eba] | 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; \\
|
---|
[0170229] | 50 | fi;
|
---|
[9485eba] | 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 && \\
|
---|
[0170229] | 59 | touch envars && \\
|
---|
[9199a13] | 60 | touch \$@ && \\
|
---|
| 61 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 62 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[0170229] | 63 | EOF
|
---|
| 64 | ) >> $MKFILE.tmp
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | #----------------------------#
|
---|
| 68 | chapter5_Makefiles() {
|
---|
| 69 | #----------------------------#
|
---|
[12a5707] | 70 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
---|
| 71 |
|
---|
[0170229] | 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
|
---|
[fed9756] | 77 | # Fix also locales creation when running chapter05 testsuites (ugly)
|
---|
[af4c7b1] | 78 | case "${this_script}" in
|
---|
| 79 | *tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 80 | *expect) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 81 | *dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
[47fddc8] | 82 | *stripping) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[fed9756] | 83 | *glibc) [[ "${TEST}" = "3" ]] && \
|
---|
| 84 | sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
---|
[af4c7b1] | 85 | esac
|
---|
[6b1576a] | 86 |
|
---|
[0170229] | 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 |
|
---|
[3f858ca] | 98 | #--------------------------------------------------------------------#
|
---|
| 99 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 100 | #--------------------------------------------------------------------#
|
---|
| 101 | #
|
---|
[0170229] | 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
|
---|
[3b63c8c] | 108 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[0170229] | 109 |
|
---|
[3b63c8c] | 110 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 111 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[3f858ca] | 112 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
[3b63c8c] | 113 | wrt_unpack "$pkg_tarball"
|
---|
[e35e794] | 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
|
---|
[c205656] | 117 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[0170229] | 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.
|
---|
[fed9756] | 122 | # The changingowner script must be run as root.
|
---|
| 123 | case "${this_script}" in
|
---|
[9485eba] | 124 | *changingowner) wrt_RunAsRoot "${this_script}" "$file" ;;
|
---|
| 125 | *) wrt_RunAsUser "${this_script}" "$file" ;;
|
---|
[fed9756] | 126 | esac
|
---|
[0170229] | 127 |
|
---|
| 128 | # Remove the build directory(ies) except if the package build fails
|
---|
| 129 | # (so we can review config.cache, config.log, etc.)
|
---|
[3b63c8c] | 130 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[0170229] | 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.
|
---|
[9199a13] | 136 | wrt_touch
|
---|
[3f858ca] | 137 | #
|
---|
| 138 | #--------------------------------------------------------------------#
|
---|
| 139 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 140 | #--------------------------------------------------------------------#
|
---|
[0170229] | 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 | #----------------------------#
|
---|
[615e37d] | 150 | # Set envars and scripts for iteration targets
|
---|
[4edbc92] | 151 | LOGS="" # Start with an empty global LOGS envar
|
---|
[b242136] | 152 | if [[ -z "$1" ]] ; then
|
---|
[aa08925] | 153 | local N=""
|
---|
| 154 | else
|
---|
| 155 | local N=-build_$1
|
---|
| 156 | local chapter6=""
|
---|
[615e37d] | 157 | mkdir chapter06$N
|
---|
| 158 | cp chapter06/* chapter06$N
|
---|
| 159 | for script in chapter06$N/* ; do
|
---|
[7aee0dd] | 160 | # Overwrite existing symlinks, files, and dirs
|
---|
[615e37d] | 161 | sed -e 's/ln -sv/&f/g' \
|
---|
| 162 | -e 's/mv -v/&f/g' \
|
---|
[7aee0dd] | 163 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
[615e37d] | 164 | done
|
---|
[3135831] | 165 | # Remove Bzip2 binaries before make install
|
---|
[c2fdc03] | 166 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
|
---|
[aa08925] | 167 | fi
|
---|
| 168 |
|
---|
| 169 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
|
---|
[af4c7b1] | 170 |
|
---|
[615e37d] | 171 | for file in chapter06$N/* ; do
|
---|
[0170229] | 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.
|
---|
[af4c7b1] | 177 | case "${this_script}" in
|
---|
| 178 | *chroot) continue ;;
|
---|
[47fddc8] | 179 | *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[af4c7b1] | 180 | esac
|
---|
[0170229] | 181 |
|
---|
[b242136] | 182 | # Grab the name of the target
|
---|
| 183 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 184 |
|
---|
| 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
|
---|
[3b63c8c] | 188 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[b242136] | 189 |
|
---|
[3b63c8c] | 190 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[b242136] | 191 | case "${this_script}" in
|
---|
| 192 | *stripping*) ;;
|
---|
| 193 | *) continue ;;
|
---|
| 194 | esac
|
---|
| 195 | fi
|
---|
| 196 |
|
---|
[4edbc92] | 197 | # Append each name of the script files to a list (this will become
|
---|
| 198 | # the names of the targets in the Makefile)
|
---|
[aa08925] | 199 | chapter6="$chapter6 ${this_script}${N}"
|
---|
[0170229] | 200 |
|
---|
[4edbc92] | 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 |
|
---|
[3f858ca] | 205 | #--------------------------------------------------------------------#
|
---|
| 206 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 207 | #--------------------------------------------------------------------#
|
---|
| 208 | #
|
---|
[0170229] | 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.
|
---|
[aa08925] | 211 | wrt_target "${this_script}${N}" "$PREV"
|
---|
[0170229] | 212 |
|
---|
[3b63c8c] | 213 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[0170229] | 214 | # Insert instructions for unpacking the package and changing directories
|
---|
[3b63c8c] | 215 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 216 | wrt_unpack2 "$pkg_tarball"
|
---|
[e35e794] | 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
|
---|
[c205656] | 227 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[0170229] | 228 | fi
|
---|
| 229 |
|
---|
| 230 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 231 | # and not to use chroot.
|
---|
[af4c7b1] | 232 | case "${this_script}" in
|
---|
[9485eba] | 233 | *kernfs) wrt_RunAsRoot "${this_script}" "$file" ;;
|
---|
[af4c7b1] | 234 | *) wrt_run_as_chroot1 "${this_script}" "$file" ;;
|
---|
| 235 | esac
|
---|
[0170229] | 236 |
|
---|
| 237 | # Remove the build directory(ies) except if the package build fails.
|
---|
[3b63c8c] | 238 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[a46ada0] | 239 | wrt_remove_build_dirs "$name"
|
---|
[0170229] | 240 | fi
|
---|
| 241 |
|
---|
| 242 | # Include a touch of the target name so make can check
|
---|
| 243 | # if it's already been made.
|
---|
[9199a13] | 244 | wrt_touch
|
---|
[3f858ca] | 245 | #
|
---|
| 246 | #--------------------------------------------------------------------#
|
---|
| 247 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 248 | #--------------------------------------------------------------------#
|
---|
[0170229] | 249 |
|
---|
| 250 | # Keep the script file name for Makefile dependencies.
|
---|
[aa08925] | 251 | PREV=${this_script}${N}
|
---|
| 252 | # Set system_build envar for iteration targets
|
---|
| 253 | system_build=$chapter6
|
---|
[0170229] | 254 | done # end for file in chapter06/*
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | #----------------------------#
|
---|
| 258 | chapter789_Makefiles() {
|
---|
| 259 | #----------------------------#
|
---|
[c0613fe] | 260 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9${R_arrow}"
|
---|
[af4c7b1] | 261 |
|
---|
[0170229] | 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.
|
---|
[0271c0c] | 270 | #
|
---|
[0170229] | 271 | # If no .config file is supplied, the kernel build is skipped
|
---|
[0271c0c] | 272 | #
|
---|
| 273 | case ${this_script} in
|
---|
| 274 | *grub) continue ;;
|
---|
| 275 | *reboot) continue ;;
|
---|
[6b1576a] | 276 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
[0271c0c] | 277 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 278 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
| 279 | esac
|
---|
[0170229] | 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 |
|
---|
[3f858ca] | 285 | #--------------------------------------------------------------------#
|
---|
| 286 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 287 | #--------------------------------------------------------------------#
|
---|
| 288 | #
|
---|
[0170229] | 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
|
---|
[af4c7b1] | 294 | case "${this_script}" in
|
---|
| 295 | *bootscripts)
|
---|
[3b63c8c] | 296 | name="lfs-bootscripts"
|
---|
| 297 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 298 | wrt_unpack2 "$pkg_tarball"
|
---|
[af4c7b1] | 299 | ;;
|
---|
| 300 | *kernel)
|
---|
[3b63c8c] | 301 | name="linux"
|
---|
| 302 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 303 | wrt_unpack2 "$pkg_tarball"
|
---|
[af4c7b1] | 304 | ;;
|
---|
| 305 | esac
|
---|
[6b1576a] | 306 |
|
---|
[0170229] | 307 | # Check if we have a real /etc/fstab file
|
---|
[af4c7b1] | 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
|
---|
[0170229] | 318 |
|
---|
[af4c7b1] | 319 | case "${this_script}" in
|
---|
| 320 | *bootscripts) wrt_remove_build_dirs "dummy" ;;
|
---|
| 321 | *kernel) wrt_remove_build_dirs "dummy" ;;
|
---|
| 322 | esac
|
---|
[6b1576a] | 323 |
|
---|
[0170229] | 324 | # Include a touch of the target name so make can check
|
---|
| 325 | # if it's already been made.
|
---|
[9199a13] | 326 | wrt_touch
|
---|
[3f858ca] | 327 | #
|
---|
| 328 | #--------------------------------------------------------------------#
|
---|
| 329 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 330 | #--------------------------------------------------------------------#
|
---|
[0170229] | 331 |
|
---|
| 332 | # Keep the script file name for Makefile dependencies.
|
---|
| 333 | PREV=${this_script}
|
---|
| 334 | done # for file in chapter0{7,8,9}/*
|
---|
[9e4b9a1] | 335 |
|
---|
| 336 | # Add SBU-disk_usage report target if required
|
---|
[47fddc8] | 337 | if [[ "$REPORT" = "y" ]] ; then wrt_report ; fi
|
---|
[0170229] | 338 | }
|
---|
| 339 |
|
---|
| 340 |
|
---|
| 341 | #----------------------------#
|
---|
| 342 | build_Makefile() {
|
---|
| 343 | #----------------------------#
|
---|
[a702b4d] | 344 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[0170229] | 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
|
---|
[4edbc92] | 353 | # Add the iterations targets, if needed
|
---|
[47fddc8] | 354 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
[0170229] | 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 |
|
---|
[398a037] | 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 |
|
---|
[0170229] | 387 |
|
---|
| 388 | include makefile-functions
|
---|
| 389 |
|
---|
| 390 | EOF
|
---|
| 391 | ) > $MKFILE
|
---|
| 392 |
|
---|
| 393 |
|
---|
| 394 | # Add chroot commands
|
---|
[8381f6e] | 395 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
[0170229] | 396 | i=1
|
---|
| 397 | for file in chapter06/*chroot* ; do
|
---|
[8381f6e] | 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||'`
|
---|
[0170229] | 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
|
---|
[3a27393] | 417 | all: chapter4 chapter5 chapter6 chapter789 do_housekeeping
|
---|
[0170229] | 418 | @\$(call echo_finished,$VERSION)
|
---|
| 419 |
|
---|
| 420 | chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
| 421 |
|
---|
[30737ea8] | 422 | chapter5: chapter4 $chapter5 restore-luser-env
|
---|
[0170229] | 423 |
|
---|
| 424 | chapter6: chapter5 $chapter6
|
---|
| 425 |
|
---|
| 426 | chapter789: chapter6 $chapter789
|
---|
| 427 |
|
---|
| 428 | clean-all: clean
|
---|
[db187c74] | 429 | rm -rf ./{lfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
---|
[0170229] | 430 |
|
---|
| 431 | clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
---|
| 432 |
|
---|
[9199a13] | 433 | restart: restart_code all
|
---|
| 434 |
|
---|
[0170229] | 435 | clean-chapter4:
|
---|
[30737ea8] | 436 | -if [ ! -f luser-exist ]; then \\
|
---|
[9485eba] | 437 | userdel \$(LUSER); \\
|
---|
| 438 | rm -rf /home/\$(LUSER); \\
|
---|
[0170229] | 439 | fi;
|
---|
| 440 | rm -rf \$(MOUNT_PT)/tools
|
---|
| 441 | rm -f /tools
|
---|
[30737ea8] | 442 | rm -f envars luser-exist
|
---|
[0170229] | 443 | rm -f 02* logs/02*.log
|
---|
| 444 |
|
---|
| 445 | clean-chapter5:
|
---|
| 446 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
[30737ea8] | 447 | rm -f $chapter5 restore-luser-env sources-dir
|
---|
[0170229] | 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 |
|
---|
[30737ea8] | 464 | restore-luser-env:
|
---|
[0170229] | 465 | @\$(call echo_message, Building)
|
---|
[9485eba] | 466 | @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
| 467 | mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
---|
[0170229] | 468 | fi;
|
---|
[9485eba] | 469 | @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
| 470 | mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
---|
[0170229] | 471 | fi;
|
---|
[9485eba] | 472 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
---|
[9199a13] | 473 | touch \$@ && \\
|
---|
| 474 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 475 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[460ea63] | 476 |
|
---|
[3a27393] | 477 | do_housekeeping:
|
---|
[9199a13] | 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
|
---|
[30737ea8] | 483 | @-if [ ! -f luser-exist ]; then \\
|
---|
[9485eba] | 484 | userdel \$(LUSER); \\
|
---|
| 485 | rm -rf /home/\$(LUSER); \\
|
---|
[3a27393] | 486 | fi;
|
---|
[460ea63] | 487 |
|
---|
[9199a13] | 488 | restart_code:
|
---|
| 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 |
|
---|
| 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;
|
---|
| 502 |
|
---|
| 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;\\
|
---|
[3b63c8c] | 523 | if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
|
---|
[9199a13] | 524 | mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
|
---|
| 525 | fi;\\
|
---|
| 526 | fi;
|
---|
| 527 |
|
---|
[42346b2] | 528 | EOF
|
---|
| 529 | ) >> $MKFILE
|
---|
| 530 |
|
---|
[0170229] | 531 | # Bring over the items from the Makefile.tmp
|
---|
| 532 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 533 | rm $MKFILE.tmp
|
---|
[a702b4d] | 534 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
[0170229] | 535 |
|
---|
[a702b4d] | 536 | }
|
---|
[0170229] | 537 |
|
---|