1 | #!/bin/sh
|
---|
2 | set -e # Enable error trapping
|
---|
3 | set -u # Trap undefined variables.. Forces the programmer
|
---|
4 | # to define a variable before using it
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Load the configuration file
|
---|
8 | #
|
---|
9 | source jhahlfs.conf
|
---|
10 |
|
---|
11 | # VT100 colors
|
---|
12 | declare -r BLACK=$'\e[1;30m'
|
---|
13 | declare -r DK_GRAY=$'\e[0;30m'
|
---|
14 |
|
---|
15 | declare -r RED=$'\e[31m'
|
---|
16 | declare -r GREEN=$'\e[32m'
|
---|
17 | declare -r YELLOW=$'\e[33m'
|
---|
18 | declare -r BLUE=$'\e[34m'
|
---|
19 | declare -r MAGENTA=$'\e[35m'
|
---|
20 | declare -r CYAN=$'\e[36m'
|
---|
21 | declare -r WHITE=$'\e[37m'
|
---|
22 |
|
---|
23 | declare -r OFF=$'\e[0m'
|
---|
24 | declare -r BOLD=$'\e[1m'
|
---|
25 | declare -r REVERSE=$'\e[7m'
|
---|
26 | declare -r HIDDEN=$'\e[8m'
|
---|
27 |
|
---|
28 | declare -r tab_=$'\t'
|
---|
29 | declare -r nl_=$'\n'
|
---|
30 |
|
---|
31 | declare -r DD_BORDER="${BOLD}${WHITE}==============================================================================${OFF}"
|
---|
32 | declare -r SD_BORDER="${BOLD}${WHITE}------------------------------------------------------------------------------${OFF}"
|
---|
33 | declare -r STAR_BORDER="${BOLD}${WHITE}******************************************************************************${OFF}"
|
---|
34 |
|
---|
35 | # bold yellow > < pair
|
---|
36 | declare -r R_arrow=$'\e[1;33m>\e[0m'
|
---|
37 | declare -r L_arrow=$'\e[1;33m<\e[0m'
|
---|
38 |
|
---|
39 |
|
---|
40 | # START predefine some internal vars.. proper programming style
|
---|
41 |
|
---|
42 | # If the var BOOK contains something then, maybe, it points
|
---|
43 | # to a working doc.. set WC=1, else 'null'
|
---|
44 | WC=${BOOK:+1}
|
---|
45 |
|
---|
46 | CLEAN=0 # Clean out build dir?
|
---|
47 | DL= # The download app to use
|
---|
48 | PREV= # name of previous script processed
|
---|
49 | chapter5=
|
---|
50 | chapter6=
|
---|
51 | chapter7=
|
---|
52 |
|
---|
53 | # END predefined vars section
|
---|
54 |
|
---|
55 | _inline_doc="
|
---|
56 | This script, jhahlfs, strives to create an accurate makefile
|
---|
57 | directly from the xml files used to generate the Hardened Linux From
|
---|
58 | Scratch document.
|
---|
59 | The usage of this script assumes you have read and are familiar with
|
---|
60 | the book and therefore the configuration variables found in jhahlfs.conf
|
---|
61 | will have meaning to you. There are a limited number of command line
|
---|
62 | switches which, if used, will override the config file settings.
|
---|
63 |
|
---|
64 | NOTES::
|
---|
65 | *. The resulting Makefile takes considerable time to run to completion,
|
---|
66 | lay in a supply of caffeine beverages.
|
---|
67 |
|
---|
68 | *. The document, Hardened Linux From Scratch, specifies a Linux kernel
|
---|
69 | >=2.6.2 and GCC >=3.0 for proper compilation.
|
---|
70 |
|
---|
71 | *. It is recommended that you temporarily unpack your linux kernel and
|
---|
72 | run <make menuconfig> and configure the kernal as per the book and save
|
---|
73 | the resulting .config file.
|
---|
74 |
|
---|
75 | *. Chapter07 contains numerous command files which require customizing
|
---|
76 | before you start 129-console, 131-profile, 133-hosts, 134-network,
|
---|
77 | 135-fstab, 136-kernel.
|
---|
78 | "
|
---|
79 |
|
---|
80 | version="
|
---|
81 | jhahlfs development \$Date$
|
---|
82 |
|
---|
83 | Written by George Boudreau
|
---|
84 |
|
---|
85 | Based on the jhalfs code written by Jeremy Huntwork and Manuel Canales Esparcia.
|
---|
86 |
|
---|
87 | This program is published under the ${WHITE}Gnu General Public License, Version 2.${OFF}
|
---|
88 | "
|
---|
89 |
|
---|
90 | usage() {
|
---|
91 | 'clear'
|
---|
92 | cat <<- -EOF-
|
---|
93 | ${DD_BORDER}
|
---|
94 | ${BOLD}
|
---|
95 | Usage: $0 ${BOLD}[OPTION]
|
---|
96 |
|
---|
97 | Options:
|
---|
98 | ${BOLD} -h, --help
|
---|
99 | ${OFF} print this help, then exit
|
---|
100 | ${BOLD} --readme
|
---|
101 | ${OFF} print a small readme file, then exit
|
---|
102 | ${BOLD} -V, --version
|
---|
103 | ${OFF} print version number, then exit
|
---|
104 | ${BOLD} -d --directory DIR
|
---|
105 | ${OFF} use DIR directory for building HLFS; all files jhahlfs produces will be
|
---|
106 | in the directory DIR/jhahlfs. Default is \"/mnt/lfs\".
|
---|
107 | ${BOLD} --rebuild
|
---|
108 | ${OFF} clean the build directory before to perfom any other task. The directory
|
---|
109 | is cleaned only if it was populated by a previous jhahlfs run.
|
---|
110 | ${BOLD} -P, --get-packages
|
---|
111 | ${OFF} download the packages and patches. This assumes that the server declared in the
|
---|
112 | jhahlfs.conf file has the proper packages and patches for the book version being
|
---|
113 | processed.
|
---|
114 | ${BOLD} -W, --working-copy DIR
|
---|
115 | ${OFF} use the local working copy placed in DIR as the HLFS book
|
---|
116 | ${BOLD} -L, --HLFS-version VER
|
---|
117 | ${OFF} checkout VER version of the HLFS book. Supported versions at this time are:
|
---|
118 | dev* | trunk | SVN aliases for Development HLFS
|
---|
119 | ${BOLD} --fstab FILE
|
---|
120 | ${OFF} use FILE as the /etc/fstab file for the HLFS system. If not specified,
|
---|
121 | a default /etc/fstab file with dummy values is created.
|
---|
122 | ${BOLD} -C, --kernel-config FILE
|
---|
123 | ${OFF} use the kernel configuration file specified in FILE to build the kernel.
|
---|
124 | if the file is not found, or if not specified, the kernel build is skipped.
|
---|
125 | ${BOLD} -M, --run-make
|
---|
126 | ${OFF} run make on the generated Makefile
|
---|
127 | ${DD_BORDER}
|
---|
128 | -EOF-
|
---|
129 | exit
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | help="\
|
---|
134 | Try '$0 --help' for more information."
|
---|
135 |
|
---|
136 | no_empty_builddir() {
|
---|
137 | 'clear'
|
---|
138 | cat <<- -EOF-
|
---|
139 | ${DD_BORDER}
|
---|
140 |
|
---|
141 | ${tab_}${tab_}${RED}W A R N I N G${OFF}
|
---|
142 | ${GREEN}
|
---|
143 | Looks like the \$BUILDDIR directory contains subdirectories
|
---|
144 | from a previous HLFS build.
|
---|
145 |
|
---|
146 | Please format the partition mounted on \$BUILDDIR or set
|
---|
147 | a different build directory before running jhahlfs.
|
---|
148 | ${OFF}
|
---|
149 | ${DD_BORDER}
|
---|
150 | -EOF-
|
---|
151 | exit
|
---|
152 | }
|
---|
153 |
|
---|
154 | exit_missing_arg="\
|
---|
155 | echo \"Option '\$1' requires an argument\" >&2
|
---|
156 | echo \"\$help\" >&2
|
---|
157 | exit 1"
|
---|
158 |
|
---|
159 | no_dl_client="\
|
---|
160 | echo \"Could not find a way to download the HLFS sources.\" >&2
|
---|
161 | echo \"Attempting to continue.\" >&2"
|
---|
162 |
|
---|
163 | HEADER="# This file is automatically generated by jhahlfs
|
---|
164 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
165 | #
|
---|
166 | # Generated on `date \"+%F %X %Z\"`"
|
---|
167 |
|
---|
168 | #>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
|
---|
169 | #-----------------------#
|
---|
170 | simple_error() { # Basic error trap.... JUST DIE
|
---|
171 | #-----------------------#
|
---|
172 | # If +e then disable text output
|
---|
173 | if [[ "$-" =~ "e" ]]; then
|
---|
174 | echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
|
---|
175 | fi
|
---|
176 | }
|
---|
177 |
|
---|
178 | see_ya() {
|
---|
179 | echo -e "\n\t${BOLD}Goodbye and thank you for choosing ${YELLOW}JHAHLFS\n${OFF}"
|
---|
180 | }
|
---|
181 | ##### Simple error TRAPS
|
---|
182 | # ctrl-c SIGINT
|
---|
183 | # ctrl-y
|
---|
184 | # ctrl-z SIGTSTP
|
---|
185 | # SIGHUP 1 HANGUP
|
---|
186 | # SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
|
---|
187 | # SIGQUIT 3
|
---|
188 | # SIGKILL 9 KILL
|
---|
189 | # SIGTERM 15 TERMINATION
|
---|
190 | # SIGSTOP 17,18,23 STOP THE PROCESS
|
---|
191 | #####
|
---|
192 | set -e
|
---|
193 | trap see_ya 0
|
---|
194 | trap simple_error ERR
|
---|
195 | trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
|
---|
196 | #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
---|
197 |
|
---|
198 |
|
---|
199 | ###################################
|
---|
200 | ### FUNCTIONS ###
|
---|
201 | ###################################
|
---|
202 |
|
---|
203 | #----------------------------#
|
---|
204 | check_requirements() { # Simple routine to validate gcc and kernel versions against requirements
|
---|
205 | #----------------------------#
|
---|
206 | # Minimum values acceptable
|
---|
207 | # bash 3.0>
|
---|
208 | # gcc 3.0>
|
---|
209 | # kernel 2.6.2>
|
---|
210 |
|
---|
211 | [[ $1 = "1" ]] && echo "${nl_}BASH: ${L_arrow}${BOLD}${BASH_VERSION}${R_arrow}"
|
---|
212 | case $BASH_VERSION in
|
---|
213 | [3-9].*) ;;
|
---|
214 | *) 'clear'
|
---|
215 | echo -e "
|
---|
216 | $DD_BORDER
|
---|
217 | \t\t${OFF}${RED}BASH version ${BOLD}${YELLOW}-->${WHITE} $BASH_VERSION ${YELLOW}<--${OFF}${RED} is too old.
|
---|
218 | \t\t This script requires 3.0${OFF}${RED} or greater
|
---|
219 | $DD_BORDER"
|
---|
220 | exit 1
|
---|
221 | ;;
|
---|
222 | esac
|
---|
223 |
|
---|
224 | [[ $1 = "1" ]] && echo "GCC: ${L_arrow}${BOLD}`gcc -dumpversion`${R_arrow}"
|
---|
225 | case `gcc -dumpversion` in
|
---|
226 | [3-9].[0-9].* ) ;;
|
---|
227 | *) 'clear'
|
---|
228 | echo -e "
|
---|
229 | $DD_BORDER
|
---|
230 | \t\t${OFF}${RED}GCC version ${BOLD}${YELLOW}-->${WHITE} $(gcc -dumpversion) ${YELLOW}<--${OFF}${RED} is too old.
|
---|
231 | \t\t This script requires ${BOLD}${WHITE}3.0${OFF}${RED} or greater
|
---|
232 | $DD_BORDER"
|
---|
233 | exit 1
|
---|
234 | ;;
|
---|
235 | esac
|
---|
236 |
|
---|
237 | #
|
---|
238 | # >>>> Check kernel version against the minimum acceptable level <<<<
|
---|
239 | #
|
---|
240 | [[ $1 = "1" ]] && echo "LINUX: ${L_arrow}${BOLD}`uname -r`${R_arrow}"
|
---|
241 |
|
---|
242 | local IFS
|
---|
243 | declare -i major minor revision change
|
---|
244 | min_kernel_vers=2.6.2
|
---|
245 |
|
---|
246 | IFS=".-" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
|
---|
247 | set -- $min_kernel_vers # set postional parameters to minimum ver values
|
---|
248 | major=$1; minor=$2; revision=$3
|
---|
249 | #
|
---|
250 | set -- `uname -r` # Set postional parameters to user kernel version
|
---|
251 | #Compare against minimum acceptable kernel version..
|
---|
252 | (( $1 > major )) && return
|
---|
253 | (( $1 == major )) && ((( $2 > minor )) ||
|
---|
254 | ((( $2 == minor )) && (( $3 >= revision )))) && return
|
---|
255 |
|
---|
256 | # oops.. write error msg and die
|
---|
257 | echo -e "
|
---|
258 | $DD_BORDER
|
---|
259 | \t\t${OFF}${RED}The kernel version ${BOLD}${YELLOW}-->${WHITE} $(uname -r) ${YELLOW}<--${OFF}${RED} is too old.
|
---|
260 | \t\tThis script requires version ${BOLD}${WHITE}$min_kernel_vers${OFF}${RED} or greater
|
---|
261 | $DD_BORDER"
|
---|
262 | exit 1
|
---|
263 | }
|
---|
264 |
|
---|
265 |
|
---|
266 | #----------------------------#
|
---|
267 | validate_config() { # Are the config values sane (within reason)
|
---|
268 | #----------------------------#
|
---|
269 | local -r PARAM_LIST="BUILDDIR HPKG MODEL TEST TOOLCHAINTEST STRIP VIMLANG PAGE GRSECURITY_HOST RUNMAKE"
|
---|
270 | local -r ERROR_MSG='${OFF}${RED}The variable \"${GREEN}${config_param}${RED}\" value ${BOLD}${YELLOW}--\>${WHITE}${!config_param}${YELLOW}\<--${OFF}${RED} is invalid, check the config file ${GREEN}\<jhahlfs.conf\>${OFF}'
|
---|
271 | local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
272 | local config_param
|
---|
273 | local validation_str
|
---|
274 |
|
---|
275 | write_error_and_die() {
|
---|
276 | echo -e "\n${DD_BORDER}"
|
---|
277 | echo "`eval echo ${ERROR_MSG}`" >&2
|
---|
278 | echo -e "${DD_BORDER}\n"
|
---|
279 | exit 1
|
---|
280 | }
|
---|
281 |
|
---|
282 | set +e
|
---|
283 |
|
---|
284 | for config_param in $PARAM_LIST; do
|
---|
285 | [[ $1 = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
---|
286 | case $config_param in
|
---|
287 | BUILDDIR) # We cannot have an <empty> or </> root mount point
|
---|
288 | if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
|
---|
289 | write_error_and_die
|
---|
290 | fi
|
---|
291 | continue ;;
|
---|
292 | HPKG) validation_str="x0x x1x" ;;
|
---|
293 | RUNMAKE) validation_str="x0x x1x" ;;
|
---|
294 | TEST) validation_str="x0x x1x" ;;
|
---|
295 | STRIP) validation_str="x0x x1x" ;;
|
---|
296 | VIMLANG) validation_str="x0x x1x" ;;
|
---|
297 | TOOLCHAINTEST) validation_str="x0x x1x" ;;
|
---|
298 | GRSECURITY_HOST) validation_str="x0x x1x" ;;
|
---|
299 |
|
---|
300 | MODEL) validation_str="xglibcx xuclibcx" ;;
|
---|
301 | PAGE) validation_str="xletterx xA4x" ;;
|
---|
302 | *)
|
---|
303 | echo "WHAT PARAMETER IS THIS.. <<${config_param}>>"
|
---|
304 | exit
|
---|
305 | ;;
|
---|
306 | esac
|
---|
307 | # This is the 'regexp' test available in bash-3.0..
|
---|
308 | # using it as a poor man's test for substring
|
---|
309 | if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
|
---|
310 | # parameter value entered is no good
|
---|
311 | write_error_and_die
|
---|
312 | fi
|
---|
313 | done # for loop
|
---|
314 |
|
---|
315 | for config_param in LC_ALL LANG; do
|
---|
316 | [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
317 | [[ -z "${!config_param}" ]] && continue
|
---|
318 | # See it the locale values exist on this machine
|
---|
319 | [[ "`locale -a | grep -c ${!config_param}`" > 0 ]] && continue
|
---|
320 |
|
---|
321 | # If you make it this far then there is a problem
|
---|
322 | write_error_and_die
|
---|
323 | done
|
---|
324 |
|
---|
325 | for config_param in FSTAB CONFIG KEYMAP BOOK; do
|
---|
326 | [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
327 | # If this is not a working copy, ie the default book, then skip
|
---|
328 | [[ -z $WC ]] && continue
|
---|
329 | [[ -z "${!config_param}" ]] && continue
|
---|
330 | [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
|
---|
331 |
|
---|
332 | # If you make it this far then there is a problem
|
---|
333 | write_error_and_die
|
---|
334 | done
|
---|
335 |
|
---|
336 | set -e
|
---|
337 | echo "$tab_${BOLD}${YELLOW} Config parameters look good${OFF}${nl_}"
|
---|
338 | }
|
---|
339 |
|
---|
340 |
|
---|
341 | #----------------------------#
|
---|
342 | build_patches_file() { # Supply a suitably formated list of patches.
|
---|
343 | #----------------------------#
|
---|
344 | local saveIFS=$IFS
|
---|
345 |
|
---|
346 | LOC_add_patches_entry() {
|
---|
347 | for f in `grep "/$1-" patcheslist_.wget`; do
|
---|
348 | basename $f | sed "s|${2}|\&${1}-version;|" >> patches
|
---|
349 | done
|
---|
350 | }
|
---|
351 |
|
---|
352 | xsltproc --nonet \
|
---|
353 | --xinclude \
|
---|
354 | -o patcheslist_.wget \
|
---|
355 | hlfs-patcheslist_.xsl \
|
---|
356 | $BOOK/index.xml > /dev/null 2>&1
|
---|
357 |
|
---|
358 | rm -f patches
|
---|
359 |
|
---|
360 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
361 | for f in `cat packages`; do
|
---|
362 | IFS=$saveIFS
|
---|
363 | LOC_add_patches_entry \
|
---|
364 | `echo $f | sed -e 's/-version//' \
|
---|
365 | -e 's/-file.*//' \
|
---|
366 | -e 's/"//g' \
|
---|
367 | -e 's/uclibc/uClibc/'`
|
---|
368 | done
|
---|
369 |
|
---|
370 | # .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
---|
371 | for f in `grep "/grsecurity-" patcheslist_.wget`; do
|
---|
372 | basename $f >> patches
|
---|
373 | done
|
---|
374 |
|
---|
375 | IFS=$saveIFS
|
---|
376 | rm -f patcheslist_.wget
|
---|
377 | }
|
---|
378 |
|
---|
379 |
|
---|
380 | #----------------------------#
|
---|
381 | clean_builddir() { #
|
---|
382 | #----------------------------#
|
---|
383 | # Test if the clean must be done.
|
---|
384 | if [ "$CLEAN" = "1" ] ; then
|
---|
385 | # Test to make sure we're running the clean as root
|
---|
386 | if [ "$UID" != "0" ] ; then
|
---|
387 | echo "You must be logged in as root to clean the build directory."
|
---|
388 | exit 1
|
---|
389 | fi
|
---|
390 | # Test to make sure that the build directory was populated by jhahlfs
|
---|
391 | if [ ! -d $JHAHLFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
392 | echo "Looks like $BUILDDIR was not populated by a previous jhahlfs run."
|
---|
393 | exit 1
|
---|
394 | else
|
---|
395 | # Clean the build directory
|
---|
396 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
397 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var}
|
---|
398 | echo -ne "Cleaning $JHAHLFSDIR...\n"
|
---|
399 | rm -rf $JHAHLFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-hlfs-scripts.xsl,hlfs-functions,packages,patches}
|
---|
400 | echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
---|
401 | rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
402 | echo -ne "done\n"
|
---|
403 | fi
|
---|
404 | fi
|
---|
405 | }
|
---|
406 |
|
---|
407 | #----------------------------#
|
---|
408 | get_book() { #
|
---|
409 | #----------------------------#
|
---|
410 | cd $JHAHLFSDIR
|
---|
411 |
|
---|
412 | if [ -z $WC ] ; then
|
---|
413 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
414 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
415 | exit 1"
|
---|
416 |
|
---|
417 | echo -n "Downloading the HLFS Book, version $HLFSVRS... "
|
---|
418 | # Grab a fresh HLFS book if it's missing, otherwise, update it from the
|
---|
419 | # repo. If we've already extracted the commands, move on to getting the
|
---|
420 | # sources.
|
---|
421 | if [ -d hlfs-$HLFSVRS ] ; then
|
---|
422 | cd hlfs-$HLFSVRS
|
---|
423 | if LC_ALL=C svn up | grep -q At && \
|
---|
424 | test -d $JHAHLFSDIR/commands && \
|
---|
425 | test -f $JHAHLFSDIR/packages && \
|
---|
426 | test -f $JHAHLFSDIR/patches ; then
|
---|
427 | echo -ne "done\n"
|
---|
428 | # Set the canonical book version
|
---|
429 | cd $JHAHLFSDIR
|
---|
430 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
431 | get_sources
|
---|
432 | else
|
---|
433 | echo -ne "${BOLD}done\n"
|
---|
434 | extract_commands
|
---|
435 | fi
|
---|
436 | else
|
---|
437 | case $HLFSVRS in
|
---|
438 | development)
|
---|
439 | svn co $SVN/HLFS/trunk/BOOK hlfs-$HLFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
440 | ;;
|
---|
441 | *) echo -e "${RED}Invalid document version selected${OFF}"
|
---|
442 | ;;
|
---|
443 | esac
|
---|
444 | echo -ne "${BOLD}done\n"
|
---|
445 | extract_commands
|
---|
446 | fi
|
---|
447 | else
|
---|
448 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
449 | extract_commands
|
---|
450 | fi
|
---|
451 | }
|
---|
452 |
|
---|
453 | #----------------------------#
|
---|
454 | extract_commands() { #
|
---|
455 | #----------------------------#
|
---|
456 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
457 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
458 | exit 1"
|
---|
459 |
|
---|
460 | cd $JHAHLFSDIR
|
---|
461 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
462 |
|
---|
463 | # Start clean
|
---|
464 | if [ -d commands ]; then
|
---|
465 | rm -rf commands
|
---|
466 | mkdir -v commands
|
---|
467 | fi
|
---|
468 | echo -n "Extracting commands..."
|
---|
469 |
|
---|
470 | # Dump the commands in shell script form from the HLFS book.
|
---|
471 | xsltproc --nonet \
|
---|
472 | --xinclude \
|
---|
473 | --stringparam model $MODEL \
|
---|
474 | --stringparam testsuite $TEST \
|
---|
475 | --stringparam toolchaintest $TOOLCHAINTEST \
|
---|
476 | --stringparam vim-lang $VIMLANG \
|
---|
477 | -o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
478 |
|
---|
479 | # Make the scripts executable.
|
---|
480 | chmod -R +x $JHAHLFSDIR/commands
|
---|
481 |
|
---|
482 | # Grab the patches and package names.
|
---|
483 | cd $JHAHLFSDIR
|
---|
484 | for i in patches packages ; do rm -f $i ; done
|
---|
485 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
|
---|
486 | -e '/generic/d' >> packages
|
---|
487 |
|
---|
488 | # Download the vim-lang package if it must be installed
|
---|
489 | if [ "$VIMLANG" = "1" ] ; then
|
---|
490 | echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
---|
491 | fi
|
---|
492 | echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
|
---|
493 |
|
---|
494 | # There is no HLFS patches.ent file so we will create one.
|
---|
495 | build_patches_file
|
---|
496 |
|
---|
497 | # Done. Moving on...
|
---|
498 | echo -ne "${BOLD}done\n"
|
---|
499 | get_sources
|
---|
500 | }
|
---|
501 |
|
---|
502 | #----------------------------#
|
---|
503 | download() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
504 | #----------------------------#
|
---|
505 | cd $BUILDDIR/sources
|
---|
506 |
|
---|
507 | # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} and
|
---|
508 | # module-init-tools-testsuite packages that don't conform to
|
---|
509 | # norms in the URL scheme.
|
---|
510 | DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
|
---|
511 |
|
---|
512 | # Find the md5 sum for this package.
|
---|
513 | if [ $2 != MD5SUMS ] ; then
|
---|
514 | set +e
|
---|
515 | MD5=`grep " $2" MD5SUMS`
|
---|
516 | if [ $? -ne 0 ]; then
|
---|
517 | set -e
|
---|
518 | echo "${RED}$2 not found in MD5SUMS${OFF}"
|
---|
519 | echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
|
---|
520 | return
|
---|
521 | fi
|
---|
522 | set -e
|
---|
523 | fi
|
---|
524 |
|
---|
525 | if [ ! -f $2 ] ; then
|
---|
526 | case $DL in
|
---|
527 | wget ) wget --passive $FTP/$DIR/$2 ;;
|
---|
528 | curl ) `curl -# $FTP/$DIR/$2 -o $2` ;;
|
---|
529 | * ) echo "$DL not supported at this time." ;;
|
---|
530 | esac
|
---|
531 | elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
|
---|
532 | case $DL in
|
---|
533 | wget ) wget --passive -c $FTP/$DIR/$2 ;;
|
---|
534 | curl ) `curl -# -C - $FTP/$DIR/$2 -o $2` ;;
|
---|
535 | * ) echo "$DL not supported at this time." ;;
|
---|
536 | esac
|
---|
537 | fi
|
---|
538 |
|
---|
539 | if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
|
---|
540 | exit 1
|
---|
541 | fi
|
---|
542 | if [ $2 != MD5SUMS ] ; then
|
---|
543 | echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
|
---|
544 | fi
|
---|
545 | }
|
---|
546 |
|
---|
547 |
|
---|
548 | #----------------------------#
|
---|
549 | get_sources() { #
|
---|
550 | #----------------------------#
|
---|
551 | local IFS
|
---|
552 |
|
---|
553 | # Test if the packages must be downloaded
|
---|
554 | if [ ! "$HPKG" = "1" ] ; then
|
---|
555 | return
|
---|
556 | fi
|
---|
557 |
|
---|
558 | # Modify the 'internal field separator' to break on 'LF' only
|
---|
559 | IFS=$'\x0A'
|
---|
560 |
|
---|
561 | if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
---|
562 | cd $BUILDDIR/sources
|
---|
563 |
|
---|
564 | > MISSING_FILES.DMP # Files not in md5sum end up here
|
---|
565 |
|
---|
566 | if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
---|
567 | if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
---|
568 |
|
---|
569 | # Retrieve the master md5sum file
|
---|
570 | download "" MD5SUMS
|
---|
571 |
|
---|
572 | # Iterate through each package and grab it, along with any patches it needs.
|
---|
573 | for i in `cat $JHAHLFSDIR/packages` ; do
|
---|
574 | PKG=`echo $i | sed -e 's/-version.*//' \
|
---|
575 | -e 's/-file.*//' \
|
---|
576 | -e 's/uclibc/uClibc/' `
|
---|
577 |
|
---|
578 | # Needed for Groff patchlevel patch on UTF-8 branch
|
---|
579 | GROFFLEVEL=`grep "groff-patchlevel" $JHAHLFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
|
---|
580 |
|
---|
581 | #
|
---|
582 | # How to deal with orphan packages..??
|
---|
583 | #
|
---|
584 | VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
---|
585 | case "$PKG" in
|
---|
586 | "expect-lib" ) continue ;; # not valid packages
|
---|
587 | "linux-dl" ) continue ;;
|
---|
588 | "groff-patchlevel" ) continue ;;
|
---|
589 | "uClibc-patch" ) continue ;;
|
---|
590 |
|
---|
591 | "tcl" ) FILE="$PKG$VRS-src.tar.bz2" ; download $PKG $FILE ;;
|
---|
592 | "vim-lang" ) FILE="vim-$VRS-lang.tar.bz2"; PKG="vim" ; download $PKG $FILE ;;
|
---|
593 | "udev-config" ) FILE="$VRS" ; PKG="udev" ; download $PKG $FILE ;;
|
---|
594 |
|
---|
595 | "uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc"
|
---|
596 | download $PKG $FILE
|
---|
597 | # There can be no patches for this file
|
---|
598 | continue ;;
|
---|
599 |
|
---|
600 | "gcc" ) download $PKG "gcc-core-$VRS.tar.bz2"
|
---|
601 | download $PKG "gcc-g++-$VRS.tar.bz2"
|
---|
602 | ;;
|
---|
603 | "glibc") download $PKG "$PKG-$VRS.tar.bz2"
|
---|
604 | download $PKG "$PKG-libidn-$VRS.tar.bz2"
|
---|
605 | ;;
|
---|
606 | * ) FILE="$PKG-$VRS.tar.bz2"
|
---|
607 | download $PKG $FILE
|
---|
608 | ;;
|
---|
609 | esac
|
---|
610 |
|
---|
611 | for patch in `grep "$PKG-&$PKG" $JHAHLFSDIR/patches` ; do
|
---|
612 | PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
---|
613 | download $PKG $PATCH
|
---|
614 | done
|
---|
615 |
|
---|
616 | done
|
---|
617 |
|
---|
618 | # .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
---|
619 | download grsecurity `grep grsecurity $JHAHLFSDIR/patches`
|
---|
620 |
|
---|
621 | # .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue.
|
---|
622 | bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz
|
---|
623 |
|
---|
624 | if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
|
---|
625 | echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check <MISSING_FILES.DMP> for names ${OFF}\n\n"
|
---|
626 | fi
|
---|
627 | }
|
---|
628 |
|
---|
629 |
|
---|
630 | #----------------------------#
|
---|
631 | _IS_() { # Function to test build scripts names
|
---|
632 | #----------------------------#
|
---|
633 | # Returns substr $2 or null str
|
---|
634 | # Must use string testing
|
---|
635 | case $1 in
|
---|
636 | *$2*) echo "$2" ;;
|
---|
637 | *) echo "" ;;
|
---|
638 | esac
|
---|
639 | }
|
---|
640 |
|
---|
641 | #----------------------------#
|
---|
642 | chapter4_Makefiles() { # Initialization of the system
|
---|
643 | #----------------------------#
|
---|
644 | local TARGET LOADER
|
---|
645 |
|
---|
646 | echo " Processing Chapter-4 scripts "
|
---|
647 |
|
---|
648 | # Define a few model dependant variables
|
---|
649 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
650 | TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
651 | else
|
---|
652 | TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
653 | fi
|
---|
654 |
|
---|
655 | # 022-
|
---|
656 | # If /home/hlfs is already present in the host, we asume that the
|
---|
657 | # hlfs user and group are also presents in the host, and a backup
|
---|
658 | # of their bash init files is made.
|
---|
659 | (
|
---|
660 | cat << EOF
|
---|
661 | 020-creatingtoolsdir:
|
---|
662 | @\$(call echo_message, Building)
|
---|
663 | @mkdir -v \$(HLFS)/tools && \\
|
---|
664 | rm -fv /tools && \\
|
---|
665 | ln -sv \$(HLFS)/tools /
|
---|
666 | @if [ ! -d \$(HLFS)/sources ]; then \\
|
---|
667 | mkdir \$(HLFS)/sources; \\
|
---|
668 | fi;
|
---|
669 | @chmod a+wt \$(HLFS)/sources && \\
|
---|
670 | touch \$@
|
---|
671 |
|
---|
672 | 021-addinguser: 020-creatingtoolsdir
|
---|
673 | @\$(call echo_message, Building)
|
---|
674 | @if [ ! -d /home/hlfs ]; then \\
|
---|
675 | groupadd hlfs; \\
|
---|
676 | useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
|
---|
677 | else \\
|
---|
678 | touch user-hlfs-exist; \\
|
---|
679 | fi;
|
---|
680 | @chown hlfs \$(HLFS)/tools && \\
|
---|
681 | chown hlfs \$(HLFS)/sources && \\
|
---|
682 | touch \$@
|
---|
683 |
|
---|
684 | 022-settingenvironment: 021-addinguser
|
---|
685 | @\$(call echo_message, Building)
|
---|
686 | @if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
|
---|
687 | mv -v /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
|
---|
688 | fi;
|
---|
689 | @if [ -f /home/hlfs/.bash_profile -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
|
---|
690 | mv -v /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
|
---|
691 | fi;
|
---|
692 | @echo "set +h" > /home/hlfs/.bashrc && \\
|
---|
693 | echo "umask 022" >> /home/hlfs/.bashrc && \\
|
---|
694 | echo "HLFS=\$(HLFS)" >> /home/hlfs/.bashrc && \\
|
---|
695 | echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
|
---|
696 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
|
---|
697 | echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
|
---|
698 | echo "" >> /home/hlfs/.bashrc && \\
|
---|
699 | echo "target=$(uname -m)-${TARGET}" >> /home/hlfs/.bashrc && \\
|
---|
700 | echo "ldso=/tools/lib/${LOADER}" >> /home/hlfs/.bashrc && \\
|
---|
701 | echo "export target ldso" >> /home/hlfs/.bashrc && \\
|
---|
702 | echo "source $JHAHLFSDIR/envars" >> /home/hlfs/.bashrc && \\
|
---|
703 | chown hlfs:hlfs /home/hlfs/.bashrc && \\
|
---|
704 | touch envars && \\
|
---|
705 | touch \$@
|
---|
706 | EOF
|
---|
707 | ) >> $MKFILE.tmp
|
---|
708 |
|
---|
709 | }
|
---|
710 |
|
---|
711 | #----------------------------#
|
---|
712 | chapter5_Makefiles() { # Bootstrap or temptools phase
|
---|
713 | #----------------------------#
|
---|
714 |
|
---|
715 | echo " Processing Chapter-5 scripts"
|
---|
716 |
|
---|
717 | for file in chapter05/* ; do
|
---|
718 | # Keep the script file name
|
---|
719 | this_script=`basename $file`
|
---|
720 |
|
---|
721 | # Skip this script depending on jhahlfs.conf flags set.
|
---|
722 | case $this_script in
|
---|
723 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
724 | *tcl* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
|
---|
725 | *expect* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
|
---|
726 | *dejagnu* ) [[ "$TOOLCHAINTEST" = "0" ]] && continue; ;;
|
---|
727 | # Test if the stripping phase must be skipped
|
---|
728 | *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
729 | # Select the appropriate library
|
---|
730 | *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
|
---|
731 | *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
|
---|
732 | *) ;;
|
---|
733 | esac
|
---|
734 |
|
---|
735 | # First append each name of the script files to a list (this will become
|
---|
736 | # the names of the targets in the Makefile
|
---|
737 | chapter5="$chapter5 $this_script"
|
---|
738 |
|
---|
739 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
740 | # and binutils in chapter 5)
|
---|
741 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
|
---|
742 |
|
---|
743 | # >>>>>>>>>> U G L Y <<<<<<<<<
|
---|
744 | # Adjust 'name' and patch a few scripts on the fly..
|
---|
745 | case $name in
|
---|
746 | linux-libc) name=linux-libc-headers
|
---|
747 | ;;
|
---|
748 | uclibc) # this sucks as method to deal with gettext/libint inside uClibc
|
---|
749 | sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter05/$this_script
|
---|
750 | ;;
|
---|
751 | gcc) # to compensate for the compiler test inside gcc (which fails), disable error trap
|
---|
752 | sed 's@^gcc -o test test.c@set +e; gcc -o test test.c@' -i chapter05/$this_script
|
---|
753 | ;;
|
---|
754 | esac
|
---|
755 |
|
---|
756 | # Set the dependency for the first target.
|
---|
757 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
758 |
|
---|
759 |
|
---|
760 | #--------------------------------------------------------------------#
|
---|
761 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
762 | #--------------------------------------------------------------------#
|
---|
763 | #
|
---|
764 | # Drop in the name of the target on a new line, and the previous target
|
---|
765 | # as a dependency. Also call the echo_message function.
|
---|
766 | echo -e "\n$this_script: $PREV
|
---|
767 | @\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
768 |
|
---|
769 | # Find the version of the command files, if it corresponds with the building of
|
---|
770 | # a specific package
|
---|
771 | vrs=`grep "^$name-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
772 | # If $vrs isn't empty, we've got a package...
|
---|
773 | if [ "$vrs" != "" ] ; then
|
---|
774 | # Deal with non-standard names
|
---|
775 | case $name in
|
---|
776 | tcl) FILE="$name$vrs-src.tar" ;;
|
---|
777 | uclibc) FILE="uClibc-$vrs.tar" ;;
|
---|
778 | gcc) FILE=gcc-core-$vrs.tar ;;
|
---|
779 | *) FILE="$name-$vrs.tar" ;;
|
---|
780 | esac
|
---|
781 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
782 | (
|
---|
783 | cat << EOF
|
---|
784 | @\$(call unpack,$FILE)
|
---|
785 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
786 | chown -R hlfs \$(HLFS)\$(SRC)/\$\$ROOT && \\
|
---|
787 | echo "export PKGDIR=\$(HLFS)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
788 | EOF
|
---|
789 | ) >> $MKFILE.tmp
|
---|
790 | fi
|
---|
791 |
|
---|
792 | case $this_script in
|
---|
793 | *binutils* ) # Dump the path to sources directory for later removal
|
---|
794 | echo -e '\techo "$(HLFS)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp
|
---|
795 | ;;
|
---|
796 | *adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
797 | echo -e '\t@echo "export PKGDIR=$(HLFS)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
798 | ;;
|
---|
799 | * ) # Everything else, add a true statment so we don't confuse make
|
---|
800 | echo -e '\ttrue' >> $MKFILE.tmp
|
---|
801 | ;;
|
---|
802 | esac
|
---|
803 |
|
---|
804 | # Insert date and disk usage at the top of the log file, the script run
|
---|
805 | # and date and disk usage again at the bottom of the log file.
|
---|
806 | (
|
---|
807 | cat << EOF
|
---|
808 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
|
---|
809 | su - hlfs -c "source /home/hlfs/.bashrc && $JHAHLFSDIR/commands/$file" >>logs/$this_script 2>&1 && \\
|
---|
810 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
|
---|
811 | EOF
|
---|
812 | ) >> $MKFILE.tmp
|
---|
813 |
|
---|
814 | # Remove the build directory(ies) except if the package build fails
|
---|
815 | # (so we can review config.cache, config.log, etc.)
|
---|
816 | # For Binutils the sources must be retained for some time.
|
---|
817 | if [ "$vrs" != "" ] ; then
|
---|
818 | if [[ ! `_IS_ $this_script binutils` ]]; then
|
---|
819 | (
|
---|
820 | cat << EOF
|
---|
821 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
822 | rm -r \$(HLFS)\$(SRC)/\$\$ROOT && \\
|
---|
823 | if [ -e \$(HLFS)\$(SRC)/$name-build ]; then \\
|
---|
824 | rm -r \$(HLFS)\$(SRC)/$name-build; \\
|
---|
825 | fi;
|
---|
826 | EOF
|
---|
827 | ) >> $MKFILE.tmp
|
---|
828 | fi
|
---|
829 | fi
|
---|
830 |
|
---|
831 | # Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
---|
832 | if [[ `_IS_ $this_script adjusting` ]] ; then
|
---|
833 | (
|
---|
834 | cat << EOF
|
---|
835 | @rm -r \`cat sources-dir\` && \\
|
---|
836 | rm -r \$(HLFS)\$(SRC)/binutils-build && \\
|
---|
837 | rm sources-dir
|
---|
838 | EOF
|
---|
839 | ) >> $MKFILE.tmp
|
---|
840 | fi
|
---|
841 |
|
---|
842 | # Include a touch of the target name so make can check if it's already been made.
|
---|
843 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
844 | #
|
---|
845 | #--------------------------------------------------------------------#
|
---|
846 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
847 | #--------------------------------------------------------------------#
|
---|
848 |
|
---|
849 | # Keep the script file name for Makefile dependencies.
|
---|
850 | PREV=$this_script
|
---|
851 | done # end for file in chapter05/*
|
---|
852 | }
|
---|
853 |
|
---|
854 |
|
---|
855 | #----------------------------#
|
---|
856 | chapter6_Makefiles() { # sysroot or chroot build phase
|
---|
857 | #----------------------------#
|
---|
858 | local TARGET LOADER
|
---|
859 |
|
---|
860 | #
|
---|
861 | # Set these definitions early and only once
|
---|
862 | #
|
---|
863 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
864 | TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
865 | else
|
---|
866 | TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
867 | fi
|
---|
868 |
|
---|
869 | echo -e " Processing Chapter-6 scripts "
|
---|
870 | for file in chapter06/* ; do
|
---|
871 | # Keep the script file name
|
---|
872 | this_script=`basename $file`
|
---|
873 |
|
---|
874 | # Skip this script depending on jhahlfs.conf flags set.
|
---|
875 | case $this_script in
|
---|
876 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
877 | # dependencies and target creation.
|
---|
878 | *chroot* ) continue ;;
|
---|
879 | # Test if the stripping phase must be skipped
|
---|
880 | *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
881 | # Select the appropriate library
|
---|
882 | *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
|
---|
883 | *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
|
---|
884 | *) ;;
|
---|
885 | esac
|
---|
886 |
|
---|
887 | # First append each name of the script files to a list (this will become
|
---|
888 | # the names of the targets in the Makefile
|
---|
889 | chapter6="$chapter6 $this_script"
|
---|
890 |
|
---|
891 | # Grab the name of the target
|
---|
892 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
893 |
|
---|
894 | #
|
---|
895 | # Sed replacement for 'nodump' tag in xml scripts until Manuel has a chance to fix them
|
---|
896 | #
|
---|
897 | case $name in
|
---|
898 | kernfs) # Remove sysctl code if host does not have grsecurity enabled
|
---|
899 | if [[ "$GRSECURITY_HOST" = "0" ]]; then
|
---|
900 | sed '/sysctl/d' -i chapter06/$this_script
|
---|
901 | fi
|
---|
902 | ;;
|
---|
903 | module-init-tools)
|
---|
904 | if [[ "$TEST" = "0" ]]; then # This needs rework....
|
---|
905 | sed '/make distclean/d' -i chapter06/$this_script
|
---|
906 | fi
|
---|
907 | ;;
|
---|
908 | glibc) # PATCH.. Turn off error trapping for the remainder of the script.
|
---|
909 | sed 's|^make install|make install; set +e|' -i chapter06/$this_script
|
---|
910 | ;;
|
---|
911 | uclibc) # PATCH..
|
---|
912 | sed 's/EST5EDT/${TIMEZONE}/' -i chapter06/$this_script
|
---|
913 | # PATCH.. Cannot use interactive programs/scripts.
|
---|
914 | sed 's/make menuconfig/make oldconfig/' -i chapter06/$this_script
|
---|
915 | sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter06/$this_script
|
---|
916 | ;;
|
---|
917 | gcc) # PATCH..
|
---|
918 | sed 's/rm /rm -f /' -i chapter06/$this_script
|
---|
919 | ;;
|
---|
920 | esac
|
---|
921 |
|
---|
922 | #--------------------------------------------------------------------#
|
---|
923 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
924 | #--------------------------------------------------------------------#
|
---|
925 | #
|
---|
926 | # Drop in the name of the target on a new line, and the previous target
|
---|
927 | # as a dependency. Also call the echo_message function.
|
---|
928 | echo -e "\n$this_script: $PREV
|
---|
929 | @\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
930 |
|
---|
931 | # Find the version of the command files, if it corresponds with the building of
|
---|
932 | # a specific package
|
---|
933 | vrs=`grep "^$name-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
934 |
|
---|
935 | # If $vrs isn't empty, we've got a package...
|
---|
936 | # Insert instructions for unpacking the package and changing directories
|
---|
937 | if [ "$vrs" != "" ] ; then
|
---|
938 | # Deal with non-standard names
|
---|
939 | case $name in
|
---|
940 | tcl) FILE="$name$vrs-src.tar.*" ;;
|
---|
941 | uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
---|
942 | gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
---|
943 | *) FILE="$name-$vrs.tar.*" ;;
|
---|
944 | esac
|
---|
945 | (
|
---|
946 | cat << EOF
|
---|
947 | @\$(call unpack2,$FILE)
|
---|
948 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
949 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
950 | echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
951 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
952 | EOF
|
---|
953 | ) >> $MKFILE.tmp
|
---|
954 | fi
|
---|
955 |
|
---|
956 | case $this_script in
|
---|
957 | *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
---|
958 | echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
959 | ;;
|
---|
960 | *glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar.
|
---|
961 | echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp
|
---|
962 | ;;
|
---|
963 | *groff* ) # For Groff we need to set PAGE envar.
|
---|
964 | echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp
|
---|
965 | ;;
|
---|
966 | esac
|
---|
967 |
|
---|
968 |
|
---|
969 | # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
|
---|
970 | if [[ `_IS_ $this_script kernfs` ]] ; then
|
---|
971 | (
|
---|
972 | cat << EOF
|
---|
973 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
|
---|
974 | export HLFS=\$(HLFS) && commands/$file >>logs/$this_script 2>&1 && \\
|
---|
975 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
|
---|
976 | EOF
|
---|
977 | ) >> $MKFILE.tmp
|
---|
978 |
|
---|
979 | # The rest of Chapter06
|
---|
980 | else
|
---|
981 | (
|
---|
982 | cat << EOF
|
---|
983 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
|
---|
984 | \$(CHROOT1) 'cd /jhahlfs && source envars && /jhahlfs/commands/$file >>/jhahlfs/logs/$this_script 2>&1' && \\
|
---|
985 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
|
---|
986 | EOF
|
---|
987 | ) >> $MKFILE.tmp
|
---|
988 | fi
|
---|
989 |
|
---|
990 | # Remove the build directory(ies) except if the package build fails.
|
---|
991 | if [ "$vrs" != "" ] ; then
|
---|
992 | (
|
---|
993 | cat << EOF
|
---|
994 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
995 | rm -r \$(HLFS)\$(SRC)/\$\$ROOT && \\
|
---|
996 | if [ -e \$(HLFS)\$(SRC)/$name-build ]; then \\
|
---|
997 | rm -r \$(HLFS)\$(SRC)/$name-build; \\
|
---|
998 | fi;
|
---|
999 | EOF
|
---|
1000 | ) >> $MKFILE.tmp
|
---|
1001 | fi
|
---|
1002 |
|
---|
1003 | # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
---|
1004 | if [[ `_IS_ $this_script readjusting` ]] ; then
|
---|
1005 | (
|
---|
1006 | cat << EOF
|
---|
1007 | @rm -r \`cat sources-dir\` && \\
|
---|
1008 | rm -r \$(HLFS)\$(SRC)/binutils-build && \\
|
---|
1009 | rm sources-dir
|
---|
1010 | EOF
|
---|
1011 | ) >> $MKFILE.tmp
|
---|
1012 | fi
|
---|
1013 |
|
---|
1014 | # Include a touch of the target name so make can check if it's already been made.
|
---|
1015 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
1016 | #
|
---|
1017 | #--------------------------------------------------------------------#
|
---|
1018 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
1019 | #--------------------------------------------------------------------#
|
---|
1020 |
|
---|
1021 | # Keep the script file name for Makefile dependencies.
|
---|
1022 | PREV=$this_script
|
---|
1023 | done # end for file in chapter06/*
|
---|
1024 |
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | #----------------------------#
|
---|
1028 | chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
---|
1029 | #----------------------------#
|
---|
1030 |
|
---|
1031 | echo " Processing Chapter-7 scripts "
|
---|
1032 | for file in chapter07/*; do
|
---|
1033 | # Keep the script file name
|
---|
1034 | this_script=`basename $file`
|
---|
1035 |
|
---|
1036 | # Grub must be configured manually.
|
---|
1037 | # The filesystems can't be unmounted via Makefile and the user
|
---|
1038 | # should enter the chroot environment to create the root
|
---|
1039 | # password, edit several files and setup Grub.
|
---|
1040 | case $this_script in
|
---|
1041 | *grub) continue ;;
|
---|
1042 | *reboot) continue ;;
|
---|
1043 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
1044 |
|
---|
1045 | *kernel) # How does Manuel add this string to the file..
|
---|
1046 | sed 's|cd \$PKGDIR.*||' -i chapter07/$this_script
|
---|
1047 | # You cannot run menuconfig from within the makefile
|
---|
1048 | sed 's|make menuconfig|make oldconfig|' -i chapter07/$this_script
|
---|
1049 | # The files in the conglomeration dir are xxx.bz2
|
---|
1050 | sed 's|.patch.gz|.patch.bz2|' -i chapter07/$this_script
|
---|
1051 | sed 's|gunzip|bunzip2|' -i chapter07/$this_script
|
---|
1052 | # If defined include the keymap in the kernel
|
---|
1053 | if [[ -n "$KEYMAP" ]]; then
|
---|
1054 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i chapter07/$this_script
|
---|
1055 | else
|
---|
1056 | sed '/loadkeys -m/d' -i chapter07/$this_script
|
---|
1057 | sed '/drivers\/char/d' -i chapter07/$this_script
|
---|
1058 | fi
|
---|
1059 | # If no .config file is supplied, the kernel build is skipped
|
---|
1060 | [[ -z $CONFIG ]] && continue
|
---|
1061 | ;;
|
---|
1062 | *usage) # The script bombs, disable error trapping
|
---|
1063 | sed 's|set -e|set +e|' -i chapter07/$this_script
|
---|
1064 | ;;
|
---|
1065 | *profile) # Add the config values to the script
|
---|
1066 | sed "s|LC_ALL=\*\*EDITME.*EDITME\*\*|LC_ALL=$LC_ALL|" -i chapter07/$this_script
|
---|
1067 | sed "s|LANG=\*\*EDITME.*EDITME\*\*|LANG=$LANG|" -i chapter07/$this_script
|
---|
1068 | ;;
|
---|
1069 | esac
|
---|
1070 |
|
---|
1071 | # First append then name of the script file to a list (this will become
|
---|
1072 | # the names of the targets in the Makefile
|
---|
1073 | chapter7="$chapter7 $this_script"
|
---|
1074 |
|
---|
1075 | #--------------------------------------------------------------------#
|
---|
1076 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
1077 | #--------------------------------------------------------------------#
|
---|
1078 | #
|
---|
1079 | # Drop in the name of the target on a new line, and the previous target
|
---|
1080 | # as a dependency. Also call the echo_message function.
|
---|
1081 | echo -e "\n$this_script: $PREV
|
---|
1082 | @\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
1083 |
|
---|
1084 | if [[ `_IS_ $this_script bootscripts` ]] ; then
|
---|
1085 | vrs=`grep "^lfs-bootscripts-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
1086 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
1087 | # The bootscript pkg references both lfs AND blfs bootscripts...
|
---|
1088 | # see XML script for other additions to bootscripts file
|
---|
1089 | # PATCH
|
---|
1090 | vrs=`grep "^blfs-bootscripts-version" $JHAHLFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
1091 | sed "s|make install$|make install; cd ../blfs-bootscripts-$vrs|" -i chapter07/$this_script
|
---|
1092 | (
|
---|
1093 | cat << EOF
|
---|
1094 | @\$(call unpack2,$FILE)
|
---|
1095 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
1096 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
1097 | echo "\$(HLFS)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir
|
---|
1098 | EOF
|
---|
1099 | ) >> $MKFILE.tmp
|
---|
1100 | fi
|
---|
1101 |
|
---|
1102 | if [[ `_IS_ $this_script kernel` ]] ; then
|
---|
1103 | # not much really, script does everything..
|
---|
1104 | echo -e "\t@cp -f $CONFIG \$(HLFS)/sources/kernel-config" >> $MKFILE.tmp
|
---|
1105 | fi
|
---|
1106 |
|
---|
1107 | # Check if we have a real /etc/fstab file
|
---|
1108 | if [[ `_IS_ $this_script fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
---|
1109 | (
|
---|
1110 | cat << EOF
|
---|
1111 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
|
---|
1112 | cp -v $FSTAB \$(HLFS)/etc/fstab >>logs/$this_script 2>&1 && \\
|
---|
1113 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
|
---|
1114 | EOF
|
---|
1115 | ) >> $MKFILE.tmp
|
---|
1116 | else
|
---|
1117 | # Initialize the log and run the script
|
---|
1118 | (
|
---|
1119 | cat << EOF
|
---|
1120 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >logs/$this_script && \\
|
---|
1121 | \$(CHROOT2) 'cd /jhahlfs && source envars && /jhahlfs/commands/$file >>/jhahlfs/logs/$this_script 2>&1' && \\
|
---|
1122 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(HLFS)\`\n" >>logs/$this_script
|
---|
1123 | EOF
|
---|
1124 | ) >> $MKFILE.tmp
|
---|
1125 | fi
|
---|
1126 |
|
---|
1127 | # Remove the build directory except if the package build fails.
|
---|
1128 | if [[ `_IS_ $this_script bootscripts` ]]; then
|
---|
1129 | (
|
---|
1130 | cat << EOF
|
---|
1131 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
1132 | rm -r \$(HLFS)\$(SRC)/\$\$ROOT
|
---|
1133 | @rm -r \`cat sources-dir\` && \\
|
---|
1134 | rm sources-dir
|
---|
1135 |
|
---|
1136 | EOF
|
---|
1137 | ) >> $MKFILE.tmp
|
---|
1138 | fi
|
---|
1139 |
|
---|
1140 | # Include a touch of the target name so make can check if it's already been made.
|
---|
1141 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
1142 | #
|
---|
1143 | #--------------------------------------------------------------------#
|
---|
1144 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
1145 | #--------------------------------------------------------------------#
|
---|
1146 |
|
---|
1147 | # Keep the script file name for Makefile dependencies.
|
---|
1148 | PREV=$this_script
|
---|
1149 | done # for file in chapter07/*
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 |
|
---|
1153 | #----------------------------#
|
---|
1154 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
1155 | #----------------------------#
|
---|
1156 | echo -e "Creating Makefile... "
|
---|
1157 |
|
---|
1158 | cd $JHAHLFSDIR/commands
|
---|
1159 | # Start with a clean Makefile.tmp file
|
---|
1160 | >$MKFILE.tmp
|
---|
1161 |
|
---|
1162 | chapter4_Makefiles
|
---|
1163 | chapter5_Makefiles
|
---|
1164 | chapter6_Makefiles
|
---|
1165 | chapter7_Makefiles
|
---|
1166 |
|
---|
1167 | # Add a header, some variables and include the function file
|
---|
1168 | # to the top of the real Makefile.
|
---|
1169 | (
|
---|
1170 | cat << EOF
|
---|
1171 | $HEADER
|
---|
1172 |
|
---|
1173 | SRC= /sources
|
---|
1174 | HLFS= $BUILDDIR
|
---|
1175 | PAGE= $PAGE
|
---|
1176 | TIMEZONE= $TIMEZONE
|
---|
1177 |
|
---|
1178 | include hlfs-functions
|
---|
1179 |
|
---|
1180 | EOF
|
---|
1181 | ) > $MKFILE
|
---|
1182 |
|
---|
1183 |
|
---|
1184 | # Add chroot commands
|
---|
1185 | i=1
|
---|
1186 | for file in chapter06/*chroot* ; do
|
---|
1187 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
1188 | -e '/^export/d' \
|
---|
1189 | -e '/^logout/d' \
|
---|
1190 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
1191 | -e 's|\\$|&&|g' \
|
---|
1192 | -e 's|exit||g' \
|
---|
1193 | -e 's|$| -c|' \
|
---|
1194 | -e 's|"$$HLFS"|$(HLFS)|'\
|
---|
1195 | -e 's|set -e||'`
|
---|
1196 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
1197 | i=`expr $i + 1`
|
---|
1198 | done
|
---|
1199 |
|
---|
1200 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
1201 | # as a dependency.
|
---|
1202 | (
|
---|
1203 | cat << EOF
|
---|
1204 | all: chapter4 chapter5 chapter6 chapter7
|
---|
1205 | @\$(call echo_finished,$VERSION)
|
---|
1206 |
|
---|
1207 | chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
1208 |
|
---|
1209 | chapter5: chapter4 $chapter5 restore-hlfs-env
|
---|
1210 |
|
---|
1211 | chapter6: chapter5 $chapter6
|
---|
1212 |
|
---|
1213 | chapter7: chapter6 $chapter7
|
---|
1214 |
|
---|
1215 | clean-all: clean
|
---|
1216 | rm -rf ./{commands,logs,Makefile,dump-hlfs-scripts.xsl,functions,packages,patches}
|
---|
1217 |
|
---|
1218 | clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter4
|
---|
1219 |
|
---|
1220 | clean-chapter4:
|
---|
1221 | -if [ ! -f user-hlfs-exist ]; then \\
|
---|
1222 | userdel hlfs; \\
|
---|
1223 | rm -rf /home/hlfs; \\
|
---|
1224 | fi;
|
---|
1225 | rm -rf \$(HLFS)/tools
|
---|
1226 | rm -f /tools
|
---|
1227 | rm -f envars user-hlfs-exist
|
---|
1228 | rm -f 02* logs/02*.log
|
---|
1229 |
|
---|
1230 | clean-chapter5:
|
---|
1231 | rm -rf \$(HLFS)/tools/*
|
---|
1232 | rm -f $chapter5 restore-hlfs-env sources-dir
|
---|
1233 | cd logs && rm -f $chapter5 && cd ..
|
---|
1234 |
|
---|
1235 | clean-chapter6:
|
---|
1236 | -umount \$(HLFS)/sys
|
---|
1237 | -umount \$(HLFS)/proc
|
---|
1238 | -umount \$(HLFS)/dev/shm
|
---|
1239 | -umount \$(HLFS)/dev/pts
|
---|
1240 | -umount \$(HLFS)/dev
|
---|
1241 | rm -rf \$(HLFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
1242 | rm -f $chapter6
|
---|
1243 | cd logs && rm -f $chapter6 && cd ..
|
---|
1244 |
|
---|
1245 | clean-chapter7:
|
---|
1246 | rm -f $chapter7
|
---|
1247 | cd logs && rm -f $chapter7 && cd ..
|
---|
1248 |
|
---|
1249 | restore-hlfs-env:
|
---|
1250 | @\$(call echo_message, Building)
|
---|
1251 | @if [ -f /home/hlfs/.bashrc.XXX ]; then \\
|
---|
1252 | mv -fv /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
|
---|
1253 | fi;
|
---|
1254 | @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
|
---|
1255 | mv -v /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
|
---|
1256 | fi;
|
---|
1257 | @chown hlfs:hlfs /home/hlfs/.bash* && \\
|
---|
1258 | touch \$@
|
---|
1259 |
|
---|
1260 | EOF
|
---|
1261 | ) >> $MKFILE
|
---|
1262 |
|
---|
1263 | # Bring over the items from the Makefile.tmp
|
---|
1264 | cat $MKFILE.tmp >> $MKFILE
|
---|
1265 | rm $MKFILE.tmp
|
---|
1266 | echo -ne "${BOLD}done\n${OFF}"
|
---|
1267 | }
|
---|
1268 |
|
---|
1269 | #----------------------------#
|
---|
1270 | run_make() { # Execute the newly constructed Makefile
|
---|
1271 | #----------------------------#
|
---|
1272 | # Test if make must be run.
|
---|
1273 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
1274 | # Test to make sure we're running the build as root
|
---|
1275 | if [ "$UID" != "0" ] ; then
|
---|
1276 | echo "You must be logged in as root to successfully build HLFS."
|
---|
1277 | exit 1
|
---|
1278 | fi
|
---|
1279 | # Build the system
|
---|
1280 | if [ -e $MKFILE ] ; then
|
---|
1281 | echo -ne "Building the HLFS system...\n"
|
---|
1282 | cd $JHAHLFSDIR && make
|
---|
1283 | echo -ne "done\n"
|
---|
1284 | fi
|
---|
1285 | fi
|
---|
1286 | }
|
---|
1287 |
|
---|
1288 |
|
---|
1289 |
|
---|
1290 | ###################################
|
---|
1291 | ### MAIN ###
|
---|
1292 | ###################################
|
---|
1293 |
|
---|
1294 | # Evaluate any command line switches
|
---|
1295 |
|
---|
1296 | while test $# -gt 0 ; do
|
---|
1297 | case $1 in
|
---|
1298 | --version | -V ) 'clear'; echo "$version" ; exit 0; ;;
|
---|
1299 | --help | -h ) usage | less
|
---|
1300 | 'clear' ; exit 0
|
---|
1301 | ;;
|
---|
1302 |
|
---|
1303 | --HLFS-version | -L )
|
---|
1304 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1305 | shift
|
---|
1306 | case $1 in
|
---|
1307 | dev* | SVN | trunk )
|
---|
1308 | BOOK="" # necessary to overide any value set inside jhahlfs.conf
|
---|
1309 | WC=
|
---|
1310 | HLFSVRS=development
|
---|
1311 | ;;
|
---|
1312 | * )
|
---|
1313 | echo "$1 is an unsupported version at this time."
|
---|
1314 | exit 1
|
---|
1315 | ;;
|
---|
1316 | esac
|
---|
1317 | ;;
|
---|
1318 |
|
---|
1319 | --directory | -d )
|
---|
1320 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1321 | shift
|
---|
1322 | BUILDDIR=$1
|
---|
1323 | JHAHLFSDIR=$BUILDDIR/jhahlfs
|
---|
1324 | LOGDIR=$JHAHLFSDIR/logs
|
---|
1325 | MKFILE=$JHAHLFSDIR/Makefile
|
---|
1326 | ;;
|
---|
1327 |
|
---|
1328 | --working-copy | -W )
|
---|
1329 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1330 | shift
|
---|
1331 | if [ -f $1/patches.ent ] ; then
|
---|
1332 | WC=1
|
---|
1333 | BOOK=$1
|
---|
1334 | else
|
---|
1335 | echo -e "\nLook like $1 isn't a supported working copy."
|
---|
1336 | echo -e "Verify your selection and the command line.\n"
|
---|
1337 | exit 1
|
---|
1338 | fi
|
---|
1339 | ;;
|
---|
1340 |
|
---|
1341 | --get-packages | -P ) HPKG=1 ;;
|
---|
1342 | --run-make | -M ) RUNMAKE=1 ;;
|
---|
1343 | --rebuild ) CLEAN=1 ;;
|
---|
1344 |
|
---|
1345 | --readme )
|
---|
1346 | 'clear'
|
---|
1347 | echo "$_inline_doc" | less
|
---|
1348 | 'clear'; exit
|
---|
1349 | ;;
|
---|
1350 |
|
---|
1351 | --fstab )
|
---|
1352 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1353 | shift
|
---|
1354 | if [ -f $1 ] ; then
|
---|
1355 | FSTAB=$1
|
---|
1356 | else
|
---|
1357 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
1358 | exit 1
|
---|
1359 | fi
|
---|
1360 | ;;
|
---|
1361 |
|
---|
1362 | --kernel-config | -C )
|
---|
1363 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1364 | shift
|
---|
1365 | if [ -f $1 ] ; then
|
---|
1366 | CONFIG=$1
|
---|
1367 | else
|
---|
1368 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
1369 | exit 1
|
---|
1370 | fi
|
---|
1371 | ;;
|
---|
1372 | * )
|
---|
1373 | echo "$usage"
|
---|
1374 | exit 1
|
---|
1375 | ;;
|
---|
1376 | esac
|
---|
1377 | shift
|
---|
1378 | done
|
---|
1379 |
|
---|
1380 | # Prevents setting "-d /" by mistake.
|
---|
1381 | if [ $BUILDDIR = / ] ; then
|
---|
1382 | echo -ne "\nThe root directory can't be used to build HLFS.\n\n"
|
---|
1383 | exit 1
|
---|
1384 | fi
|
---|
1385 |
|
---|
1386 | # If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
---|
1387 | # and notify the user about that.
|
---|
1388 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
---|
1389 | no_empty_builddir
|
---|
1390 | fi
|
---|
1391 |
|
---|
1392 | # If requested, clean the build directory
|
---|
1393 | clean_builddir
|
---|
1394 |
|
---|
1395 | # Find the download client to use, if not already specified.
|
---|
1396 | if [ -z $DL ] ; then
|
---|
1397 | if [ `type -p wget` ] ; then
|
---|
1398 | DL=wget
|
---|
1399 | elif [ `type -p curl` ] ; then
|
---|
1400 | DL=curl
|
---|
1401 | else
|
---|
1402 | eval "$no_dl_client"
|
---|
1403 | fi
|
---|
1404 | fi
|
---|
1405 |
|
---|
1406 | # Set the document location..
|
---|
1407 | # if set by conf file leave it alone otherwise load the specified version
|
---|
1408 | BOOK=${BOOK:=hlfs-$HLFSVRS}
|
---|
1409 |
|
---|
1410 | [[ ! -d $JHAHLFSDIR ]] && mkdir -pv $JHAHLFSDIR
|
---|
1411 | [[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
|
---|
1412 | if [[ "$PWD" != "$JHAHLFSDIR" ]]; then
|
---|
1413 | cp -v $FILES $JHAHLFSDIR/
|
---|
1414 | sed 's,FAKEDIR,'$BOOK',' $XSL > $JHAHLFSDIR/dump-hlfs-scripts.xsl
|
---|
1415 | export XSL=$JHAHLFSDIR/dump-hlfs-scripts.xsl
|
---|
1416 | fi
|
---|
1417 |
|
---|
1418 | >$LOGDIR/$LOG
|
---|
1419 |
|
---|
1420 |
|
---|
1421 | # Check for minumum gcc and kernel versions
|
---|
1422 | check_requirements 1 # 0/1 0-do not display values.
|
---|
1423 | validate_config 1 # 0/1 0-do not display values
|
---|
1424 | get_book
|
---|
1425 | build_Makefile
|
---|
1426 | run_make
|
---|