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