[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)
|
---|
[962793a] | 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 |
|
---|
| 80 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
[a241c33] | 81 | # Fix also locales creation when running chapter05 testsuites (ugly)
|
---|
[877cc6a] | 82 | case "${this_script}" in
|
---|
| 83 | *tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 84 | *expect) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 85 | *dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
[401f81e] | 86 | *stripping) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[a241c33] | 87 | *glibc) [[ "${TEST}" = "3" ]] && \
|
---|
[d46a46e] | 88 | sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
---|
[877cc6a] | 89 | esac
|
---|
| 90 |
|
---|
| 91 | # First append each name of the script files to a list (this will become
|
---|
| 92 | # the names of the targets in the Makefile
|
---|
[4eba1ea] | 93 | # DO NOT append the changingowner script, it need be run as root.
|
---|
[045b2dc] | 94 | # A hack is necessary: create script in chap5 BUT run as a dependency for
|
---|
[4eba1ea] | 95 | # SUDO target
|
---|
[045b2dc] | 96 | case "${this_script}" in
|
---|
[4eba1ea] | 97 | *changingowner) runasroot="$runasroot ${this_script}" ;;
|
---|
[045b2dc] | 98 | *) chapter5="$chapter5 ${this_script}" ;;
|
---|
| 99 | esac
|
---|
[877cc6a] | 100 |
|
---|
| 101 | # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
---|
| 102 | # and binutils in chapter 5)
|
---|
| 103 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
---|
| 104 |
|
---|
| 105 | # Set the dependency for the first target.
|
---|
| 106 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
| 107 |
|
---|
| 108 | #--------------------------------------------------------------------#
|
---|
| 109 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 110 | #--------------------------------------------------------------------#
|
---|
| 111 | #
|
---|
| 112 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 113 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 114 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 115 |
|
---|
| 116 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 117 | # a specific package
|
---|
[a160d86] | 118 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[b7faa5a] | 119 |
|
---|
[a160d86] | 120 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 121 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[877cc6a] | 122 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
[045b2dc] | 123 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[a229600] | 124 | # If the testsuites must be run, initialize the log file
|
---|
[045b2dc] | 125 | [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}"
|
---|
[a229600] | 126 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 127 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 128 | fi
|
---|
| 129 |
|
---|
| 130 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 131 | # and date and disk usage again at the bottom of the log file.
|
---|
[a241c33] | 132 | # The changingowner script must be run as root.
|
---|
| 133 | case "${this_script}" in
|
---|
[8f2c086] | 134 | *changingowner) wrt_RunAsRoot "$file" ;;
|
---|
[045b2dc] | 135 | *) LUSER_wrt_RunAsUser "$file" ;;
|
---|
[a241c33] | 136 | esac
|
---|
[877cc6a] | 137 |
|
---|
| 138 | # Remove the build directory(ies) except if the package build fails
|
---|
| 139 | # (so we can review config.cache, config.log, etc.)
|
---|
[a160d86] | 140 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[4b54394] | 141 | case "${name}" in
|
---|
| 142 | *xz-utils) LUSER_RemoveBuildDirs "xz" ;;
|
---|
| 143 | *) LUSER_RemoveBuildDirs "$name" ;;
|
---|
| 144 | esac
|
---|
[877cc6a] | 145 | fi
|
---|
| 146 |
|
---|
| 147 | # Include a touch of the target name so make can check
|
---|
| 148 | # if it's already been made.
|
---|
[e2ef100] | 149 | wrt_touch
|
---|
[877cc6a] | 150 | #
|
---|
| 151 | #--------------------------------------------------------------------#
|
---|
| 152 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 153 | #--------------------------------------------------------------------#
|
---|
| 154 |
|
---|
| 155 | # Keep the script file name for Makefile dependencies.
|
---|
| 156 | PREV=${this_script}
|
---|
| 157 | done # end for file in chapter05/*
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[045b2dc] | 160 |
|
---|
[877cc6a] | 161 | #----------------------------#
|
---|
| 162 | chapter6_Makefiles() {
|
---|
| 163 | #----------------------------#
|
---|
[045b2dc] | 164 |
|
---|
[45f82718] | 165 | # Set envars and scripts for iteration targets
|
---|
| 166 | if [[ -z "$1" ]] ; then
|
---|
| 167 | local N=""
|
---|
| 168 | else
|
---|
| 169 | local N=-build_$1
|
---|
| 170 | local chapter6=""
|
---|
| 171 | mkdir chapter06$N
|
---|
| 172 | cp chapter06/* chapter06$N
|
---|
| 173 | for script in chapter06$N/* ; do
|
---|
| 174 | # Overwrite existing symlinks, files, and dirs
|
---|
| 175 | sed -e 's/ln -sv/&f/g' \
|
---|
| 176 | -e 's/mv -v/&f/g' \
|
---|
| 177 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
[10c8b78] | 178 | # Rename the scripts
|
---|
| 179 | mv ${script} ${script}$N
|
---|
[45f82718] | 180 | done
|
---|
[a5f52ba] | 181 | # Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
|
---|
| 182 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
|
---|
[45f82718] | 183 | fi
|
---|
| 184 |
|
---|
[045b2dc] | 185 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
|
---|
[45f82718] | 186 |
|
---|
| 187 | for file in chapter06$N/* ; do
|
---|
[877cc6a] | 188 | # Keep the script file name
|
---|
| 189 | this_script=`basename $file`
|
---|
| 190 |
|
---|
| 191 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 192 | # dependencies and target creation.
|
---|
[8426d1f] | 193 | # Skip also linux-headers in iterative builds.
|
---|
[877cc6a] | 194 | case "${this_script}" in
|
---|
| 195 | *chroot) continue ;;
|
---|
[401f81e] | 196 | *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[8426d1f] | 197 | *linux-headers*) [[ -n "$N" ]] && continue ;;
|
---|
[877cc6a] | 198 | esac
|
---|
| 199 |
|
---|
[4eba1ea] | 200 | # Grab the name of the target.
|
---|
[10c8b78] | 201 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
|
---|
[877cc6a] | 202 |
|
---|
[45f82718] | 203 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 204 | # a specific package. We need this here to can skip scripts not needed for
|
---|
| 205 | # iterations rebuilds
|
---|
[a160d86] | 206 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[45f82718] | 207 |
|
---|
[a160d86] | 208 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[45f82718] | 209 | case "${this_script}" in
|
---|
| 210 | *stripping*) ;;
|
---|
| 211 | *) continue ;;
|
---|
| 212 | esac
|
---|
| 213 | fi
|
---|
| 214 |
|
---|
| 215 | # Append each name of the script files to a list (this will become
|
---|
| 216 | # the names of the targets in the Makefile)
|
---|
[4eba1ea] | 217 | # The kernfs script must be run as part of SUDO target.
|
---|
| 218 | case "${this_script}" in
|
---|
| 219 | *kernfs) runasroot="$runasroot ${this_script}" ;;
|
---|
[10c8b78] | 220 | *) chapter6="$chapter6 ${this_script}" ;;
|
---|
[4eba1ea] | 221 | esac
|
---|
[45f82718] | 222 |
|
---|
[877cc6a] | 223 | #--------------------------------------------------------------------#
|
---|
| 224 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 225 | #--------------------------------------------------------------------#
|
---|
| 226 | #
|
---|
| 227 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 228 | # as a dependency. Also call the echo_message function.
|
---|
[8bea2c8] | 229 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 230 | # and not to use chroot.
|
---|
| 231 | case "${this_script}" in
|
---|
| 232 | *kernfs) LUSER_wrt_target "${this_script}" "$PREV" ;;
|
---|
[10c8b78] | 233 | *) CHROOT_wrt_target "${this_script}" "$PREV" ;;
|
---|
[8bea2c8] | 234 | esac
|
---|
[877cc6a] | 235 |
|
---|
[a160d86] | 236 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[877cc6a] | 237 | # Insert instructions for unpacking the package and changing directories
|
---|
[a160d86] | 238 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[38d2de6] | 239 | # Touch timestamp file if installed files logs will be created.
|
---|
[81fca31] | 240 | # But only for the firt build when running iterative builds.
|
---|
| 241 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
[93346ee] | 242 | CHROOT_wrt_TouchTimestamp
|
---|
| 243 | fi
|
---|
[045b2dc] | 244 | CHROOT_Unpack "$pkg_tarball"
|
---|
[a229600] | 245 | # If the testsuites must be run, initialize the log file
|
---|
| 246 | case $name in
|
---|
| 247 | binutils | gcc | glibc )
|
---|
[10c8b78] | 248 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 249 | ;;
|
---|
| 250 | * )
|
---|
[10c8b78] | 251 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 252 | ;;
|
---|
| 253 | esac
|
---|
| 254 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 255 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 256 | fi
|
---|
| 257 |
|
---|
| 258 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 259 | # and not to use chroot.
|
---|
| 260 | case "${this_script}" in
|
---|
[8f2c086] | 261 | *kernfs) wrt_RunAsRoot "$file" ;;
|
---|
[045b2dc] | 262 | *) CHROOT_wrt_RunAsRoot "$file" ;;
|
---|
[877cc6a] | 263 | esac
|
---|
| 264 |
|
---|
[93346ee] | 265 | # Write installed files log and remove the build directory(ies)
|
---|
| 266 | # except if the package build fails.
|
---|
[a160d86] | 267 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[4b54394] | 268 | case "${name}" in
|
---|
| 269 | *xz-utils) CHROOT_wrt_RemoveBuildDirs "xz" ;;
|
---|
| 270 | *) CHROOT_wrt_RemoveBuildDirs "$name" ;;
|
---|
| 271 | esac
|
---|
[81fca31] | 272 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
[93346ee] | 273 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 274 | fi
|
---|
[877cc6a] | 275 | fi
|
---|
| 276 |
|
---|
| 277 | # Include a touch of the target name so make can check
|
---|
| 278 | # if it's already been made.
|
---|
[e2ef100] | 279 | wrt_touch
|
---|
[877cc6a] | 280 | #
|
---|
| 281 | #--------------------------------------------------------------------#
|
---|
| 282 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 283 | #--------------------------------------------------------------------#
|
---|
| 284 |
|
---|
| 285 | # Keep the script file name for Makefile dependencies.
|
---|
[10c8b78] | 286 | PREV=${this_script}
|
---|
[45f82718] | 287 | # Set system_build envar for iteration targets
|
---|
| 288 | system_build=$chapter6
|
---|
[877cc6a] | 289 | done # end for file in chapter06/*
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | #----------------------------#
|
---|
[14eaa9f] | 293 | chapter78_Makefiles() {
|
---|
[877cc6a] | 294 | #----------------------------#
|
---|
[b11c10b] | 295 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
---|
[877cc6a] | 296 |
|
---|
[14eaa9f] | 297 | for file in chapter0{7,8}/* ; do
|
---|
[877cc6a] | 298 | # Keep the script file name
|
---|
| 299 | this_script=`basename $file`
|
---|
| 300 |
|
---|
| 301 | # Grub must be configured manually.
|
---|
[14eaa9f] | 302 | # Handle fstab creation.
|
---|
[877cc6a] | 303 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 304 | case ${this_script} in
|
---|
| 305 | *grub) continue ;;
|
---|
[045b2dc] | 306 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[877cc6a] | 307 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 308 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
| 309 | esac
|
---|
| 310 |
|
---|
| 311 | # First append each name of the script files to a list (this will become
|
---|
| 312 | # the names of the targets in the Makefile
|
---|
[14eaa9f] | 313 | chapter78="$chapter78 ${this_script}"
|
---|
[877cc6a] | 314 |
|
---|
| 315 | #--------------------------------------------------------------------#
|
---|
| 316 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 317 | #--------------------------------------------------------------------#
|
---|
| 318 | #
|
---|
| 319 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 320 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 321 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 322 |
|
---|
| 323 | # Find the bootscripts and kernel package names
|
---|
| 324 | case "${this_script}" in
|
---|
| 325 | *bootscripts)
|
---|
[a160d86] | 326 | name="lfs-bootscripts"
|
---|
| 327 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[93346ee] | 328 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 329 | CHROOT_wrt_TouchTimestamp
|
---|
| 330 | fi
|
---|
[81fca31] | 331 | CHROOT_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 332 | ;;
|
---|
| 333 | *kernel)
|
---|
[a160d86] | 334 | name="linux"
|
---|
| 335 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[93346ee] | 336 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 337 | CHROOT_wrt_TouchTimestamp
|
---|
| 338 | fi
|
---|
[81fca31] | 339 | CHROOT_Unpack "$pkg_tarball"
|
---|
[877cc6a] | 340 | ;;
|
---|
| 341 | esac
|
---|
| 342 |
|
---|
| 343 | # Check if we have a real /etc/fstab file
|
---|
| 344 | case "${this_script}" in
|
---|
| 345 | *fstab) if [[ -n $FSTAB ]]; then
|
---|
[045b2dc] | 346 | CHROOT_wrt_CopyFstab
|
---|
[877cc6a] | 347 | else
|
---|
[045b2dc] | 348 | CHROOT_wrt_RunAsRoot "$file"
|
---|
[877cc6a] | 349 | fi
|
---|
| 350 | ;;
|
---|
[045b2dc] | 351 | *) CHROOT_wrt_RunAsRoot "$file"
|
---|
[877cc6a] | 352 | ;;
|
---|
| 353 | esac
|
---|
| 354 |
|
---|
| 355 | case "${this_script}" in
|
---|
[93346ee] | 356 | *bootscripts) CHROOT_wrt_RemoveBuildDirs "dummy"
|
---|
| 357 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 358 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 359 | fi ;;
|
---|
| 360 | *kernel) CHROOT_wrt_RemoveBuildDirs "dummy"
|
---|
| 361 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 362 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 363 | fi ;;
|
---|
[877cc6a] | 364 | esac
|
---|
| 365 |
|
---|
| 366 | # Include a touch of the target name so make can check
|
---|
| 367 | # if it's already been made.
|
---|
[e2ef100] | 368 | wrt_touch
|
---|
[877cc6a] | 369 | #
|
---|
| 370 | #--------------------------------------------------------------------#
|
---|
| 371 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 372 | #--------------------------------------------------------------------#
|
---|
| 373 |
|
---|
| 374 | # Keep the script file name for Makefile dependencies.
|
---|
| 375 | PREV=${this_script}
|
---|
[14eaa9f] | 376 | done # for file in chapter0{7,8}/*
|
---|
[453bef0] | 377 |
|
---|
[877cc6a] | 378 | }
|
---|
| 379 |
|
---|
| 380 |
|
---|
[045b2dc] | 381 |
|
---|
[877cc6a] | 382 | #----------------------------#
|
---|
[045b2dc] | 383 | build_Makefile() { #
|
---|
[877cc6a] | 384 | #----------------------------#
|
---|
[045b2dc] | 385 |
|
---|
[c7c5a53] | 386 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[045b2dc] | 387 |
|
---|
[877cc6a] | 388 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 389 |
|
---|
| 390 | # Start with a clean Makefile.tmp file
|
---|
[045b2dc] | 391 | >$MKFILE
|
---|
[877cc6a] | 392 |
|
---|
| 393 | chapter4_Makefiles
|
---|
| 394 | chapter5_Makefiles
|
---|
| 395 | chapter6_Makefiles
|
---|
[45f82718] | 396 | # Add the iterations targets, if needed
|
---|
[401f81e] | 397 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
[14eaa9f] | 398 | chapter78_Makefiles
|
---|
[3e7ceed] | 399 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 400 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
[045b2dc] | 401 | # Add the BLFS_TOOL targets, if needed
|
---|
| 402 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
[877cc6a] | 403 |
|
---|
| 404 | # Add a header, some variables and include the function file
|
---|
| 405 | # to the top of the real Makefile.
|
---|
[195ed9f] | 406 | wrt_Makefile_header
|
---|
[877cc6a] | 407 |
|
---|
| 408 | # Add chroot commands
|
---|
[6ad5a2f] | 409 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
[877cc6a] | 410 | i=1
|
---|
| 411 | for file in chapter06/*chroot* ; do
|
---|
[6ad5a2f] | 412 | chroot=`cat $file | \
|
---|
| 413 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
[d3802b1] | 414 | -e '/#!\/bin\/bash/d' \
|
---|
[6ad5a2f] | 415 | -e 's@ \\\@ @g' | \
|
---|
| 416 | tr -d '\n' | \
|
---|
| 417 | sed -e 's/ */ /g' \
|
---|
| 418 | -e 's|\\$|&&|g' \
|
---|
| 419 | -e 's|exit||g' \
|
---|
| 420 | -e 's|$| -c|' \
|
---|
| 421 | -e 's|"$$LFS"|$(MOUNT_PT)|' \
|
---|
[f3a7f3b] | 422 | -e 's|set -e||' \
|
---|
| 423 | -e 's|set +h||'`
|
---|
[877cc6a] | 424 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 425 | i=`expr $i + 1`
|
---|
| 426 | done
|
---|
| 427 |
|
---|
| 428 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 429 | # as a dependency.
|
---|
| 430 | (
|
---|
| 431 | cat << EOF
|
---|
[045b2dc] | 432 |
|
---|
[3e7ceed] | 433 | all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
[045b2dc] | 434 | @sudo make do_housekeeping
|
---|
[ac35c8e] | 435 | @echo "$VERSION - jhalfs build" > lfs-release && \\
|
---|
| 436 | sudo mv lfs-release \$(MOUNT_PT)/etc
|
---|
[877cc6a] | 437 | @\$(call echo_finished,$VERSION)
|
---|
| 438 |
|
---|
[045b2dc] | 439 | ck_UID:
|
---|
| 440 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 441 | echo "--------------------------------------------------"; \\
|
---|
| 442 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 443 | echo "--------------------------------------------------"; \\
|
---|
| 444 | exit 1; \\
|
---|
| 445 | fi
|
---|
| 446 |
|
---|
[7c17066] | 447 | ck_LFS:
|
---|
| 448 | @if [ \`echo \$(LFS)\`x = "x" ]; then \\
|
---|
| 449 | echo "--------------------------------------------------"; \\
|
---|
| 450 | echo "Enviroment variable LFS must be set"; \\
|
---|
| 451 | echo "--------------------------------------------------"; \\
|
---|
| 452 | exit 1; \
|
---|
| 453 | fi
|
---|
| 454 |
|
---|
[045b2dc] | 455 | mk_SETUP:
|
---|
| 456 | @\$(call echo_SU_request)
|
---|
[dbcdfd7] | 457 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[045b2dc] | 458 | @touch \$@
|
---|
| 459 |
|
---|
| 460 | mk_LUSER: mk_SETUP
|
---|
| 461 | @\$(call echo_SULUSER_request)
|
---|
[dbcdfd7] | 462 | @( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
[045b2dc] | 463 | @sudo make restore-luser-env
|
---|
| 464 | @touch \$@
|
---|
| 465 |
|
---|
| 466 | mk_SUDO: mk_LUSER
|
---|
[dbcdfd7] | 467 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
[1330ebc] | 468 | @touch \$@
|
---|
| 469 |
|
---|
[045b2dc] | 470 | mk_CHROOT: mk_SUDO
|
---|
| 471 | @\$(call echo_CHROOT_request)
|
---|
[dbcdfd7] | 472 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
[045b2dc] | 473 | @touch \$@
|
---|
[877cc6a] | 474 |
|
---|
[045b2dc] | 475 | mk_BOOT: mk_CHROOT
|
---|
| 476 | @\$(call echo_CHROOT_request)
|
---|
[dbcdfd7] | 477 | @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
[045b2dc] | 478 | @touch \$@
|
---|
[877cc6a] | 479 |
|
---|
[3e7ceed] | 480 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
| 481 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 482 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
[3e7ceed] | 483 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
[dbcdfd7] | 484 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
[3e7ceed] | 485 | fi;
|
---|
| 486 | @touch \$@
|
---|
| 487 |
|
---|
| 488 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
[1838bc7] | 489 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 490 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
[1838bc7] | 491 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
[dbcdfd7] | 492 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
---|
[1838bc7] | 493 | fi;
|
---|
| 494 | @touch \$@
|
---|
[877cc6a] | 495 |
|
---|
[7c17066] | 496 | devices: ck_LFS ck_UID
|
---|
| 497 | sudo mount -v --bind /dev \$(LFS)/dev
|
---|
| 498 | sudo mount -vt devpts devpts \$(LFS)/dev/pts
|
---|
| 499 | sudo mount -vt tmpfs shm \$(LFS)/dev/shm
|
---|
| 500 | sudo mount -vt proc proc \$(LFS)/proc
|
---|
| 501 | sudo mount -vt sysfs sysfs \$(LFS)/sys
|
---|
| 502 |
|
---|
| 503 | teardown: ck_LFS
|
---|
| 504 | sudo umount -v \$(LFS)/sys
|
---|
| 505 | sudo umount -v \$(LFS)/proc
|
---|
| 506 | sudo umount -v \$(LFS)/dev/shm
|
---|
| 507 | sudo umount -v \$(LFS)/dev/pts
|
---|
| 508 | sudo umount -v \$(LFS)/dev
|
---|
| 509 |
|
---|
| 510 | chroot: devices
|
---|
| 511 | sudo /usr/sbin/chroot \$(LFS) /tools/bin/env -i \\
|
---|
| 512 | HOME=/root TERM=\$(TERM) PS1='\\u:\\w\\\$\$ ' \\
|
---|
| 513 | PATH=/bin:/usr/bin:/sbin:/usr/sbin \\
|
---|
| 514 | /tools/bin/bash --login
|
---|
| 515 | \$(MAKE) teardown
|
---|
[877cc6a] | 516 |
|
---|
[3e7ceed] | 517 | SETUP: $chapter4
|
---|
| 518 | LUSER: $chapter5
|
---|
| 519 | SUDO: $runasroot
|
---|
[aec4483] | 520 | CHROOT: SHELL=/tools/bin/bash
|
---|
[3e7ceed] | 521 | CHROOT: $chapter6
|
---|
| 522 | BOOT: $chapter78
|
---|
| 523 | CUSTOM_TOOLS: $custom_list
|
---|
| 524 | BLFS_TOOL: $blfs_tool
|
---|
[fe24ca6] | 525 |
|
---|
[045b2dc] | 526 |
|
---|
[1838bc7] | 527 | create-sbu_du-report: mk_BOOT
|
---|
| 528 | @\$(call echo_message, Building)
|
---|
| 529 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
| 530 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
| 531 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
| 532 | fi;
|
---|
| 533 | @touch \$@
|
---|
[045b2dc] | 534 |
|
---|
[6ad5a2f] | 535 | restore-luser-env:
|
---|
[877cc6a] | 536 | @\$(call echo_message, Building)
|
---|
[962793a] | 537 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 538 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
[877cc6a] | 539 | fi;
|
---|
[962793a] | 540 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
| 541 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
[877cc6a] | 542 | fi;
|
---|
[962793a] | 543 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
|
---|
[dbcdfd7] | 544 | @\$(call housekeeping)
|
---|
[a858a78] | 545 |
|
---|
[7d9a82d] | 546 | do_housekeeping:
|
---|
[4524fb2] | 547 | @-umount \$(MOUNT_PT)/sys
|
---|
| 548 | @-umount \$(MOUNT_PT)/proc
|
---|
| 549 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
| 550 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
| 551 | @-umount \$(MOUNT_PT)/dev
|
---|
[045b2dc] | 552 | @-rm /tools
|
---|
[6ad5a2f] | 553 | @-if [ ! -f luser-exist ]; then \\
|
---|
| 554 | userdel \$(LUSER); \\
|
---|
[962793a] | 555 | rm -rf \$(LUSER_HOME); \\
|
---|
[7d9a82d] | 556 | fi;
|
---|
[a858a78] | 557 |
|
---|
[fe24ca6] | 558 |
|
---|
[877cc6a] | 559 | EOF
|
---|
| 560 | ) >> $MKFILE
|
---|
| 561 |
|
---|
| 562 | # Bring over the items from the Makefile.tmp
|
---|
| 563 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 564 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 565 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 566 | }
|
---|