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