[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
|
---|
[3b6adab] | 23 | 04_02-creatingtoolsdir:
|
---|
[0170229] | 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 |
|
---|
[3b6adab] | 30 | 04_03-addinguser: 020-creatingtoolsdir
|
---|
[0170229] | 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 |
|
---|
[3b6adab] | 43 | 04_04-settingenvironment: 021-addinguser
|
---|
[0170229] | 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 && \\
|
---|
[3b6adab] | 54 | echo "SRCDIR=\$(MOUNT_PT)/sources" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
[9c9775f] | 55 | echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
| 56 | echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
| 57 | echo "export LFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
| 58 | echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
| 59 | chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
|
---|
[0170229] | 60 | touch envars && \\
|
---|
[9c9775f] | 61 | chown \$(LUSER) envars
|
---|
| 62 | @\$(call housekeeping)
|
---|
[0170229] | 63 | EOF
|
---|
[50fb011] | 64 | ) > $MKFILE.tmp
|
---|
| 65 |
|
---|
[3b6adab] | 66 | chapter4=" 04_02-creatingtoolsdir 04_03-addinguser 04_04-settingenvironment"
|
---|
[0170229] | 67 | }
|
---|
| 68 |
|
---|
[50fb011] | 69 |
|
---|
| 70 |
|
---|
[0170229] | 71 | #----------------------------#
|
---|
| 72 | chapter5_Makefiles() {
|
---|
| 73 | #----------------------------#
|
---|
[50fb011] | 74 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
|
---|
[12a5707] | 75 |
|
---|
[0170229] | 76 | for file in chapter05/* ; do
|
---|
| 77 | # Keep the script file name
|
---|
| 78 | this_script=`basename $file`
|
---|
| 79 |
|
---|
| 80 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
[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 ;;
|
---|
[af4c7b1] | 86 | esac
|
---|
[6b1576a] | 87 |
|
---|
[0170229] | 88 | # First append each name of the script files to a list (this will become
|
---|
| 89 | # the names of the targets in the Makefile
|
---|
[9c9775f] | 90 | # DO NOT append the changingowner script, it need be run as root.
|
---|
[50fb011] | 91 | # A hack is necessary: create script in chap5 BUT run as a dependency for
|
---|
[9c9775f] | 92 | # SUDO target
|
---|
[50fb011] | 93 | case "${this_script}" in
|
---|
[9c9775f] | 94 | *changingowner) runasroot="$runasroot ${this_script}" ;;
|
---|
[50fb011] | 95 | *) chapter5="$chapter5 ${this_script}" ;;
|
---|
| 96 | esac
|
---|
[0170229] | 97 |
|
---|
[3b6adab] | 98 | # Grab the package name, if the script is building a package
|
---|
| 99 | name=`grep "^PACKAGE=" ${file} | sed -e 's@PACKAGE=@@'`
|
---|
[0170229] | 100 |
|
---|
| 101 | # Set the dependency for the first target.
|
---|
[3b6adab] | 102 | if [ -z $PREV ] ; then PREV=04_04-settingenvironment ; fi
|
---|
[0170229] | 103 |
|
---|
[3f858ca] | 104 | #--------------------------------------------------------------------#
|
---|
| 105 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 106 | #--------------------------------------------------------------------#
|
---|
| 107 | #
|
---|
[0170229] | 108 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 109 | # as a dependency. Also call the echo_message function.
|
---|
[50fb011] | 110 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[0170229] | 111 |
|
---|
[3b6adab] | 112 | # If $name isn't empty, we've got a package...
|
---|
| 113 | if [ "$name" != "" ] ; then
|
---|
[e35e794] | 114 | # If the testsuites must be run, initialize the log file
|
---|
[50fb011] | 115 | [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}"
|
---|
[e35e794] | 116 | # If using optimizations, write the instructions
|
---|
[c205656] | 117 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[0170229] | 118 | fi
|
---|
| 119 |
|
---|
[3b6adab] | 120 | # Run the script.
|
---|
[fed9756] | 121 | # The changingowner script must be run as root.
|
---|
| 122 | case "${this_script}" in
|
---|
[9c9775f] | 123 | *changingowner) wrt_RunAsRoot "$file" ;;
|
---|
[50fb011] | 124 | *) LUSER_wrt_RunAsUser "$file" ;;
|
---|
[fed9756] | 125 | esac
|
---|
[0170229] | 126 |
|
---|
| 127 | # Include a touch of the target name so make can check
|
---|
| 128 | # if it's already been made.
|
---|
[9199a13] | 129 | wrt_touch
|
---|
[3f858ca] | 130 | #
|
---|
| 131 | #--------------------------------------------------------------------#
|
---|
| 132 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 133 | #--------------------------------------------------------------------#
|
---|
[0170229] | 134 |
|
---|
| 135 | # Keep the script file name for Makefile dependencies.
|
---|
| 136 | PREV=${this_script}
|
---|
| 137 | done # end for file in chapter05/*
|
---|
| 138 | }
|
---|
| 139 |
|
---|
[50fb011] | 140 |
|
---|
[0170229] | 141 | #----------------------------#
|
---|
| 142 | chapter6_Makefiles() {
|
---|
| 143 | #----------------------------#
|
---|
[50fb011] | 144 |
|
---|
[615e37d] | 145 | # Set envars and scripts for iteration targets
|
---|
[b242136] | 146 | if [[ -z "$1" ]] ; then
|
---|
[aa08925] | 147 | local N=""
|
---|
| 148 | else
|
---|
| 149 | local N=-build_$1
|
---|
| 150 | local chapter6=""
|
---|
[615e37d] | 151 | mkdir chapter06$N
|
---|
| 152 | cp chapter06/* chapter06$N
|
---|
| 153 | for script in chapter06$N/* ; do
|
---|
[7aee0dd] | 154 | # Overwrite existing symlinks, files, and dirs
|
---|
[615e37d] | 155 | sed -e 's/ln -sv/&f/g' \
|
---|
| 156 | -e 's/mv -v/&f/g' \
|
---|
[7aee0dd] | 157 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
[9c9775f] | 158 | # Rename the scripts
|
---|
| 159 | mv ${script} ${script}$N
|
---|
[615e37d] | 160 | done
|
---|
[aa08925] | 161 | fi
|
---|
| 162 |
|
---|
[50fb011] | 163 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
|
---|
[af4c7b1] | 164 |
|
---|
[615e37d] | 165 | for file in chapter06$N/* ; do
|
---|
[0170229] | 166 | # Keep the script file name
|
---|
| 167 | this_script=`basename $file`
|
---|
| 168 |
|
---|
| 169 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 170 | # dependencies and target creation.
|
---|
[9c9775f] | 171 | # Skip also linux-headers in iterative builds.
|
---|
[af4c7b1] | 172 | case "${this_script}" in
|
---|
| 173 | *chroot) continue ;;
|
---|
[47fddc8] | 174 | *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[9c9775f] | 175 | *linux-headers*) [[ -n "$N" ]] && continue ;;
|
---|
[af4c7b1] | 176 | esac
|
---|
[0170229] | 177 |
|
---|
[9c9775f] | 178 | # Grab the name of the target.
|
---|
[3b6adab] | 179 | name=`grep "^PACKAGE=" ${file} | sed -e 's@PACKAGE=@@'`
|
---|
[b242136] | 180 |
|
---|
[3b6adab] | 181 | # Skip scripts not needed for iterations rebuilds
|
---|
| 182 | if [[ "$name" = "" ]] && [[ -n "$N" ]] ; then
|
---|
[b242136] | 183 | case "${this_script}" in
|
---|
| 184 | *stripping*) ;;
|
---|
| 185 | *) continue ;;
|
---|
| 186 | esac
|
---|
| 187 | fi
|
---|
| 188 |
|
---|
[4edbc92] | 189 | # Append each name of the script files to a list (this will become
|
---|
| 190 | # the names of the targets in the Makefile)
|
---|
[9c9775f] | 191 | # The kernfs script must be run as part of SUDO target.
|
---|
| 192 | case "${this_script}" in
|
---|
| 193 | *kernfs) runasroot="$runasroot ${this_script}" ;;
|
---|
| 194 | *) chapter6="$chapter6 ${this_script}" ;;
|
---|
| 195 | esac
|
---|
[4edbc92] | 196 |
|
---|
[3f858ca] | 197 | #--------------------------------------------------------------------#
|
---|
| 198 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 199 | #--------------------------------------------------------------------#
|
---|
| 200 | #
|
---|
[0170229] | 201 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 202 | # as a dependency. Also call the echo_message function.
|
---|
[9c9775f] | 203 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 204 | # and not to use chroot.
|
---|
| 205 | case "${this_script}" in
|
---|
| 206 | *kernfs) LUSER_wrt_target "${this_script}" "$PREV" ;;
|
---|
| 207 | *) CHROOT_wrt_target "${this_script}" "$PREV" ;;
|
---|
| 208 | esac
|
---|
[0170229] | 209 |
|
---|
[3b6adab] | 210 | # If $name isn't empty, we've got a package...
|
---|
| 211 | if [ "$name" != "" ] ; then
|
---|
[9c9775f] | 212 | # Touch timestamp file if installed files logs will be created.
|
---|
| 213 | # But only for the firt build when running iterative builds.
|
---|
| 214 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
| 215 | CHROOT_wrt_TouchTimestamp
|
---|
| 216 | fi
|
---|
[e35e794] | 217 | # If the testsuites must be run, initialize the log file
|
---|
| 218 | case $name in
|
---|
| 219 | binutils | gcc | glibc )
|
---|
[50fb011] | 220 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[e35e794] | 221 | ;;
|
---|
| 222 | * )
|
---|
[50fb011] | 223 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
[e35e794] | 224 | ;;
|
---|
| 225 | esac
|
---|
| 226 | # If using optimizations, write the instructions
|
---|
[c205656] | 227 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[0170229] | 228 | fi
|
---|
| 229 |
|
---|
| 230 | # In the mount of kernel filesystems we need to set LFS
|
---|
| 231 | # and not to use chroot.
|
---|
[af4c7b1] | 232 | case "${this_script}" in
|
---|
[9c9775f] | 233 | *kernfs) wrt_RunAsRoot "$file" ;;
|
---|
[50fb011] | 234 | *) CHROOT_wrt_RunAsRoot "$file" ;;
|
---|
[af4c7b1] | 235 | esac
|
---|
[0170229] | 236 |
|
---|
[3b6adab] | 237 | # Write installed files log
|
---|
| 238 | if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
| 239 | CHROOT_wrt_LogNewFiles "$name"
|
---|
[0170229] | 240 | fi
|
---|
| 241 |
|
---|
| 242 | # Include a touch of the target name so make can check
|
---|
| 243 | # if it's already been made.
|
---|
[9199a13] | 244 | wrt_touch
|
---|
[3f858ca] | 245 | #
|
---|
| 246 | #--------------------------------------------------------------------#
|
---|
| 247 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 248 | #--------------------------------------------------------------------#
|
---|
[0170229] | 249 |
|
---|
| 250 | # Keep the script file name for Makefile dependencies.
|
---|
[9c9775f] | 251 | PREV=${this_script}
|
---|
[aa08925] | 252 | # Set system_build envar for iteration targets
|
---|
| 253 | system_build=$chapter6
|
---|
[0170229] | 254 | done # end for file in chapter06/*
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | #----------------------------#
|
---|
[9c9775f] | 258 | chapter78_Makefiles() {
|
---|
[0170229] | 259 | #----------------------------#
|
---|
[9c9775f] | 260 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
---|
[af4c7b1] | 261 |
|
---|
[9c9775f] | 262 | for file in chapter0{7,8}/* ; do
|
---|
[0170229] | 263 | # Keep the script file name
|
---|
| 264 | this_script=`basename $file`
|
---|
| 265 |
|
---|
| 266 | # Grub must be configured manually.
|
---|
[9c9775f] | 267 | # Handle fstab creation.
|
---|
[0170229] | 268 | # If no .config file is supplied, the kernel build is skipped
|
---|
[0271c0c] | 269 | case ${this_script} in
|
---|
| 270 | *grub) continue ;;
|
---|
[50fb011] | 271 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[0271c0c] | 272 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 273 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
| 274 | esac
|
---|
[0170229] | 275 |
|
---|
| 276 | # First append each name of the script files to a list (this will become
|
---|
| 277 | # the names of the targets in the Makefile
|
---|
[9c9775f] | 278 | chapter78="$chapter78 ${this_script}"
|
---|
[0170229] | 279 |
|
---|
[3f858ca] | 280 | #--------------------------------------------------------------------#
|
---|
| 281 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 282 | #--------------------------------------------------------------------#
|
---|
| 283 | #
|
---|
[0170229] | 284 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 285 | # as a dependency. Also call the echo_message function.
|
---|
[50fb011] | 286 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
[0170229] | 287 |
|
---|
[3b6adab] | 288 | # For bootscripts and kernel, start INSTALL_LOG if requested
|
---|
[af4c7b1] | 289 | case "${this_script}" in
|
---|
[3b6adab] | 290 | *bootscripts | *kernel ) if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 291 | CHROOT_wrt_TouchTimestamp
|
---|
| 292 | fi ;;
|
---|
[af4c7b1] | 293 | esac
|
---|
[6b1576a] | 294 |
|
---|
[0170229] | 295 | # Check if we have a real /etc/fstab file
|
---|
[af4c7b1] | 296 | case "${this_script}" in
|
---|
| 297 | *fstab) if [[ -n $FSTAB ]]; then
|
---|
[50fb011] | 298 | CHROOT_wrt_CopyFstab
|
---|
[af4c7b1] | 299 | else
|
---|
[50fb011] | 300 | CHROOT_wrt_RunAsRoot "$file"
|
---|
[af4c7b1] | 301 | fi
|
---|
| 302 | ;;
|
---|
[50fb011] | 303 | *) CHROOT_wrt_RunAsRoot "$file"
|
---|
[af4c7b1] | 304 | ;;
|
---|
| 305 | esac
|
---|
[0170229] | 306 |
|
---|
[af4c7b1] | 307 | case "${this_script}" in
|
---|
[3b6adab] | 308 | *bootscripts) if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 309 | CHROOT_wrt_LogNewFiles "lfs-bootscripts"
|
---|
[9c9775f] | 310 | fi ;;
|
---|
[3b6adab] | 311 | *kernel) if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 312 | CHROOT_wrt_LogNewFiles "linux"
|
---|
[9c9775f] | 313 | fi ;;
|
---|
[af4c7b1] | 314 | esac
|
---|
[6b1576a] | 315 |
|
---|
[0170229] | 316 | # Include a touch of the target name so make can check
|
---|
| 317 | # if it's already been made.
|
---|
[9199a13] | 318 | wrt_touch
|
---|
[3f858ca] | 319 | #
|
---|
| 320 | #--------------------------------------------------------------------#
|
---|
| 321 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 322 | #--------------------------------------------------------------------#
|
---|
[0170229] | 323 |
|
---|
| 324 | # Keep the script file name for Makefile dependencies.
|
---|
| 325 | PREV=${this_script}
|
---|
[9c9775f] | 326 | done # for file in chapter0{7,8}/*
|
---|
[9e4b9a1] | 327 |
|
---|
[0170229] | 328 | }
|
---|
| 329 |
|
---|
| 330 |
|
---|
[50fb011] | 331 |
|
---|
[0170229] | 332 | #----------------------------#
|
---|
[50fb011] | 333 | build_Makefile() { #
|
---|
[0170229] | 334 | #----------------------------#
|
---|
[50fb011] | 335 |
|
---|
[a702b4d] | 336 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[03b3eba] | 337 |
|
---|
[0170229] | 338 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 339 |
|
---|
| 340 | # Start with a clean Makefile.tmp file
|
---|
[50fb011] | 341 | >$MKFILE
|
---|
[03b3eba] | 342 |
|
---|
[0170229] | 343 | chapter4_Makefiles
|
---|
| 344 | chapter5_Makefiles
|
---|
| 345 | chapter6_Makefiles
|
---|
[4edbc92] | 346 | # Add the iterations targets, if needed
|
---|
[47fddc8] | 347 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
[9c9775f] | 348 | chapter78_Makefiles
|
---|
| 349 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 350 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
[fd7455c] | 351 | # Add the BLFS_TOOL targets, if needed
|
---|
| 352 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
[0170229] | 353 |
|
---|
| 354 | # Add a header, some variables and include the function file
|
---|
| 355 | # to the top of the real Makefile.
|
---|
[9c9775f] | 356 | wrt_Makefile_header
|
---|
[0170229] | 357 |
|
---|
| 358 | # Add chroot commands
|
---|
[8381f6e] | 359 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
[0170229] | 360 | i=1
|
---|
| 361 | for file in chapter06/*chroot* ; do
|
---|
[3b6adab] | 362 | chroot=`cat $file | tr -d '\n' | \
|
---|
[8381f6e] | 363 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
[3b6adab] | 364 | -e 's@ \\\@ @g' \
|
---|
[8381f6e] | 365 | -e 's|\\$|&&|g' \
|
---|
| 366 | -e 's|"$$LFS"|$(MOUNT_PT)|' \
|
---|
[3b6adab] | 367 | -e 's|$| -c|'`
|
---|
[0170229] | 368 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 369 | i=`expr $i + 1`
|
---|
| 370 | done
|
---|
| 371 |
|
---|
| 372 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 373 | # as a dependency.
|
---|
| 374 | (
|
---|
| 375 | cat << EOF
|
---|
[50fb011] | 376 |
|
---|
[9c9775f] | 377 | all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
[4012541] | 378 | @sudo make do_housekeeping
|
---|
[9c9775f] | 379 | @echo "$VERSION - jhalfs build" > lfs-release && \\
|
---|
| 380 | sudo mv lfs-release \$(MOUNT_PT)/etc
|
---|
[0170229] | 381 | @\$(call echo_finished,$VERSION)
|
---|
| 382 |
|
---|
[7d4cc81] | 383 | ck_UID:
|
---|
| 384 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 385 | echo "--------------------------------------------------"; \\
|
---|
| 386 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 387 | echo "--------------------------------------------------"; \\
|
---|
| 388 | exit 1; \\
|
---|
| 389 | fi
|
---|
[0167dd8] | 390 |
|
---|
[50fb011] | 391 | mk_SETUP:
|
---|
| 392 | @\$(call echo_SU_request)
|
---|
[9c9775f] | 393 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[50fb011] | 394 | @touch \$@
|
---|
[03b3eba] | 395 |
|
---|
[50fb011] | 396 | mk_LUSER: mk_SETUP
|
---|
| 397 | @\$(call echo_SULUSER_request)
|
---|
[9c9775f] | 398 | @( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
[621f01f] | 399 | @sudo make restore-luser-env
|
---|
[50fb011] | 400 | @touch \$@
|
---|
[7d4cc81] | 401 |
|
---|
| 402 | mk_SUDO: mk_LUSER
|
---|
[9c9775f] | 403 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
| 404 | @touch \$@
|
---|
| 405 |
|
---|
[496f8f3] | 406 | mk_CHROOT: mk_SUDO
|
---|
[50fb011] | 407 | @\$(call echo_CHROOT_request)
|
---|
[9c9775f] | 408 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
[50fb011] | 409 | @touch \$@
|
---|
| 410 |
|
---|
[03b3eba] | 411 | mk_BOOT: mk_CHROOT
|
---|
[50fb011] | 412 | @\$(call echo_CHROOT_request)
|
---|
[9c9775f] | 413 | @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
[50fb011] | 414 | @touch \$@
|
---|
[03b3eba] | 415 |
|
---|
[9c9775f] | 416 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
| 417 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
| 418 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
| 419 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
| 420 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
| 421 | fi;
|
---|
| 422 | @touch \$@
|
---|
[50fb011] | 423 |
|
---|
[9c9775f] | 424 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
| 425 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 426 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
| 427 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
| 428 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
---|
| 429 | fi;
|
---|
| 430 | @touch \$@
|
---|
[50fb011] | 431 |
|
---|
[7d4cc81] | 432 |
|
---|
[9c9775f] | 433 | SETUP: $chapter4
|
---|
| 434 | LUSER: $chapter5
|
---|
| 435 | SUDO: $runasroot
|
---|
| 436 | CHROOT: SHELL=/tools/bin/bash
|
---|
| 437 | CHROOT: $chapter6
|
---|
| 438 | BOOT: $chapter78
|
---|
| 439 | CUSTOM_TOOLS: $custom_list
|
---|
| 440 | BLFS_TOOL: $blfs_tool
|
---|
[50fb011] | 441 |
|
---|
[0170229] | 442 |
|
---|
[9c9775f] | 443 | create-sbu_du-report: mk_BOOT
|
---|
| 444 | @\$(call echo_message, Building)
|
---|
| 445 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
| 446 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
| 447 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
| 448 | fi;
|
---|
| 449 | @touch \$@
|
---|
[0170229] | 450 |
|
---|
[30737ea8] | 451 | restore-luser-env:
|
---|
[0170229] | 452 | @\$(call echo_message, Building)
|
---|
[9c9775f] | 453 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 454 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
[0170229] | 455 | fi;
|
---|
[9c9775f] | 456 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
| 457 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
[0170229] | 458 | fi;
|
---|
[9c9775f] | 459 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
|
---|
| 460 | @\$(call housekeeping)
|
---|
[460ea63] | 461 |
|
---|
[3a27393] | 462 | do_housekeeping:
|
---|
[9199a13] | 463 | @-umount \$(MOUNT_PT)/sys
|
---|
| 464 | @-umount \$(MOUNT_PT)/proc
|
---|
| 465 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
| 466 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
| 467 | @-umount \$(MOUNT_PT)/dev
|
---|
[0167dd8] | 468 | @-rm /tools
|
---|
[30737ea8] | 469 | @-if [ ! -f luser-exist ]; then \\
|
---|
[9485eba] | 470 | userdel \$(LUSER); \\
|
---|
[9c9775f] | 471 | rm -rf \$(LUSER_HOME); \\
|
---|
[3a27393] | 472 | fi;
|
---|
[460ea63] | 473 |
|
---|
[9199a13] | 474 |
|
---|
[42346b2] | 475 | EOF
|
---|
| 476 | ) >> $MKFILE
|
---|
| 477 |
|
---|
[0170229] | 478 | # Bring over the items from the Makefile.tmp
|
---|
| 479 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 480 | rm $MKFILE.tmp
|
---|
[a702b4d] | 481 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 482 | }
|
---|