[0170229] | 1 | #!/bin/sh
|
---|
| 2 | set -e # Enable error trapping
|
---|
| 3 |
|
---|
[57ca090] | 4 | # $Id$
|
---|
[0170229] | 5 |
|
---|
| 6 | ###################################
|
---|
| 7 | ### FUNCTIONS ###
|
---|
| 8 | ###################################
|
---|
| 9 |
|
---|
[65a2be6] | 10 | #----------------------------------#
|
---|
| 11 | wrt_ExecuteAsUser() { # Execute the file ($3) under the users account ($1), log in $2
|
---|
| 12 | #----------------------------------#
|
---|
| 13 | local this_user=$1
|
---|
| 14 | local this_script=$2
|
---|
| 15 | local file=$3
|
---|
| 16 |
|
---|
| 17 | (
|
---|
| 18 | cat << EOF
|
---|
| 19 | @( time { su - ${this_user} -c "source /home/${this_user}/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
| 20 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 21 | EOF
|
---|
| 22 | ) >> $MKFILE.tmp
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | #----------------------------------#
|
---|
| 27 | wrt_Unpack_SetOwner() { # Unpack and set owner. Assign 'ROOT' var
|
---|
| 28 | #----------------------------------#
|
---|
| 29 | local USER_ACCT=$1
|
---|
| 30 | local FILE=$2
|
---|
| 31 | local optSAVE_PREVIOUS=$3
|
---|
| 32 |
|
---|
| 33 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 34 | wrt_remove_existing_dirs "$FILE"
|
---|
| 35 | fi
|
---|
| 36 | (
|
---|
| 37 | cat << EOF
|
---|
| 38 | @\$(call unpack,$FILE)
|
---|
| 39 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 40 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
| 41 | chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 42 | EOF
|
---|
| 43 | ) >> $MKFILE.tmp
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[21dab83] | 46 | #----------------------------------#
|
---|
| 47 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 48 | #----------------------------------#
|
---|
| 49 | local user_ACCT=$(echo $1 | tr [a-z] [A-Z])
|
---|
| 50 | local this_script=$2
|
---|
| 51 | local file=$3
|
---|
| 52 |
|
---|
| 53 | (
|
---|
| 54 | cat << EOF
|
---|
| 55 | @( time { export ${user_ACCT}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
| 56 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 57 | EOF
|
---|
| 58 | ) >> $MKFILE.tmp
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 |
|
---|
[65a2be6] | 62 | #----------------------------#
|
---|
| 63 | process_toolchain() { # embryo,cocoon and butterfly need special handling
|
---|
| 64 | #----------------------------#
|
---|
| 65 | local toolchain=$1
|
---|
| 66 | local this_script=$2
|
---|
| 67 | local tc_phase
|
---|
| 68 |
|
---|
| 69 | echo "${tab_}${tab_}${GREEN}toolchain ${L_arrow}${toolchain}${R_arrow}"
|
---|
| 70 |
|
---|
[21dab83] | 71 | case ${toolchain} in
|
---|
| 72 | *butterfly*)
|
---|
| 73 | [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
|
---|
| 74 | (
|
---|
| 75 | cat << EOF
|
---|
| 76 | @echo "export PKGDIR=\$(SRC)" > envars
|
---|
| 77 | EOF
|
---|
| 78 | ) >> $MKFILE.tmp
|
---|
| 79 | wrt_run_as_chroot1 "$toolchain" "$this_script"
|
---|
| 80 | ;;
|
---|
[a82bbc0] | 81 |
|
---|
[21dab83] | 82 | *)
|
---|
[65a2be6] | 83 | (
|
---|
| 84 | cat << EOF
|
---|
| 85 | @echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars
|
---|
| 86 | EOF
|
---|
| 87 | ) >> $MKFILE.tmp
|
---|
[21dab83] | 88 | wrt_ExecuteAsUser "hlfs" "$toolchain" "$this_script"
|
---|
| 89 | ;;
|
---|
| 90 | esac
|
---|
[a82bbc0] | 91 | #
|
---|
| 92 | # Safe method to remove packages unpacked outside the toolchain
|
---|
[65a2be6] | 93 | pkg_tarball=$(get_package_tarball_name "binutils")
|
---|
| 94 | wrt_remove_existing_dirs "$pkg_tarball"
|
---|
| 95 | pkg_tarball=$(get_package_tarball_name "gcc-core")
|
---|
| 96 | wrt_remove_existing_dirs "$pkg_tarball"
|
---|
[21dab83] | 97 | #
|
---|
[65a2be6] | 98 | # Manually remove the toolchain directories..
|
---|
| 99 | tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'`
|
---|
| 100 | (
|
---|
| 101 | cat << EOF
|
---|
| 102 | @rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\
|
---|
| 103 | rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-build
|
---|
| 104 | EOF
|
---|
| 105 | ) >> $MKFILE.tmp
|
---|
| 106 |
|
---|
| 107 | }
|
---|
| 108 |
|
---|
[0170229] | 109 |
|
---|
| 110 | #----------------------------#
|
---|
[389fe2a] | 111 | chapter3_Makefiles() { # Initialization of the system
|
---|
[0170229] | 112 | #----------------------------#
|
---|
| 113 |
|
---|
[e10232b] | 114 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
|
---|
[0170229] | 115 |
|
---|
| 116 |
|
---|
[65a2be6] | 117 | # NOTE: We use the hlfs username and groupname also in HLFS
|
---|
| 118 | # If /home/hlfs is already present in the host, we asume that the
|
---|
| 119 | # hlfs user and group are also presents in the host, and a backup
|
---|
[0170229] | 120 | # of their bash init files is made.
|
---|
| 121 | (
|
---|
| 122 | cat << EOF
|
---|
| 123 | 020-creatingtoolsdir:
|
---|
| 124 | @\$(call echo_message, Building)
|
---|
[9199a13] | 125 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
| 126 | rm -f /tools && \\
|
---|
| 127 | ln -s \$(MOUNT_PT)/tools /
|
---|
[0170229] | 128 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
| 129 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
| 130 | fi;
|
---|
| 131 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
[9199a13] | 132 | touch \$@ && \\
|
---|
| 133 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 134 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[0170229] | 135 |
|
---|
| 136 | 021-addinguser: 020-creatingtoolsdir
|
---|
| 137 | @\$(call echo_message, Building)
|
---|
[65a2be6] | 138 | @if [ ! -d /home/hlfs ]; then \\
|
---|
| 139 | groupadd hlfs; \\
|
---|
| 140 | useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
|
---|
[0170229] | 141 | else \\
|
---|
[65a2be6] | 142 | touch user-hlfs-exist; \\
|
---|
[0170229] | 143 | fi;
|
---|
[65a2be6] | 144 | @chown hlfs \$(MOUNT_PT)/tools && \\
|
---|
| 145 | chown hlfs \$(MOUNT_PT)/sources && \\
|
---|
[9199a13] | 146 | touch \$@ && \\
|
---|
| 147 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 148 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[0170229] | 149 |
|
---|
| 150 | 022-settingenvironment: 021-addinguser
|
---|
| 151 | @\$(call echo_message, Building)
|
---|
[65a2be6] | 152 | @if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
|
---|
| 153 | mv /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
|
---|
[0170229] | 154 | fi;
|
---|
[65a2be6] | 155 | @if [ -f /home/hlfs/.bash_profile -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
|
---|
| 156 | mv /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
|
---|
[0170229] | 157 | fi;
|
---|
[65a2be6] | 158 | @echo "set +h" > /home/hlfs/.bashrc && \\
|
---|
| 159 | echo "umask 022" >> /home/hlfs/.bashrc && \\
|
---|
| 160 | echo "HLFS=\$(MOUNT_PT)" >> /home/hlfs/.bashrc && \\
|
---|
| 161 | echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
|
---|
| 162 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
|
---|
| 163 | echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
|
---|
| 164 | echo "" >> /home/hlfs/.bashrc && \\
|
---|
| 165 | echo "source $JHALFSDIR/envars" >> /home/hlfs/.bashrc && \\
|
---|
| 166 | chown hlfs:hlfs /home/hlfs/.bashrc && \\
|
---|
[0170229] | 167 | touch envars && \\
|
---|
[9199a13] | 168 | touch \$@ && \\
|
---|
| 169 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 170 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[0170229] | 171 | EOF
|
---|
| 172 | ) >> $MKFILE.tmp
|
---|
| 173 |
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | #----------------------------#
|
---|
| 177 | chapter5_Makefiles() { # Bootstrap or temptools phase
|
---|
| 178 | #----------------------------#
|
---|
| 179 | local file
|
---|
| 180 | local this_script
|
---|
[57ca090] | 181 |
|
---|
[e10232b] | 182 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
---|
[0170229] | 183 |
|
---|
| 184 | for file in chapter05/* ; do
|
---|
| 185 | # Keep the script file name
|
---|
| 186 | this_script=`basename $file`
|
---|
| 187 |
|
---|
| 188 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 189 | case $this_script in
|
---|
| 190 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
[821a2c6] | 191 | *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 192 | *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 193 | *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
[7d018d1] | 194 | # Nothing interestin in this script
|
---|
| 195 | *introduction* ) continue ;;
|
---|
[0170229] | 196 | # Test if the stripping phase must be skipped
|
---|
| 197 | *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 198 | *) ;;
|
---|
| 199 | esac
|
---|
| 200 |
|
---|
| 201 | # First append each name of the script files to a list (this will become
|
---|
| 202 | # the names of the targets in the Makefile
|
---|
| 203 | chapter5="$chapter5 $this_script"
|
---|
| 204 |
|
---|
| 205 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 206 | # and binutils in chapter 5)
|
---|
[65a2be6] | 207 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' `
|
---|
[0170229] | 208 |
|
---|
[5c5a010] | 209 | # Adjust 'name'
|
---|
[0170229] | 210 | case $name in
|
---|
[3b63c8c] | 211 | uclibc) name="uClibc" ;;
|
---|
[0170229] | 212 | esac
|
---|
| 213 |
|
---|
| 214 | # Set the dependency for the first target.
|
---|
| 215 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
| 216 |
|
---|
| 217 | #--------------------------------------------------------------------#
|
---|
| 218 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 219 | #--------------------------------------------------------------------#
|
---|
| 220 | #
|
---|
| 221 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 222 | # as a dependency. Also call the echo_message function.
|
---|
[65a2be6] | 223 |
|
---|
| 224 | # This is a very special script and requires manual processing
|
---|
| 225 | # NO Optimization allowed
|
---|
| 226 | if [[ ${name} = "embryo-toolchain" ]] || \
|
---|
| 227 | [[ ${name} = "cocoon-toolchain" ]]; then
|
---|
| 228 | wrt_target "$this_script" "$PREV"
|
---|
| 229 | process_toolchain "${this_script}" "${file}"
|
---|
| 230 | wrt_touch
|
---|
| 231 | PREV=$this_script
|
---|
| 232 | continue
|
---|
| 233 | fi
|
---|
| 234 | #
|
---|
[0170229] | 235 | wrt_target "$this_script" "$PREV"
|
---|
| 236 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 237 | # a specific package
|
---|
[3b63c8c] | 238 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 239 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 240 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[29f9ec8] | 241 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
[65a2be6] | 242 | wrt_Unpack_SetOwner "hlfs" "$pkg_tarball"
|
---|
[e35e794] | 243 | # If the testsuites must be run, initialize the log file
|
---|
| 244 | [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}"
|
---|
| 245 | # If using optimizations, write the instructions
|
---|
[c205656] | 246 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[29f9ec8] | 247 | fi
|
---|
[0170229] | 248 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 249 | # and date and disk usage again at the bottom of the log file.
|
---|
[65a2be6] | 250 | wrt_ExecuteAsUser "hlfs" "$this_script" "${file}"
|
---|
[0170229] | 251 |
|
---|
| 252 | # Remove the build directory(ies) except if the package build fails
|
---|
| 253 | # (so we can review config.cache, config.log, etc.)
|
---|
| 254 | # For Binutils the sources must be retained for some time.
|
---|
[3b63c8c] | 255 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[65a2be6] | 256 | wrt_remove_build_dirs "$name"
|
---|
[0170229] | 257 | fi
|
---|
| 258 |
|
---|
| 259 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[9199a13] | 260 | wrt_touch
|
---|
[0170229] | 261 | #
|
---|
| 262 | #--------------------------------------------------------------------#
|
---|
| 263 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 264 | #--------------------------------------------------------------------#
|
---|
| 265 |
|
---|
| 266 | # Keep the script file name for Makefile dependencies.
|
---|
| 267 | PREV=$this_script
|
---|
| 268 | done # end for file in chapter05/*
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 |
|
---|
| 272 | #----------------------------#
|
---|
| 273 | chapter6_Makefiles() { # sysroot or chroot build phase
|
---|
| 274 | #----------------------------#
|
---|
| 275 | local file
|
---|
| 276 | local this_script
|
---|
[c483858] | 277 | # Set envars and scripts for iteration targets
|
---|
| 278 | LOGS="" # Start with an empty global LOGS envar
|
---|
| 279 | if [[ -z "$1" ]] ; then
|
---|
| 280 | local N=""
|
---|
| 281 | else
|
---|
| 282 | local N=-build_$1
|
---|
| 283 | local chapter6=""
|
---|
| 284 | mkdir chapter06$N
|
---|
| 285 | cp chapter06/* chapter06$N
|
---|
| 286 | for script in chapter06$N/* ; do
|
---|
| 287 | # Overwrite existing symlinks, files, and dirs
|
---|
| 288 | sed -e 's/ln -s /ln -sf /g' \
|
---|
| 289 | -e 's/^mv /&-f/g' -i ${script}
|
---|
| 290 | done
|
---|
| 291 | # Remove Bzip2 binaries before make install
|
---|
| 292 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
|
---|
| 293 | # Fix how Module-Init-Tools do the install target
|
---|
| 294 | sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
|
---|
| 295 | # Delete *old Readline libraries just after make install
|
---|
| 296 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
|
---|
| 297 | # Don't readd already existing groups
|
---|
| 298 | sed -e '/groupadd/d' -i chapter06$N/*-udev
|
---|
| 299 | fi
|
---|
[0170229] | 300 |
|
---|
[c483858] | 301 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
|
---|
[0170229] | 302 |
|
---|
[c483858] | 303 | for file in chapter06$N/* ; do
|
---|
[0170229] | 304 | # Keep the script file name
|
---|
| 305 | this_script=`basename $file`
|
---|
| 306 |
|
---|
| 307 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 308 | case $this_script in
|
---|
| 309 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 310 | # dependencies and target creation.
|
---|
| 311 | *chroot* ) continue ;;
|
---|
| 312 | # Test if the stripping phase must be skipped
|
---|
| 313 | *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 314 | esac
|
---|
| 315 |
|
---|
| 316 | # Grab the name of the target
|
---|
| 317 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 318 |
|
---|
[3b63c8c] | 319 | #
|
---|
| 320 | # Sed replacement to fix some rm command that could fail.
|
---|
| 321 | # That should be fixed in the book sources.
|
---|
| 322 | #
|
---|
| 323 | case $name in
|
---|
| 324 | glibc) sed 's/rm /rm -f /' -i chapter06$N/$this_script ;;
|
---|
| 325 | esac
|
---|
| 326 |
|
---|
| 327 | case $name in
|
---|
| 328 | uclibc) name="uClibc" ;;
|
---|
| 329 | esac
|
---|
| 330 |
|
---|
[c483858] | 331 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 332 | # a specific package
|
---|
[3b63c8c] | 333 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[c483858] | 334 |
|
---|
[3b63c8c] | 335 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[c483858] | 336 | case "${this_script}" in
|
---|
| 337 | *stripping*) ;;
|
---|
| 338 | *) continue ;;
|
---|
| 339 | esac
|
---|
| 340 | fi
|
---|
| 341 |
|
---|
| 342 | # Append each name of the script files to a list (this will become
|
---|
| 343 | # the names of the targets in the Makefile
|
---|
| 344 | chapter6="$chapter6 ${this_script}${N}"
|
---|
| 345 |
|
---|
| 346 | # Append each name of the script files to a list (this will become
|
---|
[7635367] | 347 | # the names of the logs to be moved for each iteration)
|
---|
| 348 | LOGS="$LOGS ${this_script}"
|
---|
[c483858] | 349 |
|
---|
[0170229] | 350 |
|
---|
| 351 | #--------------------------------------------------------------------#
|
---|
| 352 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 353 | #--------------------------------------------------------------------#
|
---|
| 354 | #
|
---|
| 355 | # Drop in the name of the target on a new line, and the previous target
|
---|
[65a2be6] | 356 | # as a dependency. Also call the echo_message function.
|
---|
| 357 | if [[ ${name} = "butterfly-toolchain" ]]; then
|
---|
| 358 | wrt_target "$this_script" "$PREV"
|
---|
| 359 | process_toolchain "${this_script}" "${file}"
|
---|
| 360 | wrt_touch
|
---|
| 361 | PREV=$this_script
|
---|
| 362 | continue
|
---|
| 363 | fi
|
---|
| 364 |
|
---|
[c483858] | 365 | wrt_target "${this_script}${N}" "$PREV"
|
---|
[0170229] | 366 |
|
---|
[3b63c8c] | 367 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[0170229] | 368 | # Insert instructions for unpacking the package and changing directories
|
---|
[3b63c8c] | 369 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 370 | wrt_unpack2 "$pkg_tarball"
|
---|
[e35e794] | 371 | # If the testsuites must be run, initialize the log file
|
---|
| 372 | case $name in
|
---|
[65a2be6] | 373 | glibc )
|
---|
[e35e794] | 374 | [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
|
---|
| 375 | ;;
|
---|
| 376 | * )
|
---|
| 377 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
|
---|
| 378 | ;;
|
---|
| 379 | esac
|
---|
| 380 | # If using optimizations, write the instructions
|
---|
[c205656] | 381 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[0170229] | 382 | fi
|
---|
| 383 |
|
---|
[582feec] | 384 | # In the mount of kernel filesystems we need to set LFS and not to use chroot.
|
---|
[5f4d08f] | 385 | case "${this_script}" in
|
---|
| 386 | *kernfs*)
|
---|
[21dab83] | 387 | wrt_RunAsRoot "hlfs" "${this_script}" "${file}"
|
---|
[5f4d08f] | 388 | ;;
|
---|
| 389 | *) # The rest of Chapter06
|
---|
| 390 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
| 391 | ;;
|
---|
| 392 | esac
|
---|
[0170229] | 393 | #
|
---|
| 394 | # Remove the build directory(ies) except if the package build fails.
|
---|
[3b63c8c] | 395 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[0170229] | 396 | wrt_remove_build_dirs "$name"
|
---|
| 397 | fi
|
---|
| 398 | #
|
---|
| 399 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[9199a13] | 400 | wrt_touch
|
---|
[0170229] | 401 | #
|
---|
| 402 | #--------------------------------------------------------------------#
|
---|
| 403 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 404 | #--------------------------------------------------------------------#
|
---|
| 405 |
|
---|
| 406 | # Keep the script file name for Makefile dependencies.
|
---|
[c483858] | 407 | PREV=${this_script}${N}
|
---|
| 408 | # Set system_build envar for iteration targets
|
---|
| 409 | system_build=$chapter6
|
---|
[0170229] | 410 | done # end for file in chapter06/*
|
---|
| 411 |
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | #----------------------------#
|
---|
| 415 | chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
---|
| 416 | #----------------------------#
|
---|
| 417 | local file
|
---|
| 418 | local this_script
|
---|
[57ca090] | 419 |
|
---|
[e10232b] | 420 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
|
---|
[0170229] | 421 | for file in chapter07/*; do
|
---|
| 422 | # Keep the script file name
|
---|
| 423 | this_script=`basename $file`
|
---|
| 424 |
|
---|
| 425 | # Grub must be configured manually.
|
---|
| 426 | # The filesystems can't be unmounted via Makefile and the user
|
---|
| 427 | # should enter the chroot environment to create the root
|
---|
| 428 | # password, edit several files and setup Grub.
|
---|
| 429 | case $this_script in
|
---|
[0ac273e] | 430 | *usage) continue ;; # Contains example commands
|
---|
[0170229] | 431 | *grub) continue ;;
|
---|
| 432 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
| 433 |
|
---|
[57ca090] | 434 | *kernel)
|
---|
[821a2c6] | 435 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 436 | [[ -z $CONFIG ]] && continue
|
---|
[1d756b0] | 437 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
[0170229] | 438 | ;;
|
---|
| 439 | esac
|
---|
| 440 |
|
---|
| 441 | # First append then name of the script file to a list (this will become
|
---|
| 442 | # the names of the targets in the Makefile
|
---|
| 443 | chapter7="$chapter7 $this_script"
|
---|
| 444 |
|
---|
| 445 | #--------------------------------------------------------------------#
|
---|
| 446 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 447 | #--------------------------------------------------------------------#
|
---|
| 448 | #
|
---|
| 449 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 450 | # as a dependency. Also call the echo_message function.
|
---|
| 451 | wrt_target "$this_script" "$PREV"
|
---|
| 452 |
|
---|
[5f4d08f] | 453 | case "${this_script}" in
|
---|
[db187c74] | 454 | *bootscripts*)
|
---|
[3b63c8c] | 455 | wrt_unpack2 $(get_package_tarball_name "lfs-bootscripts")
|
---|
| 456 | blfs_bootscripts=$(get_package_tarball_name "blfs-bootscripts" | sed -e 's/.tar.*//' )
|
---|
| 457 | echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/$blfs_bootscripts\" >> sources-dir" >> $MKFILE.tmp
|
---|
[5f4d08f] | 458 | ;;
|
---|
| 459 | esac
|
---|
[0170229] | 460 |
|
---|
[db187c74] | 461 | case "${this_script}" in
|
---|
[5f4d08f] | 462 | *fstab*) # Check if we have a real /etc/fstab file
|
---|
| 463 | if [[ -n "$FSTAB" ]] ; then
|
---|
| 464 | wrt_copy_fstab "$this_script"
|
---|
| 465 | else # Initialize the log and run the script
|
---|
| 466 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
| 467 | fi
|
---|
| 468 | ;;
|
---|
| 469 | *) # All other scripts
|
---|
| 470 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
| 471 | ;;
|
---|
| 472 | esac
|
---|
[0170229] | 473 |
|
---|
| 474 | # Remove the build directory except if the package build fails.
|
---|
[5f4d08f] | 475 | case "${this_script}" in
|
---|
| 476 | *bootscripts*)
|
---|
[0170229] | 477 | (
|
---|
| 478 | cat << EOF
|
---|
[460ea63] | 479 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[0170229] | 480 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 481 | @rm -r \`cat sources-dir\` && \\
|
---|
| 482 | rm sources-dir
|
---|
| 483 | EOF
|
---|
| 484 | ) >> $MKFILE.tmp
|
---|
[5f4d08f] | 485 | ;;
|
---|
| 486 | esac
|
---|
[0170229] | 487 |
|
---|
| 488 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[9199a13] | 489 | wrt_touch
|
---|
[0170229] | 490 | #
|
---|
| 491 | #--------------------------------------------------------------------#
|
---|
| 492 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 493 | #--------------------------------------------------------------------#
|
---|
| 494 |
|
---|
| 495 | # Keep the script file name for Makefile dependencies.
|
---|
| 496 | PREV=$this_script
|
---|
| 497 | done # for file in chapter07/*
|
---|
[9e4b9a1] | 498 |
|
---|
| 499 | # Add SBU-disk_usage report target if required
|
---|
| 500 | if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
|
---|
[0170229] | 501 | }
|
---|
| 502 |
|
---|
| 503 |
|
---|
| 504 | #----------------------------#
|
---|
| 505 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 506 | #----------------------------#
|
---|
[a702b4d] | 507 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[0170229] | 508 |
|
---|
| 509 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 510 | # Start with a clean Makefile.tmp file
|
---|
| 511 | >$MKFILE.tmp
|
---|
| 512 |
|
---|
[389fe2a] | 513 | chapter3_Makefiles
|
---|
[0170229] | 514 | chapter5_Makefiles
|
---|
| 515 | chapter6_Makefiles
|
---|
[c483858] | 516 | # Add the iterations targets, if needed
|
---|
| 517 | [[ "$COMPARE" != "0" ]] && wrt_compare_targets
|
---|
[0170229] | 518 | chapter7_Makefiles
|
---|
| 519 |
|
---|
| 520 | # Add a header, some variables and include the function file
|
---|
| 521 | # to the top of the real Makefile.
|
---|
| 522 | (
|
---|
| 523 | cat << EOF
|
---|
| 524 | $HEADER
|
---|
| 525 |
|
---|
| 526 | SRC= /sources
|
---|
| 527 | MOUNT_PT= $BUILDDIR
|
---|
[460ea63] | 528 | PKG_LST= $PKG_LST
|
---|
[0170229] | 529 |
|
---|
| 530 | include makefile-functions
|
---|
| 531 |
|
---|
| 532 | EOF
|
---|
| 533 | ) > $MKFILE
|
---|
| 534 |
|
---|
| 535 |
|
---|
| 536 | # Add chroot commands
|
---|
| 537 | i=1
|
---|
| 538 | for file in chapter06/*chroot* ; do
|
---|
| 539 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
| 540 | -e '/^export/d' \
|
---|
| 541 | -e '/^logout/d' \
|
---|
| 542 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
| 543 | -e 's|\\$|&&|g' \
|
---|
| 544 | -e 's|exit||g' \
|
---|
| 545 | -e 's|$| -c|' \
|
---|
| 546 | -e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
---|
| 547 | -e 's|set -e||'`
|
---|
| 548 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 549 | i=`expr $i + 1`
|
---|
| 550 | done
|
---|
| 551 |
|
---|
| 552 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 553 | # as a dependency.
|
---|
| 554 | (
|
---|
| 555 | cat << EOF
|
---|
[3a27393] | 556 | all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
|
---|
[0170229] | 557 | @\$(call echo_finished,$VERSION)
|
---|
| 558 |
|
---|
[0ac273e] | 559 | chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
[0170229] | 560 |
|
---|
[65a2be6] | 561 | chapter5: chapter3 $chapter5 restore-hlfs-env
|
---|
[0170229] | 562 |
|
---|
| 563 | chapter6: chapter5 $chapter6
|
---|
| 564 |
|
---|
| 565 | chapter7: chapter6 $chapter7
|
---|
| 566 |
|
---|
| 567 | clean-all: clean
|
---|
[bc097cd] | 568 | rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
---|
[0170229] | 569 |
|
---|
[0ac273e] | 570 | clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
|
---|
[0170229] | 571 |
|
---|
[3b63c8c] | 572 | restart: restart_code all
|
---|
| 573 |
|
---|
[0ac273e] | 574 | clean-chapter3:
|
---|
[65a2be6] | 575 | -if [ ! -f user-hlfs-exist ]; then \\
|
---|
| 576 | userdel hlfs; \\
|
---|
| 577 | rm -rf /home/hlfs; \\
|
---|
[0170229] | 578 | fi;
|
---|
| 579 | rm -rf \$(MOUNT_PT)/tools
|
---|
| 580 | rm -f /tools
|
---|
[65a2be6] | 581 | rm -f envars user-hlfs-exist
|
---|
[0170229] | 582 | rm -f 02* logs/02*.log
|
---|
| 583 |
|
---|
| 584 | clean-chapter5:
|
---|
| 585 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
[65a2be6] | 586 | rm -f $chapter5 restore-hlfs-env sources-dir
|
---|
[0170229] | 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 |
|
---|
[65a2be6] | 603 | restore-hlfs-env:
|
---|
[0170229] | 604 | @\$(call echo_message, Building)
|
---|
[65a2be6] | 605 | @if [ -f /home/hlfs/.bashrc.XXX ]; then \\
|
---|
| 606 | mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
|
---|
[0170229] | 607 | fi;
|
---|
[65a2be6] | 608 | @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
|
---|
| 609 | mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
|
---|
[0170229] | 610 | fi;
|
---|
[65a2be6] | 611 | @chown hlfs:hlfs /home/hlfs/.bash* && \\
|
---|
[9199a13] | 612 | touch \$@ && \\
|
---|
| 613 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 614 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[0170229] | 615 |
|
---|
[3a27393] | 616 | do-housekeeping:
|
---|
[9199a13] | 617 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
| 618 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
| 619 | @-umount \$(MOUNT_PT)/dev
|
---|
| 620 | @-umount \$(MOUNT_PT)/sys
|
---|
| 621 | @-umount \$(MOUNT_PT)/proc
|
---|
[65a2be6] | 622 | @-if [ ! -f user-hlfs-exist ]; then \\
|
---|
| 623 | userdel hlfs; \\
|
---|
| 624 | rm -rf /home/hlfs; \\
|
---|
[3a27393] | 625 | fi;
|
---|
[460ea63] | 626 |
|
---|
[3b63c8c] | 627 | restart_code:
|
---|
| 628 | @echo ">>> This feature is experimental, BUGS may exist"
|
---|
| 629 |
|
---|
| 630 | @if [ ! -L /tools ]; then \\
|
---|
| 631 | echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
|
---|
| 632 | fi;
|
---|
| 633 |
|
---|
| 634 | @if [ ! -e /tools ]; then \\
|
---|
| 635 | echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
|
---|
| 636 | fi;
|
---|
| 637 |
|
---|
| 638 | @if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
|
---|
| 639 | echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
|
---|
| 640 | fi;
|
---|
| 641 |
|
---|
| 642 | @if [ -f ???-kernfs ]; then \\
|
---|
| 643 | mkdir -pv \$(MOUNT_PT)/{proc,sys};\\
|
---|
| 644 | if ! mount -l | "\$(MOUNT_PT)/dev" >/dev/null ; then \\
|
---|
| 645 | mount -vt ramfs ramfs \$(MOUNT_PT)/dev;\\
|
---|
| 646 | fi;\\
|
---|
| 647 | if [ ! -e \$(MOUNT_PT)/dev/console ]; then \\
|
---|
| 648 | mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1;\\
|
---|
| 649 | fi;\\
|
---|
| 650 | if [ ! -e \$(MOUNT_PT)/dev/null ]; then \\
|
---|
| 651 | mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3;\\
|
---|
| 652 | fi;\\
|
---|
| 653 | if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
|
---|
| 654 | mount -vt devpts -o gid=4,mode=620 devpts \$(MOUNT_PT)/dev/pts;\\
|
---|
| 655 | fi;\\
|
---|
| 656 | if ! mount -l | grep "\$(MOUNT_PT)/dev/shm" >/dev/null ; then \\
|
---|
| 657 | mount -vt tmpfs shm \$(MOUNT_PT)/dev/shm;\\
|
---|
| 658 | fi;\\
|
---|
| 659 | if ! mount -l | grep "\$(MOUNT_PT)/proc" >/dev/null ; then \\
|
---|
| 660 | mount -vt proc proc \$(MOUNT_PT)/proc;\\
|
---|
| 661 | fi;\\
|
---|
| 662 | if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
|
---|
| 663 | mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
|
---|
| 664 | fi;\\
|
---|
| 665 | fi;
|
---|
| 666 |
|
---|
| 667 |
|
---|
[0170229] | 668 | EOF
|
---|
| 669 | ) >> $MKFILE
|
---|
| 670 |
|
---|
| 671 | # Bring over the items from the Makefile.tmp
|
---|
| 672 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 673 | rm $MKFILE.tmp
|
---|
[a702b4d] | 674 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 675 |
|
---|
[0170229] | 676 | }
|
---|