[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
|
---|
[93346ee] | 235 | # Touch timestamp file if inelalled files logs will be created.
|
---|
| 236 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 237 | CHROOT_wrt_TouchTimestamp
|
---|
| 238 | fi
|
---|
[045b2dc] | 239 | CHROOT_Unpack "$pkg_tarball"
|
---|
[a229600] | 240 | # If the testsuites must be run, initialize the log file
|
---|
| 241 | case $name in
|
---|
| 242 | binutils | gcc | glibc )
|
---|
[10c8b78] | 243 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 244 | ;;
|
---|
| 245 | * )
|
---|
[10c8b78] | 246 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[a229600] | 247 | ;;
|
---|
| 248 | esac
|
---|
| 249 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 250 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 251 | fi
|
---|
| 252 |
|
---|
| 253 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 254 | # and not to use chroot.
|
---|
| 255 | case "${this_script}" in
|
---|
[8f2c086] | 256 | *kernfs) wrt_RunAsRoot "$file" ;;
|
---|
[045b2dc] | 257 | *) CHROOT_wrt_RunAsRoot "$file" ;;
|
---|
[877cc6a] | 258 | esac
|
---|
| 259 |
|
---|
[93346ee] | 260 | # Write installed files log and remove the build directory(ies)
|
---|
| 261 | # except if the package build fails.
|
---|
[a160d86] | 262 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[045b2dc] | 263 | CHROOT_wrt_RemoveBuildDirs "$name"
|
---|
[93346ee] | 264 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 265 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 266 | fi
|
---|
[877cc6a] | 267 | fi
|
---|
| 268 |
|
---|
| 269 | # Include a touch of the target name so make can check
|
---|
| 270 | # if it's already been made.
|
---|
[e2ef100] | 271 | wrt_touch
|
---|
[877cc6a] | 272 | #
|
---|
| 273 | #--------------------------------------------------------------------#
|
---|
| 274 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 275 | #--------------------------------------------------------------------#
|
---|
| 276 |
|
---|
| 277 | # Keep the script file name for Makefile dependencies.
|
---|
[10c8b78] | 278 | PREV=${this_script}
|
---|
[45f82718] | 279 | # Set system_build envar for iteration targets
|
---|
| 280 | system_build=$chapter6
|
---|
[877cc6a] | 281 | done # end for file in chapter06/*
|
---|
| 282 | }
|
---|
| 283 |
|
---|
| 284 | #----------------------------#
|
---|
[14eaa9f] | 285 | chapter78_Makefiles() {
|
---|
[877cc6a] | 286 | #----------------------------#
|
---|
[b11c10b] | 287 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
---|
[877cc6a] | 288 |
|
---|
[14eaa9f] | 289 | for file in chapter0{7,8}/* ; do
|
---|
[877cc6a] | 290 | # Keep the script file name
|
---|
| 291 | this_script=`basename $file`
|
---|
| 292 |
|
---|
| 293 | # Grub must be configured manually.
|
---|
[14eaa9f] | 294 | # Handle fstab creation.
|
---|
[877cc6a] | 295 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 296 | case ${this_script} in
|
---|
| 297 | *grub) continue ;;
|
---|
[045b2dc] | 298 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[877cc6a] | 299 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 300 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
| 301 | esac
|
---|
| 302 |
|
---|
| 303 | # First append each name of the script files to a list (this will become
|
---|
| 304 | # the names of the targets in the Makefile
|
---|
[14eaa9f] | 305 | chapter78="$chapter78 ${this_script}"
|
---|
[877cc6a] | 306 |
|
---|
| 307 | #--------------------------------------------------------------------#
|
---|
| 308 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 309 | #--------------------------------------------------------------------#
|
---|
| 310 | #
|
---|
| 311 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 312 | # as a dependency. Also call the echo_message function.
|
---|
[045b2dc] | 313 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[877cc6a] | 314 |
|
---|
| 315 | # Find the bootscripts and kernel package names
|
---|
| 316 | case "${this_script}" in
|
---|
| 317 | *bootscripts)
|
---|
[a160d86] | 318 | name="lfs-bootscripts"
|
---|
| 319 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[045b2dc] | 320 | CHROOT_Unpack "$pkg_tarball"
|
---|
[93346ee] | 321 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 322 | CHROOT_wrt_TouchTimestamp
|
---|
| 323 | fi
|
---|
[877cc6a] | 324 | ;;
|
---|
| 325 | *kernel)
|
---|
[a160d86] | 326 | name="linux"
|
---|
| 327 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[045b2dc] | 328 | CHROOT_Unpack "$pkg_tarball"
|
---|
[93346ee] | 329 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 330 | CHROOT_wrt_TouchTimestamp
|
---|
| 331 | fi
|
---|
[877cc6a] | 332 | ;;
|
---|
| 333 | esac
|
---|
| 334 |
|
---|
| 335 | # Check if we have a real /etc/fstab file
|
---|
| 336 | case "${this_script}" in
|
---|
| 337 | *fstab) if [[ -n $FSTAB ]]; then
|
---|
[045b2dc] | 338 | CHROOT_wrt_CopyFstab
|
---|
[877cc6a] | 339 | else
|
---|
[045b2dc] | 340 | CHROOT_wrt_RunAsRoot "$file"
|
---|
[877cc6a] | 341 | fi
|
---|
| 342 | ;;
|
---|
[045b2dc] | 343 | *) CHROOT_wrt_RunAsRoot "$file"
|
---|
[877cc6a] | 344 | ;;
|
---|
| 345 | esac
|
---|
| 346 |
|
---|
| 347 | case "${this_script}" in
|
---|
[93346ee] | 348 | *bootscripts) CHROOT_wrt_RemoveBuildDirs "dummy"
|
---|
| 349 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 350 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 351 | fi ;;
|
---|
| 352 | *kernel) CHROOT_wrt_RemoveBuildDirs "dummy"
|
---|
| 353 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 354 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 355 | fi ;;
|
---|
[877cc6a] | 356 | esac
|
---|
| 357 |
|
---|
| 358 | # Include a touch of the target name so make can check
|
---|
| 359 | # if it's already been made.
|
---|
[e2ef100] | 360 | wrt_touch
|
---|
[877cc6a] | 361 | #
|
---|
| 362 | #--------------------------------------------------------------------#
|
---|
| 363 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 364 | #--------------------------------------------------------------------#
|
---|
| 365 |
|
---|
| 366 | # Keep the script file name for Makefile dependencies.
|
---|
| 367 | PREV=${this_script}
|
---|
[14eaa9f] | 368 | done # for file in chapter0{7,8}/*
|
---|
[453bef0] | 369 |
|
---|
[877cc6a] | 370 | }
|
---|
| 371 |
|
---|
| 372 |
|
---|
[045b2dc] | 373 |
|
---|
[877cc6a] | 374 | #----------------------------#
|
---|
[045b2dc] | 375 | build_Makefile() { #
|
---|
[877cc6a] | 376 | #----------------------------#
|
---|
[045b2dc] | 377 |
|
---|
[c7c5a53] | 378 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[045b2dc] | 379 |
|
---|
[877cc6a] | 380 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 381 |
|
---|
| 382 | # Start with a clean Makefile.tmp file
|
---|
[045b2dc] | 383 | >$MKFILE
|
---|
[877cc6a] | 384 |
|
---|
| 385 | chapter4_Makefiles
|
---|
| 386 | chapter5_Makefiles
|
---|
| 387 | chapter6_Makefiles
|
---|
[45f82718] | 388 | # Add the iterations targets, if needed
|
---|
[401f81e] | 389 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
[14eaa9f] | 390 | chapter78_Makefiles
|
---|
[3e7ceed] | 391 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 392 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
[045b2dc] | 393 | # Add the BLFS_TOOL targets, if needed
|
---|
| 394 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
[877cc6a] | 395 |
|
---|
| 396 | # Add a header, some variables and include the function file
|
---|
| 397 | # to the top of the real Makefile.
|
---|
[195ed9f] | 398 | wrt_Makefile_header
|
---|
[877cc6a] | 399 |
|
---|
| 400 | # Add chroot commands
|
---|
[6ad5a2f] | 401 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
[877cc6a] | 402 | i=1
|
---|
| 403 | for file in chapter06/*chroot* ; do
|
---|
[6ad5a2f] | 404 | chroot=`cat $file | \
|
---|
| 405 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
[d3802b1] | 406 | -e '/#!\/bin\/bash/d' \
|
---|
[6ad5a2f] | 407 | -e 's@ \\\@ @g' | \
|
---|
| 408 | tr -d '\n' | \
|
---|
| 409 | sed -e 's/ */ /g' \
|
---|
| 410 | -e 's|\\$|&&|g' \
|
---|
| 411 | -e 's|exit||g' \
|
---|
| 412 | -e 's|$| -c|' \
|
---|
| 413 | -e 's|"$$LFS"|$(MOUNT_PT)|' \
|
---|
[f3a7f3b] | 414 | -e 's|set -e||' \
|
---|
| 415 | -e 's|set +h||'`
|
---|
[877cc6a] | 416 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 417 | i=`expr $i + 1`
|
---|
| 418 | done
|
---|
| 419 |
|
---|
| 420 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 421 | # as a dependency.
|
---|
| 422 | (
|
---|
| 423 | cat << EOF
|
---|
[045b2dc] | 424 |
|
---|
[3e7ceed] | 425 | all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
[045b2dc] | 426 | @sudo make do_housekeeping
|
---|
[ac35c8e] | 427 | @echo "$VERSION - jhalfs build" > lfs-release && \\
|
---|
| 428 | sudo mv lfs-release \$(MOUNT_PT)/etc
|
---|
[877cc6a] | 429 | @\$(call echo_finished,$VERSION)
|
---|
| 430 |
|
---|
[045b2dc] | 431 | ck_UID:
|
---|
| 432 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 433 | echo "--------------------------------------------------"; \\
|
---|
| 434 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 435 | echo "--------------------------------------------------"; \\
|
---|
| 436 | exit 1; \\
|
---|
| 437 | fi
|
---|
| 438 |
|
---|
| 439 | mk_SETUP:
|
---|
| 440 | @\$(call echo_SU_request)
|
---|
[dbcdfd7] | 441 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[045b2dc] | 442 | @touch \$@
|
---|
| 443 |
|
---|
| 444 | mk_LUSER: mk_SETUP
|
---|
| 445 | @\$(call echo_SULUSER_request)
|
---|
[dbcdfd7] | 446 | @( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
[045b2dc] | 447 | @sudo make restore-luser-env
|
---|
| 448 | @touch \$@
|
---|
| 449 |
|
---|
| 450 | mk_SUDO: mk_LUSER
|
---|
[dbcdfd7] | 451 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
[1330ebc] | 452 | @touch \$@
|
---|
| 453 |
|
---|
[045b2dc] | 454 | mk_CHROOT: mk_SUDO
|
---|
| 455 | @\$(call echo_CHROOT_request)
|
---|
[dbcdfd7] | 456 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
[045b2dc] | 457 | @touch \$@
|
---|
[877cc6a] | 458 |
|
---|
[045b2dc] | 459 | mk_BOOT: mk_CHROOT
|
---|
| 460 | @\$(call echo_CHROOT_request)
|
---|
[dbcdfd7] | 461 | @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
[045b2dc] | 462 | @touch \$@
|
---|
[877cc6a] | 463 |
|
---|
[3e7ceed] | 464 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
| 465 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 466 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
[3e7ceed] | 467 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
[dbcdfd7] | 468 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
[3e7ceed] | 469 | fi;
|
---|
| 470 | @touch \$@
|
---|
| 471 |
|
---|
| 472 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
[1838bc7] | 473 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 474 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
[1838bc7] | 475 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
[dbcdfd7] | 476 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
---|
[1838bc7] | 477 | fi;
|
---|
| 478 | @touch \$@
|
---|
[877cc6a] | 479 |
|
---|
| 480 |
|
---|
[3e7ceed] | 481 | SETUP: $chapter4
|
---|
| 482 | LUSER: $chapter5
|
---|
| 483 | SUDO: $runasroot
|
---|
[aec4483] | 484 | CHROOT: SHELL=/tools/bin/bash
|
---|
[3e7ceed] | 485 | CHROOT: $chapter6
|
---|
| 486 | BOOT: $chapter78
|
---|
| 487 | CUSTOM_TOOLS: $custom_list
|
---|
| 488 | BLFS_TOOL: $blfs_tool
|
---|
[fe24ca6] | 489 |
|
---|
[045b2dc] | 490 |
|
---|
[1838bc7] | 491 | create-sbu_du-report: mk_BOOT
|
---|
| 492 | @\$(call echo_message, Building)
|
---|
| 493 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
| 494 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
| 495 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
| 496 | fi;
|
---|
| 497 | @touch \$@
|
---|
[045b2dc] | 498 |
|
---|
[6ad5a2f] | 499 | restore-luser-env:
|
---|
[877cc6a] | 500 | @\$(call echo_message, Building)
|
---|
[962793a] | 501 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 502 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
[877cc6a] | 503 | fi;
|
---|
[962793a] | 504 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
| 505 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
[877cc6a] | 506 | fi;
|
---|
[962793a] | 507 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
|
---|
[dbcdfd7] | 508 | @\$(call housekeeping)
|
---|
[a858a78] | 509 |
|
---|
[7d9a82d] | 510 | do_housekeeping:
|
---|
[4524fb2] | 511 | @-umount \$(MOUNT_PT)/sys
|
---|
| 512 | @-umount \$(MOUNT_PT)/proc
|
---|
| 513 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
| 514 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
| 515 | @-umount \$(MOUNT_PT)/dev
|
---|
[045b2dc] | 516 | @-rm /tools
|
---|
[6ad5a2f] | 517 | @-if [ ! -f luser-exist ]; then \\
|
---|
| 518 | userdel \$(LUSER); \\
|
---|
[962793a] | 519 | rm -rf \$(LUSER_HOME); \\
|
---|
[7d9a82d] | 520 | fi;
|
---|
[a858a78] | 521 |
|
---|
[fe24ca6] | 522 |
|
---|
[877cc6a] | 523 | EOF
|
---|
| 524 | ) >> $MKFILE
|
---|
| 525 |
|
---|
| 526 | # Bring over the items from the Makefile.tmp
|
---|
| 527 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 528 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 529 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 530 | }
|
---|