[877cc6a] | 1 | #!/bin/sh
|
---|
| 2 | set -e # Enable error trapping
|
---|
| 3 |
|
---|
| 4 | # $Id$
|
---|
| 5 |
|
---|
| 6 | ###################################
|
---|
| 7 | ### FUNCTIONS ###
|
---|
| 8 | ###################################
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | #----------------------------#
|
---|
| 12 | chapter3_Makefiles() { # Initialization of the system
|
---|
| 13 | #----------------------------#
|
---|
| 14 | local TARGET LOADER
|
---|
| 15 |
|
---|
| 16 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
|
---|
| 17 |
|
---|
| 18 | # Define a few model dependant variables
|
---|
| 19 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
| 20 | TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
| 21 | else
|
---|
| 22 | TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
| 23 | fi
|
---|
| 24 |
|
---|
| 25 | # NOTE: We use the lfs username and groupname also in HLFS
|
---|
| 26 | # If /home/lfs is already present in the host, we asume that the
|
---|
| 27 | # lfs user and group are also presents in the host, and a backup
|
---|
| 28 | # of their bash init files is made.
|
---|
| 29 | (
|
---|
| 30 | cat << EOF
|
---|
| 31 | 020-creatingtoolsdir:
|
---|
| 32 | @\$(call echo_message, Building)
|
---|
| 33 | @mkdir -v \$(MOUNT_PT)/tools && \\
|
---|
| 34 | rm -fv /tools && \\
|
---|
| 35 | ln -sv \$(MOUNT_PT)/tools /
|
---|
| 36 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
| 37 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
| 38 | fi;
|
---|
| 39 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
| 40 | touch \$@
|
---|
| 41 |
|
---|
| 42 | 021-addinguser: 020-creatingtoolsdir
|
---|
| 43 | @\$(call echo_message, Building)
|
---|
| 44 | @if [ ! -d /home/lfs ]; then \\
|
---|
| 45 | groupadd lfs; \\
|
---|
| 46 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
| 47 | else \\
|
---|
| 48 | touch user-lfs-exist; \\
|
---|
| 49 | fi;
|
---|
| 50 | @chown lfs \$(MOUNT_PT)/tools && \\
|
---|
| 51 | chown lfs \$(MOUNT_PT)/sources && \\
|
---|
| 52 | touch \$@
|
---|
| 53 |
|
---|
| 54 | 022-settingenvironment: 021-addinguser
|
---|
| 55 | @\$(call echo_message, Building)
|
---|
| 56 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
| 57 | mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
| 58 | fi;
|
---|
| 59 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
| 60 | mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
| 61 | fi;
|
---|
| 62 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
| 63 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
| 64 | echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
---|
| 65 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
| 66 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
| 67 | echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
| 68 | echo "" >> /home/lfs/.bashrc && \\
|
---|
| 69 | echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
|
---|
| 70 | echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
|
---|
| 71 | echo "export target ldso" >> /home/lfs/.bashrc && \\
|
---|
| 72 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
---|
| 73 | chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
| 74 | touch envars && \\
|
---|
| 75 | touch \$@
|
---|
| 76 | EOF
|
---|
| 77 | ) >> $MKFILE.tmp
|
---|
| 78 |
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | #----------------------------#
|
---|
| 82 | chapter5_Makefiles() { # Bootstrap or temptools phase
|
---|
| 83 | #----------------------------#
|
---|
| 84 | local file
|
---|
| 85 | local this_script
|
---|
| 86 |
|
---|
| 87 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
---|
| 88 |
|
---|
| 89 | for file in chapter05/* ; do
|
---|
| 90 | # Keep the script file name
|
---|
| 91 | this_script=`basename $file`
|
---|
| 92 |
|
---|
| 93 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 94 | case $this_script in
|
---|
| 95 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
| 96 | *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 97 | *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 98 | *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 99 | # Nothing interestin in this script
|
---|
| 100 | *introduction* ) continue ;;
|
---|
| 101 | # Test if the stripping phase must be skipped
|
---|
| 102 | *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 103 | *) ;;
|
---|
| 104 | esac
|
---|
| 105 |
|
---|
| 106 | # First append each name of the script files to a list (this will become
|
---|
| 107 | # the names of the targets in the Makefile
|
---|
| 108 | chapter5="$chapter5 $this_script"
|
---|
| 109 |
|
---|
| 110 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 111 | # and binutils in chapter 5)
|
---|
| 112 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
|
---|
| 113 |
|
---|
| 114 | # Adjust 'name'
|
---|
| 115 | case $name in
|
---|
| 116 | linux-libc) name=linux-libc-headers ;;
|
---|
| 117 | esac
|
---|
| 118 |
|
---|
| 119 | # Set the dependency for the first target.
|
---|
| 120 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | #--------------------------------------------------------------------#
|
---|
| 124 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 125 | #--------------------------------------------------------------------#
|
---|
| 126 | #
|
---|
| 127 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 128 | # as a dependency. Also call the echo_message function.
|
---|
| 129 | wrt_target "$this_script" "$PREV"
|
---|
| 130 |
|
---|
| 131 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 132 | # a specific package
|
---|
| 133 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 134 | # If $vrs isn't empty, we've got a package...
|
---|
| 135 | if [ "$vrs" != "" ] ; then
|
---|
| 136 | # Deal with non-standard names
|
---|
| 137 | case $name in
|
---|
| 138 | tcl) FILE="$name$vrs-src.tar.*" ;;
|
---|
| 139 | uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
---|
| 140 | gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
---|
| 141 | *) FILE="$name-$vrs.tar.*" ;;
|
---|
| 142 | esac
|
---|
[1b65a84] | 143 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
[5842156] | 144 | case $this_script in
|
---|
[82eb8c1] | 145 | *binutils* )
|
---|
[5842156] | 146 | wrt_unpack "$FILE" 1 ;; # Do not delete an existing package directories
|
---|
| 147 | *)
|
---|
| 148 | wrt_unpack "$FILE" ;;
|
---|
| 149 | esac
|
---|
[1b65a84] | 150 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 151 | fi
|
---|
[877cc6a] | 152 |
|
---|
| 153 | case $this_script in
|
---|
| 154 | *binutils* ) # Dump the path to sources directory for later removal
|
---|
[15537d5] | 155 | (
|
---|
| 156 | cat << EOF
|
---|
[82eb8c1] | 157 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[15537d5] | 158 | echo "\$(MOUNT_PT)\$(SRC)/\$\$ROOT" >> sources-dir
|
---|
| 159 | EOF
|
---|
| 160 | ) >> $MKFILE.tmp
|
---|
[877cc6a] | 161 | ;;
|
---|
| 162 | *adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 163 | echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
| 164 | ;;
|
---|
| 165 | esac
|
---|
| 166 |
|
---|
| 167 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 168 | # and date and disk usage again at the bottom of the log file.
|
---|
| 169 | wrt_run_as_su "${this_script}" "${file}"
|
---|
| 170 |
|
---|
| 171 | # Remove the build directory(ies) except if the package build fails
|
---|
| 172 | # (so we can review config.cache, config.log, etc.)
|
---|
| 173 | # For Binutils the sources must be retained for some time.
|
---|
| 174 | if [ "$vrs" != "" ] ; then
|
---|
| 175 | case "${this_script}" in
|
---|
| 176 | *binutils*) : # do NOTHING
|
---|
| 177 | ;;
|
---|
| 178 | *) wrt_remove_build_dirs "$name"
|
---|
| 179 | ;;
|
---|
| 180 | esac
|
---|
| 181 | fi
|
---|
| 182 |
|
---|
| 183 | # Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
---|
| 184 | case "${this_script}" in
|
---|
| 185 | *adjusting*)
|
---|
| 186 | (
|
---|
| 187 | cat << EOF
|
---|
| 188 | @rm -r \`cat sources-dir\` && \\
|
---|
| 189 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
| 190 | rm sources-dir
|
---|
| 191 | EOF
|
---|
| 192 | ) >> $MKFILE.tmp
|
---|
| 193 | ;;
|
---|
| 194 | esac
|
---|
| 195 |
|
---|
| 196 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 197 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 198 | #
|
---|
| 199 | #--------------------------------------------------------------------#
|
---|
| 200 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 201 | #--------------------------------------------------------------------#
|
---|
| 202 |
|
---|
| 203 | # Keep the script file name for Makefile dependencies.
|
---|
| 204 | PREV=$this_script
|
---|
| 205 | done # end for file in chapter05/*
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | #----------------------------#
|
---|
| 210 | chapter6_Makefiles() { # sysroot or chroot build phase
|
---|
| 211 | #----------------------------#
|
---|
| 212 | local TARGET LOADER
|
---|
| 213 | local file
|
---|
| 214 | local this_script
|
---|
[45f82718] | 215 | # Set envars and scripts for iteration targets
|
---|
| 216 | LOGS="" # Start with an empty global LOGS envar
|
---|
| 217 | if [[ -z "$1" ]] ; then
|
---|
| 218 | local N=""
|
---|
| 219 | else
|
---|
| 220 | local N=-build_$1
|
---|
| 221 | local chapter6=""
|
---|
| 222 | mkdir chapter06$N
|
---|
| 223 | cp chapter06/* chapter06$N
|
---|
| 224 | for script in chapter06$N/* ; do
|
---|
| 225 | # Overwrite existing symlinks, files, and dirs
|
---|
| 226 | sed -e 's/ln -s /ln -sf /g' \
|
---|
| 227 | -e 's/^mv /&-f/g' -i ${script}
|
---|
| 228 | done
|
---|
| 229 | # Remove Bzip2 binaries before make install
|
---|
| 230 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
|
---|
| 231 | # Fix how Module-Init-Tools do the install target
|
---|
| 232 | sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
|
---|
| 233 | # Delete *old Readline libraries just after make install
|
---|
| 234 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
|
---|
| 235 | # Don't readd already existing groups
|
---|
| 236 | sed -e '/groupadd/d' -i chapter06$N/*-udev
|
---|
| 237 | fi
|
---|
[877cc6a] | 238 |
|
---|
[45f82718] | 239 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
|
---|
[877cc6a] | 240 | #
|
---|
| 241 | # Set these definitions early and only once
|
---|
| 242 | #
|
---|
| 243 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
| 244 | TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
| 245 | else
|
---|
| 246 | TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
| 247 | fi
|
---|
| 248 |
|
---|
[45f82718] | 249 | for file in chapter06$N/* ; do
|
---|
[877cc6a] | 250 | # Keep the script file name
|
---|
| 251 | this_script=`basename $file`
|
---|
| 252 |
|
---|
| 253 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 254 | case $this_script in
|
---|
| 255 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 256 | # dependencies and target creation.
|
---|
| 257 | *chroot* ) continue ;;
|
---|
| 258 | # Test if the stripping phase must be skipped
|
---|
| 259 | *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 260 | esac
|
---|
| 261 |
|
---|
| 262 | # Grab the name of the target
|
---|
| 263 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 264 |
|
---|
[45f82718] | 265 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 266 | # a specific package
|
---|
| 267 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 268 |
|
---|
| 269 | if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
|
---|
| 270 | case "${this_script}" in
|
---|
| 271 | *stripping*) ;;
|
---|
| 272 | *) continue ;;
|
---|
| 273 | esac
|
---|
| 274 | fi
|
---|
| 275 |
|
---|
| 276 | # Append each name of the script files to a list (this will become
|
---|
| 277 | # the names of the targets in the Makefile
|
---|
| 278 | chapter6="$chapter6 ${this_script}${N}"
|
---|
| 279 |
|
---|
| 280 | # Append each name of the script files to a list (this will become
|
---|
| 281 | # the names of the logs to be moved for each iteration)
|
---|
| 282 | LOGS="$LOGS ${this_script}"
|
---|
| 283 |
|
---|
[877cc6a] | 284 | #
|
---|
| 285 | # Sed replacement to fix some rm command that could fail.
|
---|
| 286 | # That should be fixed in the book sources.
|
---|
| 287 | #
|
---|
| 288 | case $name in
|
---|
| 289 | glibc)
|
---|
[45f82718] | 290 | sed 's/rm /rm -f /' -i chapter06$N/$this_script
|
---|
[877cc6a] | 291 | ;;
|
---|
| 292 | gcc)
|
---|
[45f82718] | 293 | sed 's/rm /rm -f /' -i chapter06$N/$this_script
|
---|
[877cc6a] | 294 | ;;
|
---|
| 295 | esac
|
---|
| 296 |
|
---|
| 297 | #--------------------------------------------------------------------#
|
---|
| 298 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 299 | #--------------------------------------------------------------------#
|
---|
| 300 | #
|
---|
| 301 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 302 | # as a dependency. Also call the echo_message function.
|
---|
[45f82718] | 303 | wrt_target "${this_script}${N}" "$PREV"
|
---|
[877cc6a] | 304 |
|
---|
| 305 | # If $vrs isn't empty, we've got a package...
|
---|
| 306 | # Insert instructions for unpacking the package and changing directories
|
---|
| 307 | if [ "$vrs" != "" ] ; then
|
---|
| 308 | # Deal with non-standard names
|
---|
| 309 | case $name in
|
---|
| 310 | tcl) FILE="$name$vrs-src.tar.*" ;;
|
---|
| 311 | uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
---|
| 312 | gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
---|
| 313 | *) FILE="$name-$vrs.tar.*" ;;
|
---|
| 314 | esac
|
---|
| 315 | wrt_unpack2 "$FILE"
|
---|
| 316 | wrt_target_vars
|
---|
[1b65a84] | 317 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 318 | fi
|
---|
| 319 |
|
---|
| 320 | case $this_script in
|
---|
| 321 | *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 322 | echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
| 323 | ;;
|
---|
| 324 | esac
|
---|
| 325 |
|
---|
| 326 | # In the mount of kernel filesystems we need to set LFS and not to use chroot.
|
---|
| 327 | case "${this_script}" in
|
---|
| 328 | *kernfs*)
|
---|
| 329 | wrt_run_as_root "${this_script}" "${file}"
|
---|
| 330 | ;;
|
---|
| 331 | *) # The rest of Chapter06
|
---|
| 332 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
| 333 | ;;
|
---|
| 334 | esac
|
---|
| 335 | #
|
---|
| 336 | # Remove the build directory(ies) except if the package build fails.
|
---|
| 337 | if [ "$vrs" != "" ] ; then
|
---|
| 338 | wrt_remove_build_dirs "$name"
|
---|
| 339 | fi
|
---|
| 340 | #
|
---|
| 341 | # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
---|
| 342 | case "${this_script}" in
|
---|
| 343 | *readjusting*)
|
---|
| 344 | (
|
---|
| 345 | cat << EOF
|
---|
| 346 | @rm -r \`cat sources-dir\` && \\
|
---|
| 347 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
| 348 | rm sources-dir
|
---|
| 349 | EOF
|
---|
| 350 | ) >> $MKFILE.tmp
|
---|
| 351 | ;;
|
---|
| 352 | esac
|
---|
| 353 |
|
---|
| 354 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 355 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 356 | #
|
---|
| 357 | #--------------------------------------------------------------------#
|
---|
| 358 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 359 | #--------------------------------------------------------------------#
|
---|
| 360 |
|
---|
| 361 | # Keep the script file name for Makefile dependencies.
|
---|
[45f82718] | 362 | PREV=${this_script}${N}
|
---|
| 363 | # Set system_build envar for iteration targets
|
---|
| 364 | system_build=$chapter6
|
---|
[877cc6a] | 365 | done # end for file in chapter06/*
|
---|
| 366 |
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | #----------------------------#
|
---|
| 370 | chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
---|
| 371 | #----------------------------#
|
---|
| 372 | local file
|
---|
| 373 | local this_script
|
---|
| 374 |
|
---|
| 375 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
|
---|
| 376 | for file in chapter07/*; do
|
---|
| 377 | # Keep the script file name
|
---|
| 378 | this_script=`basename $file`
|
---|
| 379 |
|
---|
| 380 | # Grub must be configured manually.
|
---|
| 381 | # The filesystems can't be unmounted via Makefile and the user
|
---|
| 382 | # should enter the chroot environment to create the root
|
---|
| 383 | # password, edit several files and setup Grub.
|
---|
| 384 | case $this_script in
|
---|
| 385 | *usage) continue ;; # Contains example commands
|
---|
| 386 | *grub) continue ;;
|
---|
| 387 | *reboot) continue ;;
|
---|
| 388 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
| 389 |
|
---|
| 390 | *kernel)
|
---|
| 391 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 392 | [[ -z $CONFIG ]] && continue
|
---|
| 393 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 394 | ;;
|
---|
| 395 | esac
|
---|
| 396 |
|
---|
| 397 | # First append then name of the script file to a list (this will become
|
---|
| 398 | # the names of the targets in the Makefile
|
---|
| 399 | chapter7="$chapter7 $this_script"
|
---|
| 400 |
|
---|
| 401 | #--------------------------------------------------------------------#
|
---|
| 402 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 403 | #--------------------------------------------------------------------#
|
---|
| 404 | #
|
---|
| 405 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 406 | # as a dependency. Also call the echo_message function.
|
---|
| 407 | wrt_target "$this_script" "$PREV"
|
---|
| 408 |
|
---|
| 409 | case "${this_script}" in
|
---|
| 410 | *bootscripts*)
|
---|
| 411 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 412 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
| 413 | wrt_unpack2 "$FILE"
|
---|
| 414 | vrs=`grep "^blfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 415 | echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/blfs-bootscripts-$vrs\" >> sources-dir" >> $MKFILE.tmp
|
---|
| 416 | ;;
|
---|
| 417 | esac
|
---|
| 418 |
|
---|
| 419 | case "${this_script}" in
|
---|
| 420 | *fstab*) # Check if we have a real /etc/fstab file
|
---|
| 421 | if [[ -n "$FSTAB" ]] ; then
|
---|
| 422 | wrt_copy_fstab "$this_script"
|
---|
| 423 | else # Initialize the log and run the script
|
---|
| 424 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
| 425 | fi
|
---|
| 426 | ;;
|
---|
| 427 | *) # All other scripts
|
---|
| 428 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
| 429 | ;;
|
---|
| 430 | esac
|
---|
| 431 |
|
---|
| 432 | # Remove the build directory except if the package build fails.
|
---|
| 433 | case "${this_script}" in
|
---|
| 434 | *bootscripts*)
|
---|
| 435 | (
|
---|
| 436 | cat << EOF
|
---|
[82eb8c1] | 437 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 438 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 439 | @rm -r \`cat sources-dir\` && \\
|
---|
| 440 | rm sources-dir
|
---|
| 441 | EOF
|
---|
| 442 | ) >> $MKFILE.tmp
|
---|
| 443 | ;;
|
---|
| 444 | esac
|
---|
| 445 |
|
---|
| 446 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 447 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 448 | #
|
---|
| 449 | #--------------------------------------------------------------------#
|
---|
| 450 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 451 | #--------------------------------------------------------------------#
|
---|
| 452 |
|
---|
| 453 | # Keep the script file name for Makefile dependencies.
|
---|
| 454 | PREV=$this_script
|
---|
| 455 | done # for file in chapter07/*
|
---|
[453bef0] | 456 |
|
---|
| 457 | # Add SBU-disk_usage report target if required
|
---|
| 458 | if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
|
---|
[877cc6a] | 459 | }
|
---|
| 460 |
|
---|
| 461 |
|
---|
| 462 | #----------------------------#
|
---|
| 463 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 464 | #----------------------------#
|
---|
[c7c5a53] | 465 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[877cc6a] | 466 |
|
---|
| 467 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 468 | # Start with a clean Makefile.tmp file
|
---|
| 469 | >$MKFILE.tmp
|
---|
| 470 |
|
---|
| 471 | chapter3_Makefiles
|
---|
| 472 | chapter5_Makefiles
|
---|
| 473 | chapter6_Makefiles
|
---|
[45f82718] | 474 | # Add the iterations targets, if needed
|
---|
| 475 | [[ "$COMPARE" != "0" ]] && wrt_compare_targets
|
---|
[877cc6a] | 476 | chapter7_Makefiles
|
---|
| 477 |
|
---|
| 478 | # Add a header, some variables and include the function file
|
---|
| 479 | # to the top of the real Makefile.
|
---|
| 480 | (
|
---|
| 481 | cat << EOF
|
---|
| 482 | $HEADER
|
---|
| 483 |
|
---|
| 484 | SRC= /sources
|
---|
| 485 | MOUNT_PT= $BUILDDIR
|
---|
[82eb8c1] | 486 | PKG_LST= $PKG_LST
|
---|
[a858a78] | 487 | MAKE_PID=\`pidof make | cut -d " " -f1\`
|
---|
[877cc6a] | 488 |
|
---|
| 489 | include makefile-functions
|
---|
| 490 |
|
---|
| 491 | EOF
|
---|
| 492 | ) > $MKFILE
|
---|
| 493 |
|
---|
| 494 |
|
---|
| 495 | # Add chroot commands
|
---|
| 496 | i=1
|
---|
| 497 | for file in chapter06/*chroot* ; do
|
---|
| 498 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
| 499 | -e '/^export/d' \
|
---|
| 500 | -e '/^logout/d' \
|
---|
| 501 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
| 502 | -e 's|\\$|&&|g' \
|
---|
| 503 | -e 's|exit||g' \
|
---|
| 504 | -e 's|$| -c|' \
|
---|
| 505 | -e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
---|
| 506 | -e 's|set -e||'`
|
---|
| 507 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 508 | i=`expr $i + 1`
|
---|
| 509 | done
|
---|
| 510 |
|
---|
| 511 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 512 | # as a dependency.
|
---|
| 513 | (
|
---|
| 514 | cat << EOF
|
---|
[c8f9cd8] | 515 | all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
|
---|
[877cc6a] | 516 | @\$(call echo_finished,$VERSION)
|
---|
| 517 |
|
---|
| 518 | chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
| 519 |
|
---|
| 520 | chapter5: chapter3 $chapter5 restore-lfs-env
|
---|
| 521 |
|
---|
| 522 | chapter6: chapter5 $chapter6
|
---|
| 523 |
|
---|
| 524 | chapter7: chapter6 $chapter7
|
---|
| 525 |
|
---|
| 526 | clean-all: clean
|
---|
| 527 | rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
---|
| 528 |
|
---|
| 529 | clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
|
---|
| 530 |
|
---|
| 531 | clean-chapter3:
|
---|
| 532 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 533 | userdel lfs; \\
|
---|
| 534 | rm -rf /home/lfs; \\
|
---|
| 535 | fi;
|
---|
| 536 | rm -rf \$(MOUNT_PT)/tools
|
---|
| 537 | rm -f /tools
|
---|
| 538 | rm -f envars user-lfs-exist
|
---|
| 539 | rm -f 02* logs/02*.log
|
---|
| 540 |
|
---|
| 541 | clean-chapter5:
|
---|
| 542 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
| 543 | rm -f $chapter5 restore-lfs-env sources-dir
|
---|
| 544 | cd logs && rm -f $chapter5 && cd ..
|
---|
| 545 |
|
---|
| 546 | clean-chapter6:
|
---|
| 547 | -umount \$(MOUNT_PT)/sys
|
---|
| 548 | -umount \$(MOUNT_PT)/proc
|
---|
| 549 | -umount \$(MOUNT_PT)/dev/shm
|
---|
| 550 | -umount \$(MOUNT_PT)/dev/pts
|
---|
| 551 | -umount \$(MOUNT_PT)/dev
|
---|
| 552 | rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
| 553 | rm -f $chapter6
|
---|
| 554 | cd logs && rm -f $chapter6 && cd ..
|
---|
| 555 |
|
---|
| 556 | clean-chapter7:
|
---|
| 557 | rm -f $chapter7
|
---|
| 558 | cd logs && rm -f $chapter7 && cd ..
|
---|
| 559 |
|
---|
| 560 | restore-lfs-env:
|
---|
| 561 | @\$(call echo_message, Building)
|
---|
| 562 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
| 563 | mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
| 564 | fi;
|
---|
| 565 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
| 566 | mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
| 567 | fi;
|
---|
| 568 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
| 569 | touch \$@
|
---|
| 570 |
|
---|
[7d9a82d] | 571 | do-housekeeping:
|
---|
| 572 | -umount \$(MOUNT_PT)/dev/pts
|
---|
| 573 | -umount \$(MOUNT_PT)/dev/shm
|
---|
| 574 | -umount \$(MOUNT_PT)/dev
|
---|
| 575 | -umount \$(MOUNT_PT)/sys
|
---|
| 576 | -umount \$(MOUNT_PT)/proc
|
---|
| 577 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 578 | userdel lfs; \\
|
---|
| 579 | rm -rf /home/lfs; \\
|
---|
| 580 | fi;
|
---|
[a858a78] | 581 |
|
---|
[877cc6a] | 582 | EOF
|
---|
| 583 | ) >> $MKFILE
|
---|
| 584 |
|
---|
| 585 | # Bring over the items from the Makefile.tmp
|
---|
| 586 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 587 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 588 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 589 |
|
---|
[877cc6a] | 590 | }
|
---|