[0170229] | 1 | #!/bin/bash
|
---|
| 2 | set +e
|
---|
| 3 |
|
---|
| 4 | # VT100 colors
|
---|
| 5 | declare -r BLACK=$'\e[1;30m'
|
---|
| 6 | declare -r DK_GRAY=$'\e[0;30m'
|
---|
| 7 |
|
---|
| 8 | declare -r RED=$'\e[31m'
|
---|
| 9 | declare -r GREEN=$'\e[32m'
|
---|
| 10 | declare -r YELLOW=$'\e[33m'
|
---|
| 11 | declare -r BLUE=$'\e[34m'
|
---|
| 12 | declare -r MAGENTA=$'\e[35m'
|
---|
| 13 | declare -r CYAN=$'\e[36m'
|
---|
| 14 | declare -r WHITE=$'\e[37m'
|
---|
| 15 |
|
---|
| 16 | declare -r OFF=$'\e[0m'
|
---|
| 17 | declare -r BOLD=$'\e[1m'
|
---|
| 18 | declare -r REVERSE=$'\e[7m'
|
---|
| 19 | declare -r HIDDEN=$'\e[8m'
|
---|
| 20 |
|
---|
| 21 | declare -r tab_=$'\t'
|
---|
| 22 | declare -r nl_=$'\n'
|
---|
| 23 |
|
---|
| 24 | declare -r DD_BORDER="${BOLD}${WHITE}==============================================================================${OFF}"
|
---|
| 25 | declare -r SD_BORDER="${BOLD}${WHITE}------------------------------------------------------------------------------${OFF}"
|
---|
| 26 | declare -r STAR_BORDER="${BOLD}${WHITE}******************************************************************************${OFF}"
|
---|
| 27 |
|
---|
| 28 | # bold yellow > < pair
|
---|
| 29 | declare -r R_arrow=$'\e[1;33m>\e[0m'
|
---|
| 30 | declare -r L_arrow=$'\e[1;33m<\e[0m'
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | usage() {
|
---|
| 35 | 'clear'
|
---|
| 36 | cat <<- -EOF-
|
---|
| 37 | ${DD_BORDER}
|
---|
| 38 | ${BOLD}
|
---|
| 39 | Usage: $0 ${BOLD}[OPTION]
|
---|
| 40 |
|
---|
| 41 | Options:
|
---|
| 42 | ${BOLD} -h, --help${OFF}
|
---|
| 43 | print this help, then exit
|
---|
| 44 | ${BOLD} --readme${OFF}
|
---|
| 45 | print a small readme file, then exit
|
---|
| 46 | ${BOLD} -V, --version${OFF}
|
---|
| 47 | print version number, then exit
|
---|
| 48 | ${BOLD} -d --directory DIR${OFF}
|
---|
| 49 | use DIR directory for building HLFS; all files jhahlfs produces will be
|
---|
| 50 | in the directory DIR/jhahlfs. Default is \"/mnt/lfs\".
|
---|
| 51 | ${BOLD} --rebuild${OFF}
|
---|
| 52 | clean the build directory before to perfom any other task. The directory
|
---|
| 53 | is cleaned only if it was populated by a previous jhahlfs run.
|
---|
| 54 | ${BOLD} -P, --get-packages${OFF}
|
---|
| 55 | download the packages and patches. This assumes that the server declared in the
|
---|
| 56 | jhahlfs.conf file has the proper packages and patches for the book version being
|
---|
| 57 | processed.
|
---|
| 58 | ${BOLD} -D, --download-client CLIENT
|
---|
| 59 | use CLIENT as the program for retrieving packages (use in conjunction with -P)
|
---|
| 60 | ${BOLD} -W, --working-copy DIR${OFF}
|
---|
| 61 | use the local working copy placed in DIR as the HLFS book
|
---|
| 62 | ${BOLD} -L, --HLFS-version VER${OFF}
|
---|
| 63 | checkout VER version of the HLFS book. Supported versions at this time are:
|
---|
| 64 | dev* | trunk | SVN aliases for Development HLFS
|
---|
| 65 | ${BOLD} --fstab FILE${OFF}
|
---|
| 66 | use FILE as the /etc/fstab file for the HLFS system. If not specified,
|
---|
| 67 | a default /etc/fstab file with dummy values is created.
|
---|
| 68 | ${BOLD} -C, --kernel-config FILE${OFF}
|
---|
| 69 | use the kernel configuration file specified in FILE to build the kernel.
|
---|
| 70 | if the file is not found, or if not specified, the kernel build is skipped.
|
---|
| 71 | ${BOLD} -M, --run-make${OFF}
|
---|
| 72 | run make on the generated Makefile
|
---|
| 73 | ${DD_BORDER}
|
---|
| 74 | -EOF-
|
---|
| 75 | exit
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | blfs_usage() {
|
---|
| 80 | 'clear'
|
---|
| 81 | cat <<- -EOF-
|
---|
| 82 | ${DD_BORDER}
|
---|
| 83 | ${BOLD}
|
---|
| 84 | Usage: $0 ${BOLD}[OPTION]
|
---|
| 85 |
|
---|
| 86 | Options:
|
---|
| 87 | ${BOLD} -h, --help${OFF}
|
---|
| 88 | print this help, then exit
|
---|
| 89 |
|
---|
| 90 | ${BOLD} -V, --version${OFF}
|
---|
| 91 | print version number, then exit
|
---|
| 92 |
|
---|
| 93 | ${BOLD} -B, --BLFS-version VER${OFF}
|
---|
| 94 | checkout VER version of the BLFS book.
|
---|
| 95 | If not set, the development version is used.
|
---|
| 96 |
|
---|
| 97 | Supported versions at this time are:
|
---|
| 98 | dev* | trunk | SVN aliases for Development BLFS
|
---|
| 99 |
|
---|
| 100 | ${BOLD} -W, --working-copy DIR${OFF}
|
---|
| 101 | use the local working copy placed in DIR as the BLFS book
|
---|
| 102 |
|
---|
| 103 | ${BOLD} -D, --dependencies TYPE${OFF}
|
---|
| 104 | add dependencies of type TYPE to the build tree.
|
---|
| 105 | If not set, both required a recommended are used.
|
---|
| 106 |
|
---|
| 107 | Possible values are:
|
---|
| 108 |
|
---|
| 109 | required only required dependecies are used
|
---|
| 110 | recommended both required a recommended dependencies are used
|
---|
| 111 | optional all dependencies are used
|
---|
| 112 |
|
---|
| 113 | ${BOLD} -S, --server SERVER${OFF}
|
---|
| 114 | set the FTP/HTTP server used as fallback to download the packages.
|
---|
| 115 | If not specified, the one set in jhablfs.conf is used.
|
---|
| 116 |
|
---|
| 117 | ${BOLD} -T, --testsuites${OFF}
|
---|
| 118 | add support to run the optional testsuites
|
---|
| 119 | ${DD_BORDER}
|
---|
| 120 | -EOF-
|
---|
| 121 | exit
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | _inline_doc="
|
---|
| 126 | This script, ${PROGNAME}, strives to create an accurate makefile
|
---|
| 127 | directly from the xml files used to generate the Hardened Linux From
|
---|
| 128 | Scratch document.
|
---|
| 129 | The usage of this script assumes you have read and are familiar with
|
---|
| 130 | the book and therefore the configuration variables found in jhahlfs.conf
|
---|
| 131 | will have meaning to you. There are a limited number of command line
|
---|
| 132 | switches which, if used, will override the config file settings.
|
---|
| 133 |
|
---|
| 134 | NOTES::
|
---|
| 135 | *. The resulting Makefile takes considerable time to run to completion,
|
---|
| 136 | lay in a supply of caffeine beverages.
|
---|
| 137 |
|
---|
| 138 | *. It is recommended that you temporarily unpack your linux kernel and
|
---|
| 139 | run <make menuconfig> and configure the kernal as per the book and save
|
---|
| 140 | the resulting .config file.
|
---|
| 141 |
|
---|
| 142 | *. Chapter07 contains numerous command files which require customizing
|
---|
| 143 | before you start console, profile, hosts, network, fstab, kernel.
|
---|
| 144 | "
|
---|
| 145 |
|
---|
| 146 | version="
|
---|
| 147 | ${BOLD}\"${PROGNAME}\"${OFF} script module (development) \$Date$
|
---|
| 148 |
|
---|
| 149 | Written by Jeremy Huntwork,
|
---|
| 150 | Manuel Caneles Esparcia,
|
---|
| 151 | George Boudreau
|
---|
| 152 |
|
---|
| 153 | This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
|
---|
| 154 | "
|
---|
| 155 |
|
---|
| 156 |
|
---|
| 157 | no_empty_builddir() {
|
---|
| 158 | 'clear'
|
---|
| 159 | cat <<- -EOF-
|
---|
| 160 | ${DD_BORDER}
|
---|
| 161 |
|
---|
| 162 | ${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
|
---|
| 163 | Looks like the \$BUILDDIR directory contains subdirectories
|
---|
| 164 | from a previous HLFS build.
|
---|
| 165 |
|
---|
| 166 | Please format the partition mounted on \$BUILDDIR or set
|
---|
| 167 | a different build directory before running jhahlfs.
|
---|
| 168 | ${OFF}
|
---|
| 169 | ${DD_BORDER}
|
---|
| 170 | -EOF-
|
---|
| 171 | exit
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | help="${nl_}Try '$0 --help' for more information."
|
---|
| 176 |
|
---|
| 177 |
|
---|
| 178 | exit_missing_arg="\
|
---|
| 179 | echo \"Option '\$1' requires an argument\" >&2
|
---|
| 180 | echo \"\$help\" >&2
|
---|
| 181 | exit 1"
|
---|
| 182 |
|
---|
| 183 | no_dl_client="\
|
---|
| 184 | echo \"Could not find a way to download the CLFS sources.\" >&2
|
---|
| 185 | echo \"Attempting to continue.\" >&2"
|
---|
| 186 |
|
---|
| 187 | HEADER="# This file is automatically generated by jhalfs
|
---|
| 188 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
| 189 | #
|
---|
| 190 | # Generated on `date \"+%F %X %Z\"`"
|
---|
| 191 |
|
---|
| 192 |
|
---|
| 193 |
|
---|
| 194 |
|
---|
| 195 |
|
---|
| 196 | #----------------------------------#
|
---|
| 197 | wrt_target() { #
|
---|
| 198 | #----------------------------------#
|
---|
| 199 | local i=$1
|
---|
| 200 | local PREV=$2
|
---|
| 201 | (
|
---|
| 202 | cat << EOF
|
---|
| 203 |
|
---|
| 204 | $i: $PREV
|
---|
| 205 | @\$(call echo_message, Building)
|
---|
| 206 | EOF
|
---|
| 207 | ) >> $MKFILE.tmp
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 |
|
---|
| 211 | #----------------------------------#
|
---|
| 212 | wrt_unpack() { #
|
---|
| 213 | #----------------------------------#
|
---|
| 214 | local FILE=$1
|
---|
| 215 | (
|
---|
| 216 | cat << EOF
|
---|
| 217 | @\$(call unpack,$FILE)
|
---|
| 218 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 219 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
| 220 |
|
---|
| 221 | chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 222 | EOF
|
---|
| 223 | ) >> $MKFILE.tmp
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 |
|
---|
| 227 | #=============================#
|
---|
| 228 | wrt_unpack3() { # Unpack and set 'ROOT' var
|
---|
| 229 | #=============================#
|
---|
| 230 | local FILE=$1
|
---|
| 231 | (
|
---|
| 232 | cat << EOF
|
---|
| 233 | @\$(call unpack3,$FILE)
|
---|
| 234 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 235 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
| 236 |
|
---|
| 237 | chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 238 | EOF
|
---|
| 239 | ) >> $MKFILE.tmp
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 |
|
---|
| 243 | #----------------------------------#
|
---|
| 244 | wrt_unpack2() { #
|
---|
| 245 | #----------------------------------#
|
---|
| 246 | local FILE=$1
|
---|
| 247 | (
|
---|
| 248 | cat << EOF
|
---|
| 249 | @\$(call unpack2,$FILE)
|
---|
| 250 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 251 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 252 | EOF
|
---|
| 253 | ) >> $MKFILE.tmp
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 |
|
---|
| 257 | #=============================#
|
---|
| 258 | wrt_unpack4() { # Unpack and set 'ROOT' var
|
---|
| 259 | #=============================#
|
---|
| 260 | local FILE=$1
|
---|
| 261 | (
|
---|
| 262 | cat << EOF
|
---|
| 263 | @\$(call unpack4,$FILE)
|
---|
| 264 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 265 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 266 | EOF
|
---|
| 267 | ) >> $MKFILE.tmp
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 |
|
---|
| 271 |
|
---|
| 272 | #----------------------------------#
|
---|
| 273 | wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
---|
| 274 | #----------------------------------#
|
---|
| 275 | (
|
---|
| 276 | cat << EOF
|
---|
| 277 | echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
| 278 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
| 279 | EOF
|
---|
| 280 | ) >> $MKFILE.tmp
|
---|
| 281 |
|
---|
| 282 | }
|
---|
| 283 |
|
---|
| 284 |
|
---|
| 285 | #----------------------------------#
|
---|
| 286 | wrt_run_as_su() { #
|
---|
| 287 | #----------------------------------#
|
---|
| 288 | local this_script=$1
|
---|
| 289 | local file=$2
|
---|
| 290 | (
|
---|
| 291 | cat << EOF
|
---|
| 292 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
---|
| 293 | su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
|
---|
| 294 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 295 | EOF
|
---|
| 296 | ) >> $MKFILE.tmp
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 |
|
---|
| 300 | #==================================#
|
---|
| 301 | wrt_run_as_lfs() { # header to log file, execute script, footer to log file
|
---|
| 302 | #==================================#
|
---|
| 303 | local this_script=$1
|
---|
| 304 | local file=$2
|
---|
| 305 | (
|
---|
| 306 | cat << EOF
|
---|
| 307 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
---|
| 308 | su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
|
---|
| 309 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 310 | EOF
|
---|
| 311 | ) >> $MKFILE.tmp
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 |
|
---|
| 315 | #----------------------------------#
|
---|
| 316 | wrt_run_as_root() { #
|
---|
| 317 | #----------------------------------#
|
---|
| 318 | local this_script=$1
|
---|
| 319 | local file=$2
|
---|
| 320 | (
|
---|
| 321 | cat << EOF
|
---|
| 322 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
---|
| 323 | export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
---|
| 324 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 325 | EOF
|
---|
| 326 | ) >> $MKFILE.tmp
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 |
|
---|
| 330 | #=============================#
|
---|
| 331 | wrt_run_as_root2() { # Some scripts must be run as root..
|
---|
| 332 | #=============================#
|
---|
| 333 | local this_script=$1
|
---|
| 334 | local file=$2
|
---|
| 335 | (
|
---|
| 336 | cat << EOF
|
---|
| 337 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >logs/$this_script && \\
|
---|
| 338 | source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
---|
| 339 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >>logs/$this_script
|
---|
| 340 | EOF
|
---|
| 341 | ) >> $MKFILE.tmp
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 |
|
---|
| 345 | #----------------------------------#
|
---|
| 346 | wrt_remove_build_dirs() { #
|
---|
| 347 | #----------------------------------#
|
---|
| 348 | local name=$1
|
---|
| 349 | (
|
---|
| 350 | cat << EOF
|
---|
| 351 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 352 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
| 353 | if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
---|
| 354 | rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
---|
| 355 | fi;
|
---|
| 356 | EOF
|
---|
| 357 | ) >> $MKFILE.tmp
|
---|
| 358 | }
|
---|
| 359 |
|
---|
| 360 |
|
---|
| 361 | #----------------------------------#
|
---|
| 362 | wrt_remove_build_dirs2() { #
|
---|
| 363 | #----------------------------------#
|
---|
| 364 | local name=$1
|
---|
| 365 | (
|
---|
| 366 | cat << EOF
|
---|
| 367 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 368 | rm -r \$(SRC)/\$\$ROOT && \\
|
---|
| 369 | if [ -e \$(SRC)/$name-build ]; then \\
|
---|
| 370 | rm -r \$(SRC)/$name-build; \\
|
---|
| 371 | fi;
|
---|
| 372 | EOF
|
---|
| 373 | ) >> $MKFILE.tmp
|
---|
| 374 | }
|
---|
| 375 |
|
---|
| 376 |
|
---|
| 377 |
|
---|
| 378 | #----------------------------------#
|
---|
| 379 | wrt_run_as_chroot1() { #
|
---|
| 380 | #----------------------------------#
|
---|
| 381 | local this_script=$1
|
---|
| 382 | local file=$2
|
---|
| 383 | (
|
---|
| 384 | cat << EOF
|
---|
| 385 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
|
---|
| 386 | \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
|
---|
| 387 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
| 388 | EOF
|
---|
| 389 | ) >> $MKFILE.tmp
|
---|
| 390 | }
|
---|
| 391 |
|
---|
| 392 |
|
---|
| 393 | #----------------------------------#
|
---|
| 394 | wrt_run_as_chroot2() { #
|
---|
| 395 | #----------------------------------#
|
---|
| 396 | local this_script=$1
|
---|
| 397 | local file=$2
|
---|
| 398 | (
|
---|
| 399 | cat << EOF
|
---|
| 400 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
|
---|
| 401 | \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
|
---|
| 402 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
| 403 | EOF
|
---|
| 404 | ) >> $MKFILE.tmp
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 |
|
---|
| 408 | #----------------------------------#
|
---|
| 409 | wrt_copy_fstab() { #
|
---|
| 410 | #----------------------------------#
|
---|
| 411 | local i=$1
|
---|
| 412 | (
|
---|
| 413 | cat << EOF
|
---|
| 414 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$i && \\
|
---|
| 415 | cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1 && \\
|
---|
| 416 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$i
|
---|
| 417 | EOF
|
---|
| 418 | ) >> $MKFILE.tmp
|
---|
| 419 | }
|
---|
| 420 |
|
---|
| 421 | #----------------------------------#
|
---|
| 422 | wrt_copy_fstab2() { #
|
---|
| 423 | #----------------------------------#
|
---|
| 424 | local i=$1
|
---|
| 425 | (
|
---|
| 426 | cat << EOF
|
---|
| 427 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >logs/$i && \\
|
---|
| 428 | cp -v $FSTAB /etc/fstab >>logs/$i 2>&1 && \\
|
---|
| 429 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >>logs/$i
|
---|
| 430 | EOF
|
---|
| 431 | ) >> $MKFILE.tmp
|
---|
| 432 | }
|
---|
| 433 |
|
---|
| 434 |
|
---|
| 435 | #----------------------------------#
|
---|
| 436 | wrt_export_timezone() { #
|
---|
| 437 | #----------------------------------#
|
---|
| 438 | echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp
|
---|
| 439 | }
|
---|
| 440 |
|
---|
| 441 |
|
---|
| 442 | #----------------------------------#
|
---|
| 443 | wrt_export_pagesize() { #
|
---|
| 444 | #----------------------------------#
|
---|
| 445 | echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp
|
---|
| 446 | }
|
---|
| 447 |
|
---|
| 448 |
|
---|
| 449 | #----------------------------------#
|
---|
| 450 | wrt_export_pkgdir() { #
|
---|
| 451 | #----------------------------------#
|
---|
| 452 | (
|
---|
| 453 | cat << EOF
|
---|
| 454 | @echo "export PKGDIR=\$(SRC)/binutils-build" > envars
|
---|
| 455 | EOF
|
---|
| 456 | ) >> $MKFILE.tmp
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 |
|
---|
| 460 | #----------------------------#
|
---|
| 461 | run_make() {
|
---|
| 462 | #----------------------------#
|
---|
| 463 | # Test if make must be run.
|
---|
| 464 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
| 465 | # Test to make sure we're running the build as root
|
---|
| 466 | if [ "$UID" != "0" ] ; then
|
---|
| 467 | echo "You must be logged in as root to successfully build LFS."
|
---|
| 468 | exit 1
|
---|
| 469 | fi
|
---|
| 470 | # Build the system
|
---|
| 471 | if [ -e $MKFILE ] ; then
|
---|
| 472 | echo -ne "Building the LFS system...\n"
|
---|
| 473 | cd $JHALFSDIR && make -f ${PROGNAME}-Makefile
|
---|
| 474 | echo -ne "done\n"
|
---|
| 475 | fi
|
---|
| 476 | fi
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 |
|
---|
| 480 | #----------------------------#
|
---|
| 481 | clean_builddir() {
|
---|
| 482 | #----------------------------#
|
---|
| 483 | # Test if the clean must be done.
|
---|
| 484 | if [ "$CLEAN" = "1" ] ; then
|
---|
| 485 | # Test to make sure we're running the clean as root
|
---|
| 486 | if [ "$UID" != "0" ] ; then
|
---|
| 487 | echo "You must be logged in as root to clean the build directory."
|
---|
| 488 | exit 1
|
---|
| 489 | fi
|
---|
| 490 | # Test to make sure that the build directory was populated by jhalfs
|
---|
| 491 | if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
| 492 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
---|
| 493 | exit 1
|
---|
| 494 | else
|
---|
| 495 | # Clean the build directory
|
---|
| 496 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
| 497 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var}
|
---|
| 498 | echo -ne "Cleaning $JHALFSDIR...\n"
|
---|
| 499 | rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
---|
| 500 | echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
---|
| 501 | rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
| 502 | echo -ne "done\n"
|
---|
| 503 | fi
|
---|
| 504 | fi
|
---|
| 505 | }
|
---|
| 506 |
|
---|
| 507 | #----------------------------#
|
---|
| 508 | get_book() {
|
---|
| 509 | #----------------------------#
|
---|
| 510 | cd $JHALFSDIR
|
---|
| 511 |
|
---|
| 512 | if [ -z $WC ] ; then
|
---|
| 513 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
| 514 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
| 515 | exit 1"
|
---|
| 516 | echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
|
---|
| 517 |
|
---|
| 518 | case $PROGNAME in
|
---|
| 519 | lfs) svn_root="LFS" ;;
|
---|
| 520 | hlfs) svn_root="HLFS" ;;
|
---|
| 521 | clfs) svn_root="cross-lfs" ;;
|
---|
| 522 | blfs) svn_root="BLFS" ;;
|
---|
| 523 | *) echo "BOOK not defined in function <get_book>"
|
---|
| 524 | exit 1 ;;
|
---|
| 525 | esac
|
---|
| 526 | # Grab a fresh LFS book if it's missing, otherwise, update it from the
|
---|
| 527 | # repo. If we've already extracted the commands, move on to getting the
|
---|
| 528 | # sources.
|
---|
| 529 | if [ -d ${PROGNAME}-$LFSVRS ] ; then
|
---|
| 530 | cd ${PROGNAME}-$LFSVRS
|
---|
| 531 | if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \
|
---|
| 532 | test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
|
---|
| 533 | echo -ne "done\n"
|
---|
| 534 | # Set the canonical book version
|
---|
| 535 | cd $JHALFSDIR
|
---|
| 536 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
| 537 | get_sources
|
---|
| 538 | else
|
---|
| 539 | echo -ne "done\n"
|
---|
| 540 | # Set the canonical book version
|
---|
| 541 | cd $JHALFSDIR
|
---|
| 542 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
| 543 | extract_commands
|
---|
| 544 | fi
|
---|
| 545 | else
|
---|
| 546 | case $LFSVRS in
|
---|
| 547 | development)
|
---|
| 548 | svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
| 549 | alphabetical)
|
---|
| 550 | svn co $SVN/${svn_root}/branches/$LFSVRS/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
| 551 | esac
|
---|
| 552 | echo -ne "done\n"
|
---|
| 553 | # Set the canonical book version
|
---|
| 554 | cd $JHALFSDIR
|
---|
| 555 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
| 556 | extract_commands
|
---|
| 557 | fi
|
---|
| 558 | else
|
---|
| 559 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
| 560 | # Set the canonical book version
|
---|
| 561 | cd $JHALFSDIR
|
---|
| 562 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
| 563 | extract_commands
|
---|
| 564 | fi
|
---|
| 565 | }
|
---|
| 566 |
|
---|
| 567 |
|
---|
| 568 | #----------------------------#
|
---|
| 569 | build_patches_file() { # Supply a suitably formated list of patches.
|
---|
| 570 | #----------------------------#
|
---|
| 571 | local saveIFS=$IFS
|
---|
| 572 |
|
---|
| 573 | LOC_add_patches_entry() {
|
---|
| 574 | for f in `grep "/$1-" patcheslist_.wget`; do
|
---|
| 575 | basename $f | sed "s|${2}|\&${1}-version;|" >> patches
|
---|
| 576 | done
|
---|
| 577 | }
|
---|
| 578 |
|
---|
| 579 | xsltproc --nonet \
|
---|
| 580 | --xinclude \
|
---|
| 581 | -o patcheslist_.wget \
|
---|
| 582 | hlfs-patcheslist_.xsl \
|
---|
| 583 | $BOOK/index.xml > /dev/null 2>&1
|
---|
| 584 |
|
---|
| 585 | rm -f patches
|
---|
| 586 |
|
---|
| 587 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
| 588 | for f in `cat packages`; do
|
---|
| 589 | IFS=$saveIFS
|
---|
| 590 | LOC_add_patches_entry \
|
---|
| 591 | `echo $f | sed -e 's/-version//' \
|
---|
| 592 | -e 's/-file.*//' \
|
---|
| 593 | -e 's/"//g' \
|
---|
| 594 | -e 's/uclibc/uClibc/'`
|
---|
| 595 | done
|
---|
| 596 |
|
---|
| 597 | # .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
---|
| 598 | for f in `grep "/grsecurity-" patcheslist_.wget`; do
|
---|
| 599 | basename $f >> patches
|
---|
| 600 | done
|
---|
| 601 |
|
---|
| 602 | IFS=$saveIFS
|
---|
| 603 | rm -f patcheslist_.wget
|
---|
| 604 | }
|
---|
| 605 |
|
---|
| 606 |
|
---|
| 607 |
|
---|
| 608 | #----------------------------#
|
---|
| 609 | extract_commands() { #
|
---|
| 610 | #----------------------------#
|
---|
| 611 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
| 612 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
| 613 | exit 1"
|
---|
| 614 |
|
---|
| 615 | cd $JHALFSDIR
|
---|
| 616 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
| 617 |
|
---|
| 618 | # Start clean
|
---|
| 619 | if [ -d commands ]; then
|
---|
| 620 | rm -rf commands
|
---|
| 621 | mkdir -v commands
|
---|
| 622 | fi
|
---|
| 623 | echo -n "Extracting commands..."
|
---|
| 624 |
|
---|
| 625 | # Dump the commands in shell script form from the HLFS book.
|
---|
| 626 | case ${PROGNAME} in
|
---|
| 627 | clfs)
|
---|
| 628 | echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
| 629 | xsltproc --xinclude \
|
---|
| 630 | --nonet \
|
---|
| 631 | --output ./${PROGNAME}-commands/ \
|
---|
| 632 | $BOOK/stylesheets/dump-commands.xsl $BOOK/$ARCH-index.xml
|
---|
| 633 | ;;
|
---|
| 634 | hlfs)
|
---|
| 635 | echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS architecture"
|
---|
| 636 | xsltproc --nonet \
|
---|
| 637 | --xinclude \
|
---|
| 638 | --stringparam model $MODEL \
|
---|
| 639 | --stringparam testsuite $TEST \
|
---|
| 640 | --stringparam vim-lang $VIMLANG \
|
---|
| 641 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 642 | ;;
|
---|
| 643 | lfs)
|
---|
| 644 | echo "${tab_}Extracting commands for ${L_arrow}${BOLD}LFS${R_arrow} build"
|
---|
| 645 | xsltproc --nonet \
|
---|
| 646 | --xinclude \
|
---|
| 647 | --stringparam testsuite $TEST \
|
---|
| 648 | --stringparam vim-lang $VIMLANG \
|
---|
| 649 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 650 | ;;
|
---|
| 651 | blfs)
|
---|
| 652 | echo "${tab_}Extracting commands for ${L_arrow}${BOLD}BLFS${R_arrow} build"
|
---|
| 653 | xsltproc --nonet \
|
---|
| 654 | --xinclude \
|
---|
| 655 | --stringparam testsuite $TEST \
|
---|
| 656 | --stringparam server $SERVER \
|
---|
| 657 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 658 | ;;
|
---|
| 659 | *) exit 1
|
---|
| 660 | esac
|
---|
| 661 |
|
---|
| 662 |
|
---|
| 663 |
|
---|
| 664 | # Make the scripts executable.
|
---|
| 665 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
| 666 |
|
---|
| 667 | # Grab the patches and package names.
|
---|
| 668 | cd $JHALFSDIR
|
---|
| 669 | for i in patches packages ; do rm -f $i ; done
|
---|
| 670 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
|
---|
| 671 | -e '/generic/d' >> packages
|
---|
| 672 |
|
---|
| 673 | # Download the vim-lang package if it must be installed
|
---|
| 674 | if [ "$VIMLANG" = "1" ] ; then
|
---|
| 675 | echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
---|
| 676 | fi
|
---|
| 677 | echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
|
---|
| 678 |
|
---|
| 679 | # There is no HLFS patches.ent file so we will create one.
|
---|
| 680 |
|
---|
| 681 | case "${PROGNAME}" in
|
---|
| 682 | hlfs) build_patches_file ;;
|
---|
| 683 | clfs) ;;
|
---|
| 684 | lfs) ;;
|
---|
| 685 | blfs) ;;
|
---|
| 686 | *) exit 1
|
---|
| 687 | esac
|
---|
| 688 |
|
---|
| 689 |
|
---|
| 690 | # Done. Moving on...
|
---|
| 691 | echo -ne " ... done\n"
|
---|
| 692 | get_sources
|
---|
| 693 | }
|
---|
| 694 |
|
---|
| 695 |
|
---|
| 696 | #----------------------------#
|
---|
| 697 | download() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
| 698 | #----------------------------#
|
---|
| 699 | cd $BUILDDIR/sources
|
---|
| 700 |
|
---|
[12a5707] | 701 | # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn}
|
---|
| 702 | # that don't conform to norms in the URL scheme.
|
---|
[0170229] | 703 | DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
|
---|
| 704 |
|
---|
| 705 | # Find the md5 sum for this package.
|
---|
| 706 | if [ $2 != MD5SUMS ] ; then
|
---|
| 707 | set +e
|
---|
| 708 | MD5=`grep " $2" MD5SUMS`
|
---|
| 709 | if [ $? -ne 0 ]; then
|
---|
| 710 | set -e
|
---|
| 711 | echo "${RED}$2 not found in MD5SUMS${OFF}"
|
---|
| 712 | echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
|
---|
| 713 | return
|
---|
| 714 | fi
|
---|
| 715 | set -e
|
---|
| 716 | fi
|
---|
| 717 |
|
---|
| 718 | if [ ! -f $2 ] ; then
|
---|
| 719 | case $DL in
|
---|
[12a5707] | 720 | wget ) wget --passive $FTP/$DIR/$2 ;;
|
---|
| 721 | curl ) `curl -# $FTP/$DIR/$2 -o $2` ;;
|
---|
[0170229] | 722 | * ) echo "$DL not supported at this time." ;;
|
---|
| 723 | esac
|
---|
| 724 | elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
|
---|
| 725 | case $DL in
|
---|
[12a5707] | 726 | wget ) wget --passive -c $FTP/$DIR/$2 ;;
|
---|
| 727 | curl ) `curl -# -C - $FTP/$DIR/$2 -o $2` ;;
|
---|
[0170229] | 728 | * ) echo "$DL not supported at this time." ;;
|
---|
| 729 | esac
|
---|
| 730 | fi
|
---|
| 731 |
|
---|
| 732 | if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
|
---|
| 733 | exit 1
|
---|
| 734 | fi
|
---|
| 735 | if [ $2 != MD5SUMS ] ; then
|
---|
| 736 | echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
|
---|
| 737 | fi
|
---|
| 738 | }
|
---|
| 739 |
|
---|
| 740 |
|
---|
| 741 | #----------------------------#
|
---|
| 742 | get_sources() {
|
---|
| 743 | #----------------------------#
|
---|
| 744 |
|
---|
| 745 | # Test if the packages must be downloaded
|
---|
| 746 | if [ "$HPKG" = "1" ] ; then
|
---|
| 747 |
|
---|
| 748 | # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
|
---|
| 749 | # separates each iteration by lines. It is necessary to have the second
|
---|
| 750 | # ' on the next line.
|
---|
| 751 | IFS='
|
---|
| 752 | '
|
---|
| 753 |
|
---|
| 754 | if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
---|
| 755 | cd $BUILDDIR/sources
|
---|
| 756 | if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
---|
| 757 | if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
---|
| 758 |
|
---|
| 759 | download "" MD5SUMS
|
---|
| 760 |
|
---|
| 761 | # Iterate through each package and grab it, along with any patches it needs.
|
---|
| 762 | for i in `cat $JHALFSDIR/packages` ; do
|
---|
| 763 | PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
|
---|
| 764 |
|
---|
| 765 | # There are some entities that aren't valid packages.
|
---|
[12a5707] | 766 | if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
|
---|
[0170229] | 767 |
|
---|
| 768 | VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 769 | case $PKG in
|
---|
| 770 | tcl) FILE="$PKG$VRS-src.tar.bz2" ;;
|
---|
| 771 | vim-lang) PKG="vim"
|
---|
| 772 | FILE="vim-$VRS-lang.tar.bz2" ;;
|
---|
| 773 | udev-config) PKG="udev"
|
---|
| 774 | FILE="$VRS" ;;
|
---|
| 775 | *) FILE="$PKG-$VRS.tar.bz2" ;;
|
---|
| 776 | esac
|
---|
| 777 | download $PKG $FILE
|
---|
| 778 |
|
---|
| 779 | # Download any associated patches
|
---|
| 780 | for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
|
---|
| 781 | PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
---|
| 782 | download $PKG $PATCH
|
---|
| 783 | done
|
---|
| 784 | done
|
---|
| 785 | fi
|
---|
| 786 | }
|
---|
| 787 |
|
---|
| 788 | #-----------------------------------------------#
|
---|
| 789 | _IS_() # Function to test build scripts names
|
---|
| 790 | #-----------------------------------------------#
|
---|
| 791 | {
|
---|
| 792 | # Returns substr $2 or null str
|
---|
| 793 | # Must use string testing
|
---|
| 794 | case $1 in
|
---|
| 795 | *$2*) echo "$2" ;;
|
---|
| 796 | *) echo "" ;;
|
---|
| 797 | esac
|
---|
| 798 | }
|
---|