[9c9775f] | 1 | #!/bin/bash
|
---|
[0170229] | 2 |
|
---|
[a46ada0] | 3 | # $Id$
|
---|
[0170229] | 4 |
|
---|
| 5 | ###################################
|
---|
| 6 | ### FUNCTIONS ###
|
---|
| 7 | ###################################
|
---|
| 8 |
|
---|
| 9 |
|
---|
[50fb011] | 10 | #############################################################
|
---|
| 11 |
|
---|
| 12 |
|
---|
[0170229] | 13 | #----------------------------#
|
---|
[50fb011] | 14 | chapter4_Makefiles() { #
|
---|
[0170229] | 15 | #----------------------------#
|
---|
[50fb011] | 16 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${R_arrow}"
|
---|
[0170229] | 17 |
|
---|
[9c9775f] | 18 | # If $LUSER_HOME is already present in the host, we asume that the
|
---|
[0170229] | 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)
|
---|
[9199a13] | 25 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
| 26 | rm -f /tools && \\
|
---|
[9c9775f] | 27 | ln -s \$(MOUNT_PT)/tools /
|
---|
| 28 | @\$(call housekeeping)
|
---|
[0170229] | 29 |
|
---|
| 30 | 021-addinguser: 020-creatingtoolsdir
|
---|
| 31 | @\$(call echo_message, Building)
|
---|
[9c9775f] | 32 | @if [ ! -d \$(LUSER_HOME) ]; then \\
|
---|
[9485eba] | 33 | groupadd \$(LGROUP); \\
|
---|
| 34 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
[0170229] | 35 | else \\
|
---|
[30737ea8] | 36 | touch luser-exist; \\
|
---|
[0170229] | 37 | fi;
|
---|
[9485eba] | 38 | @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
---|
[9c9775f] | 39 | chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
| 40 | chmod a+wt \$(SRCSDIR)
|
---|
| 41 | @\$(call housekeeping)
|
---|
[0170229] | 42 |
|
---|
| 43 | 022-settingenvironment: 021-addinguser
|
---|
| 44 | @\$(call echo_message, Building)
|
---|
[9c9775f] | 45 | @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 46 | mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
---|
[0170229] | 47 | fi;
|
---|
[9c9775f] | 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; \\
|
---|
[0170229] | 50 | fi;
|
---|
[9c9775f] | 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 && \\
|
---|
[0170229] | 59 | touch envars && \\
|
---|
[9c9775f] | 60 | chown \$(LUSER) envars
|
---|
| 61 | @\$(call housekeeping)
|
---|
[0170229] | 62 | EOF
|
---|
[50fb011] | 63 | ) > $MKFILE.tmp
|
---|
| 64 |
|
---|
| 65 | chapter4=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
|
---|
[0170229] | 66 | }
|
---|
| 67 |
|
---|
[50fb011] | 68 |
|
---|
| 69 |
|
---|
[0170229] | 70 | #----------------------------#
|
---|
| 71 | chapter5_Makefiles() {
|
---|
| 72 | #----------------------------#
|
---|
[50fb011] | 73 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
|
---|
[12a5707] | 74 |
|
---|
[0170229] | 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
|
---|
[fed9756] | 80 | # Fix also locales creation when running chapter05 testsuites (ugly)
|
---|
[af4c7b1] | 81 | case "${this_script}" in
|
---|
| 82 | *tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 83 | *expect) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
| 84 | *dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
[47fddc8] | 85 | *stripping) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[fed9756] | 86 | *glibc) [[ "${TEST}" = "3" ]] && \
|
---|
| 87 | sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
---|
[af4c7b1] | 88 | esac
|
---|
[6b1576a] | 89 |
|
---|
[0170229] | 90 | # First append each name of the script files to a list (this will become
|
---|
| 91 | # the names of the targets in the Makefile
|
---|
[9c9775f] | 92 | # DO NOT append the changingowner script, it need be run as root.
|
---|
[50fb011] | 93 | # A hack is necessary: create script in chap5 BUT run as a dependency for
|
---|
[9c9775f] | 94 | # SUDO target
|
---|
[50fb011] | 95 | case "${this_script}" in
|
---|
[9c9775f] | 96 | *changingowner) runasroot="$runasroot ${this_script}" ;;
|
---|
[50fb011] | 97 | *) chapter5="$chapter5 ${this_script}" ;;
|
---|
| 98 | esac
|
---|
[0170229] | 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 |
|
---|
[3f858ca] | 107 | #--------------------------------------------------------------------#
|
---|
| 108 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 109 | #--------------------------------------------------------------------#
|
---|
| 110 | #
|
---|
[0170229] | 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.
|
---|
[50fb011] | 113 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[0170229] | 114 |
|
---|
| 115 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 116 | # a specific package
|
---|
[3b63c8c] | 117 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[0170229] | 118 |
|
---|
[3b63c8c] | 119 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 120 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[3f858ca] | 121 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
[50fb011] | 122 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[e35e794] | 123 | # If the testsuites must be run, initialize the log file
|
---|
[50fb011] | 124 | [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}"
|
---|
[e35e794] | 125 | # If using optimizations, write the instructions
|
---|
[c205656] | 126 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[0170229] | 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.
|
---|
[fed9756] | 131 | # The changingowner script must be run as root.
|
---|
| 132 | case "${this_script}" in
|
---|
[9c9775f] | 133 | *changingowner) wrt_RunAsRoot "$file" ;;
|
---|
[50fb011] | 134 | *) LUSER_wrt_RunAsUser "$file" ;;
|
---|
[fed9756] | 135 | esac
|
---|
[0170229] | 136 |
|
---|
| 137 | # Remove the build directory(ies) except if the package build fails
|
---|
| 138 | # (so we can review config.cache, config.log, etc.)
|
---|
[3b63c8c] | 139 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[50fb011] | 140 | LUSER_RemoveBuildDirs "$name"
|
---|
[0170229] | 141 | fi
|
---|
| 142 |
|
---|
| 143 | # Include a touch of the target name so make can check
|
---|
| 144 | # if it's already been made.
|
---|
[9199a13] | 145 | wrt_touch
|
---|
[3f858ca] | 146 | #
|
---|
| 147 | #--------------------------------------------------------------------#
|
---|
| 148 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 149 | #--------------------------------------------------------------------#
|
---|
[0170229] | 150 |
|
---|
| 151 | # Keep the script file name for Makefile dependencies.
|
---|
| 152 | PREV=${this_script}
|
---|
| 153 | done # end for file in chapter05/*
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[50fb011] | 156 |
|
---|
[0170229] | 157 | #----------------------------#
|
---|
| 158 | chapter6_Makefiles() {
|
---|
| 159 | #----------------------------#
|
---|
[50fb011] | 160 |
|
---|
[615e37d] | 161 | # Set envars and scripts for iteration targets
|
---|
[b242136] | 162 | if [[ -z "$1" ]] ; then
|
---|
[aa08925] | 163 | local N=""
|
---|
| 164 | else
|
---|
| 165 | local N=-build_$1
|
---|
| 166 | local chapter6=""
|
---|
[615e37d] | 167 | mkdir chapter06$N
|
---|
| 168 | cp chapter06/* chapter06$N
|
---|
| 169 | for script in chapter06$N/* ; do
|
---|
[7aee0dd] | 170 | # Overwrite existing symlinks, files, and dirs
|
---|
[615e37d] | 171 | sed -e 's/ln -sv/&f/g' \
|
---|
| 172 | -e 's/mv -v/&f/g' \
|
---|
[7aee0dd] | 173 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
[9c9775f] | 174 | # Rename the scripts
|
---|
| 175 | mv ${script} ${script}$N
|
---|
[615e37d] | 176 | done
|
---|
[9c9775f] | 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
|
---|
[aa08925] | 179 | fi
|
---|
| 180 |
|
---|
[50fb011] | 181 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
|
---|
[af4c7b1] | 182 |
|
---|
[615e37d] | 183 | for file in chapter06$N/* ; do
|
---|
[0170229] | 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.
|
---|
[9c9775f] | 189 | # Skip also linux-headers in iterative builds.
|
---|
[af4c7b1] | 190 | case "${this_script}" in
|
---|
| 191 | *chroot) continue ;;
|
---|
[47fddc8] | 192 | *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[9c9775f] | 193 | *linux-headers*) [[ -n "$N" ]] && continue ;;
|
---|
[af4c7b1] | 194 | esac
|
---|
[0170229] | 195 |
|
---|
[9c9775f] | 196 | # Grab the name of the target.
|
---|
| 197 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
|
---|
[b242136] | 198 |
|
---|
| 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
|
---|
[3b63c8c] | 202 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[b242136] | 203 |
|
---|
[3b63c8c] | 204 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[b242136] | 205 | case "${this_script}" in
|
---|
| 206 | *stripping*) ;;
|
---|
| 207 | *) continue ;;
|
---|
| 208 | esac
|
---|
| 209 | fi
|
---|
| 210 |
|
---|
[4edbc92] | 211 | # Append each name of the script files to a list (this will become
|
---|
| 212 | # the names of the targets in the Makefile)
|
---|
[9c9775f] | 213 | # The kernfs script must be run as part of SUDO target.
|
---|
| 214 | case "${this_script}" in
|
---|
| 215 | *kernfs) runasroot="$runasroot ${this_script}" ;;
|
---|
| 216 | *) chapter6="$chapter6 ${this_script}" ;;
|
---|
| 217 | esac
|
---|
[4edbc92] | 218 |
|
---|
[3f858ca] | 219 | #--------------------------------------------------------------------#
|
---|
| 220 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 221 | #--------------------------------------------------------------------#
|
---|
| 222 | #
|
---|
[0170229] | 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.
|
---|
[9c9775f] | 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" ;;
|
---|
| 229 | *) CHROOT_wrt_target "${this_script}" "$PREV" ;;
|
---|
| 230 | esac
|
---|
[0170229] | 231 |
|
---|
[3b63c8c] | 232 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[0170229] | 233 | # Insert instructions for unpacking the package and changing directories
|
---|
[3b63c8c] | 234 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[9c9775f] | 235 | # Touch timestamp file if installed files logs will be created.
|
---|
| 236 | # But only for the firt build when running iterative builds.
|
---|
| 237 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
| 238 | CHROOT_wrt_TouchTimestamp
|
---|
| 239 | fi
|
---|
[50fb011] | 240 | CHROOT_Unpack "$pkg_tarball"
|
---|
[e35e794] | 241 | # If the testsuites must be run, initialize the log file
|
---|
| 242 | case $name in
|
---|
| 243 | binutils | gcc | glibc )
|
---|
[50fb011] | 244 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[e35e794] | 245 | ;;
|
---|
| 246 | * )
|
---|
[50fb011] | 247 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[e35e794] | 248 | ;;
|
---|
| 249 | esac
|
---|
| 250 | # If using optimizations, write the instructions
|
---|
[c205656] | 251 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[0170229] | 252 | fi
|
---|
| 253 |
|
---|
| 254 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 255 | # and not to use chroot.
|
---|
[af4c7b1] | 256 | case "${this_script}" in
|
---|
[9c9775f] | 257 | *kernfs) wrt_RunAsRoot "$file" ;;
|
---|
[50fb011] | 258 | *) CHROOT_wrt_RunAsRoot "$file" ;;
|
---|
[af4c7b1] | 259 | esac
|
---|
[0170229] | 260 |
|
---|
[9c9775f] | 261 | # Write installed files log and remove the build directory(ies)
|
---|
| 262 | # except if the package build fails.
|
---|
[3b63c8c] | 263 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[50fb011] | 264 | CHROOT_wrt_RemoveBuildDirs "$name"
|
---|
[9c9775f] | 265 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
| 266 | CHROOT_wrt_LogNewFiles "$name"
|
---|
| 267 | fi
|
---|
[0170229] | 268 | fi
|
---|
| 269 |
|
---|
| 270 | # Include a touch of the target name so make can check
|
---|
| 271 | # if it's already been made.
|
---|
[9199a13] | 272 | wrt_touch
|
---|
[3f858ca] | 273 | #
|
---|
| 274 | #--------------------------------------------------------------------#
|
---|
| 275 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 276 | #--------------------------------------------------------------------#
|
---|
[0170229] | 277 |
|
---|
| 278 | # Keep the script file name for Makefile dependencies.
|
---|
[9c9775f] | 279 | PREV=${this_script}
|
---|
[aa08925] | 280 | # Set system_build envar for iteration targets
|
---|
| 281 | system_build=$chapter6
|
---|
[0170229] | 282 | done # end for file in chapter06/*
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | #----------------------------#
|
---|
[9c9775f] | 286 | chapter78_Makefiles() {
|
---|
[0170229] | 287 | #----------------------------#
|
---|
[9c9775f] | 288 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
---|
[af4c7b1] | 289 |
|
---|
[9c9775f] | 290 | for file in chapter0{7,8}/* ; do
|
---|
[0170229] | 291 | # Keep the script file name
|
---|
| 292 | this_script=`basename $file`
|
---|
| 293 |
|
---|
| 294 | # Grub must be configured manually.
|
---|
[9c9775f] | 295 | # Handle fstab creation.
|
---|
[0170229] | 296 | # If no .config file is supplied, the kernel build is skipped
|
---|
[0271c0c] | 297 | case ${this_script} in
|
---|
| 298 | *grub) continue ;;
|
---|
[50fb011] | 299 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[0271c0c] | 300 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 301 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
| 302 | esac
|
---|
[0170229] | 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
|
---|
[9c9775f] | 306 | chapter78="$chapter78 ${this_script}"
|
---|
[0170229] | 307 |
|
---|
[3f858ca] | 308 | #--------------------------------------------------------------------#
|
---|
| 309 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 310 | #--------------------------------------------------------------------#
|
---|
| 311 | #
|
---|
[0170229] | 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.
|
---|
[50fb011] | 314 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[0170229] | 315 |
|
---|
| 316 | # Find the bootscripts and kernel package names
|
---|
[af4c7b1] | 317 | case "${this_script}" in
|
---|
| 318 | *bootscripts)
|
---|
[3b63c8c] | 319 | name="lfs-bootscripts"
|
---|
| 320 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[9c9775f] | 321 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 322 | CHROOT_wrt_TouchTimestamp
|
---|
| 323 | fi
|
---|
[50fb011] | 324 | CHROOT_Unpack "$pkg_tarball"
|
---|
[af4c7b1] | 325 | ;;
|
---|
| 326 | *kernel)
|
---|
[3b63c8c] | 327 | name="linux"
|
---|
| 328 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
[9c9775f] | 329 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 330 | CHROOT_wrt_TouchTimestamp
|
---|
| 331 | fi
|
---|
[50fb011] | 332 | CHROOT_Unpack "$pkg_tarball"
|
---|
[af4c7b1] | 333 | ;;
|
---|
| 334 | esac
|
---|
[6b1576a] | 335 |
|
---|
[0170229] | 336 | # Check if we have a real /etc/fstab file
|
---|
[af4c7b1] | 337 | case "${this_script}" in
|
---|
| 338 | *fstab) if [[ -n $FSTAB ]]; then
|
---|
[50fb011] | 339 | CHROOT_wrt_CopyFstab
|
---|
[af4c7b1] | 340 | else
|
---|
[50fb011] | 341 | CHROOT_wrt_RunAsRoot "$file"
|
---|
[af4c7b1] | 342 | fi
|
---|
| 343 | ;;
|
---|
[50fb011] | 344 | *) CHROOT_wrt_RunAsRoot "$file"
|
---|
[af4c7b1] | 345 | ;;
|
---|
| 346 | esac
|
---|
[0170229] | 347 |
|
---|
[af4c7b1] | 348 | case "${this_script}" in
|
---|
[9c9775f] | 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 ;;
|
---|
[af4c7b1] | 357 | esac
|
---|
[6b1576a] | 358 |
|
---|
[0170229] | 359 | # Include a touch of the target name so make can check
|
---|
| 360 | # if it's already been made.
|
---|
[9199a13] | 361 | wrt_touch
|
---|
[3f858ca] | 362 | #
|
---|
| 363 | #--------------------------------------------------------------------#
|
---|
| 364 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 365 | #--------------------------------------------------------------------#
|
---|
[0170229] | 366 |
|
---|
| 367 | # Keep the script file name for Makefile dependencies.
|
---|
| 368 | PREV=${this_script}
|
---|
[9c9775f] | 369 | done # for file in chapter0{7,8}/*
|
---|
[9e4b9a1] | 370 |
|
---|
[0170229] | 371 | }
|
---|
| 372 |
|
---|
| 373 |
|
---|
[50fb011] | 374 |
|
---|
[0170229] | 375 | #----------------------------#
|
---|
[50fb011] | 376 | build_Makefile() { #
|
---|
[0170229] | 377 | #----------------------------#
|
---|
[50fb011] | 378 |
|
---|
[a702b4d] | 379 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[03b3eba] | 380 |
|
---|
[0170229] | 381 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 382 |
|
---|
| 383 | # Start with a clean Makefile.tmp file
|
---|
[50fb011] | 384 | >$MKFILE
|
---|
[03b3eba] | 385 |
|
---|
[0170229] | 386 | chapter4_Makefiles
|
---|
| 387 | chapter5_Makefiles
|
---|
| 388 | chapter6_Makefiles
|
---|
[4edbc92] | 389 | # Add the iterations targets, if needed
|
---|
[47fddc8] | 390 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
[9c9775f] | 391 | chapter78_Makefiles
|
---|
| 392 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 393 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
[fd7455c] | 394 | # Add the BLFS_TOOL targets, if needed
|
---|
| 395 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
[0170229] | 396 |
|
---|
| 397 | # Add a header, some variables and include the function file
|
---|
| 398 | # to the top of the real Makefile.
|
---|
[9c9775f] | 399 | wrt_Makefile_header
|
---|
[0170229] | 400 |
|
---|
| 401 | # Add chroot commands
|
---|
[8381f6e] | 402 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
[0170229] | 403 | i=1
|
---|
| 404 | for file in chapter06/*chroot* ; do
|
---|
[8381f6e] | 405 | chroot=`cat $file | \
|
---|
| 406 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
[9c9775f] | 407 | -e '/#!\/bin\/bash/d' \
|
---|
[8381f6e] | 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)|' \
|
---|
[9c9775f] | 415 | -e 's|set -e||' \
|
---|
| 416 | -e 's|set +h||'`
|
---|
[0170229] | 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
|
---|
[50fb011] | 425 |
|
---|
[9c9775f] | 426 | all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
[4012541] | 427 | @sudo make do_housekeeping
|
---|
[9c9775f] | 428 | @echo "$VERSION - jhalfs build" > lfs-release && \\
|
---|
| 429 | sudo mv lfs-release \$(MOUNT_PT)/etc
|
---|
[0170229] | 430 | @\$(call echo_finished,$VERSION)
|
---|
| 431 |
|
---|
[7d4cc81] | 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
|
---|
[0167dd8] | 439 |
|
---|
[50fb011] | 440 | mk_SETUP:
|
---|
| 441 | @\$(call echo_SU_request)
|
---|
[9c9775f] | 442 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[50fb011] | 443 | @touch \$@
|
---|
[03b3eba] | 444 |
|
---|
[50fb011] | 445 | mk_LUSER: mk_SETUP
|
---|
| 446 | @\$(call echo_SULUSER_request)
|
---|
[9c9775f] | 447 | @( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
[621f01f] | 448 | @sudo make restore-luser-env
|
---|
[50fb011] | 449 | @touch \$@
|
---|
[7d4cc81] | 450 |
|
---|
| 451 | mk_SUDO: mk_LUSER
|
---|
[9c9775f] | 452 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
| 453 | @touch \$@
|
---|
| 454 |
|
---|
[496f8f3] | 455 | mk_CHROOT: mk_SUDO
|
---|
[50fb011] | 456 | @\$(call echo_CHROOT_request)
|
---|
[9c9775f] | 457 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
[50fb011] | 458 | @touch \$@
|
---|
| 459 |
|
---|
[03b3eba] | 460 | mk_BOOT: mk_CHROOT
|
---|
[50fb011] | 461 | @\$(call echo_CHROOT_request)
|
---|
[9c9775f] | 462 | @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
[50fb011] | 463 | @touch \$@
|
---|
[03b3eba] | 464 |
|
---|
[9c9775f] | 465 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
| 466 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
| 467 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
| 468 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
| 469 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
| 470 | fi;
|
---|
| 471 | @touch \$@
|
---|
[50fb011] | 472 |
|
---|
[9c9775f] | 473 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
| 474 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 475 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
| 476 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
| 477 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
---|
| 478 | fi;
|
---|
| 479 | @touch \$@
|
---|
[50fb011] | 480 |
|
---|
[7d4cc81] | 481 |
|
---|
[9c9775f] | 482 | SETUP: $chapter4
|
---|
| 483 | LUSER: $chapter5
|
---|
| 484 | SUDO: $runasroot
|
---|
| 485 | CHROOT: SHELL=/tools/bin/bash
|
---|
| 486 | CHROOT: $chapter6
|
---|
| 487 | BOOT: $chapter78
|
---|
| 488 | CUSTOM_TOOLS: $custom_list
|
---|
| 489 | BLFS_TOOL: $blfs_tool
|
---|
[50fb011] | 490 |
|
---|
[0170229] | 491 |
|
---|
[9c9775f] | 492 | create-sbu_du-report: mk_BOOT
|
---|
| 493 | @\$(call echo_message, Building)
|
---|
| 494 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
| 495 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
| 496 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
| 497 | fi;
|
---|
| 498 | @touch \$@
|
---|
[0170229] | 499 |
|
---|
[30737ea8] | 500 | restore-luser-env:
|
---|
[0170229] | 501 | @\$(call echo_message, Building)
|
---|
[9c9775f] | 502 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 503 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
[0170229] | 504 | fi;
|
---|
[9c9775f] | 505 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
| 506 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
[0170229] | 507 | fi;
|
---|
[9c9775f] | 508 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
|
---|
| 509 | @\$(call housekeeping)
|
---|
[460ea63] | 510 |
|
---|
[3a27393] | 511 | do_housekeeping:
|
---|
[9199a13] | 512 | @-umount \$(MOUNT_PT)/sys
|
---|
| 513 | @-umount \$(MOUNT_PT)/proc
|
---|
| 514 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
| 515 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
| 516 | @-umount \$(MOUNT_PT)/dev
|
---|
[0167dd8] | 517 | @-rm /tools
|
---|
[30737ea8] | 518 | @-if [ ! -f luser-exist ]; then \\
|
---|
[9485eba] | 519 | userdel \$(LUSER); \\
|
---|
[9c9775f] | 520 | rm -rf \$(LUSER_HOME); \\
|
---|
[3a27393] | 521 | fi;
|
---|
[460ea63] | 522 |
|
---|
[9199a13] | 523 |
|
---|
[42346b2] | 524 | EOF
|
---|
| 525 | ) >> $MKFILE
|
---|
| 526 |
|
---|
[0170229] | 527 | # Bring over the items from the Makefile.tmp
|
---|
| 528 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 529 | rm $MKFILE.tmp
|
---|
[a702b4d] | 530 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 531 | }
|
---|