[0170229] | 1 | #!/bin/sh
|
---|
| 2 | set -e # Enable error trapping
|
---|
| 3 |
|
---|
[57ca090] | 4 | # $Id$
|
---|
[0170229] | 5 |
|
---|
| 6 | ###################################
|
---|
| 7 | ### FUNCTIONS ###
|
---|
| 8 | ###################################
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | #----------------------------#
|
---|
| 12 | get_sources() { #
|
---|
| 13 | #----------------------------#
|
---|
| 14 | local IFS
|
---|
| 15 |
|
---|
| 16 | # Test if the packages must be downloaded
|
---|
| 17 | if [ ! "$HPKG" = "1" ] ; then
|
---|
| 18 | return
|
---|
| 19 | fi
|
---|
| 20 |
|
---|
| 21 | # Modify the 'internal field separator' to break on 'LF' only
|
---|
| 22 | IFS=$'\x0A'
|
---|
| 23 |
|
---|
| 24 | if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
---|
| 25 | cd $BUILDDIR/sources
|
---|
| 26 |
|
---|
| 27 | > MISSING_FILES.DMP # Files not in md5sum end up here
|
---|
| 28 |
|
---|
| 29 | if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
---|
| 30 | if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
---|
| 31 |
|
---|
| 32 | # Retrieve the master md5sum file
|
---|
| 33 | download "" MD5SUMS
|
---|
| 34 |
|
---|
| 35 | # Iterate through each package and grab it, along with any patches it needs.
|
---|
| 36 | for i in `cat $JHALFSDIR/packages` ; do
|
---|
| 37 | PKG=`echo $i | sed -e 's/-version.*//' \
|
---|
| 38 | -e 's/-file.*//' \
|
---|
| 39 | -e 's/uclibc/uClibc/' `
|
---|
| 40 |
|
---|
| 41 | # Needed for Groff patchlevel patch on UTF-8 branch
|
---|
| 42 | GROFFLEVEL=`grep "groff-patchlevel" $JHALFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
|
---|
| 43 |
|
---|
| 44 | #
|
---|
| 45 | # How to deal with orphan packages..??
|
---|
| 46 | #
|
---|
| 47 | VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 48 | case "$PKG" in
|
---|
| 49 | "uClibc-patch" ) continue ;;
|
---|
| 50 |
|
---|
[0ebdc33] | 51 | "tcl" ) FILE="$PKG$VRS-src.tar.bz2" ; download $PKG $FILE ;;
|
---|
[0170229] | 52 |
|
---|
| 53 | "uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc"
|
---|
| 54 | download $PKG $FILE
|
---|
| 55 | # There can be no patches for this file
|
---|
| 56 | continue ;;
|
---|
| 57 |
|
---|
| 58 | "gcc" ) download $PKG "gcc-core-$VRS.tar.bz2"
|
---|
| 59 | download $PKG "gcc-g++-$VRS.tar.bz2"
|
---|
[57ca090] | 60 | if [ ! "$TEST" = "0" ] ; then
|
---|
| 61 | download $PKG "gcc-testsuite-$VRS.tar.bz2" ;
|
---|
| 62 | fi
|
---|
[0170229] | 63 | ;;
|
---|
| 64 | "glibc") download $PKG "$PKG-$VRS.tar.bz2"
|
---|
| 65 | download $PKG "$PKG-libidn-$VRS.tar.bz2"
|
---|
| 66 | ;;
|
---|
| 67 | * ) FILE="$PKG-$VRS.tar.bz2"
|
---|
| 68 | download $PKG $FILE
|
---|
| 69 | ;;
|
---|
| 70 | esac
|
---|
| 71 |
|
---|
| 72 | for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
|
---|
| 73 | PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
---|
| 74 | download $PKG $PATCH
|
---|
| 75 | done
|
---|
| 76 |
|
---|
| 77 | done
|
---|
| 78 |
|
---|
| 79 | # .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
---|
| 80 | download grsecurity `grep grsecurity $JHALFSDIR/patches`
|
---|
| 81 |
|
---|
| 82 | # .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue.
|
---|
| 83 | bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz
|
---|
| 84 |
|
---|
| 85 | if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
|
---|
| 86 | echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check <MISSING_FILES.DMP> for names ${OFF}\n\n"
|
---|
| 87 | fi
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | #----------------------------#
|
---|
[389fe2a] | 92 | chapter3_Makefiles() { # Initialization of the system
|
---|
[0170229] | 93 | #----------------------------#
|
---|
| 94 | local TARGET LOADER
|
---|
| 95 |
|
---|
[e10232b] | 96 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
|
---|
[0170229] | 97 |
|
---|
| 98 | # Define a few model dependant variables
|
---|
| 99 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
| 100 | TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
| 101 | else
|
---|
| 102 | TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
[5c5a010] | 103 | fi
|
---|
[0170229] | 104 |
|
---|
[5c5a010] | 105 | # NOTE: We use the lfs username and groupname also in HLFS
|
---|
| 106 | # If /home/lfs is already present in the host, we asume that the
|
---|
| 107 | # lfs user and group are also presents in the host, and a backup
|
---|
[0170229] | 108 | # of their bash init files is made.
|
---|
| 109 | (
|
---|
| 110 | cat << EOF
|
---|
| 111 | 020-creatingtoolsdir:
|
---|
| 112 | @\$(call echo_message, Building)
|
---|
| 113 | @mkdir -v \$(MOUNT_PT)/tools && \\
|
---|
| 114 | rm -fv /tools && \\
|
---|
| 115 | ln -sv \$(MOUNT_PT)/tools /
|
---|
| 116 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
| 117 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
| 118 | fi;
|
---|
| 119 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
| 120 | touch \$@
|
---|
| 121 |
|
---|
| 122 | 021-addinguser: 020-creatingtoolsdir
|
---|
| 123 | @\$(call echo_message, Building)
|
---|
| 124 | @if [ ! -d /home/lfs ]; then \\
|
---|
| 125 | groupadd lfs; \\
|
---|
| 126 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
| 127 | else \\
|
---|
| 128 | touch user-lfs-exist; \\
|
---|
| 129 | fi;
|
---|
| 130 | @chown lfs \$(MOUNT_PT)/tools && \\
|
---|
| 131 | chown lfs \$(MOUNT_PT)/sources && \\
|
---|
| 132 | touch \$@
|
---|
| 133 |
|
---|
| 134 | 022-settingenvironment: 021-addinguser
|
---|
| 135 | @\$(call echo_message, Building)
|
---|
| 136 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
| 137 | mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
| 138 | fi;
|
---|
| 139 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
| 140 | mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
| 141 | fi;
|
---|
| 142 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
| 143 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
| 144 | echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
---|
| 145 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
| 146 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
| 147 | echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
| 148 | echo "" >> /home/lfs/.bashrc && \\
|
---|
| 149 | echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
|
---|
| 150 | echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
|
---|
| 151 | echo "export target ldso" >> /home/lfs/.bashrc && \\
|
---|
| 152 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
---|
| 153 | chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
| 154 | touch envars && \\
|
---|
| 155 | touch \$@
|
---|
| 156 | EOF
|
---|
| 157 | ) >> $MKFILE.tmp
|
---|
| 158 |
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | #----------------------------#
|
---|
| 162 | chapter5_Makefiles() { # Bootstrap or temptools phase
|
---|
| 163 | #----------------------------#
|
---|
| 164 | local file
|
---|
| 165 | local this_script
|
---|
[57ca090] | 166 |
|
---|
[e10232b] | 167 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
---|
[0170229] | 168 |
|
---|
| 169 | for file in chapter05/* ; do
|
---|
| 170 | # Keep the script file name
|
---|
| 171 | this_script=`basename $file`
|
---|
| 172 |
|
---|
| 173 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 174 | case $this_script in
|
---|
| 175 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
[821a2c6] | 176 | *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 177 | *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 178 | *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
[7d018d1] | 179 | # Nothing interestin in this script
|
---|
| 180 | *introduction* ) continue ;;
|
---|
[0170229] | 181 | # Test if the stripping phase must be skipped
|
---|
| 182 | *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 183 | *) ;;
|
---|
| 184 | esac
|
---|
| 185 |
|
---|
| 186 | # First append each name of the script files to a list (this will become
|
---|
| 187 | # the names of the targets in the Makefile
|
---|
| 188 | chapter5="$chapter5 $this_script"
|
---|
| 189 |
|
---|
| 190 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 191 | # and binutils in chapter 5)
|
---|
| 192 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
|
---|
| 193 |
|
---|
[5c5a010] | 194 | # Adjust 'name'
|
---|
[0170229] | 195 | case $name in
|
---|
[5c5a010] | 196 | linux-libc) name=linux-libc-headers ;;
|
---|
[0170229] | 197 | esac
|
---|
| 198 |
|
---|
| 199 | # Set the dependency for the first target.
|
---|
| 200 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | #--------------------------------------------------------------------#
|
---|
| 204 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 205 | #--------------------------------------------------------------------#
|
---|
| 206 | #
|
---|
| 207 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 208 | # as a dependency. Also call the echo_message function.
|
---|
| 209 | wrt_target "$this_script" "$PREV"
|
---|
| 210 |
|
---|
| 211 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 212 | # a specific package
|
---|
| 213 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 214 | # If $vrs isn't empty, we've got a package...
|
---|
| 215 | if [ "$vrs" != "" ] ; then
|
---|
| 216 | # Deal with non-standard names
|
---|
| 217 | case $name in
|
---|
| 218 | tcl) FILE="$name$vrs-src.tar" ;;
|
---|
| 219 | uclibc) FILE="uClibc-$vrs.tar" ;;
|
---|
| 220 | gcc) FILE="gcc-core-$vrs.tar" ;;
|
---|
| 221 | *) FILE="$name-$vrs.tar" ;;
|
---|
| 222 | esac
|
---|
| 223 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
| 224 | wrt_unpack "$FILE"
|
---|
| 225 | fi
|
---|
| 226 |
|
---|
| 227 | case $this_script in
|
---|
| 228 | *binutils* ) # Dump the path to sources directory for later removal
|
---|
| 229 | echo -e '\techo "$(MOUNT_PT)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp
|
---|
| 230 | ;;
|
---|
| 231 | *adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 232 | echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
| 233 | ;;
|
---|
| 234 | * ) # Everything else, add a true statment so we don't confuse make
|
---|
| 235 | echo -e '\ttrue' >> $MKFILE.tmp
|
---|
| 236 | ;;
|
---|
| 237 | esac
|
---|
| 238 |
|
---|
| 239 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 240 | # and date and disk usage again at the bottom of the log file.
|
---|
| 241 | wrt_run_as_su "${this_script}" "${file}"
|
---|
| 242 |
|
---|
| 243 | # Remove the build directory(ies) except if the package build fails
|
---|
| 244 | # (so we can review config.cache, config.log, etc.)
|
---|
| 245 | # For Binutils the sources must be retained for some time.
|
---|
| 246 | if [ "$vrs" != "" ] ; then
|
---|
| 247 | if [[ ! `_IS_ $this_script binutils` ]]; then
|
---|
| 248 | wrt_remove_build_dirs "$name"
|
---|
| 249 | fi
|
---|
| 250 | fi
|
---|
| 251 |
|
---|
| 252 | # Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
---|
| 253 | if [[ `_IS_ $this_script adjusting` ]] ; then
|
---|
| 254 | (
|
---|
| 255 | cat << EOF
|
---|
| 256 | @rm -r \`cat sources-dir\` && \\
|
---|
| 257 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
| 258 | rm sources-dir
|
---|
| 259 | EOF
|
---|
| 260 | ) >> $MKFILE.tmp
|
---|
| 261 | fi
|
---|
| 262 |
|
---|
| 263 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 264 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 265 | #
|
---|
| 266 | #--------------------------------------------------------------------#
|
---|
| 267 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 268 | #--------------------------------------------------------------------#
|
---|
| 269 |
|
---|
| 270 | # Keep the script file name for Makefile dependencies.
|
---|
| 271 | PREV=$this_script
|
---|
| 272 | done # end for file in chapter05/*
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 |
|
---|
| 276 | #----------------------------#
|
---|
| 277 | chapter6_Makefiles() { # sysroot or chroot build phase
|
---|
| 278 | #----------------------------#
|
---|
| 279 | local TARGET LOADER
|
---|
| 280 | local file
|
---|
| 281 | local this_script
|
---|
| 282 |
|
---|
[e10232b] | 283 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6${R_arrow}"
|
---|
[0170229] | 284 | #
|
---|
| 285 | # Set these definitions early and only once
|
---|
| 286 | #
|
---|
| 287 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
| 288 | TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
| 289 | else
|
---|
| 290 | TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
| 291 | fi
|
---|
| 292 |
|
---|
| 293 | for file in chapter06/* ; do
|
---|
| 294 | # Keep the script file name
|
---|
| 295 | this_script=`basename $file`
|
---|
| 296 |
|
---|
| 297 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 298 | case $this_script in
|
---|
| 299 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 300 | # dependencies and target creation.
|
---|
| 301 | *chroot* ) continue ;;
|
---|
| 302 | # Test if the stripping phase must be skipped
|
---|
| 303 | *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 304 | *) ;;
|
---|
| 305 | esac
|
---|
| 306 |
|
---|
| 307 | # First append each name of the script files to a list (this will become
|
---|
| 308 | # the names of the targets in the Makefile
|
---|
| 309 | chapter6="$chapter6 $this_script"
|
---|
| 310 |
|
---|
| 311 | # Grab the name of the target
|
---|
| 312 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 313 |
|
---|
| 314 | #
|
---|
[582feec] | 315 | # Sed replacement to fix some rm command that could fail.
|
---|
| 316 | # That should be fixed in the book sources.
|
---|
[0170229] | 317 | #
|
---|
| 318 | case $name in
|
---|
[582feec] | 319 | glibc)
|
---|
| 320 | sed 's/rm /rm -f /' -i chapter06/$this_script
|
---|
[0170229] | 321 | ;;
|
---|
[582feec] | 322 | gcc)
|
---|
[0170229] | 323 | sed 's/rm /rm -f /' -i chapter06/$this_script
|
---|
| 324 | ;;
|
---|
| 325 | esac
|
---|
| 326 |
|
---|
| 327 | #--------------------------------------------------------------------#
|
---|
| 328 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 329 | #--------------------------------------------------------------------#
|
---|
| 330 | #
|
---|
| 331 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 332 | # as a dependency. Also call the echo_message function.
|
---|
| 333 | wrt_target "$this_script" "$PREV"
|
---|
| 334 |
|
---|
| 335 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 336 | # a specific package
|
---|
| 337 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 338 |
|
---|
| 339 | # If $vrs isn't empty, we've got a package...
|
---|
| 340 | # Insert instructions for unpacking the package and changing directories
|
---|
| 341 | if [ "$vrs" != "" ] ; then
|
---|
| 342 | # Deal with non-standard names
|
---|
| 343 | case $name in
|
---|
| 344 | tcl) FILE="$name$vrs-src.tar.*" ;;
|
---|
| 345 | uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
---|
| 346 | gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
---|
| 347 | *) FILE="$name-$vrs.tar.*" ;;
|
---|
| 348 | esac
|
---|
| 349 | wrt_unpack2 "$FILE"
|
---|
| 350 | wrt_target_vars
|
---|
| 351 | fi
|
---|
| 352 |
|
---|
| 353 | case $this_script in
|
---|
| 354 | *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 355 | echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
| 356 | ;;
|
---|
| 357 | *glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar.
|
---|
| 358 | wrt_export_timezone
|
---|
| 359 | ;;
|
---|
| 360 | *groff* ) # For Groff we need to set PAGE envar.
|
---|
| 361 | wrt_export_pagesize
|
---|
| 362 | ;;
|
---|
| 363 | esac
|
---|
| 364 |
|
---|
[582feec] | 365 | # In the mount of kernel filesystems we need to set LFS and not to use chroot.
|
---|
[0170229] | 366 | if [[ `_IS_ $this_script kernfs` ]] ; then
|
---|
| 367 | wrt_run_as_root "${this_script}" "${file}"
|
---|
| 368 | #
|
---|
| 369 | # The rest of Chapter06
|
---|
| 370 | else
|
---|
| 371 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
| 372 | fi
|
---|
| 373 | #
|
---|
| 374 | # Remove the build directory(ies) except if the package build fails.
|
---|
| 375 | if [ "$vrs" != "" ] ; then
|
---|
| 376 | wrt_remove_build_dirs "$name"
|
---|
| 377 | fi
|
---|
| 378 | #
|
---|
| 379 | # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
---|
| 380 | if [[ `_IS_ $this_script readjusting` ]] ; then
|
---|
| 381 | (
|
---|
| 382 | cat << EOF
|
---|
| 383 | @rm -r \`cat sources-dir\` && \\
|
---|
| 384 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
| 385 | rm sources-dir
|
---|
| 386 | EOF
|
---|
| 387 | ) >> $MKFILE.tmp
|
---|
| 388 | fi
|
---|
| 389 |
|
---|
| 390 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 391 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 392 | #
|
---|
| 393 | #--------------------------------------------------------------------#
|
---|
| 394 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 395 | #--------------------------------------------------------------------#
|
---|
| 396 |
|
---|
| 397 | # Keep the script file name for Makefile dependencies.
|
---|
| 398 | PREV=$this_script
|
---|
| 399 | done # end for file in chapter06/*
|
---|
| 400 |
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | #----------------------------#
|
---|
| 404 | chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
---|
| 405 | #----------------------------#
|
---|
| 406 | local file
|
---|
| 407 | local this_script
|
---|
[57ca090] | 408 |
|
---|
[e10232b] | 409 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
|
---|
[0170229] | 410 | for file in chapter07/*; do
|
---|
| 411 | # Keep the script file name
|
---|
| 412 | this_script=`basename $file`
|
---|
| 413 |
|
---|
| 414 | # Grub must be configured manually.
|
---|
| 415 | # The filesystems can't be unmounted via Makefile and the user
|
---|
| 416 | # should enter the chroot environment to create the root
|
---|
| 417 | # password, edit several files and setup Grub.
|
---|
| 418 | case $this_script in
|
---|
[0ac273e] | 419 | *usage) continue ;; # Contains example commands
|
---|
[0170229] | 420 | *grub) continue ;;
|
---|
| 421 | *reboot) continue ;;
|
---|
| 422 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
| 423 |
|
---|
[57ca090] | 424 | *kernel)
|
---|
[821a2c6] | 425 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 426 | [[ -z $CONFIG ]] && continue
|
---|
[0170229] | 427 | # The files in the conglomeration dir are xxx.bz2
|
---|
[0ac273e] | 428 | # What if the user download the original file?
|
---|
[0170229] | 429 | sed 's|.patch.gz|.patch.bz2|' -i chapter07/$this_script
|
---|
| 430 | sed 's|gunzip|bunzip2|' -i chapter07/$this_script
|
---|
| 431 | ;;
|
---|
| 432 | esac
|
---|
| 433 |
|
---|
| 434 | # First append then name of the script file to a list (this will become
|
---|
| 435 | # the names of the targets in the Makefile
|
---|
| 436 | chapter7="$chapter7 $this_script"
|
---|
| 437 |
|
---|
| 438 | #--------------------------------------------------------------------#
|
---|
| 439 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 440 | #--------------------------------------------------------------------#
|
---|
| 441 | #
|
---|
| 442 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 443 | # as a dependency. Also call the echo_message function.
|
---|
| 444 | wrt_target "$this_script" "$PREV"
|
---|
| 445 |
|
---|
| 446 | if [[ `_IS_ $this_script bootscripts` ]] ; then
|
---|
| 447 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 448 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
| 449 | wrt_unpack2 "$FILE"
|
---|
| 450 | (
|
---|
| 451 | cat << EOF
|
---|
[7d018d1] | 452 | @echo "\$(MOUNT_PT)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir
|
---|
[0170229] | 453 | EOF
|
---|
| 454 | ) >> $MKFILE.tmp
|
---|
| 455 | fi
|
---|
| 456 |
|
---|
| 457 | if [[ `_IS_ $this_script kernel` ]] ; then
|
---|
| 458 | # not much really, script does everything..
|
---|
| 459 | echo -e "\t@cp -f $CONFIG \$(MOUNT_PT)/sources/kernel-config" >> $MKFILE.tmp
|
---|
| 460 | fi
|
---|
| 461 |
|
---|
[5365c39] | 462 | case "${this_script}" in
|
---|
| 463 | *profile* ) wrt_export_lang2 ;; # For /etc/profile we need to set LANG envar.
|
---|
| 464 | esac
|
---|
| 465 |
|
---|
[0170229] | 466 | # Check if we have a real /etc/fstab file
|
---|
| 467 | if [[ `_IS_ $this_script fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
---|
| 468 | wrt_copy_fstab "$this_script"
|
---|
| 469 | else
|
---|
| 470 | # Initialize the log and run the script
|
---|
| 471 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
| 472 | fi
|
---|
| 473 |
|
---|
| 474 | # Remove the build directory except if the package build fails.
|
---|
| 475 | if [[ `_IS_ $this_script bootscripts` ]]; then
|
---|
| 476 | (
|
---|
| 477 | cat << EOF
|
---|
| 478 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 479 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 480 | @rm -r \`cat sources-dir\` && \\
|
---|
| 481 | rm sources-dir
|
---|
| 482 | EOF
|
---|
| 483 | ) >> $MKFILE.tmp
|
---|
| 484 | fi
|
---|
| 485 |
|
---|
| 486 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 487 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 488 | #
|
---|
| 489 | #--------------------------------------------------------------------#
|
---|
| 490 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 491 | #--------------------------------------------------------------------#
|
---|
| 492 |
|
---|
| 493 | # Keep the script file name for Makefile dependencies.
|
---|
| 494 | PREV=$this_script
|
---|
| 495 | done # for file in chapter07/*
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 |
|
---|
| 499 | #----------------------------#
|
---|
| 500 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 501 | #----------------------------#
|
---|
[e10232b] | 502 | echo "Creating Makefile... "
|
---|
[0170229] | 503 |
|
---|
| 504 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 505 | # Start with a clean Makefile.tmp file
|
---|
| 506 | >$MKFILE.tmp
|
---|
| 507 |
|
---|
[389fe2a] | 508 | chapter3_Makefiles
|
---|
[0170229] | 509 | chapter5_Makefiles
|
---|
| 510 | chapter6_Makefiles
|
---|
| 511 | chapter7_Makefiles
|
---|
| 512 |
|
---|
| 513 | # Add a header, some variables and include the function file
|
---|
| 514 | # to the top of the real Makefile.
|
---|
| 515 | (
|
---|
| 516 | cat << EOF
|
---|
| 517 | $HEADER
|
---|
| 518 |
|
---|
| 519 | SRC= /sources
|
---|
| 520 | MOUNT_PT= $BUILDDIR
|
---|
| 521 | PAGE= $PAGE
|
---|
| 522 | TIMEZONE= $TIMEZONE
|
---|
[5365c39] | 523 | LC_ALL= $LC_ALL
|
---|
| 524 | LANG= $LANG
|
---|
[0170229] | 525 |
|
---|
| 526 | include makefile-functions
|
---|
| 527 |
|
---|
| 528 | EOF
|
---|
| 529 | ) > $MKFILE
|
---|
| 530 |
|
---|
| 531 |
|
---|
| 532 | # Add chroot commands
|
---|
| 533 | i=1
|
---|
| 534 | for file in chapter06/*chroot* ; do
|
---|
| 535 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
| 536 | -e '/^export/d' \
|
---|
| 537 | -e '/^logout/d' \
|
---|
| 538 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
| 539 | -e 's|\\$|&&|g' \
|
---|
| 540 | -e 's|exit||g' \
|
---|
| 541 | -e 's|$| -c|' \
|
---|
| 542 | -e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
---|
| 543 | -e 's|set -e||'`
|
---|
| 544 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 545 | i=`expr $i + 1`
|
---|
| 546 | done
|
---|
| 547 |
|
---|
| 548 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 549 | # as a dependency.
|
---|
| 550 | (
|
---|
| 551 | cat << EOF
|
---|
[0ac273e] | 552 | all: chapter3 chapter5 chapter6 chapter7
|
---|
[0170229] | 553 | @\$(call echo_finished,$VERSION)
|
---|
| 554 |
|
---|
[0ac273e] | 555 | chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
[0170229] | 556 |
|
---|
[0ac273e] | 557 | chapter5: chapter3 $chapter5 restore-lfs-env
|
---|
[0170229] | 558 |
|
---|
| 559 | chapter6: chapter5 $chapter6
|
---|
| 560 |
|
---|
| 561 | chapter7: chapter6 $chapter7
|
---|
| 562 |
|
---|
| 563 | clean-all: clean
|
---|
[0ac273e] | 564 | rm -rf ./{hlfs-commands,logs,Makefile,hlfs.xsl,patcheslist.xsl,functions,packages,patches}
|
---|
[0170229] | 565 |
|
---|
[0ac273e] | 566 | clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
|
---|
[0170229] | 567 |
|
---|
[0ac273e] | 568 | clean-chapter3:
|
---|
| 569 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 570 | userdel lfs; \\
|
---|
| 571 | rm -rf /home/lfs; \\
|
---|
[0170229] | 572 | fi;
|
---|
| 573 | rm -rf \$(MOUNT_PT)/tools
|
---|
| 574 | rm -f /tools
|
---|
[0ac273e] | 575 | rm -f envars user-lfs-exist
|
---|
[0170229] | 576 | rm -f 02* logs/02*.log
|
---|
| 577 |
|
---|
| 578 | clean-chapter5:
|
---|
| 579 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
[0ac273e] | 580 | rm -f $chapter5 restore-lfs-env sources-dir
|
---|
[0170229] | 581 | cd logs && rm -f $chapter5 && cd ..
|
---|
| 582 |
|
---|
| 583 | clean-chapter6:
|
---|
| 584 | -umount \$(MOUNT_PT)/sys
|
---|
| 585 | -umount \$(MOUNT_PT)/proc
|
---|
| 586 | -umount \$(MOUNT_PT)/dev/shm
|
---|
| 587 | -umount \$(MOUNT_PT)/dev/pts
|
---|
| 588 | -umount \$(MOUNT_PT)/dev
|
---|
| 589 | rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
| 590 | rm -f $chapter6
|
---|
| 591 | cd logs && rm -f $chapter6 && cd ..
|
---|
| 592 |
|
---|
| 593 | clean-chapter7:
|
---|
| 594 | rm -f $chapter7
|
---|
| 595 | cd logs && rm -f $chapter7 && cd ..
|
---|
| 596 |
|
---|
[0ac273e] | 597 | restore-lfs-env:
|
---|
[0170229] | 598 | @\$(call echo_message, Building)
|
---|
| 599 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
[7d018d1] | 600 | mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
[0170229] | 601 | fi;
|
---|
[7d018d1] | 602 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
| 603 | mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
[0170229] | 604 | fi;
|
---|
| 605 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
| 606 | touch \$@
|
---|
| 607 |
|
---|
| 608 | EOF
|
---|
| 609 | ) >> $MKFILE
|
---|
| 610 |
|
---|
| 611 | # Bring over the items from the Makefile.tmp
|
---|
| 612 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 613 | rm $MKFILE.tmp
|
---|
[e10232b] | 614 | echo "done"
|
---|
[0170229] | 615 | }
|
---|