[91ff6a9] | 1 | #!/bin/bash
|
---|
[877cc6a] | 2 | # $Id$
|
---|
| 3 |
|
---|
[045b2dc] | 4 |
|
---|
| 5 | orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
|
---|
| 6 |
|
---|
[877cc6a] | 7 | ###################################
|
---|
| 8 | ### FUNCTIONS ###
|
---|
| 9 | ###################################
|
---|
| 10 |
|
---|
[045b2dc] | 11 | #--------------------------------------#
|
---|
| 12 | BOOT_wrt_target() { # "${this_script}" "$PREV"
|
---|
| 13 | #--------------------------------------#
|
---|
| 14 | local i=$1
|
---|
| 15 | local PREV=$2
|
---|
| 16 | case $i in
|
---|
| 17 | iteration* ) local LOGFILE=$this_script.log ;;
|
---|
| 18 | * ) local LOGFILE=$this_script ;;
|
---|
| 19 | esac
|
---|
| 20 | (
|
---|
| 21 | cat << EOF
|
---|
| 22 |
|
---|
| 23 | $i: $PREV
|
---|
| 24 | @\$(call echo_message, Building)
|
---|
| 25 | @./progress_bar.sh \$@ \$\$PPID &
|
---|
| 26 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT}\`\n" >logs/$LOGFILE
|
---|
| 27 | EOF
|
---|
| 28 | ) >> $MKFILE.tmp
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | #--------------------------------------#
|
---|
| 32 | BOOT_wrt_Unpack() { # "$pkg_tarball"
|
---|
| 33 | #--------------------------------------#
|
---|
| 34 | local FILE=$1
|
---|
| 35 | local optSAVE_PREVIOUS=$2
|
---|
| 36 |
|
---|
| 37 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 38 | (
|
---|
| 39 | cat << EOF
|
---|
| 40 | @\$(call remove_existing_dirs2,$FILE)
|
---|
| 41 | EOF
|
---|
| 42 | ) >> $MKFILE.tmp
|
---|
| 43 | fi
|
---|
| 44 | (
|
---|
| 45 | cat << EOF
|
---|
| 46 | @\$(call unpack3,$FILE)
|
---|
| 47 | @\$(call get_pkg_root2)
|
---|
| 48 | EOF
|
---|
| 49 | ) >> $MKFILE.tmp
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | #----------------------------------#
|
---|
| 53 | BOOT_wrt_RunAsRoot() { # "${this_script}" "${file}"
|
---|
| 54 | #----------------------------------#
|
---|
| 55 | local this_script=$1
|
---|
| 56 | local file=$2
|
---|
| 57 | (
|
---|
| 58 | cat << EOF
|
---|
| 59 | @( time { source envars && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
|
---|
| 60 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/\$@
|
---|
| 61 | EOF
|
---|
| 62 | ) >> $MKFILE.tmp
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | #--------------------------------------#
|
---|
| 66 | BOOT_wrt_RemoveBuildDirs() { # "${name}"
|
---|
| 67 | #--------------------------------------#
|
---|
| 68 | local name=$1
|
---|
| 69 | (
|
---|
| 70 | cat << EOF
|
---|
| 71 | @\$(call remove_build_dirs2,$name)
|
---|
| 72 | EOF
|
---|
| 73 | ) >> $MKFILE.tmp
|
---|
| 74 | }
|
---|
[877cc6a] | 75 |
|
---|
[045b2dc] | 76 | #----------------------------------#
|
---|
| 77 | BOOT_wrt_test_log() { #
|
---|
| 78 | #----------------------------------#
|
---|
| 79 | local TESTLOGFILE=$1
|
---|
| 80 | (
|
---|
| 81 | cat << EOF
|
---|
| 82 | @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\
|
---|
| 83 | echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
|
---|
| 84 | EOF
|
---|
| 85 | ) >> $MKFILE.tmp
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | #----------------------------------#
|
---|
| 89 | BOOT_wrt_CopyFstab() { #
|
---|
| 90 | #----------------------------------#
|
---|
| 91 | (
|
---|
| 92 | cat << EOF
|
---|
| 93 | @( time { cp -v /sources/fstab /etc/fstab >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
|
---|
| 94 | EOF
|
---|
| 95 | ) >> $MKFILE.tmp
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | ########################################
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | #--------------------------------------#
|
---|
| 103 | host_prep_Makefiles() { #
|
---|
| 104 | #--------------------------------------#
|
---|
[e2ec07a] | 105 | local CLFS_HOST
|
---|
[877cc6a] | 106 |
|
---|
[045b2dc] | 107 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
|
---|
[877cc6a] | 108 |
|
---|
| 109 | # defined here, only for ease of reading
|
---|
[ff4d1ab] | 110 | CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
|
---|
[877cc6a] | 111 | (
|
---|
| 112 | cat << EOF
|
---|
| 113 | 023-creatingtoolsdir:
|
---|
| 114 | @\$(call echo_message, Building)
|
---|
[e314f7e] | 115 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
| 116 | rm -f /tools && \\
|
---|
| 117 | ln -s \$(MOUNT_PT)/tools /
|
---|
[877cc6a] | 118 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
| 119 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
| 120 | fi;
|
---|
| 121 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
[93f38e7] | 122 | touch \$@ && \\
|
---|
| 123 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 124 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 125 |
|
---|
| 126 | 024-creatingcrossdir: 023-creatingtoolsdir
|
---|
| 127 | @mkdir -v \$(MOUNT_PT)/cross-tools && \\
|
---|
[e314f7e] | 128 | rm -f /cross-tools && \\
|
---|
| 129 | ln -s \$(MOUNT_PT)/cross-tools /
|
---|
[93f38e7] | 130 | @touch \$@ && \\
|
---|
| 131 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 132 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 133 |
|
---|
| 134 | 025-addinguser: 024-creatingcrossdir
|
---|
| 135 | @\$(call echo_message, Building)
|
---|
[6ad5a2f] | 136 | @if [ ! -d /home/\$(LUSER) ]; then \\
|
---|
| 137 | groupadd \$(LGROUP); \\
|
---|
| 138 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
[877cc6a] | 139 | else \\
|
---|
[6ad5a2f] | 140 | touch luser-exist; \\
|
---|
[877cc6a] | 141 | fi;
|
---|
[6ad5a2f] | 142 | @chown \$(LUSER) \$(MOUNT_PT) && \\
|
---|
| 143 | chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
---|
| 144 | chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
|
---|
| 145 | chown \$(LUSER) \$(MOUNT_PT)/sources && \\
|
---|
[93f38e7] | 146 | touch \$@ && \\
|
---|
| 147 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 148 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 149 |
|
---|
| 150 | 026-settingenvironment: 025-addinguser
|
---|
| 151 | @\$(call echo_message, Building)
|
---|
[6ad5a2f] | 152 | @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
| 153 | mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
---|
[877cc6a] | 154 | fi;
|
---|
[6ad5a2f] | 155 | @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
| 156 | mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
---|
[877cc6a] | 157 | fi;
|
---|
[6ad5a2f] | 158 | @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
---|
| 159 | echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 160 | echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 161 | echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 162 | echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 163 | echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 164 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 165 | echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 166 | echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 167 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 168 | echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 169 | echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 170 | echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 171 | echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
|
---|
| 172 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
---|
[877cc6a] | 173 | touch envars && \\
|
---|
[045b2dc] | 174 | chmod -R a+wt \$(MOUNT_PT) && \\
|
---|
| 175 | chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
[93f38e7] | 176 | touch \$@ && \\
|
---|
| 177 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 178 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 179 | EOF
|
---|
| 180 | ) >> $MKFILE.tmp
|
---|
[045b2dc] | 181 | host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
|
---|
[877cc6a] | 182 |
|
---|
| 183 | }
|
---|
| 184 |
|
---|
[045b2dc] | 185 | #--------------------------------------#
|
---|
| 186 | cross_tools_Makefiles() { #
|
---|
| 187 | #--------------------------------------#
|
---|
| 188 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
[877cc6a] | 189 |
|
---|
| 190 | for file in cross-tools/* ; do
|
---|
| 191 | # Keep the script file name
|
---|
| 192 | this_script=`basename $file`
|
---|
| 193 | #
|
---|
| 194 | # Skip this script...
|
---|
| 195 | case $this_script in
|
---|
| 196 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
| 197 | continue; ;;
|
---|
| 198 | *) ;;
|
---|
| 199 | esac
|
---|
| 200 | #
|
---|
| 201 | # Set the dependency for the first target.
|
---|
| 202 | if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
|
---|
| 203 |
|
---|
| 204 | # First append each name of the script files to a list (this will become
|
---|
| 205 | # the names of the targets in the Makefile
|
---|
| 206 | cross_tools="$cross_tools $this_script"
|
---|
| 207 |
|
---|
| 208 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 209 | # and binutils in chapter 5)
|
---|
| 210 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 211 | -e 's@-static@@' \
|
---|
| 212 | -e 's@-final@@' \
|
---|
[a160d86] | 213 | -e 's@-64@@' \
|
---|
[877cc6a] | 214 | -e 's@-n32@@'`
|
---|
[a160d86] | 215 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 216 |
|
---|
| 217 | #--------------------------------------------------------------------#
|
---|
| 218 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 219 | #--------------------------------------------------------------------#
|
---|
| 220 | #
|
---|
| 221 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 222 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 223 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 224 | #
|
---|
[a160d86] | 225 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 226 | #
|
---|
[045b2dc] | 227 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
[877cc6a] | 228 | #
|
---|
[045b2dc] | 229 | LUSER_wrt_RunAsUser "${file}"
|
---|
[877cc6a] | 230 | #
|
---|
[045b2dc] | 231 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 232 | #
|
---|
| 233 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 234 | wrt_touch
|
---|
[877cc6a] | 235 | #
|
---|
| 236 | #--------------------------------------------------------------------#
|
---|
| 237 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 238 | #--------------------------------------------------------------------#
|
---|
| 239 | #
|
---|
| 240 | # Keep the script file name for Makefile dependencies.
|
---|
| 241 | PREV=$this_script
|
---|
| 242 |
|
---|
| 243 | done # for file in ....
|
---|
| 244 | }
|
---|
| 245 |
|
---|
[045b2dc] | 246 | #--------------------------------------#
|
---|
| 247 | temptools_Makefiles() { #
|
---|
| 248 | #--------------------------------------#
|
---|
| 249 | echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
|
---|
[877cc6a] | 250 |
|
---|
| 251 | for file in temp-system/* ; do
|
---|
| 252 | # Keep the script file name
|
---|
| 253 | this_script=`basename $file`
|
---|
[6f2cd96] | 254 | #
|
---|
| 255 | # Deal with any odd scripts..
|
---|
| 256 | case $this_script in
|
---|
| 257 | *choose) # The choose script will fail if you cannot enter the new environment
|
---|
| 258 | # If the 'boot' build method was chosen don't run the script
|
---|
| 259 | [[ $METHOD = "boot" ]] && continue; ;;
|
---|
| 260 | *) ;;
|
---|
| 261 | esac
|
---|
[e2ec07a] | 262 |
|
---|
[877cc6a] | 263 | #
|
---|
| 264 | # First append each name of the script files to a list (this will become
|
---|
| 265 | # the names of the targets in the Makefile
|
---|
| 266 | temptools="$temptools $this_script"
|
---|
| 267 |
|
---|
| 268 | #
|
---|
| 269 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 270 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 271 | #
|
---|
[a160d86] | 272 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 273 |
|
---|
| 274 | #--------------------------------------------------------------------#
|
---|
| 275 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 276 | #--------------------------------------------------------------------#
|
---|
| 277 | #
|
---|
| 278 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 279 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 280 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 281 | #
|
---|
[a160d86] | 282 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 283 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
| 284 | #
|
---|
[045b2dc] | 285 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
[a160d86] | 286 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 287 | #
|
---|
[045b2dc] | 288 | LUSER_wrt_RunAsUser "${file}"
|
---|
[877cc6a] | 289 | #
|
---|
[045b2dc] | 290 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 291 | #
|
---|
| 292 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 293 | wrt_touch
|
---|
[877cc6a] | 294 | #
|
---|
| 295 | #--------------------------------------------------------------------#
|
---|
| 296 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 297 | #--------------------------------------------------------------------#
|
---|
| 298 | #
|
---|
| 299 | # Keep the script file name for Makefile dependencies.
|
---|
| 300 | PREV=$this_script
|
---|
| 301 | done # for file in ....
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 |
|
---|
[045b2dc] | 305 | #--------------------------------------#
|
---|
| 306 | chroot_Makefiles() { #
|
---|
| 307 | #--------------------------------------#
|
---|
| 308 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
|
---|
[877cc6a] | 309 |
|
---|
[045b2dc] | 310 | for file in chroot/* ; do
|
---|
[877cc6a] | 311 | # Keep the script file name
|
---|
| 312 | this_script=`basename $file`
|
---|
[045b2dc] | 313 | #
|
---|
| 314 | # Skipping scripts is done now and not included in the build tree.
|
---|
[877cc6a] | 315 | case $this_script in
|
---|
[045b2dc] | 316 | *chroot*) continue ;;
|
---|
[877cc6a] | 317 | esac
|
---|
[045b2dc] | 318 |
|
---|
[877cc6a] | 319 | #
|
---|
| 320 | # First append each name of the script files to a list (this will become
|
---|
| 321 | # the names of the targets in the Makefile
|
---|
[045b2dc] | 322 | case "${this_script}" in
|
---|
| 323 | *util-linux) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 324 | *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 325 | *) chroottools="$chroottools $this_script" ;;
|
---|
[877cc6a] | 326 | esac
|
---|
[045b2dc] | 327 |
|
---|
| 328 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 329 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 330 |
|
---|
[a160d86] | 331 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 332 |
|
---|
[045b2dc] | 333 | # This is very ugly:: util-linux is in /chroot but must be run under LUSER
|
---|
| 334 | # .. Customized makefile entry
|
---|
| 335 | case "${this_script}" in
|
---|
| 336 | *util-linux)
|
---|
| 337 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
| 338 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 339 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 340 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 341 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 342 | wrt_touch
|
---|
| 343 | temptools="$temptools $this_script"
|
---|
| 344 | continue ;;
|
---|
| 345 | esac
|
---|
| 346 |
|
---|
| 347 |
|
---|
[877cc6a] | 348 | #--------------------------------------------------------------------#
|
---|
| 349 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 350 | #--------------------------------------------------------------------#
|
---|
| 351 | #
|
---|
| 352 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 353 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 354 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 355 | #
|
---|
[a160d86] | 356 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 357 | # Insert instructions for unpacking the package and changing directories
|
---|
| 358 | #
|
---|
[045b2dc] | 359 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[8f2c086] | 360 | CHROOT_Unpack "$pkg_tarball"
|
---|
[045b2dc] | 361 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 362 | fi
|
---|
[877cc6a] | 363 | #
|
---|
| 364 | # Select a script execution method
|
---|
| 365 | case $this_script in
|
---|
[8f2c086] | 366 | *kernfs) wrt_RunAsRoot "${file}" ;;
|
---|
[045b2dc] | 367 | *) CHROOT_wrt_RunAsRoot "${file}" ;;
|
---|
[877cc6a] | 368 | esac
|
---|
| 369 | #
|
---|
[045b2dc] | 370 | # Housekeeping...remove the build directory(ies), except if the package build fails.
|
---|
| 371 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 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.
|
---|
| 381 | PREV=$this_script
|
---|
| 382 |
|
---|
[045b2dc] | 383 | done # for file in...
|
---|
[877cc6a] | 384 | }
|
---|
| 385 |
|
---|
| 386 |
|
---|
[045b2dc] | 387 | #--------------------------------------#
|
---|
| 388 | boot_Makefiles() { #
|
---|
| 389 | #--------------------------------------#
|
---|
[877cc6a] | 390 |
|
---|
[045b2dc] | 391 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
|
---|
| 392 | #
|
---|
| 393 | # Create a target bootable partition containing a compile environment. Later
|
---|
| 394 | # on we boot into this environment and contine the build.
|
---|
| 395 | #
|
---|
| 396 | for file in boot/* ; do
|
---|
[877cc6a] | 397 | # Keep the script file name
|
---|
| 398 | this_script=`basename $file`
|
---|
[045b2dc] | 399 |
|
---|
| 400 | # A little housekeeping on the scripts
|
---|
[877cc6a] | 401 | case $this_script in
|
---|
[045b2dc] | 402 | *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
|
---|
| 403 | *whatnext*) continue ;;
|
---|
| 404 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
| 405 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 406 | [[ -z $CONFIG ]] && continue
|
---|
| 407 | # Copy the config file to /sources with a standardized name
|
---|
| 408 | cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
|
---|
| 409 | ;;
|
---|
[877cc6a] | 410 | esac
|
---|
| 411 | #
|
---|
| 412 | # First append each name of the script files to a list (this will become
|
---|
| 413 | # the names of the targets in the Makefile
|
---|
[045b2dc] | 414 | case "${this_script}" in
|
---|
| 415 | *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 416 | *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 417 | *) boottools="$boottools $this_script" ;;
|
---|
| 418 | esac
|
---|
| 419 | #
|
---|
| 420 | # Grab the name of the target, strip id number and misc words.
|
---|
| 421 | case $this_script in
|
---|
| 422 | *kernel) name=linux ;;
|
---|
| 423 | *bootscripts) name="bootscripts-cross-lfs" ;;
|
---|
| 424 | *udev-rules) name="udev-cross-lfs" ;;
|
---|
| 425 | *grub-build) name=grub ;;
|
---|
| 426 | *-aboot-build) name=aboot ;;
|
---|
| 427 | *yaboot-build) name=yaboot ;;
|
---|
| 428 | *colo-build) name=colo ;;
|
---|
| 429 | *silo-build) name=silo ;;
|
---|
| 430 | *arcload-build) name=arcload ;;
|
---|
| 431 | *lilo-build) name=lilo ;;
|
---|
| 432 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
| 433 | esac
|
---|
| 434 | # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
|
---|
[a160d86] | 435 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 436 |
|
---|
| 437 | #--------------------------------------------------------------------#
|
---|
| 438 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 439 | #--------------------------------------------------------------------#
|
---|
| 440 | #
|
---|
| 441 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 442 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 443 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 444 | #
|
---|
[a160d86] | 445 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 446 | # Insert instructions for unpacking the package and changing directories
|
---|
| 447 | #
|
---|
[045b2dc] | 448 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 449 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 450 | #
|
---|
| 451 | # Select a script execution method
|
---|
| 452 | case $this_script in
|
---|
[045b2dc] | 453 | # The following 2 scripts are defined in the /boot directory but need
|
---|
| 454 | # to be run as a root user. Set them up here but run them in another phase
|
---|
[8f2c086] | 455 | *changingowner*) wrt_RunAsRoot "${file}" ;;
|
---|
| 456 | *devices*) wrt_RunAsRoot "${file}" ;;
|
---|
[045b2dc] | 457 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
| 458 | LUSER_wrt_CopyFstab
|
---|
| 459 | else
|
---|
| 460 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 461 | fi
|
---|
| 462 | ;;
|
---|
| 463 | *) LUSER_wrt_RunAsUser "${file}" ;;
|
---|
[877cc6a] | 464 | esac
|
---|
| 465 | #
|
---|
[045b2dc] | 466 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
| 467 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 468 | #
|
---|
| 469 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 470 | wrt_touch
|
---|
[877cc6a] | 471 | #
|
---|
| 472 | #--------------------------------------------------------------------#
|
---|
| 473 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 474 | #--------------------------------------------------------------------#
|
---|
| 475 | #
|
---|
| 476 | # Keep the script file name for Makefile dependencies.
|
---|
| 477 | PREV=$this_script
|
---|
| 478 |
|
---|
[045b2dc] | 479 | done
|
---|
[877cc6a] | 480 | }
|
---|
| 481 |
|
---|
| 482 |
|
---|
[045b2dc] | 483 | #--------------------------------------#
|
---|
| 484 | chroot_testsuite_tools_Makefiles() { #
|
---|
| 485 | #--------------------------------------#
|
---|
| 486 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
|
---|
[877cc6a] | 487 |
|
---|
| 488 | for file in testsuite-tools/* ; do
|
---|
| 489 | # Keep the script file name
|
---|
| 490 | this_script=`basename $file`
|
---|
| 491 |
|
---|
| 492 | # First append each name of the script files to a list (this will become
|
---|
| 493 | # the names of the targets in the Makefile
|
---|
| 494 | testsuitetools="$testsuitetools $this_script"
|
---|
| 495 |
|
---|
| 496 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 497 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 498 | -e 's@-64bit@@' \
|
---|
| 499 | -e 's@-64@@' \
|
---|
| 500 | -e 's@64@@' \
|
---|
| 501 | -e 's@n32@@'`
|
---|
| 502 |
|
---|
[a160d86] | 503 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 504 |
|
---|
| 505 | #--------------------------------------------------------------------#
|
---|
| 506 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 507 | #--------------------------------------------------------------------#
|
---|
| 508 | #
|
---|
| 509 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 510 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 511 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 512 | #
|
---|
[045b2dc] | 513 | CHROOT_Unpack "$pkg_tarball"
|
---|
[1b65a84] | 514 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 515 | #
|
---|
[045b2dc] | 516 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
[877cc6a] | 517 | #
|
---|
[045b2dc] | 518 | CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 519 | #
|
---|
| 520 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 521 | wrt_touch
|
---|
[877cc6a] | 522 | #
|
---|
| 523 | #--------------------------------------------------------------------#
|
---|
| 524 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 525 | #--------------------------------------------------------------------#
|
---|
| 526 | #
|
---|
| 527 | # Keep the script file name for Makefile dependencies.
|
---|
| 528 | PREV=$this_script
|
---|
| 529 |
|
---|
| 530 | done
|
---|
| 531 | }
|
---|
| 532 |
|
---|
[045b2dc] | 533 | #--------------------------------------#
|
---|
| 534 | boot_testsuite_tools_Makefiles() { #
|
---|
| 535 | #--------------------------------------#
|
---|
| 536 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
|
---|
[877cc6a] | 537 | for file in testsuite-tools/* ; do
|
---|
| 538 | # Keep the script file name
|
---|
| 539 | this_script=`basename $file`
|
---|
| 540 |
|
---|
| 541 | # First append each name of the script files to a list (this will become
|
---|
| 542 | # the names of the targets in the Makefile
|
---|
| 543 | PREV=
|
---|
| 544 | testsuitetools="$testsuitetools $this_script"
|
---|
| 545 |
|
---|
| 546 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 547 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 548 | -e 's@-64bit@@' \
|
---|
| 549 | -e 's@-64@@' \
|
---|
| 550 | -e 's@64@@' \
|
---|
| 551 | -e 's@n32@@'`
|
---|
| 552 |
|
---|
[a160d86] | 553 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 554 |
|
---|
| 555 | #--------------------------------------------------------------------#
|
---|
| 556 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 557 | #--------------------------------------------------------------------#
|
---|
| 558 | #
|
---|
| 559 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 560 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 561 | BOOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 562 | #
|
---|
[045b2dc] | 563 | BOOT_wrt_Unpack "$pkg_tarball"
|
---|
[1b65a84] | 564 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 565 | #
|
---|
[045b2dc] | 566 | BOOT_wrt_RunAsRoot "${this_script}" "${file}"
|
---|
[877cc6a] | 567 | #
|
---|
[045b2dc] | 568 | BOOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 569 | #
|
---|
| 570 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 571 | wrt_touch
|
---|
[877cc6a] | 572 | #
|
---|
| 573 | #--------------------------------------------------------------------#
|
---|
| 574 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 575 | #--------------------------------------------------------------------#
|
---|
| 576 | #
|
---|
| 577 | # Keep the script file name for Makefile dependencies.
|
---|
| 578 | PREV=$this_script
|
---|
| 579 |
|
---|
| 580 | done
|
---|
[045b2dc] | 581 |
|
---|
[877cc6a] | 582 | }
|
---|
| 583 |
|
---|
| 584 |
|
---|
[045b2dc] | 585 | #--------------------------------------#
|
---|
| 586 | chroot_final_system_Makefiles() { #
|
---|
| 587 | #--------------------------------------#
|
---|
[45f82718] | 588 | # Set envars and scripts for iteration targets
|
---|
| 589 | LOGS="" # Start with an empty global LOGS envar
|
---|
| 590 | if [[ -z "$1" ]] ; then
|
---|
| 591 | local N=""
|
---|
| 592 | else
|
---|
| 593 | local N=-build_$1
|
---|
| 594 | local basicsystem=""
|
---|
| 595 | mkdir final-system$N
|
---|
| 596 | cp final-system/* final-system$N
|
---|
| 597 | for script in final-system$N/* ; do
|
---|
| 598 | # Overwrite existing symlinks, files, and dirs
|
---|
| 599 | sed -e 's/ln -sv/&f/g' \
|
---|
| 600 | -e 's/mv -v/&f/g' \
|
---|
| 601 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
| 602 | done
|
---|
| 603 | # Remove Bzip2 binaries before make install
|
---|
| 604 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
|
---|
| 605 | # Delete *old Readline libraries just after make install
|
---|
| 606 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
|
---|
| 607 | fi
|
---|
| 608 |
|
---|
[045b2dc] | 609 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
|
---|
[877cc6a] | 610 |
|
---|
[45f82718] | 611 | for file in final-system$N/* ; do
|
---|
[877cc6a] | 612 | # Keep the script file name
|
---|
| 613 | this_script=`basename $file`
|
---|
| 614 |
|
---|
[45f82718] | 615 | # Test if the stripping phase must be skipped.
|
---|
| 616 | # Skip alsp temp-perl for iterative runs
|
---|
[877cc6a] | 617 | case $this_script in
|
---|
[401f81e] | 618 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
[45f82718] | 619 | *temp-perl*) [[ -n "$N" ]] && continue ;;
|
---|
[877cc6a] | 620 | esac
|
---|
| 621 |
|
---|
| 622 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 623 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 624 | -e 's@temp-@@' \
|
---|
| 625 | -e 's@-64bit@@' \
|
---|
| 626 | -e 's@-64@@' \
|
---|
| 627 | -e 's@64@@' \
|
---|
| 628 | -e 's@n32@@'`
|
---|
| 629 |
|
---|
[45f82718] | 630 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 631 | # a specific package. We need this here to can skip scripts not needed for
|
---|
| 632 | # iterations rebuilds
|
---|
[a160d86] | 633 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[9d9ecf7] | 634 |
|
---|
[a160d86] | 635 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[45f82718] | 636 | case "${this_script}" in
|
---|
| 637 | *stripping*) ;;
|
---|
| 638 | *) continue ;;
|
---|
| 639 | esac
|
---|
| 640 | fi
|
---|
| 641 |
|
---|
| 642 | # Append each name of the script files to a list (this will become
|
---|
| 643 | # the names of the targets in the Makefile
|
---|
| 644 | basicsystem="$basicsystem ${this_script}${N}"
|
---|
| 645 |
|
---|
| 646 | # Append each name of the script files to a list (this will become
|
---|
| 647 | # the names of the logs to be moved for each iteration)
|
---|
| 648 | LOGS="$LOGS ${this_script}"
|
---|
| 649 |
|
---|
[877cc6a] | 650 | #--------------------------------------------------------------------#
|
---|
| 651 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 652 | #--------------------------------------------------------------------#
|
---|
| 653 | #
|
---|
| 654 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 655 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 656 | CHROOT_wrt_target "${this_script}${N}" "$PREV"
|
---|
[877cc6a] | 657 |
|
---|
[a160d86] | 658 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 659 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[045b2dc] | 660 | CHROOT_Unpack "$pkg_tarball"
|
---|
[a229600] | 661 | # If the testsuites must be run, initialize the log file
|
---|
| 662 | case $name in
|
---|
| 663 | binutils | gcc | glibc )
|
---|
[045b2dc] | 664 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 665 | ;;
|
---|
| 666 | * )
|
---|
[045b2dc] | 667 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 668 | ;;
|
---|
| 669 | esac
|
---|
| 670 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 671 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 672 | fi
|
---|
| 673 | #
|
---|
[045b2dc] | 674 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
[877cc6a] | 675 | #
|
---|
[045b2dc] | 676 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 677 | #
|
---|
| 678 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 679 | wrt_touch
|
---|
[877cc6a] | 680 | #
|
---|
| 681 | #--------------------------------------------------------------------#
|
---|
| 682 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 683 | #--------------------------------------------------------------------#
|
---|
| 684 | #
|
---|
| 685 | # Keep the script file name for Makefile dependencies.
|
---|
[45f82718] | 686 | PREV=${this_script}${N}
|
---|
| 687 | # Set system_build envar for iteration targets
|
---|
| 688 | system_build=$basicsystem
|
---|
[877cc6a] | 689 | done # for file in final-system/* ...
|
---|
| 690 | }
|
---|
| 691 |
|
---|
[045b2dc] | 692 | #--------------------------------------#
|
---|
| 693 | boot_final_system_Makefiles() { #
|
---|
| 694 | #--------------------------------------#
|
---|
[45f82718] | 695 | # Set envars and scripts for iteration targets
|
---|
| 696 | LOGS="" # Start with an empty global LOGS envar
|
---|
| 697 | if [[ -z "$1" ]] ; then
|
---|
| 698 | local N=""
|
---|
| 699 | # The makesys phase was initiated in bm_testsuite_tools_makefile
|
---|
| 700 | [[ "$TEST" = 0 ]] && PREV=""
|
---|
| 701 | else
|
---|
| 702 | local N=-build_$1
|
---|
| 703 | local basicsystem=""
|
---|
| 704 | mkdir final-system$N
|
---|
| 705 | cp final-system/* final-system$N
|
---|
| 706 | for script in final-system$N/* ; do
|
---|
| 707 | # Overwrite existing symlinks, files, and dirs
|
---|
| 708 | sed -e 's/ln -sv/&f/g' \
|
---|
| 709 | -e 's/mv -v/&f/g' \
|
---|
| 710 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
| 711 | done
|
---|
| 712 | # Remove Bzip2 binaries before make install
|
---|
| 713 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
|
---|
| 714 | # Delete *old Readline libraries just after make install
|
---|
| 715 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
|
---|
| 716 | fi
|
---|
[877cc6a] | 717 |
|
---|
[045b2dc] | 718 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
|
---|
[877cc6a] | 719 |
|
---|
[45f82718] | 720 | for file in final-system$N/* ; do
|
---|
[877cc6a] | 721 | # Keep the script file name
|
---|
| 722 | this_script=`basename $file`
|
---|
| 723 |
|
---|
| 724 | # Test if the stripping phase must be skipped
|
---|
[45f82718] | 725 | # Skip alsp temp-perl for iterative runs
|
---|
[877cc6a] | 726 | case $this_script in
|
---|
[401f81e] | 727 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
[45f82718] | 728 | *temp-perl*) [[ -n "$N" ]] && continue ;;
|
---|
[877cc6a] | 729 | esac
|
---|
| 730 |
|
---|
| 731 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 732 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 733 | -e 's@temp-@@' \
|
---|
| 734 | -e 's@-64bit@@' \
|
---|
| 735 | -e 's@-64@@' \
|
---|
| 736 | -e 's@64@@' \
|
---|
| 737 | -e 's@n32@@'`
|
---|
| 738 |
|
---|
[45f82718] | 739 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 740 | # a specific package. We need this here to can skip scripts not needed for
|
---|
| 741 | # iterations rebuilds
|
---|
[877cc6a] | 742 |
|
---|
[a160d86] | 743 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 744 |
|
---|
| 745 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[45f82718] | 746 | case "${this_script}" in
|
---|
| 747 | *stripping*) ;;
|
---|
| 748 | *) continue ;;
|
---|
| 749 | esac
|
---|
| 750 | fi
|
---|
| 751 |
|
---|
| 752 | # Append each name of the script files to a list (this will become
|
---|
| 753 | # the names of the targets in the Makefile
|
---|
| 754 | basicsystem="$basicsystem ${this_script}${N}"
|
---|
| 755 |
|
---|
| 756 | # Append each name of the script files to a list (this will become
|
---|
| 757 | # the names of the logs to be moved for each iteration)
|
---|
| 758 | LOGS="$LOGS ${this_script}"
|
---|
| 759 |
|
---|
[877cc6a] | 760 | #--------------------------------------------------------------------#
|
---|
| 761 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 762 | #--------------------------------------------------------------------#
|
---|
| 763 | #
|
---|
| 764 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 765 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 766 | BOOT_wrt_target "${this_script}${N}" "$PREV"
|
---|
[877cc6a] | 767 |
|
---|
[a160d86] | 768 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 769 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 770 | FILE="$pkg_tarball"
|
---|
[045b2dc] | 771 | BOOT_wrt_Unpack "$FILE"
|
---|
[a229600] | 772 | # If the testsuites must be run, initialize the log file
|
---|
| 773 | case $name in
|
---|
| 774 | binutils | gcc | glibc )
|
---|
[045b2dc] | 775 | [[ "$TEST" != "0" ]] && BOOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 776 | ;;
|
---|
| 777 | * )
|
---|
[045b2dc] | 778 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && BOOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 779 | ;;
|
---|
| 780 | esac
|
---|
| 781 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 782 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 783 | fi
|
---|
| 784 | #
|
---|
[045b2dc] | 785 | BOOT_wrt_RunAsRoot "${this_script}" "${file}"
|
---|
[877cc6a] | 786 | #
|
---|
[045b2dc] | 787 | [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 788 | #
|
---|
| 789 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 790 | wrt_touch
|
---|
[877cc6a] | 791 | #
|
---|
| 792 | #--------------------------------------------------------------------#
|
---|
| 793 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 794 | #--------------------------------------------------------------------#
|
---|
| 795 | #
|
---|
| 796 | # Keep the script file name for Makefile dependencies.
|
---|
[45f82718] | 797 | PREV=${this_script}${N}
|
---|
| 798 | # Set system_build envar for iteration targets
|
---|
| 799 | system_build=$basicsystem
|
---|
[877cc6a] | 800 | done # for file in final-system/* ...
|
---|
| 801 |
|
---|
[045b2dc] | 802 | }
|
---|
[877cc6a] | 803 |
|
---|
[045b2dc] | 804 | #--------------------------------------#
|
---|
| 805 | chroot_bootscripts_Makefiles() { #
|
---|
| 806 | #--------------------------------------#
|
---|
| 807 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
|
---|
[877cc6a] | 808 |
|
---|
| 809 | for file in bootscripts/* ; do
|
---|
| 810 | # Keep the script file name
|
---|
| 811 | this_script=`basename $file`
|
---|
| 812 |
|
---|
| 813 | case $this_script in
|
---|
| 814 | *udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
---|
| 815 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
| 816 | *) ;;
|
---|
| 817 | esac
|
---|
| 818 |
|
---|
| 819 | # First append each name of the script files to a list (this will become
|
---|
| 820 | # the names of the targets in the Makefile
|
---|
| 821 | bootscripttools="$bootscripttools $this_script"
|
---|
| 822 |
|
---|
| 823 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 824 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 825 | -e 's@-64bit@@' \
|
---|
| 826 | -e 's@-64@@' \
|
---|
| 827 | -e 's@64@@' \
|
---|
| 828 | -e 's@n32@@'`
|
---|
| 829 | case $name in
|
---|
[c044e3c] | 830 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
[877cc6a] | 831 | *udev-rules) name=udev-cross-lfs ;;
|
---|
| 832 | esac
|
---|
[c044e3c] | 833 |
|
---|
[a160d86] | 834 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 835 |
|
---|
| 836 | #--------------------------------------------------------------------#
|
---|
| 837 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 838 | #--------------------------------------------------------------------#
|
---|
| 839 | #
|
---|
| 840 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 841 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 842 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 843 | #
|
---|
[a160d86] | 844 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 845 | #
|
---|
[045b2dc] | 846 | [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 847 | #
|
---|
[045b2dc] | 848 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
[877cc6a] | 849 | #
|
---|
[045b2dc] | 850 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 851 | #
|
---|
| 852 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 853 | wrt_touch
|
---|
[877cc6a] | 854 | #
|
---|
| 855 | #--------------------------------------------------------------------#
|
---|
| 856 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 857 | #--------------------------------------------------------------------#
|
---|
| 858 | #
|
---|
| 859 | # Keep the script file name for Makefile dependencies.
|
---|
| 860 | PREV=$this_script
|
---|
| 861 |
|
---|
| 862 | done # for file in bootscripts/* ...
|
---|
| 863 | }
|
---|
| 864 |
|
---|
[045b2dc] | 865 | #--------------------------------------#
|
---|
| 866 | boot_bootscripts_Makefiles() { #
|
---|
| 867 | #--------------------------------------#
|
---|
| 868 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
|
---|
[877cc6a] | 869 |
|
---|
| 870 | for file in bootscripts/* ; do
|
---|
| 871 | # Keep the script file name
|
---|
| 872 | this_script=`basename $file`
|
---|
| 873 |
|
---|
| 874 | case $this_script in
|
---|
[33c7b13] | 875 | *udev) continue ;; # This is not a script but a commentary
|
---|
[877cc6a] | 876 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
| 877 | *) ;;
|
---|
| 878 | esac
|
---|
| 879 |
|
---|
| 880 | # First append each name of the script files to a list (this will become
|
---|
| 881 | # the names of the targets in the Makefile
|
---|
| 882 | bootscripttools="$bootscripttools $this_script"
|
---|
| 883 |
|
---|
| 884 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 885 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 886 | -e 's@-64bit@@' \
|
---|
| 887 | -e 's@-64@@' \
|
---|
| 888 | -e 's@64@@' \
|
---|
| 889 | -e 's@n32@@'`
|
---|
| 890 | case $name in
|
---|
[33c7b13] | 891 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
| 892 | *udev-rules) name=udev-cross-lfs ;;
|
---|
[877cc6a] | 893 | esac
|
---|
[a160d86] | 894 |
|
---|
| 895 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 896 |
|
---|
| 897 | #--------------------------------------------------------------------#
|
---|
| 898 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 899 | #--------------------------------------------------------------------#
|
---|
| 900 | #
|
---|
| 901 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 902 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 903 | BOOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 904 | #
|
---|
[a160d86] | 905 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 906 | #
|
---|
[045b2dc] | 907 | [[ "$pkg_tarball" != "" ]] && BOOT_wrt_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 908 | #
|
---|
[045b2dc] | 909 | BOOT_wrt_RunAsRoot "${this_script}" "${file}"
|
---|
[877cc6a] | 910 | #
|
---|
[045b2dc] | 911 | [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 912 | #
|
---|
| 913 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 914 | wrt_touch
|
---|
[877cc6a] | 915 | #
|
---|
| 916 | #--------------------------------------------------------------------#
|
---|
| 917 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 918 | #--------------------------------------------------------------------#
|
---|
| 919 | #
|
---|
| 920 | # Keep the script file name for Makefile dependencies.
|
---|
| 921 | PREV=$this_script
|
---|
| 922 |
|
---|
| 923 | done # for file in bootscripts/* ...
|
---|
| 924 | }
|
---|
| 925 |
|
---|
[045b2dc] | 926 | #--------------------------------------#
|
---|
| 927 | chroot_bootable_Makefiles() { #
|
---|
| 928 | #--------------------------------------#
|
---|
| 929 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
|
---|
[877cc6a] | 930 |
|
---|
| 931 | for file in {bootable,the-end}/* ; do
|
---|
| 932 | # Keep the script file name
|
---|
| 933 | this_script=`basename $file`
|
---|
| 934 |
|
---|
| 935 | # A little housekeeping on the scripts
|
---|
| 936 | case $this_script in
|
---|
| 937 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
[045b2dc] | 938 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[877cc6a] | 939 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 940 | [[ -z $CONFIG ]] && continue
|
---|
| 941 | # Copy the config file to /sources with a standardized name
|
---|
| 942 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 943 | ;;
|
---|
| 944 | esac
|
---|
| 945 | #
|
---|
| 946 | # First append each name of the script files to a list (this will become
|
---|
| 947 | # the names of the targets in the Makefile
|
---|
| 948 | bootabletools="$bootabletools $this_script"
|
---|
| 949 | #
|
---|
| 950 | # Grab the name of the target, strip id number and misc words.
|
---|
| 951 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
| 952 | case $this_script in
|
---|
| 953 | *kernel*) name=linux
|
---|
| 954 | ;;
|
---|
| 955 | esac
|
---|
[a160d86] | 956 |
|
---|
| 957 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 958 |
|
---|
| 959 | #--------------------------------------------------------------------#
|
---|
| 960 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 961 | #--------------------------------------------------------------------#
|
---|
| 962 | #
|
---|
| 963 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 964 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 965 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 966 | #
|
---|
[a160d86] | 967 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 968 | # Insert instructions for unpacking the package and changing directories
|
---|
| 969 | #
|
---|
[045b2dc] | 970 | [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 971 | #
|
---|
| 972 | # Select a script execution method
|
---|
| 973 | case $this_script in
|
---|
[045b2dc] | 974 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
| 975 | CHROOT_wrt_CopyFstab
|
---|
| 976 | else
|
---|
| 977 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
| 978 | fi
|
---|
| 979 | ;;
|
---|
| 980 | *) CHROOT_wrt_RunAsRoot "${file}"
|
---|
| 981 | ;;
|
---|
[877cc6a] | 982 | esac
|
---|
| 983 | #
|
---|
| 984 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
[045b2dc] | 985 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 986 | #
|
---|
| 987 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 988 | wrt_touch
|
---|
[877cc6a] | 989 | #
|
---|
| 990 | #--------------------------------------------------------------------#
|
---|
| 991 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 992 | #--------------------------------------------------------------------#
|
---|
| 993 | #
|
---|
| 994 | # Keep the script file name for Makefile dependencies.
|
---|
| 995 | PREV=$this_script
|
---|
| 996 |
|
---|
| 997 | done
|
---|
| 998 |
|
---|
| 999 | }
|
---|
| 1000 |
|
---|
[045b2dc] | 1001 | #--------------------------------------#
|
---|
| 1002 | boot_bootable_Makefiles() { #
|
---|
| 1003 | #--------------------------------------#
|
---|
| 1004 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
|
---|
[877cc6a] | 1005 |
|
---|
| 1006 | for file in {bootable,the-end}/* ; do
|
---|
| 1007 | # Keep the script file name
|
---|
| 1008 | this_script=`basename $file`
|
---|
| 1009 |
|
---|
| 1010 | # A little housekeeping on the scripts
|
---|
| 1011 | case $this_script in
|
---|
| 1012 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
| 1013 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 1014 | [[ -z $CONFIG ]] && continue
|
---|
| 1015 | # Copy the named config file to /sources with a standardized name
|
---|
| 1016 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 1017 | ;;
|
---|
| 1018 | esac
|
---|
| 1019 | #
|
---|
| 1020 | # First append each name of the script files to a list (this will become
|
---|
| 1021 | # the names of the targets in the Makefile
|
---|
| 1022 | bootabletools="$bootabletools $this_script"
|
---|
| 1023 | #
|
---|
| 1024 | # Grab the name of the target, strip id number and misc words.
|
---|
| 1025 | case $this_script in
|
---|
[a160d86] | 1026 | *kernel) name=linux ;;
|
---|
[877cc6a] | 1027 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
| 1028 | esac
|
---|
| 1029 |
|
---|
[a160d86] | 1030 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 1031 |
|
---|
| 1032 | #--------------------------------------------------------------------#
|
---|
| 1033 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 1034 | #--------------------------------------------------------------------#
|
---|
| 1035 | #
|
---|
| 1036 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 1037 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 1038 | BOOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 1039 | #
|
---|
[a160d86] | 1040 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 1041 | # Insert instructions for unpacking the package and changing directories
|
---|
| 1042 | #
|
---|
[045b2dc] | 1043 | [[ "$pkg_tarball" != "" ]] && BOOT_wrt_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 1044 | #
|
---|
| 1045 | # Select a script execution method
|
---|
| 1046 | case $this_script in
|
---|
| 1047 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
| 1048 | # Minimal boot mode has no access to original file, store in /sources
|
---|
| 1049 | cp $FSTAB $BUILDDIR/sources/fstab
|
---|
[045b2dc] | 1050 | BOOT_wrt_CopyFstab "${this_script}"
|
---|
[877cc6a] | 1051 | else
|
---|
[045b2dc] | 1052 | BOOT_wrt_RunAsRoot "${this_script}" "${file}"
|
---|
[877cc6a] | 1053 | fi
|
---|
| 1054 | ;;
|
---|
[045b2dc] | 1055 | *) BOOT_wrt_RunAsRoot "${this_script}" "${file}" ;;
|
---|
[877cc6a] | 1056 | esac
|
---|
| 1057 | #
|
---|
| 1058 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
[045b2dc] | 1059 | [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 1060 | #
|
---|
| 1061 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 1062 | wrt_touch
|
---|
[877cc6a] | 1063 | #
|
---|
| 1064 | #--------------------------------------------------------------------#
|
---|
| 1065 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 1066 | #--------------------------------------------------------------------#
|
---|
| 1067 | #
|
---|
| 1068 | # Keep the script file name for Makefile dependencies.
|
---|
| 1069 | PREV=$this_script
|
---|
| 1070 | done
|
---|
| 1071 |
|
---|
| 1072 | }
|
---|
| 1073 |
|
---|
| 1074 |
|
---|
[045b2dc] | 1075 | #--------------------------------------#
|
---|
| 1076 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 1077 | #--------------------------------------#
|
---|
| 1078 | #
|
---|
| 1079 | # Script crashes if error trapping is on
|
---|
| 1080 | #
|
---|
| 1081 | set +e
|
---|
| 1082 | declare -f method_cmds
|
---|
| 1083 | declare -f testsuite_cmds
|
---|
| 1084 | declare -f final_sys_cmds
|
---|
| 1085 | declare -f bootscripts_cmds
|
---|
| 1086 | declare -f bootable_cmds
|
---|
| 1087 | set -e
|
---|
| 1088 |
|
---|
| 1089 | echo "...Creating Makefile... ${BOLD}START${OFF}"
|
---|
[877cc6a] | 1090 |
|
---|
| 1091 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
[045b2dc] | 1092 | # Start with a clean files
|
---|
| 1093 | >$MKFILE
|
---|
[877cc6a] | 1094 | >$MKFILE.tmp
|
---|
| 1095 |
|
---|
[045b2dc] | 1096 | method_cmds=${METHOD}_Makefiles
|
---|
| 1097 | testsuite_cmds=${METHOD}_testsuite_tools_Makefiles
|
---|
| 1098 | final_sys_cmds=${METHOD}_final_system_Makefiles
|
---|
| 1099 | bootscripts_cmds=${METHOD}_bootscripts_Makefiles
|
---|
| 1100 | bootable_cmds=${METHOD}_bootable_Makefiles
|
---|
| 1101 |
|
---|
| 1102 | host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
|
---|
| 1103 | cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
|
---|
| 1104 | temptools_Makefiles # mk_TEMP (LUSER) $temptools
|
---|
| 1105 | $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
|
---|
| 1106 | if [[ ! $TEST = "0" ]]; then
|
---|
| 1107 | $testsuite_cmds # mk_SYSTOOLS (CHROOT) $testsuitetools
|
---|
[877cc6a] | 1108 | fi
|
---|
[045b2dc] | 1109 | $final_sys_cmds # mk_FINAL (CHROOT) $basicsystem
|
---|
| 1110 | # Add the iterations targets, if needed
|
---|
| 1111 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
| 1112 | $bootscripts_cmds # mk_BOOTSCRIPT (CHROOT) $bootscripttools
|
---|
| 1113 | $bootable_cmds # mk_BOOTABLE (CHROOT) $bootabletools
|
---|
[877cc6a] | 1114 |
|
---|
[c10570d] | 1115 | # Add the BLFS_TOOL targets, if needed
|
---|
| 1116 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
| 1117 |
|
---|
[877cc6a] | 1118 | # Add a header, some variables and include the function file
|
---|
| 1119 | # to the top of the real Makefile.
|
---|
[195ed9f] | 1120 | wrt_Makefile_header
|
---|
[877cc6a] | 1121 |
|
---|
| 1122 | # Add chroot commands
|
---|
| 1123 | if [ "$METHOD" = "chroot" ] ; then
|
---|
[6ad5a2f] | 1124 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
| 1125 | chroot=`cat chroot/*chroot* | \
|
---|
| 1126 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
| 1127 | -e '/#!\/tools\/bin\/bash/d' \
|
---|
| 1128 | -e '/^export/d' \
|
---|
| 1129 | -e '/^logout/d' \
|
---|
| 1130 | -e 's@ \\\@ @g' | \
|
---|
| 1131 | tr -d '\n' | \
|
---|
| 1132 | sed -e 's/ */ /g' \
|
---|
| 1133 | -e 's|\\$|&&|g' \
|
---|
| 1134 | -e 's|exit||g' \
|
---|
| 1135 | -e 's|$| -c|' \
|
---|
[f4d9a48] | 1136 | -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
|
---|
[6ad5a2f] | 1137 | -e 's|set -e||'`
|
---|
[877cc6a] | 1138 | echo -e "CHROOT1= $chroot\n" >> $MKFILE
|
---|
| 1139 | fi
|
---|
| 1140 |
|
---|
[045b2dc] | 1141 | ################## CHROOT ####################
|
---|
| 1142 |
|
---|
[877cc6a] | 1143 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
| 1144 | (
|
---|
[045b2dc] | 1145 | cat << EOF
|
---|
[877cc6a] | 1146 |
|
---|
[c10570d] | 1147 | all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_BLFS_TOOL
|
---|
[045b2dc] | 1148 | @sudo make do-housekeeping
|
---|
| 1149 | @\$(call echo_finished,$VERSION)
|
---|
[a160d86] | 1150 |
|
---|
[045b2dc] | 1151 | ck_UID:
|
---|
| 1152 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 1153 | echo "+--------------------------------------------------+"; \\
|
---|
| 1154 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
| 1155 | echo "+--------------------------------------------------+"; \\
|
---|
| 1156 | exit 1; \\
|
---|
| 1157 | fi
|
---|
| 1158 |
|
---|
| 1159 | #---------------AS ROOT
|
---|
| 1160 | mk_SETUP:
|
---|
| 1161 | @\$(call echo_SU_request)
|
---|
[a2133cb] | 1162 | @sudo make SHELL=/bin/bash SETUP
|
---|
[045b2dc] | 1163 | @touch \$@
|
---|
| 1164 |
|
---|
| 1165 | #---------------AS LUSER
|
---|
| 1166 | mk_CROSS: mk_SETUP
|
---|
| 1167 | @\$(call echo_PHASE,Cross and Temporary Tools)
|
---|
[a2133cb] | 1168 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
|
---|
[045b2dc] | 1169 | @sudo make restore-luser-env
|
---|
| 1170 | @touch \$@
|
---|
| 1171 |
|
---|
| 1172 | mk_SUDO: mk_CROSS
|
---|
[a2133cb] | 1173 | @sudo make SHELL=/bin/bash SUDO
|
---|
[045b2dc] | 1174 | @touch \$@
|
---|
| 1175 | #
|
---|
| 1176 | # The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
|
---|
| 1177 | # chroot environment. (Unless someone knows a different way)
|
---|
| 1178 | # Manually create the /bin directory and provide link to the /tools dir.
|
---|
| 1179 | # Also change the original symlink creation to include (f)orce to prevent failure due to
|
---|
| 1180 | # pre-existing links.
|
---|
| 1181 |
|
---|
| 1182 | #---------------CHROOT JAIL
|
---|
| 1183 | mk_SYSTOOLS: mk_SUDO
|
---|
| 1184 | @if [ ! -e \$(MOUNT_PT)/bin ]; then \\
|
---|
| 1185 | mkdir \$(MOUNT_PT)/bin; \\
|
---|
| 1186 | cd \$(MOUNT_PT)/bin && \\
|
---|
| 1187 | ln -svf /tools/bin/bash bash; ln -sf bash sh; \\
|
---|
| 1188 | sudo chown -R 0:0 \$(MOUNT_PT)/bin; \\
|
---|
[877cc6a] | 1189 | fi;
|
---|
[f4d9a48] | 1190 | @sudo sed -e 's|^ln -sv |ln -svf |' -i \$(CMDSDIR)/chroot/*-createfiles
|
---|
[045b2dc] | 1191 | @\$(call echo_CHROOT_request)
|
---|
| 1192 | @\$(call echo_PHASE, CHROOT JAIL )
|
---|
| 1193 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT_JAIL")
|
---|
| 1194 | @touch \$@
|
---|
[877cc6a] | 1195 |
|
---|
[c10570d] | 1196 | mk_BLFS_TOOL: mk_SYSTOOLS
|
---|
| 1197 | @\$(call echo_PHASE,Building BLFS-TOOLS); \\
|
---|
| 1198 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 1199 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
| 1200 | sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BLFS_TOOL"; \\
|
---|
| 1201 | fi
|
---|
| 1202 | @touch \$@
|
---|
[045b2dc] | 1203 |
|
---|
| 1204 | SETUP: $host_prep
|
---|
| 1205 | AS_LUSER: $cross_tools $temptools
|
---|
| 1206 | SUDO: $orphan_scripts
|
---|
| 1207 | CHROOT_JAIL: ${chroottools}${boottools} $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
[c10570d] | 1208 | BLFS_TOOL: $blfs_tool
|
---|
[877cc6a] | 1209 |
|
---|
[7d9a82d] | 1210 | do-housekeeping:
|
---|
[4524fb2] | 1211 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
| 1212 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
| 1213 | @-umount \$(MOUNT_PT)/dev
|
---|
| 1214 | @-umount \$(MOUNT_PT)/sys
|
---|
| 1215 | @-umount \$(MOUNT_PT)/proc
|
---|
[045b2dc] | 1216 | @-rm /tools /cross-tools
|
---|
[6ad5a2f] | 1217 | @-if [ ! -f luser-exist ]; then \\
|
---|
| 1218 | userdel \$(LUSER); \\
|
---|
| 1219 | rm -rf /home/\$(LUSER); \\
|
---|
[7d9a82d] | 1220 | fi;
|
---|
| 1221 |
|
---|
[877cc6a] | 1222 | EOF
|
---|
| 1223 | ) >> $MKFILE
|
---|
[045b2dc] | 1224 |
|
---|
| 1225 | # Add SBU-disk_usage report target
|
---|
| 1226 | echo "create-sbu_du-report:" >> $MKFILE
|
---|
| 1227 | if [[ "$REPORT" = "y" ]] ; then
|
---|
| 1228 | (
|
---|
| 1229 | cat << EOF
|
---|
| 1230 | @\$(call echo_message, Building)
|
---|
| 1231 | @./create-sbu_du-report.sh logs $VERSION
|
---|
| 1232 | @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
|
---|
| 1233 | @touch \$@
|
---|
| 1234 |
|
---|
| 1235 | EOF
|
---|
| 1236 | ) >> $MKFILE
|
---|
| 1237 | else echo -e "\t@true\n" >> $MKFILE; fi
|
---|
| 1238 |
|
---|
[c10570d] | 1239 |
|
---|
[877cc6a] | 1240 | fi
|
---|
| 1241 |
|
---|
[045b2dc] | 1242 | ################### BOOT #####################
|
---|
[877cc6a] | 1243 |
|
---|
| 1244 | if [[ "${METHOD}" = "boot" ]]; then
|
---|
| 1245 | (
|
---|
[045b2dc] | 1246 | cat << EOF
|
---|
[877cc6a] | 1247 |
|
---|
[045b2dc] | 1248 | all: ck_UID mk_SETUP mk_CROSS mk_SUDO
|
---|
| 1249 | @sudo make restore-luser-env
|
---|
| 1250 | @sudo make do-housekeeping
|
---|
[877cc6a] | 1251 | @\$(call echo_boot_finished,$VERSION)
|
---|
| 1252 |
|
---|
[c10570d] | 1253 | makesys: mk_FINAL mk_BLFS_TOOL
|
---|
[877cc6a] | 1254 | @\$(call echo_finished,$VERSION)
|
---|
| 1255 |
|
---|
| 1256 |
|
---|
[045b2dc] | 1257 | ck_UID:
|
---|
| 1258 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 1259 | echo "+--------------------------------------------------+"; \\
|
---|
| 1260 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
| 1261 | echo "|However, if this is the boot environment |"; \\
|
---|
| 1262 | echo "| the command you are looking for is |"; \\
|
---|
| 1263 | echo "| make makesys |"; \\
|
---|
| 1264 | echo "| to finish off the build |"; \\
|
---|
| 1265 | echo "+--------------------------------------------------+"; \\
|
---|
| 1266 | exit 1; \\
|
---|
| 1267 | fi
|
---|
[877cc6a] | 1268 |
|
---|
[045b2dc] | 1269 | #---------------AS ROOT
|
---|
[877cc6a] | 1270 |
|
---|
[045b2dc] | 1271 | mk_SETUP:
|
---|
| 1272 | @\$(call echo_SU_request)
|
---|
| 1273 | @sudo make SETUP
|
---|
| 1274 | @touch \$@
|
---|
| 1275 |
|
---|
| 1276 | #---------------AS LUSER
|
---|
[a160d86] | 1277 |
|
---|
[045b2dc] | 1278 | mk_CROSS: mk_SETUP
|
---|
| 1279 | @\$(call echo_PHASE,Cross Tool)
|
---|
[a2133cb] | 1280 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
|
---|
[045b2dc] | 1281 | @touch \$@
|
---|
| 1282 |
|
---|
[c10570d] | 1283 | mk_SUDO: mk_CROSS
|
---|
[a2133cb] | 1284 | @sudo make SHELL=/bin/bash SUDO
|
---|
[045b2dc] | 1285 | @touch \$@
|
---|
| 1286 |
|
---|
| 1287 | #---------------AS ROOT
|
---|
| 1288 |
|
---|
| 1289 | mk_FINAL:
|
---|
| 1290 | @\$(call echo_PHASE,Final System)
|
---|
| 1291 | @( make AS_ROOT )
|
---|
| 1292 | @touch \$@
|
---|
| 1293 |
|
---|
[c10570d] | 1294 | mk_BLFS_TOOL: mk_FINAL
|
---|
| 1295 | @\$(call echo_PHASE,Building BLFS-TOOLS)
|
---|
| 1296 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 1297 | mkdir -p $TRACKING_DIR; \\
|
---|
| 1298 | make BLFS_TOOL; \\
|
---|
| 1299 | fi
|
---|
| 1300 | @touch \$@
|
---|
| 1301 |
|
---|
[045b2dc] | 1302 | SETUP: $host_prep
|
---|
| 1303 | AS_LUSER: $cross_tools $temptools ${chroottools}${boottools}
|
---|
| 1304 | SUDO: $orphan_scripts
|
---|
| 1305 | AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
[c10570d] | 1306 | BLFS_TOOL: $blfs_tool
|
---|
[045b2dc] | 1307 |
|
---|
| 1308 | do-housekeeping:
|
---|
| 1309 | @-rm /tools /cross-tools
|
---|
| 1310 | @-if [ ! -f luser-exist ]; then \\
|
---|
[6ad5a2f] | 1311 | userdel \$(LUSER); \\
|
---|
| 1312 | rm -rf /home/\$(LUSER); \\
|
---|
[877cc6a] | 1313 | fi;
|
---|
| 1314 |
|
---|
[045b2dc] | 1315 | EOF
|
---|
| 1316 | ) >> $MKFILE
|
---|
| 1317 | fi
|
---|
| 1318 |
|
---|
| 1319 | (
|
---|
| 1320 | cat << EOF
|
---|
| 1321 |
|
---|
[6ad5a2f] | 1322 | restore-luser-env:
|
---|
[877cc6a] | 1323 | @\$(call echo_message, Building)
|
---|
[6ad5a2f] | 1324 | @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
[045b2dc] | 1325 | mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
---|
[877cc6a] | 1326 | fi;
|
---|
[6ad5a2f] | 1327 | @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
[045b2dc] | 1328 | mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
---|
[877cc6a] | 1329 | fi;
|
---|
[6ad5a2f] | 1330 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
---|
[93f38e7] | 1331 | touch \$@ && \\
|
---|
| 1332 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 1333 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 1334 |
|
---|
[045b2dc] | 1335 | ########################################################
|
---|
| 1336 |
|
---|
[7d9a82d] | 1337 |
|
---|
[877cc6a] | 1338 | EOF
|
---|
| 1339 | ) >> $MKFILE
|
---|
| 1340 |
|
---|
| 1341 | # Bring over the items from the Makefile.tmp
|
---|
| 1342 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 1343 | rm $MKFILE.tmp
|
---|
| 1344 |
|
---|
[045b2dc] | 1345 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
[877cc6a] | 1346 | }
|
---|