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