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