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