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