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