[91ff6a9] | 1 | #!/bin/bash
|
---|
[877cc6a] | 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
| 5 | ###################################
|
---|
| 6 | ### FUNCTIONS ###
|
---|
| 7 | ###################################
|
---|
| 8 |
|
---|
| 9 |
|
---|
[045b2dc] | 10 | #############################################################
|
---|
| 11 |
|
---|
| 12 |
|
---|
[877cc6a] | 13 | #----------------------------#
|
---|
[045b2dc] | 14 | chapter4_Makefiles() { #
|
---|
[877cc6a] | 15 | #----------------------------#
|
---|
[045b2dc] | 16 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${R_arrow}"
|
---|
[903eefd] | 17 | # Ensure the first dependency is empty
|
---|
| 18 | unset PREV
|
---|
[877cc6a] | 19 |
|
---|
[903eefd] | 20 | for file in chapter04/* ; do
|
---|
| 21 | # Keep the script file name
|
---|
| 22 | this_script=`basename $file`
|
---|
[877cc6a] | 23 |
|
---|
[903eefd] | 24 | # First append each name of the script files to a list (this will become
|
---|
| 25 | # the names of the targets in the Makefile
|
---|
| 26 | # DO NOT append the settingenvironment script, it need be run as luser.
|
---|
| 27 | # A hack is necessary: create script in chap4 BUT run as a dependency for
|
---|
| 28 | # LUSER target
|
---|
| 29 | case "${this_script}" in
|
---|
| 30 | *settingenvironment) chapter5="$chapter5 ${this_script}" ;;
|
---|
| 31 | *) chapter4="$chapter4 ${this_script}" ;;
|
---|
| 32 | esac
|
---|
[877cc6a] | 33 |
|
---|
[903eefd] | 34 | # Grab the name of the target
|
---|
| 35 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 36 |
|
---|
| 37 | #--------------------------------------------------------------------#
|
---|
| 38 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 39 | #--------------------------------------------------------------------#
|
---|
| 40 | #
|
---|
| 41 |
|
---|
| 42 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 43 | # as a dependency. Also call the echo_message function.
|
---|
| 44 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
| 45 |
|
---|
| 46 | case "${this_script}" in
|
---|
| 47 | *settingenvironment)
|
---|
| 48 | (
|
---|
| 49 | cat << EOF
|
---|
| 50 | @cd && \\
|
---|
| 51 | function source() { true; } && \\
|
---|
| 52 | export -f source && \\
|
---|
| 53 | \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1 && \\
|
---|
| 54 | sed 's|/mnt/lfs|\$(MOUNT_PT)|' -i .bashrc && \\
|
---|
| 55 | echo source $JHALFSDIR/envars >> .bashrc
|
---|
| 56 | @\$(PRT_DU) >>logs/\$@
|
---|
| 57 | EOF
|
---|
| 58 | ) >> $MKFILE.tmp
|
---|
| 59 | ;;
|
---|
| 60 | *addinguser)
|
---|
| 61 | (
|
---|
| 62 | cat << EOF
|
---|
| 63 | @if [ -f luser-id ]; then \\
|
---|
| 64 | function useradd() { true; }; \\
|
---|
| 65 | function groupadd() { true; }; \\
|
---|
| 66 | export -f useradd groupadd; \\
|
---|
| 67 | fi; \\
|
---|
| 68 | export LFS=\$(MOUNT_PT) && \\
|
---|
| 69 | \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1; \\
|
---|
| 70 | \$(PRT_DU) >>logs/\$@
|
---|
| 71 | @chown \$(LUSER):\$(LGROUP) envars
|
---|
| 72 | @chmod -R a+wt $JHALFSDIR
|
---|
| 73 | @chmod a+wt \$(SRCSDIR)
|
---|
[877cc6a] | 74 | EOF
|
---|
[903eefd] | 75 | ) >> $MKFILE.tmp
|
---|
| 76 | ;;
|
---|
| 77 | *) wrt_RunAsRoot "$file" ;;
|
---|
| 78 | esac
|
---|
[045b2dc] | 79 |
|
---|
[903eefd] | 80 | # Include a touch of the target name so make can check
|
---|
| 81 | # if it's already been made.
|
---|
| 82 | wrt_touch
|
---|
| 83 | #
|
---|
| 84 | #--------------------------------------------------------------------#
|
---|
| 85 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 86 | #--------------------------------------------------------------------#
|
---|
| 87 |
|
---|
| 88 | # Keep the script file name for Makefile dependencies.
|
---|
| 89 | PREV=${this_script}
|
---|
| 90 | done # end for file in chapter04/*
|
---|
[877cc6a] | 91 | }
|
---|
| 92 |
|
---|
[045b2dc] | 93 |
|
---|
| 94 |
|
---|
[877cc6a] | 95 | #----------------------------#
|
---|
| 96 | chapter5_Makefiles() {
|
---|
| 97 | #----------------------------#
|
---|
[045b2dc] | 98 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
|
---|
[877cc6a] | 99 |
|
---|
[3261fe7] | 100 | # Initialize the Makefile target: it'll change during chapter
|
---|
| 101 | # For vanilla lfs, the "changingowner" script should be run as root. So
|
---|
| 102 | # it belongs to the "SUDO" target, with list in the "runasroot" variable.
|
---|
| 103 | # For new lfs, changingowner and kernfs are in "runsaroot", then the following,
|
---|
| 104 | # starting at creatingdirs, are in the "CHROOT" target, in variable "chapter6".
|
---|
| 105 | # Makefile_target records the variable, not really the target!
|
---|
| 106 | # We use a case statement on that variable, because instructions in the
|
---|
| 107 | # Makefile change according to the phase of the build (LUSER, SUDO, CHROOT).
|
---|
| 108 | Makefile_target=chapter5
|
---|
| 109 |
|
---|
| 110 | # Start loop
|
---|
[877cc6a] | 111 | for file in chapter05/* ; do
|
---|
| 112 | # Keep the script file name
|
---|
| 113 | this_script=`basename $file`
|
---|
| 114 |
|
---|
[3261fe7] | 115 | # Fix locales creation when running chapter05 testsuites (ugly)
|
---|
[877cc6a] | 116 | case "${this_script}" in
|
---|
[a241c33] | 117 | *glibc) [[ "${TEST}" = "3" ]] && \
|
---|
[d46a46e] | 118 | sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
---|
[877cc6a] | 119 | esac
|
---|
| 120 |
|
---|
[3261fe7] | 121 | # Append each name of the script files to a list that Makefile_target
|
---|
| 122 | # points to. But before that, change Makefile_target at the first script
|
---|
| 123 | # of each target.
|
---|
[045b2dc] | 124 | case "${this_script}" in
|
---|
[3261fe7] | 125 | *changingowner) Makefile_target=runasroot ;;
|
---|
| 126 | *creatingdirs ) Makefile_target=chapter6 ;; # only run for new lfs
|
---|
[045b2dc] | 127 | esac
|
---|
[3261fe7] | 128 | eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
|
---|
[877cc6a] | 129 |
|
---|
| 130 | # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
---|
| 131 | # and binutils in chapter 5)
|
---|
[1849935] | 132 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 133 | -e 's@-pass[0-9]\{1\}@@' \
|
---|
| 134 | -e 's@-libstdc++@@'`
|
---|
[877cc6a] | 135 |
|
---|
| 136 | #--------------------------------------------------------------------#
|
---|
| 137 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 138 | #--------------------------------------------------------------------#
|
---|
| 139 | #
|
---|
[3cb4ef5b] | 140 | # Find the name of the tarball and the version of the package
|
---|
[2758d94] | 141 | pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
|
---|
| 142 | pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
|
---|
[3cb4ef5b] | 143 |
|
---|
[877cc6a] | 144 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 145 | # as a dependency. Also call the echo_message function.
|
---|
[3261fe7] | 146 | case $Makefile_target in
|
---|
| 147 | chapter6) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
| 148 | *) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
| 149 | esac
|
---|
[b7faa5a] | 150 |
|
---|
[a160d86] | 151 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 152 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[5a8939e] | 153 | # Always initialize the log file, since the test instructions may be
|
---|
| 154 | # "uncommented" by the user
|
---|
[3261fe7] | 155 | case $Makefile_target in
|
---|
| 156 | chapter6) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
|
---|
| 157 | *) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
|
---|
| 158 | esac
|
---|
| 159 |
|
---|
[a229600] | 160 | # If using optimizations, write the instructions
|
---|
[84a3fda] | 161 | case "${OPTIMIZE}${this_script}${REALSBU}" in
|
---|
| 162 | *binutils-pass1y) ;;
|
---|
| 163 | 2*) wrt_optimize "$name" && wrt_makeflags "$name" ;;
|
---|
| 164 | *) ;;
|
---|
| 165 | esac
|
---|
[877cc6a] | 166 | fi
|
---|
| 167 |
|
---|
| 168 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 169 | # and date and disk usage again at the bottom of the log file.
|
---|
[a241c33] | 170 | # The changingowner script must be run as root.
|
---|
[3261fe7] | 171 | case "${Makefile_target}" in
|
---|
| 172 | runasroot) wrt_RunAsRoot "$file" "$pkg_version" ;;
|
---|
| 173 | chapter5) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
|
---|
| 174 | chapter6) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
|
---|
[a241c33] | 175 | esac
|
---|
[877cc6a] | 176 |
|
---|
| 177 | # Include a touch of the target name so make can check
|
---|
| 178 | # if it's already been made.
|
---|
[e2ef100] | 179 | wrt_touch
|
---|
[877cc6a] | 180 | #
|
---|
| 181 | #--------------------------------------------------------------------#
|
---|
| 182 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 183 | #--------------------------------------------------------------------#
|
---|
| 184 |
|
---|
| 185 | # Keep the script file name for Makefile dependencies.
|
---|
| 186 | PREV=${this_script}
|
---|
| 187 | done # end for file in chapter05/*
|
---|
| 188 | }
|
---|
| 189 |
|
---|
[045b2dc] | 190 |
|
---|
[877cc6a] | 191 | #----------------------------#
|
---|
| 192 | chapter6_Makefiles() {
|
---|
| 193 | #----------------------------#
|
---|
[045b2dc] | 194 |
|
---|
[45f82718] | 195 | # Set envars and scripts for iteration targets
|
---|
| 196 | if [[ -z "$1" ]] ; then
|
---|
| 197 | local N=""
|
---|
| 198 | else
|
---|
| 199 | local N=-build_$1
|
---|
| 200 | local chapter6=""
|
---|
| 201 | mkdir chapter06$N
|
---|
| 202 | cp chapter06/* chapter06$N
|
---|
| 203 | for script in chapter06$N/* ; do
|
---|
| 204 | # Overwrite existing symlinks, files, and dirs
|
---|
[93fd2d0] | 205 | sed -e 's/ln *-sv/&f/g' \
|
---|
| 206 | -e 's/mv *-v/&f/g' \
|
---|
| 207 | -e 's/mkdir *-v/&p/g' -i ${script}
|
---|
| 208 | # Suppress the mod of "test-installation.pl" because now
|
---|
| 209 | # the library path points to /usr/lib
|
---|
| 210 | if [[ ${script} =~ glibc ]]; then
|
---|
| 211 | sed '/DL=/,/unset DL/d' -i ${script}
|
---|
| 212 | fi
|
---|
[10c8b78] | 213 | # Rename the scripts
|
---|
| 214 | mv ${script} ${script}$N
|
---|
[45f82718] | 215 | done
|
---|
[a5f52ba] | 216 | # Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
|
---|
| 217 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
|
---|
[709eb74] | 218 | # Remove openssl-<version> from /usr/share/doc (LFS-9.x), because
|
---|
| 219 | # otherwise the mv command creates an openssl directory.
|
---|
| 220 | sed -e 's@mv -v@rm -rfv /usr/share/doc/openssl-*\n&@' \
|
---|
| 221 | -i chapter06$N/*-openssl$N
|
---|
[45f82718] | 222 | fi
|
---|
| 223 |
|
---|
[045b2dc] | 224 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
|
---|
[45f82718] | 225 |
|
---|
[3261fe7] | 226 | # Initialize the Makefile target. In vanilla lfs, kernfs should be run as root,
|
---|
| 227 | # then the others are run in chroot. If in new lfs, we should start in chroot.
|
---|
| 228 | # this will be changed later because man-pages is the first script in
|
---|
| 229 | # chapter 6. Note that this Makefile_target business is not really needed here
|
---|
| 230 | # but we do it to have a similar structure to chapter 5 (we may merge all
|
---|
| 231 | # those functions at some point).
|
---|
[7b7b5e9] | 232 | case "$N" in
|
---|
| 233 | -build*) Makefile_target=chapter6 ;;
|
---|
| 234 | *) Makefile_target=runasroot ;;
|
---|
| 235 | esac
|
---|
[3261fe7] | 236 |
|
---|
| 237 | # Start loop
|
---|
[45f82718] | 238 | for file in chapter06$N/* ; do
|
---|
[877cc6a] | 239 | # Keep the script file name
|
---|
| 240 | this_script=`basename $file`
|
---|
| 241 |
|
---|
[d68eb1b] | 242 | # Skip the "stripping" scripts if the user does not want to strip.
|
---|
[8426d1f] | 243 | # Skip also linux-headers in iterative builds.
|
---|
[877cc6a] | 244 | case "${this_script}" in
|
---|
[401f81e] | 245 | *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[8426d1f] | 246 | *linux-headers*) [[ -n "$N" ]] && continue ;;
|
---|
[877cc6a] | 247 | esac
|
---|
| 248 |
|
---|
[4eba1ea] | 249 | # Grab the name of the target.
|
---|
[10c8b78] | 250 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
|
---|
[877cc6a] | 251 |
|
---|
[d68eb1b] | 252 | # Find the tarball corresponding to our script.
|
---|
[bdb0761] | 253 | # If it doesn't exist, we skip it in iterations rebuilds (except stripping
|
---|
| 254 | # and revisedchroot, where .a and .la files are removed).
|
---|
[2758d94] | 255 | pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
|
---|
| 256 | pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
|
---|
[45f82718] | 257 |
|
---|
[a160d86] | 258 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[45f82718] | 259 | case "${this_script}" in
|
---|
[bdb0761] | 260 | *stripping*|*revised*) ;;
|
---|
[45f82718] | 261 | *) continue ;;
|
---|
| 262 | esac
|
---|
| 263 | fi
|
---|
| 264 |
|
---|
| 265 | # Append each name of the script files to a list (this will become
|
---|
| 266 | # the names of the targets in the Makefile)
|
---|
[4eba1ea] | 267 | # The kernfs script must be run as part of SUDO target.
|
---|
| 268 | case "${this_script}" in
|
---|
[3261fe7] | 269 | *creatingdirs) Makefile_target=chapter6 ;;
|
---|
| 270 | *man-pages ) Makefile_target=chapter6 ;;
|
---|
[4eba1ea] | 271 | esac
|
---|
[3261fe7] | 272 | eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
|
---|
[45f82718] | 273 |
|
---|
[877cc6a] | 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.
|
---|
[8bea2c8] | 280 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 281 | # and not to use chroot.
|
---|
[3261fe7] | 282 | case "${Makefile_target}" in
|
---|
| 283 | runasroot) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
| 284 | *) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
[8bea2c8] | 285 | esac
|
---|
[877cc6a] | 286 |
|
---|
[a160d86] | 287 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 288 | # Insert instructions for unpacking the package and changing directories
|
---|
[a160d86] | 289 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[38d2de6] | 290 | # Touch timestamp file if installed files logs will be created.
|
---|
[81fca31] | 291 | # But only for the firt build when running iterative builds.
|
---|
| 292 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
[93346ee] | 293 | CHROOT_wrt_TouchTimestamp
|
---|
| 294 | fi
|
---|
[3261fe7] | 295 | # Always initialize the log file, so that the user may reinstate a
|
---|
[5a8939e] | 296 | # commented out test
|
---|
| 297 | CHROOT_wrt_test_log "${this_script}" "$pkg_version"
|
---|
[a229600] | 298 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 299 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 300 | fi
|
---|
| 301 |
|
---|
| 302 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 303 | # and not to use chroot.
|
---|
[3261fe7] | 304 | case "${Makefile_target}" in
|
---|
| 305 | runasroot) wrt_RunAsRoot "$file" "$pkg_version" ;;
|
---|
| 306 | *) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
|
---|
[877cc6a] | 307 | esac
|
---|
| 308 |
|
---|
[93346ee] | 309 | # Write installed files log and remove the build directory(ies)
|
---|
| 310 | # except if the package build fails.
|
---|
[a160d86] | 311 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[81fca31] | 312 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
[93346ee] | 313 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 314 | fi
|
---|
[877cc6a] | 315 | fi
|
---|
| 316 |
|
---|
| 317 | # Include a touch of the target name so make can check
|
---|
| 318 | # if it's already been made.
|
---|
[e2ef100] | 319 | wrt_touch
|
---|
[877cc6a] | 320 | #
|
---|
| 321 | #--------------------------------------------------------------------#
|
---|
| 322 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 323 | #--------------------------------------------------------------------#
|
---|
| 324 |
|
---|
| 325 | # Keep the script file name for Makefile dependencies.
|
---|
[10c8b78] | 326 | PREV=${this_script}
|
---|
[45f82718] | 327 | # Set system_build envar for iteration targets
|
---|
[7b7b5e9] | 328 | if [ -z "$N" ]; then
|
---|
| 329 | system_build="$system_build $this_script"
|
---|
| 330 | fi
|
---|
[877cc6a] | 331 | done # end for file in chapter06/*
|
---|
[7b7b5e9] | 332 | if [ -n "$N" ]; then
|
---|
| 333 | system_build="$chapter6"
|
---|
| 334 | fi
|
---|
[877cc6a] | 335 | }
|
---|
| 336 |
|
---|
| 337 | #----------------------------#
|
---|
[14eaa9f] | 338 | chapter78_Makefiles() {
|
---|
[877cc6a] | 339 | #----------------------------#
|
---|
[b11c10b] | 340 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
---|
[877cc6a] | 341 |
|
---|
[14eaa9f] | 342 | for file in chapter0{7,8}/* ; do
|
---|
[877cc6a] | 343 | # Keep the script file name
|
---|
| 344 | this_script=`basename $file`
|
---|
| 345 |
|
---|
| 346 | # Grub must be configured manually.
|
---|
[14eaa9f] | 347 | # Handle fstab creation.
|
---|
[877cc6a] | 348 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 349 | case ${this_script} in
|
---|
| 350 | *grub) continue ;;
|
---|
[d601cfc] | 351 | *fstab) [[ -z "${FSTAB}" ]] ||
|
---|
[85506da] | 352 | [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
|
---|
| 353 | cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[877cc6a] | 354 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
[85506da] | 355 | [[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
|
---|
[877cc6a] | 356 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
| 357 | esac
|
---|
| 358 |
|
---|
| 359 | # First append each name of the script files to a list (this will become
|
---|
| 360 | # the names of the targets in the Makefile
|
---|
[14eaa9f] | 361 | chapter78="$chapter78 ${this_script}"
|
---|
[877cc6a] | 362 |
|
---|
| 363 | #--------------------------------------------------------------------#
|
---|
| 364 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 365 | #--------------------------------------------------------------------#
|
---|
| 366 | #
|
---|
| 367 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 368 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 369 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 370 |
|
---|
[532ede6] | 371 | # Find the bootscripts or networkscripts (for systemd)
|
---|
| 372 | # and kernel package names
|
---|
[877cc6a] | 373 | case "${this_script}" in
|
---|
| 374 | *bootscripts)
|
---|
[a160d86] | 375 | name="lfs-bootscripts"
|
---|
[93346ee] | 376 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 377 | CHROOT_wrt_TouchTimestamp
|
---|
| 378 | fi
|
---|
[877cc6a] | 379 | ;;
|
---|
[532ede6] | 380 | *network-scripts)
|
---|
| 381 | name="lfs-network-scripts"
|
---|
| 382 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 383 | CHROOT_wrt_TouchTimestamp
|
---|
| 384 | fi
|
---|
| 385 | ;;
|
---|
[877cc6a] | 386 | *kernel)
|
---|
[a160d86] | 387 | name="linux"
|
---|
[93346ee] | 388 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 389 | CHROOT_wrt_TouchTimestamp
|
---|
| 390 | fi
|
---|
[93fd2d0] | 391 | # If using optimizations, use MAKEFLAGS (unless blacklisted)
|
---|
| 392 | # no setting of CFLAGS and friends.
|
---|
| 393 | [[ "$OPTIMIZE" != "0" ]] && wrt_makeflags "$name"
|
---|
[877cc6a] | 394 | ;;
|
---|
| 395 | esac
|
---|
| 396 |
|
---|
| 397 | # Check if we have a real /etc/fstab file
|
---|
| 398 | case "${this_script}" in
|
---|
[d601cfc] | 399 | *fstab) if [[ -n "$FSTAB" ]]; then
|
---|
[045b2dc] | 400 | CHROOT_wrt_CopyFstab
|
---|
[877cc6a] | 401 | else
|
---|
[045b2dc] | 402 | CHROOT_wrt_RunAsRoot "$file"
|
---|
[877cc6a] | 403 | fi
|
---|
| 404 | ;;
|
---|
[045b2dc] | 405 | *) CHROOT_wrt_RunAsRoot "$file"
|
---|
[877cc6a] | 406 | ;;
|
---|
| 407 | esac
|
---|
| 408 |
|
---|
| 409 | case "${this_script}" in
|
---|
[2758d94] | 410 | *bootscripts|*network-scripts|*kernel)
|
---|
[532ede6] | 411 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 412 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 413 | fi ;;
|
---|
[877cc6a] | 414 | esac
|
---|
| 415 | # Include a touch of the target name so make can check
|
---|
| 416 | # if it's already been made.
|
---|
[e2ef100] | 417 | wrt_touch
|
---|
[877cc6a] | 418 | #
|
---|
| 419 | #--------------------------------------------------------------------#
|
---|
| 420 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 421 | #--------------------------------------------------------------------#
|
---|
| 422 |
|
---|
| 423 | # Keep the script file name for Makefile dependencies.
|
---|
| 424 | PREV=${this_script}
|
---|
[14eaa9f] | 425 | done # for file in chapter0{7,8}/*
|
---|
[453bef0] | 426 |
|
---|
[877cc6a] | 427 | }
|
---|
| 428 |
|
---|
| 429 |
|
---|
[045b2dc] | 430 |
|
---|
[877cc6a] | 431 | #----------------------------#
|
---|
[045b2dc] | 432 | build_Makefile() { #
|
---|
[877cc6a] | 433 | #----------------------------#
|
---|
[045b2dc] | 434 |
|
---|
[c7c5a53] | 435 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[045b2dc] | 436 |
|
---|
[877cc6a] | 437 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 438 |
|
---|
| 439 | # Start with a clean Makefile.tmp file
|
---|
[045b2dc] | 440 | >$MKFILE
|
---|
[877cc6a] | 441 |
|
---|
| 442 | chapter4_Makefiles
|
---|
| 443 | chapter5_Makefiles
|
---|
| 444 | chapter6_Makefiles
|
---|
[45f82718] | 445 | # Add the iterations targets, if needed
|
---|
[401f81e] | 446 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
[14eaa9f] | 447 | chapter78_Makefiles
|
---|
[3e7ceed] | 448 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 449 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
[877cc6a] | 450 |
|
---|
| 451 | # Add a header, some variables and include the function file
|
---|
| 452 | # to the top of the real Makefile.
|
---|
[195ed9f] | 453 | wrt_Makefile_header
|
---|
[877cc6a] | 454 |
|
---|
| 455 | # Add chroot commands
|
---|
[6ad5a2f] | 456 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
[877cc6a] | 457 | i=1
|
---|
[d68eb1b] | 458 | for file in ../chroot-scripts/*chroot* ; do
|
---|
[6ad5a2f] | 459 | chroot=`cat $file | \
|
---|
[abc8b27] | 460 | perl -pe 's|\\\\\n||g' | \
|
---|
| 461 | tr -s [:space:] | \
|
---|
| 462 | grep chroot | \
|
---|
| 463 | sed -e "s|chroot|$CHROOT_LOC|" \
|
---|
[6ad5a2f] | 464 | -e 's|\\$|&&|g' \
|
---|
[abc8b27] | 465 | -e 's|"$$LFS"|$(MOUNT_PT)|'`
|
---|
[877cc6a] | 466 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 467 | i=`expr $i + 1`
|
---|
| 468 | done
|
---|
| 469 |
|
---|
[13c475b] | 470 | # Store virtual kernel file systems commands:
|
---|
| 471 | devices=`cat ../kernfs-scripts/devices.sh | \
|
---|
| 472 | sed -e 's|^| |' \
|
---|
| 473 | -e 's|mount|sudo &|' \
|
---|
| 474 | -e 's|mkdir|sudo &|' \
|
---|
| 475 | -e 's|\\$|&&|g' \
|
---|
[a659e46] | 476 | -e 's|\$|; \\\\|' \
|
---|
| 477 | -e 's|then|& :|' \
|
---|
[13c475b] | 478 | -e 's|\$\$LFS|$(MOUNT_PT)|g'`
|
---|
| 479 | teardown=`cat ../kernfs-scripts/teardown.sh | \
|
---|
| 480 | sed -e 's|^| |' \
|
---|
| 481 | -e 's|umount|sudo &|' \
|
---|
| 482 | -e 's|\$LFS|$(MOUNT_PT)|'`
|
---|
| 483 | teardownat=`cat ../kernfs-scripts/teardown.sh | \
|
---|
| 484 | sed -e 's|^| |' \
|
---|
| 485 | -e 's|umount|@-sudo &|' \
|
---|
| 486 | -e 's|\$LFS|$(MOUNT_PT)|'`
|
---|
[877cc6a] | 487 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 488 | # as a dependency.
|
---|
| 489 | (
|
---|
| 490 | cat << EOF
|
---|
[045b2dc] | 491 |
|
---|
[ac9bdc7] | 492 | all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
|
---|
[13c475b] | 493 | $teardownat
|
---|
[045b2dc] | 494 | @sudo make do_housekeeping
|
---|
[df97e68] | 495 | EOF
|
---|
| 496 | ) >> $MKFILE
|
---|
| 497 | if [ "$INITSYS" = systemd ]; then
|
---|
| 498 | (
|
---|
| 499 | cat << EOF
|
---|
| 500 | @/bin/echo -e -n \\
|
---|
| 501 | NAME=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 502 | VERSION=\\"$VERSION\\"\\\\n\\
|
---|
| 503 | ID=lfs\\\\n\\
|
---|
| 504 | PRETTY_NAME=\\"Linux From Scratch $VERSION\\"\\\\n\\
|
---|
| 505 | VERSION_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
---|
| 506 | > os-release && \\
|
---|
| 507 | sudo mv os-release \$(MOUNT_PT)/etc && \\
|
---|
| 508 | sudo chown root:root \$(MOUNT_PT)/etc/os-release
|
---|
| 509 | EOF
|
---|
| 510 | ) >> $MKFILE
|
---|
| 511 | fi
|
---|
| 512 | (
|
---|
| 513 | cat << EOF
|
---|
[e1fc855] | 514 | @echo $VERSION > lfs-release && \\
|
---|
[9096853] | 515 | sudo mv lfs-release \$(MOUNT_PT)/etc && \\
|
---|
| 516 | sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
|
---|
[e1fc855] | 517 | @/bin/echo -e -n \\
|
---|
| 518 | DISTRIB_ID=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 519 | DISTRIB_RELEASE=\\"$VERSION\\"\\\\n\\
|
---|
| 520 | DISTRIB_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
---|
| 521 | DISTRIB_DESCRIPTION=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 522 | > lsb-release && \\
|
---|
| 523 | sudo mv lsb-release \$(MOUNT_PT)/etc && \\
|
---|
| 524 | sudo chown root:root \$(MOUNT_PT)/etc/lsb-release
|
---|
[877cc6a] | 525 | @\$(call echo_finished,$VERSION)
|
---|
| 526 |
|
---|
[045b2dc] | 527 | ck_UID:
|
---|
| 528 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 529 | echo "--------------------------------------------------"; \\
|
---|
| 530 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 531 | echo "--------------------------------------------------"; \\
|
---|
| 532 | exit 1; \\
|
---|
| 533 | fi
|
---|
| 534 |
|
---|
| 535 | mk_SETUP:
|
---|
| 536 | @\$(call echo_SU_request)
|
---|
[dd7e0f67] | 537 | @sudo make save-luser
|
---|
[dbcdfd7] | 538 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[045b2dc] | 539 | @touch \$@
|
---|
| 540 |
|
---|
| 541 | mk_LUSER: mk_SETUP
|
---|
| 542 | @\$(call echo_SULUSER_request)
|
---|
[903eefd] | 543 | @\$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER"
|
---|
| 544 | @sudo make restore-luser
|
---|
[045b2dc] | 545 | @touch \$@
|
---|
| 546 |
|
---|
| 547 | mk_SUDO: mk_LUSER
|
---|
[a73ed74] | 548 | @sudo rm -f envars
|
---|
[dbcdfd7] | 549 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
[1330ebc] | 550 | @touch \$@
|
---|
| 551 |
|
---|
[045b2dc] | 552 | mk_CHROOT: mk_SUDO
|
---|
| 553 | @\$(call echo_CHROOT_request)
|
---|
[d68eb1b] | 554 | @( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
[045b2dc] | 555 | @touch \$@
|
---|
[877cc6a] | 556 |
|
---|
[045b2dc] | 557 | mk_BOOT: mk_CHROOT
|
---|
| 558 | @\$(call echo_CHROOT_request)
|
---|
[d68eb1b] | 559 | @( sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
[045b2dc] | 560 | @touch \$@
|
---|
[877cc6a] | 561 |
|
---|
[ac9bdc7] | 562 | mk_BLFS_TOOL: create-sbu_du-report
|
---|
| 563 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 564 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
[d68eb1b] | 565 | (sudo \$(CHROOT2) -c "make -C $BLFS_ROOT/work"); \\
|
---|
[ac9bdc7] | 566 | fi;
|
---|
| 567 | @touch \$@
|
---|
| 568 |
|
---|
| 569 | mk_CUSTOM_TOOLS: mk_BLFS_TOOL
|
---|
[3e7ceed] | 570 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 571 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
[3e7ceed] | 572 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
[d68eb1b] | 573 | (sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
[3e7ceed] | 574 | fi;
|
---|
| 575 | @touch \$@
|
---|
| 576 |
|
---|
[f60a8b7] | 577 | devices: ck_UID
|
---|
[13c475b] | 578 | $devices
|
---|
[d39252b] | 579 | EOF
|
---|
| 580 | ) >> $MKFILE
|
---|
| 581 | if [ "$INITSYS" = systemd ]; then
|
---|
| 582 | (
|
---|
| 583 | cat << EOF
|
---|
| 584 | sudo mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
|
---|
[426c618] | 585 | sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
|
---|
[d39252b] | 586 | EOF
|
---|
| 587 | ) >> $MKFILE
|
---|
| 588 | fi
|
---|
| 589 | (
|
---|
| 590 | cat << EOF
|
---|
[13c475b] | 591 |
|
---|
[2e1c1c3] | 592 | teardown:
|
---|
[13c475b] | 593 | $teardown
|
---|
[d39252b] | 594 |
|
---|
| 595 | chroot1: devices
|
---|
| 596 | sudo \$(CHROOT1)
|
---|
| 597 | \$(MAKE) teardown
|
---|
[7c17066] | 598 |
|
---|
| 599 | chroot: devices
|
---|
[d68eb1b] | 600 | sudo \$(CHROOT2)
|
---|
[7c17066] | 601 | \$(MAKE) teardown
|
---|
[877cc6a] | 602 |
|
---|
[3e7ceed] | 603 | SETUP: $chapter4
|
---|
| 604 | LUSER: $chapter5
|
---|
| 605 | SUDO: $runasroot
|
---|
[13c475b] | 606 | EOF
|
---|
| 607 | ) >> $MKFILE
|
---|
| 608 | if [ "$INITSYS" = systemd ]; then
|
---|
| 609 | (
|
---|
| 610 | cat << EOF
|
---|
[c6506aea] | 611 | mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
|
---|
| 612 | cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
|
---|
[13c475b] | 613 |
|
---|
| 614 | EOF
|
---|
| 615 | ) >> $MKFILE
|
---|
| 616 | fi
|
---|
| 617 | (
|
---|
| 618 | cat << EOF
|
---|
[a73ed74] | 619 | CHROOT: SHELL=\$(filter %bash,\$(CHROOT1))
|
---|
[3e7ceed] | 620 | CHROOT: $chapter6
|
---|
| 621 | BOOT: $chapter78
|
---|
| 622 | CUSTOM_TOOLS: $custom_list
|
---|
[fe24ca6] | 623 |
|
---|
[045b2dc] | 624 |
|
---|
[1838bc7] | 625 | create-sbu_du-report: mk_BOOT
|
---|
| 626 | @\$(call echo_message, Building)
|
---|
| 627 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
[c57747d] | 628 | sudo ./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
|
---|
[1838bc7] | 629 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
[903eefd] | 630 | fi
|
---|
[1838bc7] | 631 | @touch \$@
|
---|
[045b2dc] | 632 |
|
---|
[903eefd] | 633 | save-luser:
|
---|
[877cc6a] | 634 | @\$(call echo_message, Building)
|
---|
[49e2745] | 635 | @LUSER_ID=\$\$(grep '^\$(LUSER):' /etc/passwd | cut -d: -f3); \\
|
---|
[dd7e0f67] | 636 | if [ -n "\$\$LUSER_ID" ]; then \\
|
---|
[903eefd] | 637 | if [ ! -d \$(LUSER_HOME).XXX ]; then \\
|
---|
| 638 | mv \$(LUSER_HOME){,.XXX}; \\
|
---|
| 639 | mkdir \$(LUSER_HOME); \\
|
---|
| 640 | chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
|
---|
| 641 | fi; \\
|
---|
[dd7e0f67] | 642 | echo "\$\$LUSER_ID" > luser-id; \\
|
---|
| 643 | echo User \$(LUSER) exists with ID \$\$LUSER_ID; \\
|
---|
[903eefd] | 644 | else \\
|
---|
[49e2745] | 645 | rm -f luser-id; \\
|
---|
[dd7e0f67] | 646 | echo User \$(LUSER) does not exist; \\
|
---|
| 647 | echo It will be created with book instructions.; \\
|
---|
[903eefd] | 648 | fi
|
---|
[dbcdfd7] | 649 | @\$(call housekeeping)
|
---|
[a858a78] | 650 |
|
---|
[903eefd] | 651 | restore-luser:
|
---|
| 652 | @\$(call echo_message, Building)
|
---|
| 653 | @if [ -f luser-id ]; then \\
|
---|
| 654 | rm -rf \$(LUSER_HOME); \\
|
---|
| 655 | mv \$(LUSER_HOME){.XXX,}; \\
|
---|
| 656 | rm luser-id; \\
|
---|
| 657 | else \\
|
---|
[6ad5a2f] | 658 | userdel \$(LUSER); \\
|
---|
[903eefd] | 659 | groupdel \$(LGROUP); \\
|
---|
[962793a] | 660 | rm -rf \$(LUSER_HOME); \\
|
---|
[903eefd] | 661 | fi
|
---|
| 662 | @\$(call housekeeping)
|
---|
| 663 |
|
---|
| 664 | do_housekeeping:
|
---|
| 665 | @-rm /tools
|
---|
[a858a78] | 666 |
|
---|
[877cc6a] | 667 | EOF
|
---|
| 668 | ) >> $MKFILE
|
---|
| 669 |
|
---|
| 670 | # Bring over the items from the Makefile.tmp
|
---|
| 671 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 672 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 673 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 674 | }
|
---|