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