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