[91ff6a9] | 1 | #!/bin/bash
|
---|
[877cc6a] | 2 | # $Id$
|
---|
| 3 |
|
---|
[045b2dc] | 4 |
|
---|
| 5 | orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | #--------------------------------------#
|
---|
| 9 | host_prep_Makefiles() { #
|
---|
| 10 | #--------------------------------------#
|
---|
[e2ec07a] | 11 | local CLFS_HOST
|
---|
[877cc6a] | 12 |
|
---|
[045b2dc] | 13 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
|
---|
[877cc6a] | 14 |
|
---|
| 15 | # defined here, only for ease of reading
|
---|
[ff4d1ab] | 16 | CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
|
---|
[877cc6a] | 17 | (
|
---|
| 18 | cat << EOF
|
---|
| 19 | 023-creatingtoolsdir:
|
---|
| 20 | @\$(call echo_message, Building)
|
---|
[e314f7e] | 21 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
| 22 | rm -f /tools && \\
|
---|
| 23 | ln -s \$(MOUNT_PT)/tools /
|
---|
[877cc6a] | 24 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
| 25 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
| 26 | fi;
|
---|
| 27 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
[93f38e7] | 28 | touch \$@ && \\
|
---|
| 29 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 30 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 31 |
|
---|
| 32 | 024-creatingcrossdir: 023-creatingtoolsdir
|
---|
| 33 | @mkdir -v \$(MOUNT_PT)/cross-tools && \\
|
---|
[e314f7e] | 34 | rm -f /cross-tools && \\
|
---|
| 35 | ln -s \$(MOUNT_PT)/cross-tools /
|
---|
[93f38e7] | 36 | @touch \$@ && \\
|
---|
| 37 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 38 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 39 |
|
---|
| 40 | 025-addinguser: 024-creatingcrossdir
|
---|
| 41 | @\$(call echo_message, Building)
|
---|
[6ad5a2f] | 42 | @if [ ! -d /home/\$(LUSER) ]; then \\
|
---|
| 43 | groupadd \$(LGROUP); \\
|
---|
| 44 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
[877cc6a] | 45 | else \\
|
---|
[6ad5a2f] | 46 | touch luser-exist; \\
|
---|
[877cc6a] | 47 | fi;
|
---|
[6ad5a2f] | 48 | @chown \$(LUSER) \$(MOUNT_PT) && \\
|
---|
| 49 | chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
---|
| 50 | chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
|
---|
| 51 | chown \$(LUSER) \$(MOUNT_PT)/sources && \\
|
---|
[93f38e7] | 52 | touch \$@ && \\
|
---|
| 53 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 54 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 55 |
|
---|
| 56 | 026-settingenvironment: 025-addinguser
|
---|
| 57 | @\$(call echo_message, Building)
|
---|
[6ad5a2f] | 58 | @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
| 59 | mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
---|
[877cc6a] | 60 | fi;
|
---|
[6ad5a2f] | 61 | @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
| 62 | mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
---|
[877cc6a] | 63 | fi;
|
---|
[6ad5a2f] | 64 | @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
---|
| 65 | echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 66 | echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 67 | echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 68 | echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 69 | echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 70 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 71 | echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 72 | echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 73 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 74 | echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 75 | echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 76 | echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
| 77 | echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
|
---|
| 78 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
---|
[877cc6a] | 79 | touch envars && \\
|
---|
[045b2dc] | 80 | chmod -R a+wt \$(MOUNT_PT) && \\
|
---|
| 81 | chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
[93f38e7] | 82 | touch \$@ && \\
|
---|
| 83 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 84 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 85 | EOF
|
---|
| 86 | ) >> $MKFILE.tmp
|
---|
[045b2dc] | 87 | host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
|
---|
[877cc6a] | 88 |
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[045b2dc] | 91 | #--------------------------------------#
|
---|
| 92 | cross_tools_Makefiles() { #
|
---|
| 93 | #--------------------------------------#
|
---|
| 94 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
[877cc6a] | 95 |
|
---|
| 96 | for file in cross-tools/* ; do
|
---|
| 97 | # Keep the script file name
|
---|
| 98 | this_script=`basename $file`
|
---|
| 99 | #
|
---|
| 100 | # Skip this script...
|
---|
| 101 | case $this_script in
|
---|
| 102 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
| 103 | continue; ;;
|
---|
| 104 | *) ;;
|
---|
| 105 | esac
|
---|
| 106 | #
|
---|
| 107 | # Set the dependency for the first target.
|
---|
| 108 | if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
|
---|
| 109 |
|
---|
| 110 | # First append each name of the script files to a list (this will become
|
---|
| 111 | # the names of the targets in the Makefile
|
---|
| 112 | cross_tools="$cross_tools $this_script"
|
---|
| 113 |
|
---|
| 114 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 115 | # and binutils in chapter 5)
|
---|
| 116 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 117 | -e 's@-static@@' \
|
---|
| 118 | -e 's@-final@@' \
|
---|
[a160d86] | 119 | -e 's@-64@@' \
|
---|
[877cc6a] | 120 | -e 's@-n32@@'`
|
---|
[a160d86] | 121 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 122 |
|
---|
| 123 | #--------------------------------------------------------------------#
|
---|
| 124 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 125 | #--------------------------------------------------------------------#
|
---|
| 126 | #
|
---|
| 127 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 128 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 129 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 130 | #
|
---|
[a160d86] | 131 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 132 | #
|
---|
[045b2dc] | 133 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
[877cc6a] | 134 | #
|
---|
[045b2dc] | 135 | LUSER_wrt_RunAsUser "${file}"
|
---|
[877cc6a] | 136 | #
|
---|
[045b2dc] | 137 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 138 | #
|
---|
| 139 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 140 | wrt_touch
|
---|
[877cc6a] | 141 | #
|
---|
| 142 | #--------------------------------------------------------------------#
|
---|
| 143 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 144 | #--------------------------------------------------------------------#
|
---|
| 145 | #
|
---|
| 146 | # Keep the script file name for Makefile dependencies.
|
---|
| 147 | PREV=$this_script
|
---|
| 148 |
|
---|
| 149 | done # for file in ....
|
---|
| 150 | }
|
---|
| 151 |
|
---|
[045b2dc] | 152 | #--------------------------------------#
|
---|
| 153 | temptools_Makefiles() { #
|
---|
| 154 | #--------------------------------------#
|
---|
| 155 | echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
|
---|
[877cc6a] | 156 |
|
---|
| 157 | for file in temp-system/* ; do
|
---|
| 158 | # Keep the script file name
|
---|
| 159 | this_script=`basename $file`
|
---|
[6f2cd96] | 160 | #
|
---|
| 161 | # Deal with any odd scripts..
|
---|
| 162 | case $this_script in
|
---|
| 163 | *choose) # The choose script will fail if you cannot enter the new environment
|
---|
| 164 | # If the 'boot' build method was chosen don't run the script
|
---|
| 165 | [[ $METHOD = "boot" ]] && continue; ;;
|
---|
| 166 | *) ;;
|
---|
| 167 | esac
|
---|
[e2ec07a] | 168 |
|
---|
[877cc6a] | 169 | #
|
---|
| 170 | # First append each name of the script files to a list (this will become
|
---|
| 171 | # the names of the targets in the Makefile
|
---|
| 172 | temptools="$temptools $this_script"
|
---|
| 173 |
|
---|
| 174 | #
|
---|
| 175 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 176 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 177 | #
|
---|
[a160d86] | 178 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 179 |
|
---|
| 180 | #--------------------------------------------------------------------#
|
---|
| 181 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 182 | #--------------------------------------------------------------------#
|
---|
| 183 | #
|
---|
| 184 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 185 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 186 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 187 | #
|
---|
[a160d86] | 188 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 189 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
| 190 | #
|
---|
[045b2dc] | 191 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
[a160d86] | 192 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 193 | #
|
---|
[045b2dc] | 194 | LUSER_wrt_RunAsUser "${file}"
|
---|
[877cc6a] | 195 | #
|
---|
[045b2dc] | 196 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 197 | #
|
---|
| 198 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 199 | wrt_touch
|
---|
[877cc6a] | 200 | #
|
---|
| 201 | #--------------------------------------------------------------------#
|
---|
| 202 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 203 | #--------------------------------------------------------------------#
|
---|
| 204 | #
|
---|
| 205 | # Keep the script file name for Makefile dependencies.
|
---|
| 206 | PREV=$this_script
|
---|
| 207 | done # for file in ....
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 |
|
---|
[045b2dc] | 211 | #--------------------------------------#
|
---|
| 212 | chroot_Makefiles() { #
|
---|
| 213 | #--------------------------------------#
|
---|
| 214 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
|
---|
[877cc6a] | 215 |
|
---|
[045b2dc] | 216 | for file in chroot/* ; do
|
---|
[877cc6a] | 217 | # Keep the script file name
|
---|
| 218 | this_script=`basename $file`
|
---|
[045b2dc] | 219 | #
|
---|
| 220 | # Skipping scripts is done now and not included in the build tree.
|
---|
[877cc6a] | 221 | case $this_script in
|
---|
[045b2dc] | 222 | *chroot*) continue ;;
|
---|
[877cc6a] | 223 | esac
|
---|
[045b2dc] | 224 |
|
---|
[877cc6a] | 225 | #
|
---|
| 226 | # First append each name of the script files to a list (this will become
|
---|
| 227 | # the names of the targets in the Makefile
|
---|
[045b2dc] | 228 | case "${this_script}" in
|
---|
| 229 | *util-linux) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 230 | *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 231 | *) chroottools="$chroottools $this_script" ;;
|
---|
[877cc6a] | 232 | esac
|
---|
[045b2dc] | 233 |
|
---|
| 234 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 235 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 236 |
|
---|
[a160d86] | 237 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 238 |
|
---|
[045b2dc] | 239 | # This is very ugly:: util-linux is in /chroot but must be run under LUSER
|
---|
| 240 | # .. Customized makefile entry
|
---|
| 241 | case "${this_script}" in
|
---|
| 242 | *util-linux)
|
---|
| 243 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
| 244 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 245 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 246 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 247 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 248 | wrt_touch
|
---|
| 249 | temptools="$temptools $this_script"
|
---|
| 250 | continue ;;
|
---|
| 251 | esac
|
---|
| 252 |
|
---|
| 253 |
|
---|
[877cc6a] | 254 | #--------------------------------------------------------------------#
|
---|
| 255 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 256 | #--------------------------------------------------------------------#
|
---|
| 257 | #
|
---|
| 258 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 259 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 260 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 261 | #
|
---|
[a160d86] | 262 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 263 | # Insert instructions for unpacking the package and changing directories
|
---|
| 264 | #
|
---|
[045b2dc] | 265 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[8f2c086] | 266 | CHROOT_Unpack "$pkg_tarball"
|
---|
[045b2dc] | 267 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 268 | fi
|
---|
[877cc6a] | 269 | #
|
---|
| 270 | # Select a script execution method
|
---|
| 271 | case $this_script in
|
---|
[8f2c086] | 272 | *kernfs) wrt_RunAsRoot "${file}" ;;
|
---|
[045b2dc] | 273 | *) CHROOT_wrt_RunAsRoot "${file}" ;;
|
---|
[877cc6a] | 274 | esac
|
---|
| 275 | #
|
---|
[045b2dc] | 276 | # Housekeeping...remove the build directory(ies), except if the package build fails.
|
---|
| 277 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 278 | #
|
---|
| 279 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 280 | wrt_touch
|
---|
[877cc6a] | 281 | #
|
---|
| 282 | #--------------------------------------------------------------------#
|
---|
| 283 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 284 | #--------------------------------------------------------------------#
|
---|
| 285 | #
|
---|
| 286 | # Keep the script file name for Makefile dependencies.
|
---|
| 287 | PREV=$this_script
|
---|
| 288 |
|
---|
[045b2dc] | 289 | done # for file in...
|
---|
[877cc6a] | 290 | }
|
---|
| 291 |
|
---|
| 292 |
|
---|
[045b2dc] | 293 | #--------------------------------------#
|
---|
| 294 | boot_Makefiles() { #
|
---|
| 295 | #--------------------------------------#
|
---|
[877cc6a] | 296 |
|
---|
[045b2dc] | 297 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
|
---|
| 298 | #
|
---|
| 299 | # Create a target bootable partition containing a compile environment. Later
|
---|
| 300 | # on we boot into this environment and contine the build.
|
---|
| 301 | #
|
---|
| 302 | for file in boot/* ; do
|
---|
[877cc6a] | 303 | # Keep the script file name
|
---|
| 304 | this_script=`basename $file`
|
---|
[045b2dc] | 305 |
|
---|
| 306 | # A little housekeeping on the scripts
|
---|
[877cc6a] | 307 | case $this_script in
|
---|
[045b2dc] | 308 | *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
|
---|
| 309 | *whatnext*) continue ;;
|
---|
| 310 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
| 311 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 312 | [[ -z $CONFIG ]] && continue
|
---|
| 313 | # Copy the config file to /sources with a standardized name
|
---|
| 314 | cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
|
---|
| 315 | ;;
|
---|
[877cc6a] | 316 | esac
|
---|
| 317 | #
|
---|
| 318 | # First append each name of the script files to a list (this will become
|
---|
| 319 | # the names of the targets in the Makefile
|
---|
[045b2dc] | 320 | case "${this_script}" in
|
---|
| 321 | *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 322 | *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
| 323 | *) boottools="$boottools $this_script" ;;
|
---|
| 324 | esac
|
---|
| 325 | #
|
---|
| 326 | # Grab the name of the target, strip id number and misc words.
|
---|
| 327 | case $this_script in
|
---|
| 328 | *kernel) name=linux ;;
|
---|
| 329 | *bootscripts) name="bootscripts-cross-lfs" ;;
|
---|
| 330 | *udev-rules) name="udev-cross-lfs" ;;
|
---|
| 331 | *grub-build) name=grub ;;
|
---|
| 332 | *-aboot-build) name=aboot ;;
|
---|
| 333 | *yaboot-build) name=yaboot ;;
|
---|
| 334 | *colo-build) name=colo ;;
|
---|
| 335 | *silo-build) name=silo ;;
|
---|
| 336 | *arcload-build) name=arcload ;;
|
---|
| 337 | *lilo-build) name=lilo ;;
|
---|
| 338 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
| 339 | esac
|
---|
| 340 | # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
|
---|
[a160d86] | 341 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 342 |
|
---|
| 343 | #--------------------------------------------------------------------#
|
---|
| 344 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 345 | #--------------------------------------------------------------------#
|
---|
| 346 | #
|
---|
| 347 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 348 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 349 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 350 | #
|
---|
[a160d86] | 351 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 352 | # Insert instructions for unpacking the package and changing directories
|
---|
| 353 | #
|
---|
[045b2dc] | 354 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 355 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 356 | #
|
---|
| 357 | # Select a script execution method
|
---|
| 358 | case $this_script in
|
---|
[045b2dc] | 359 | # The following 2 scripts are defined in the /boot directory but need
|
---|
| 360 | # to be run as a root user. Set them up here but run them in another phase
|
---|
[8f2c086] | 361 | *changingowner*) wrt_RunAsRoot "${file}" ;;
|
---|
| 362 | *devices*) wrt_RunAsRoot "${file}" ;;
|
---|
[045b2dc] | 363 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
| 364 | LUSER_wrt_CopyFstab
|
---|
| 365 | else
|
---|
| 366 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 367 | fi
|
---|
| 368 | ;;
|
---|
| 369 | *) LUSER_wrt_RunAsUser "${file}" ;;
|
---|
[877cc6a] | 370 | esac
|
---|
| 371 | #
|
---|
[045b2dc] | 372 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
| 373 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 374 | #
|
---|
| 375 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 376 | wrt_touch
|
---|
[877cc6a] | 377 | #
|
---|
| 378 | #--------------------------------------------------------------------#
|
---|
| 379 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 380 | #--------------------------------------------------------------------#
|
---|
| 381 | #
|
---|
| 382 | # Keep the script file name for Makefile dependencies.
|
---|
| 383 | PREV=$this_script
|
---|
| 384 |
|
---|
[045b2dc] | 385 | done
|
---|
[877cc6a] | 386 | }
|
---|
| 387 |
|
---|
| 388 |
|
---|
[045b2dc] | 389 | #--------------------------------------#
|
---|
[d55a1a1] | 390 | testsuite_tools_Makefiles() { #
|
---|
[045b2dc] | 391 | #--------------------------------------#
|
---|
[877cc6a] | 392 |
|
---|
[d55a1a1] | 393 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
| 394 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
|
---|
| 395 | else
|
---|
| 396 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
|
---|
[010627d] | 397 | PREV=""
|
---|
[d55a1a1] | 398 | fi
|
---|
[877cc6a] | 399 |
|
---|
| 400 | for file in testsuite-tools/* ; do
|
---|
| 401 | # Keep the script file name
|
---|
| 402 | this_script=`basename $file`
|
---|
| 403 |
|
---|
| 404 | # First append each name of the script files to a list (this will become
|
---|
| 405 | # the names of the targets in the Makefile
|
---|
| 406 | testsuitetools="$testsuitetools $this_script"
|
---|
| 407 |
|
---|
| 408 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 409 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 410 | -e 's@-64bit@@' \
|
---|
| 411 | -e 's@-64@@' \
|
---|
| 412 | -e 's@64@@' \
|
---|
| 413 | -e 's@n32@@'`
|
---|
| 414 |
|
---|
[a160d86] | 415 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 416 |
|
---|
| 417 | #--------------------------------------------------------------------#
|
---|
| 418 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 419 | #--------------------------------------------------------------------#
|
---|
| 420 | #
|
---|
| 421 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 422 | # as a dependency. Also call the echo_message function.
|
---|
[ca6b261] | 423 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 424 | #
|
---|
[ca6b261] | 425 | CHROOT_Unpack "$pkg_tarball"
|
---|
[1b65a84] | 426 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 427 | #
|
---|
[ca6b261] | 428 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
[877cc6a] | 429 | #
|
---|
[ca6b261] | 430 | CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 431 | #
|
---|
| 432 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 433 | wrt_touch
|
---|
[877cc6a] | 434 | #
|
---|
| 435 | #--------------------------------------------------------------------#
|
---|
| 436 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 437 | #--------------------------------------------------------------------#
|
---|
| 438 | #
|
---|
| 439 | # Keep the script file name for Makefile dependencies.
|
---|
| 440 | PREV=$this_script
|
---|
| 441 |
|
---|
| 442 | done
|
---|
| 443 | }
|
---|
| 444 |
|
---|
| 445 |
|
---|
[045b2dc] | 446 | #--------------------------------------#
|
---|
[d55a1a1] | 447 | final_system_Makefiles() { #
|
---|
[045b2dc] | 448 | #--------------------------------------#
|
---|
[45f82718] | 449 | # Set envars and scripts for iteration targets
|
---|
| 450 | LOGS="" # Start with an empty global LOGS envar
|
---|
| 451 | if [[ -z "$1" ]] ; then
|
---|
| 452 | local N=""
|
---|
[d55a1a1] | 453 | # In boot method the makesys phase was initiated in testsuite_tools_makefile
|
---|
| 454 | [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
|
---|
[45f82718] | 455 | else
|
---|
| 456 | local N=-build_$1
|
---|
| 457 | local basicsystem=""
|
---|
| 458 | mkdir final-system$N
|
---|
| 459 | cp final-system/* final-system$N
|
---|
| 460 | for script in final-system$N/* ; do
|
---|
| 461 | # Overwrite existing symlinks, files, and dirs
|
---|
| 462 | sed -e 's/ln -sv/&f/g' \
|
---|
| 463 | -e 's/mv -v/&f/g' \
|
---|
| 464 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
| 465 | done
|
---|
| 466 | # Remove Bzip2 binaries before make install
|
---|
| 467 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
|
---|
| 468 | # Delete *old Readline libraries just after make install
|
---|
| 469 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
|
---|
| 470 | fi
|
---|
| 471 |
|
---|
[d55a1a1] | 472 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
| 473 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
|
---|
| 474 | else
|
---|
| 475 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
|
---|
| 476 | fi
|
---|
[877cc6a] | 477 |
|
---|
[45f82718] | 478 | for file in final-system$N/* ; do
|
---|
[877cc6a] | 479 | # Keep the script file name
|
---|
| 480 | this_script=`basename $file`
|
---|
| 481 |
|
---|
[45f82718] | 482 | # Test if the stripping phase must be skipped.
|
---|
| 483 | # Skip alsp temp-perl for iterative runs
|
---|
[877cc6a] | 484 | case $this_script in
|
---|
[401f81e] | 485 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
[45f82718] | 486 | *temp-perl*) [[ -n "$N" ]] && continue ;;
|
---|
[877cc6a] | 487 | esac
|
---|
| 488 |
|
---|
| 489 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 490 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 491 | -e 's@temp-@@' \
|
---|
| 492 | -e 's@-64bit@@' \
|
---|
| 493 | -e 's@-64@@' \
|
---|
| 494 | -e 's@64@@' \
|
---|
| 495 | -e 's@n32@@'`
|
---|
| 496 |
|
---|
[45f82718] | 497 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 498 | # a specific package. We need this here to can skip scripts not needed for
|
---|
| 499 | # iterations rebuilds
|
---|
[a160d86] | 500 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[9d9ecf7] | 501 |
|
---|
[a160d86] | 502 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[45f82718] | 503 | case "${this_script}" in
|
---|
| 504 | *stripping*) ;;
|
---|
| 505 | *) continue ;;
|
---|
| 506 | esac
|
---|
| 507 | fi
|
---|
| 508 |
|
---|
| 509 | # Append each name of the script files to a list (this will become
|
---|
| 510 | # the names of the targets in the Makefile
|
---|
| 511 | basicsystem="$basicsystem ${this_script}${N}"
|
---|
| 512 |
|
---|
| 513 | # Append each name of the script files to a list (this will become
|
---|
| 514 | # the names of the logs to be moved for each iteration)
|
---|
| 515 | LOGS="$LOGS ${this_script}"
|
---|
| 516 |
|
---|
[877cc6a] | 517 | #--------------------------------------------------------------------#
|
---|
| 518 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 519 | #--------------------------------------------------------------------#
|
---|
| 520 | #
|
---|
| 521 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 522 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 523 | CHROOT_wrt_target "${this_script}${N}" "$PREV"
|
---|
[877cc6a] | 524 |
|
---|
[a160d86] | 525 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 526 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[045b2dc] | 527 | CHROOT_Unpack "$pkg_tarball"
|
---|
[a229600] | 528 | # If the testsuites must be run, initialize the log file
|
---|
| 529 | case $name in
|
---|
| 530 | binutils | gcc | glibc )
|
---|
[045b2dc] | 531 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 532 | ;;
|
---|
| 533 | * )
|
---|
[045b2dc] | 534 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 535 | ;;
|
---|
| 536 | esac
|
---|
| 537 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 538 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 539 | fi
|
---|
| 540 | #
|
---|
[045b2dc] | 541 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
[877cc6a] | 542 | #
|
---|
[045b2dc] | 543 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 544 | #
|
---|
| 545 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 546 | wrt_touch
|
---|
[877cc6a] | 547 | #
|
---|
| 548 | #--------------------------------------------------------------------#
|
---|
| 549 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 550 | #--------------------------------------------------------------------#
|
---|
| 551 | #
|
---|
| 552 | # Keep the script file name for Makefile dependencies.
|
---|
[45f82718] | 553 | PREV=${this_script}${N}
|
---|
| 554 | # Set system_build envar for iteration targets
|
---|
| 555 | system_build=$basicsystem
|
---|
[877cc6a] | 556 | done # for file in final-system/* ...
|
---|
| 557 | }
|
---|
| 558 |
|
---|
[045b2dc] | 559 | #--------------------------------------#
|
---|
[d55a1a1] | 560 | bootscripts_Makefiles() { #
|
---|
[045b2dc] | 561 | #--------------------------------------#
|
---|
[d55a1a1] | 562 |
|
---|
| 563 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
| 564 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
|
---|
[45f82718] | 565 | else
|
---|
[d55a1a1] | 566 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
|
---|
[45f82718] | 567 | fi
|
---|
[877cc6a] | 568 |
|
---|
| 569 | for file in bootscripts/* ; do
|
---|
| 570 | # Keep the script file name
|
---|
| 571 | this_script=`basename $file`
|
---|
| 572 |
|
---|
| 573 | case $this_script in
|
---|
| 574 | *udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
---|
| 575 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
| 576 | *) ;;
|
---|
| 577 | esac
|
---|
| 578 |
|
---|
| 579 | # First append each name of the script files to a list (this will become
|
---|
| 580 | # the names of the targets in the Makefile
|
---|
| 581 | bootscripttools="$bootscripttools $this_script"
|
---|
| 582 |
|
---|
| 583 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 584 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 585 | -e 's@-64bit@@' \
|
---|
| 586 | -e 's@-64@@' \
|
---|
| 587 | -e 's@64@@' \
|
---|
| 588 | -e 's@n32@@'`
|
---|
| 589 | case $name in
|
---|
[c044e3c] | 590 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
[877cc6a] | 591 | *udev-rules) name=udev-cross-lfs ;;
|
---|
| 592 | esac
|
---|
[c044e3c] | 593 |
|
---|
[a160d86] | 594 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 595 |
|
---|
| 596 | #--------------------------------------------------------------------#
|
---|
| 597 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 598 | #--------------------------------------------------------------------#
|
---|
| 599 | #
|
---|
| 600 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 601 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 602 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 603 | #
|
---|
[a160d86] | 604 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 605 | #
|
---|
[045b2dc] | 606 | [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 607 | #
|
---|
[045b2dc] | 608 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
[877cc6a] | 609 | #
|
---|
[045b2dc] | 610 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 611 | #
|
---|
| 612 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 613 | wrt_touch
|
---|
[877cc6a] | 614 | #
|
---|
| 615 | #--------------------------------------------------------------------#
|
---|
| 616 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 617 | #--------------------------------------------------------------------#
|
---|
| 618 | #
|
---|
| 619 | # Keep the script file name for Makefile dependencies.
|
---|
| 620 | PREV=$this_script
|
---|
| 621 |
|
---|
| 622 | done # for file in bootscripts/* ...
|
---|
| 623 | }
|
---|
| 624 |
|
---|
[045b2dc] | 625 | #--------------------------------------#
|
---|
[d55a1a1] | 626 | bootable_Makefiles() { #
|
---|
[045b2dc] | 627 | #--------------------------------------#
|
---|
[877cc6a] | 628 |
|
---|
[d55a1a1] | 629 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
| 630 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
|
---|
| 631 | else
|
---|
| 632 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
|
---|
| 633 | fi
|
---|
[877cc6a] | 634 |
|
---|
| 635 |
|
---|
| 636 | for file in {bootable,the-end}/* ; do
|
---|
| 637 | # Keep the script file name
|
---|
| 638 | this_script=`basename $file`
|
---|
| 639 |
|
---|
| 640 | # A little housekeeping on the scripts
|
---|
| 641 | case $this_script in
|
---|
| 642 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
[045b2dc] | 643 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[877cc6a] | 644 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 645 | [[ -z $CONFIG ]] && continue
|
---|
| 646 | # Copy the config file to /sources with a standardized name
|
---|
| 647 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 648 | ;;
|
---|
| 649 | esac
|
---|
| 650 | #
|
---|
| 651 | # First append each name of the script files to a list (this will become
|
---|
| 652 | # the names of the targets in the Makefile
|
---|
| 653 | bootabletools="$bootabletools $this_script"
|
---|
| 654 | #
|
---|
| 655 | # Grab the name of the target, strip id number and misc words.
|
---|
| 656 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
| 657 | case $this_script in
|
---|
| 658 | *kernel*) name=linux
|
---|
| 659 | ;;
|
---|
| 660 | esac
|
---|
[a160d86] | 661 |
|
---|
| 662 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[877cc6a] | 663 |
|
---|
| 664 | #--------------------------------------------------------------------#
|
---|
| 665 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 666 | #--------------------------------------------------------------------#
|
---|
| 667 | #
|
---|
| 668 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 669 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 670 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 671 | #
|
---|
[a160d86] | 672 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 673 | # Insert instructions for unpacking the package and changing directories
|
---|
| 674 | #
|
---|
[045b2dc] | 675 | [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 676 | #
|
---|
| 677 | # Select a script execution method
|
---|
| 678 | case $this_script in
|
---|
[045b2dc] | 679 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
| 680 | CHROOT_wrt_CopyFstab
|
---|
| 681 | else
|
---|
| 682 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
| 683 | fi
|
---|
| 684 | ;;
|
---|
| 685 | *) CHROOT_wrt_RunAsRoot "${file}"
|
---|
| 686 | ;;
|
---|
[877cc6a] | 687 | esac
|
---|
| 688 | #
|
---|
| 689 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
[045b2dc] | 690 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
[877cc6a] | 691 | #
|
---|
| 692 | # Include a touch of the target name so make can check if it's already been made.
|
---|
[93f38e7] | 693 | wrt_touch
|
---|
[877cc6a] | 694 | #
|
---|
| 695 | #--------------------------------------------------------------------#
|
---|
| 696 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 697 | #--------------------------------------------------------------------#
|
---|
| 698 | #
|
---|
| 699 | # Keep the script file name for Makefile dependencies.
|
---|
| 700 | PREV=$this_script
|
---|
| 701 |
|
---|
| 702 | done
|
---|
| 703 |
|
---|
| 704 | }
|
---|
| 705 |
|
---|
| 706 |
|
---|
[045b2dc] | 707 | #--------------------------------------#
|
---|
| 708 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 709 | #--------------------------------------#
|
---|
| 710 | #
|
---|
| 711 | # Script crashes if error trapping is on
|
---|
| 712 | #
|
---|
| 713 | set +e
|
---|
| 714 | declare -f method_cmds
|
---|
| 715 | set -e
|
---|
| 716 |
|
---|
| 717 | echo "...Creating Makefile... ${BOLD}START${OFF}"
|
---|
[877cc6a] | 718 |
|
---|
| 719 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
[045b2dc] | 720 | # Start with a clean files
|
---|
| 721 | >$MKFILE
|
---|
[877cc6a] | 722 | >$MKFILE.tmp
|
---|
| 723 |
|
---|
[d55a1a1] | 724 | method_cmds=${METHOD}_Makefiles
|
---|
[045b2dc] | 725 |
|
---|
| 726 | host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
|
---|
| 727 | cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
|
---|
| 728 | temptools_Makefiles # mk_TEMP (LUSER) $temptools
|
---|
| 729 | $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
|
---|
| 730 | if [[ ! $TEST = "0" ]]; then
|
---|
[d55a1a1] | 731 | testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
|
---|
[877cc6a] | 732 | fi
|
---|
[d55a1a1] | 733 | final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
|
---|
[045b2dc] | 734 | # Add the iterations targets, if needed
|
---|
| 735 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
[d55a1a1] | 736 | bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
|
---|
| 737 | bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
|
---|
[877cc6a] | 738 |
|
---|
[c10570d] | 739 | # Add the BLFS_TOOL targets, if needed
|
---|
| 740 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
| 741 |
|
---|
[877cc6a] | 742 | # Add a header, some variables and include the function file
|
---|
| 743 | # to the top of the real Makefile.
|
---|
[195ed9f] | 744 | wrt_Makefile_header
|
---|
[877cc6a] | 745 |
|
---|
| 746 | # Add chroot commands
|
---|
| 747 | if [ "$METHOD" = "chroot" ] ; then
|
---|
[6ad5a2f] | 748 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
| 749 | chroot=`cat chroot/*chroot* | \
|
---|
| 750 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
| 751 | -e '/#!\/tools\/bin\/bash/d' \
|
---|
| 752 | -e '/^export/d' \
|
---|
| 753 | -e '/^logout/d' \
|
---|
| 754 | -e 's@ \\\@ @g' | \
|
---|
| 755 | tr -d '\n' | \
|
---|
| 756 | sed -e 's/ */ /g' \
|
---|
| 757 | -e 's|\\$|&&|g' \
|
---|
| 758 | -e 's|exit||g' \
|
---|
| 759 | -e 's|$| -c|' \
|
---|
[f4d9a48] | 760 | -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
|
---|
[f3a7f3b] | 761 | -e 's|set -e||' \
|
---|
| 762 | -e 's|set +h||'`
|
---|
[877cc6a] | 763 | echo -e "CHROOT1= $chroot\n" >> $MKFILE
|
---|
| 764 | fi
|
---|
| 765 |
|
---|
[045b2dc] | 766 | ################## CHROOT ####################
|
---|
| 767 |
|
---|
[877cc6a] | 768 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
| 769 | (
|
---|
[045b2dc] | 770 | cat << EOF
|
---|
[877cc6a] | 771 |
|
---|
[c10570d] | 772 | all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_BLFS_TOOL
|
---|
[045b2dc] | 773 | @sudo make do-housekeeping
|
---|
| 774 | @\$(call echo_finished,$VERSION)
|
---|
[a160d86] | 775 |
|
---|
[045b2dc] | 776 | ck_UID:
|
---|
| 777 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 778 | echo "+--------------------------------------------------+"; \\
|
---|
| 779 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
| 780 | echo "+--------------------------------------------------+"; \\
|
---|
| 781 | exit 1; \\
|
---|
| 782 | fi
|
---|
| 783 |
|
---|
| 784 | #---------------AS ROOT
|
---|
| 785 | mk_SETUP:
|
---|
| 786 | @\$(call echo_SU_request)
|
---|
[a2133cb] | 787 | @sudo make SHELL=/bin/bash SETUP
|
---|
[045b2dc] | 788 | @touch \$@
|
---|
| 789 |
|
---|
| 790 | #---------------AS LUSER
|
---|
| 791 | mk_CROSS: mk_SETUP
|
---|
| 792 | @\$(call echo_PHASE,Cross and Temporary Tools)
|
---|
[a2133cb] | 793 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
|
---|
[045b2dc] | 794 | @sudo make restore-luser-env
|
---|
| 795 | @touch \$@
|
---|
| 796 |
|
---|
| 797 | mk_SUDO: mk_CROSS
|
---|
[a2133cb] | 798 | @sudo make SHELL=/bin/bash SUDO
|
---|
[045b2dc] | 799 | @touch \$@
|
---|
| 800 | #
|
---|
| 801 | # The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
|
---|
| 802 | # chroot environment. (Unless someone knows a different way)
|
---|
| 803 | # Manually create the /bin directory and provide link to the /tools dir.
|
---|
| 804 | # Also change the original symlink creation to include (f)orce to prevent failure due to
|
---|
| 805 | # pre-existing links.
|
---|
| 806 |
|
---|
| 807 | #---------------CHROOT JAIL
|
---|
| 808 | mk_SYSTOOLS: mk_SUDO
|
---|
| 809 | @if [ ! -e \$(MOUNT_PT)/bin ]; then \\
|
---|
| 810 | mkdir \$(MOUNT_PT)/bin; \\
|
---|
| 811 | cd \$(MOUNT_PT)/bin && \\
|
---|
| 812 | ln -svf /tools/bin/bash bash; ln -sf bash sh; \\
|
---|
| 813 | sudo chown -R 0:0 \$(MOUNT_PT)/bin; \\
|
---|
[877cc6a] | 814 | fi;
|
---|
[f4d9a48] | 815 | @sudo sed -e 's|^ln -sv |ln -svf |' -i \$(CMDSDIR)/chroot/*-createfiles
|
---|
[045b2dc] | 816 | @\$(call echo_CHROOT_request)
|
---|
| 817 | @\$(call echo_PHASE, CHROOT JAIL )
|
---|
| 818 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT_JAIL")
|
---|
| 819 | @touch \$@
|
---|
[877cc6a] | 820 |
|
---|
[1838bc7] | 821 | mk_BLFS_TOOL: create-sbu_du-report
|
---|
| 822 | @\$(call echo_PHASE,Building BLFS-TOOLS)
|
---|
[c10570d] | 823 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 824 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
| 825 | sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BLFS_TOOL"; \\
|
---|
[1838bc7] | 826 | fi;
|
---|
[c10570d] | 827 | @touch \$@
|
---|
[045b2dc] | 828 |
|
---|
| 829 | SETUP: $host_prep
|
---|
| 830 | AS_LUSER: $cross_tools $temptools
|
---|
| 831 | SUDO: $orphan_scripts
|
---|
[d55a1a1] | 832 | CHROOT_JAIL: ${chroottools} $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
[c10570d] | 833 | BLFS_TOOL: $blfs_tool
|
---|
[877cc6a] | 834 |
|
---|
[1838bc7] | 835 |
|
---|
| 836 | create-sbu_du-report: mk_SYSTOOLS
|
---|
| 837 | @\$(call echo_message, Building)
|
---|
| 838 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
| 839 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
| 840 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
| 841 | fi;
|
---|
| 842 | @touch \$@
|
---|
| 843 |
|
---|
[7d9a82d] | 844 | do-housekeeping:
|
---|
[4524fb2] | 845 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
| 846 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
| 847 | @-umount \$(MOUNT_PT)/dev
|
---|
| 848 | @-umount \$(MOUNT_PT)/sys
|
---|
| 849 | @-umount \$(MOUNT_PT)/proc
|
---|
[045b2dc] | 850 | @-rm /tools /cross-tools
|
---|
[6ad5a2f] | 851 | @-if [ ! -f luser-exist ]; then \\
|
---|
| 852 | userdel \$(LUSER); \\
|
---|
| 853 | rm -rf /home/\$(LUSER); \\
|
---|
[7d9a82d] | 854 | fi;
|
---|
| 855 |
|
---|
[877cc6a] | 856 | EOF
|
---|
| 857 | ) >> $MKFILE
|
---|
[045b2dc] | 858 |
|
---|
[877cc6a] | 859 | fi
|
---|
| 860 |
|
---|
[045b2dc] | 861 | ################### BOOT #####################
|
---|
[877cc6a] | 862 |
|
---|
| 863 | if [[ "${METHOD}" = "boot" ]]; then
|
---|
| 864 | (
|
---|
[045b2dc] | 865 | cat << EOF
|
---|
[877cc6a] | 866 |
|
---|
[045b2dc] | 867 | all: ck_UID mk_SETUP mk_CROSS mk_SUDO
|
---|
| 868 | @sudo make restore-luser-env
|
---|
| 869 | @sudo make do-housekeeping
|
---|
[877cc6a] | 870 | @\$(call echo_boot_finished,$VERSION)
|
---|
| 871 |
|
---|
[c10570d] | 872 | makesys: mk_FINAL mk_BLFS_TOOL
|
---|
[877cc6a] | 873 | @\$(call echo_finished,$VERSION)
|
---|
| 874 |
|
---|
| 875 |
|
---|
[045b2dc] | 876 | ck_UID:
|
---|
| 877 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 878 | echo "+--------------------------------------------------+"; \\
|
---|
| 879 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
| 880 | echo "|However, if this is the boot environment |"; \\
|
---|
| 881 | echo "| the command you are looking for is |"; \\
|
---|
| 882 | echo "| make makesys |"; \\
|
---|
| 883 | echo "| to finish off the build |"; \\
|
---|
| 884 | echo "+--------------------------------------------------+"; \\
|
---|
| 885 | exit 1; \\
|
---|
| 886 | fi
|
---|
[877cc6a] | 887 |
|
---|
[045b2dc] | 888 | #---------------AS ROOT
|
---|
[877cc6a] | 889 |
|
---|
[045b2dc] | 890 | mk_SETUP:
|
---|
| 891 | @\$(call echo_SU_request)
|
---|
[d55a1a1] | 892 | @sudo make SHELL=/bin/bash SETUP
|
---|
[045b2dc] | 893 | @touch \$@
|
---|
| 894 |
|
---|
| 895 | #---------------AS LUSER
|
---|
[a160d86] | 896 |
|
---|
[045b2dc] | 897 | mk_CROSS: mk_SETUP
|
---|
| 898 | @\$(call echo_PHASE,Cross Tool)
|
---|
[a2133cb] | 899 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
|
---|
[045b2dc] | 900 | @touch \$@
|
---|
| 901 |
|
---|
[c10570d] | 902 | mk_SUDO: mk_CROSS
|
---|
[a2133cb] | 903 | @sudo make SHELL=/bin/bash SUDO
|
---|
[045b2dc] | 904 | @touch \$@
|
---|
| 905 |
|
---|
| 906 | #---------------AS ROOT
|
---|
| 907 |
|
---|
| 908 | mk_FINAL:
|
---|
| 909 | @\$(call echo_PHASE,Final System)
|
---|
[d55a1a1] | 910 | @( source /root/.bash_profile && make AS_ROOT )
|
---|
[045b2dc] | 911 | @touch \$@
|
---|
| 912 |
|
---|
[c10570d] | 913 | mk_BLFS_TOOL: mk_FINAL
|
---|
| 914 | @\$(call echo_PHASE,Building BLFS-TOOLS)
|
---|
| 915 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 916 | mkdir -p $TRACKING_DIR; \\
|
---|
[d55a1a1] | 917 | ( make BLFS_TOOL ); \\
|
---|
[c10570d] | 918 | fi
|
---|
| 919 | @touch \$@
|
---|
| 920 |
|
---|
[045b2dc] | 921 | SETUP: $host_prep
|
---|
[d55a1a1] | 922 | AS_LUSER: $cross_tools $temptools ${boottools}
|
---|
[045b2dc] | 923 | SUDO: $orphan_scripts
|
---|
| 924 | AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
[c10570d] | 925 | BLFS_TOOL: $blfs_tool
|
---|
[045b2dc] | 926 |
|
---|
| 927 | do-housekeeping:
|
---|
| 928 | @-rm /tools /cross-tools
|
---|
| 929 | @-if [ ! -f luser-exist ]; then \\
|
---|
[6ad5a2f] | 930 | userdel \$(LUSER); \\
|
---|
| 931 | rm -rf /home/\$(LUSER); \\
|
---|
[877cc6a] | 932 | fi;
|
---|
| 933 |
|
---|
[045b2dc] | 934 | EOF
|
---|
| 935 | ) >> $MKFILE
|
---|
| 936 | fi
|
---|
| 937 |
|
---|
| 938 | (
|
---|
| 939 | cat << EOF
|
---|
| 940 |
|
---|
[6ad5a2f] | 941 | restore-luser-env:
|
---|
[877cc6a] | 942 | @\$(call echo_message, Building)
|
---|
[6ad5a2f] | 943 | @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
[045b2dc] | 944 | mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
---|
[877cc6a] | 945 | fi;
|
---|
[6ad5a2f] | 946 | @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
[045b2dc] | 947 | mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
---|
[877cc6a] | 948 | fi;
|
---|
[6ad5a2f] | 949 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
---|
[93f38e7] | 950 | touch \$@ && \\
|
---|
| 951 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 952 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[877cc6a] | 953 |
|
---|
[045b2dc] | 954 | ########################################################
|
---|
| 955 |
|
---|
[7d9a82d] | 956 |
|
---|
[877cc6a] | 957 | EOF
|
---|
| 958 | ) >> $MKFILE
|
---|
| 959 |
|
---|
| 960 | # Bring over the items from the Makefile.tmp
|
---|
| 961 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 962 | rm $MKFILE.tmp
|
---|
| 963 |
|
---|
[045b2dc] | 964 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
[877cc6a] | 965 | }
|
---|