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