1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # $Id$
|
---|
4 |
|
---|
5 | ###################################
|
---|
6 | ### FUNCTIONS ###
|
---|
7 | ###################################
|
---|
8 |
|
---|
9 |
|
---|
10 | #############################################################
|
---|
11 |
|
---|
12 |
|
---|
13 | #----------------------------#
|
---|
14 | chapter4_Makefiles() { #
|
---|
15 | #----------------------------#
|
---|
16 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${R_arrow}"
|
---|
17 |
|
---|
18 | # If $LUSER_HOME is already present in the host, we asume that the
|
---|
19 | # lfs user and group are also presents in the host, and a backup
|
---|
20 | # of their bash init files is made.
|
---|
21 | (
|
---|
22 | cat << EOF
|
---|
23 | 020-creatingtoolsdir:
|
---|
24 | @\$(call echo_message, Building)
|
---|
25 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
26 | rm -f /tools && \\
|
---|
27 | ln -s \$(MOUNT_PT)/tools /
|
---|
28 | @\$(call housekeeping)
|
---|
29 |
|
---|
30 | 021-addinguser: 020-creatingtoolsdir
|
---|
31 | @\$(call echo_message, Building)
|
---|
32 | @if [ ! -d \$(LUSER_HOME) ]; then \\
|
---|
33 | groupadd \$(LGROUP); \\
|
---|
34 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
35 | else \\
|
---|
36 | touch luser-exist; \\
|
---|
37 | fi;
|
---|
38 | @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
---|
39 | chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
40 | chmod a+wt \$(SRCSDIR)
|
---|
41 | @\$(call housekeeping)
|
---|
42 |
|
---|
43 | 022-settingenvironment: 021-addinguser
|
---|
44 | @\$(call echo_message, Building)
|
---|
45 | @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
46 | mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
---|
47 | fi;
|
---|
48 | @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
49 | mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
|
---|
50 | fi;
|
---|
51 | @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
|
---|
52 | echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
53 | echo "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
54 | echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
55 | echo "LFS_TGT=`uname -m`-lfs-linux-gnu" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
56 | echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
57 | echo "export LFS LC_ALL LFS_TGT PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
58 | echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
59 | chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
|
---|
60 | touch envars && \\
|
---|
61 | chown \$(LUSER) envars
|
---|
62 | @\$(call housekeeping)
|
---|
63 | EOF
|
---|
64 | ) > $MKFILE.tmp
|
---|
65 |
|
---|
66 | chapter4=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 |
|
---|
71 | #----------------------------#
|
---|
72 | chapter5_Makefiles() {
|
---|
73 | #----------------------------#
|
---|
74 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
|
---|
75 |
|
---|
76 | for file in chapter05/* ; do
|
---|
77 | # Keep the script file name
|
---|
78 | this_script=`basename $file`
|
---|
79 |
|
---|
80 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
81 | # Fix also locales creation when running chapter05 testsuites (ugly)
|
---|
82 | case "${this_script}" in
|
---|
83 | *tcl) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
84 | *expect) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
85 | *dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
|
---|
86 | *stripping) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
87 | *glibc) [[ "${TEST}" = "3" ]] && \
|
---|
88 | sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
|
---|
89 | esac
|
---|
90 |
|
---|
91 | # First append each name of the script files to a list (this will become
|
---|
92 | # the names of the targets in the Makefile
|
---|
93 | # DO NOT append the changingowner script, it need be run as root.
|
---|
94 | # A hack is necessary: create script in chap5 BUT run as a dependency for
|
---|
95 | # SUDO target
|
---|
96 | case "${this_script}" in
|
---|
97 | *changingowner) runasroot="$runasroot ${this_script}" ;;
|
---|
98 | *) chapter5="$chapter5 ${this_script}" ;;
|
---|
99 | esac
|
---|
100 |
|
---|
101 | # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
---|
102 | # and binutils in chapter 5)
|
---|
103 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
---|
104 |
|
---|
105 | # Set the dependency for the first target.
|
---|
106 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
107 |
|
---|
108 | #--------------------------------------------------------------------#
|
---|
109 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
110 | #--------------------------------------------------------------------#
|
---|
111 | #
|
---|
112 | # Drop in the name of the target on a new line, and the previous target
|
---|
113 | # as a dependency. Also call the echo_message function.
|
---|
114 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
115 |
|
---|
116 | # Find the version of the command files, if it corresponds with the building of
|
---|
117 | # a specific package
|
---|
118 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
119 |
|
---|
120 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
121 | if [ "$pkg_tarball" != "" ] ; then
|
---|
122 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
123 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
124 | # If the testsuites must be run, initialize the log file
|
---|
125 | [[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}"
|
---|
126 | # If using optimizations, write the instructions
|
---|
127 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
128 | fi
|
---|
129 |
|
---|
130 | # Insert date and disk usage at the top of the log file, the script run
|
---|
131 | # and date and disk usage again at the bottom of the log file.
|
---|
132 | # The changingowner script must be run as root.
|
---|
133 | case "${this_script}" in
|
---|
134 | *changingowner) wrt_RunAsRoot "$file" ;;
|
---|
135 | *) LUSER_wrt_RunAsUser "$file" ;;
|
---|
136 | esac
|
---|
137 |
|
---|
138 | # Remove the build directory(ies) except if the package build fails
|
---|
139 | # (so we can review config.cache, config.log, etc.)
|
---|
140 | if [ "$pkg_tarball" != "" ] ; then
|
---|
141 | case "${name}" in
|
---|
142 | *xz-utils) LUSER_RemoveBuildDirs "xz" ;;
|
---|
143 | *) LUSER_RemoveBuildDirs "$name" ;;
|
---|
144 | esac
|
---|
145 | fi
|
---|
146 |
|
---|
147 | # Include a touch of the target name so make can check
|
---|
148 | # if it's already been made.
|
---|
149 | wrt_touch
|
---|
150 | #
|
---|
151 | #--------------------------------------------------------------------#
|
---|
152 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
153 | #--------------------------------------------------------------------#
|
---|
154 |
|
---|
155 | # Keep the script file name for Makefile dependencies.
|
---|
156 | PREV=${this_script}
|
---|
157 | done # end for file in chapter05/*
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | #----------------------------#
|
---|
162 | chapter6_Makefiles() {
|
---|
163 | #----------------------------#
|
---|
164 |
|
---|
165 | # Set envars and scripts for iteration targets
|
---|
166 | if [[ -z "$1" ]] ; then
|
---|
167 | local N=""
|
---|
168 | else
|
---|
169 | local N=-build_$1
|
---|
170 | local chapter6=""
|
---|
171 | mkdir chapter06$N
|
---|
172 | cp chapter06/* chapter06$N
|
---|
173 | for script in chapter06$N/* ; do
|
---|
174 | # Overwrite existing symlinks, files, and dirs
|
---|
175 | sed -e 's/ln *-sv/&f/g' \
|
---|
176 | -e 's/mv *-v/&f/g' \
|
---|
177 | -e 's/mkdir *-v/&p/g' -i ${script}
|
---|
178 | # Suppress the mod of "test-installation.pl" because now
|
---|
179 | # the library path points to /usr/lib
|
---|
180 | if [[ ${script} =~ glibc ]]; then
|
---|
181 | sed '/DL=/,/unset DL/d' -i ${script}
|
---|
182 | fi
|
---|
183 | # Rename the scripts
|
---|
184 | mv ${script} ${script}$N
|
---|
185 | done
|
---|
186 | # Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
|
---|
187 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
|
---|
188 | fi
|
---|
189 |
|
---|
190 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
|
---|
191 |
|
---|
192 | for file in chapter06$N/* ; do
|
---|
193 | # Keep the script file name
|
---|
194 | this_script=`basename $file`
|
---|
195 |
|
---|
196 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
197 | # dependencies and target creation.
|
---|
198 | # Skip also linux-headers in iterative builds.
|
---|
199 | case "${this_script}" in
|
---|
200 | *chroot) continue ;;
|
---|
201 | *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
202 | *linux-headers*) [[ -n "$N" ]] && continue ;;
|
---|
203 | esac
|
---|
204 |
|
---|
205 | # Grab the name of the target.
|
---|
206 | name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
|
---|
207 |
|
---|
208 | # Find the version of the command files, if it corresponds with the building of
|
---|
209 | # a specific package. We need this here to can skip scripts not needed for
|
---|
210 | # iterations rebuilds
|
---|
211 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
212 |
|
---|
213 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
214 | case "${this_script}" in
|
---|
215 | *stripping*) ;;
|
---|
216 | *) continue ;;
|
---|
217 | esac
|
---|
218 | fi
|
---|
219 |
|
---|
220 | # Append each name of the script files to a list (this will become
|
---|
221 | # the names of the targets in the Makefile)
|
---|
222 | # The kernfs script must be run as part of SUDO target.
|
---|
223 | case "${this_script}" in
|
---|
224 | *kernfs) runasroot="$runasroot ${this_script}" ;;
|
---|
225 | *) chapter6="$chapter6 ${this_script}" ;;
|
---|
226 | esac
|
---|
227 |
|
---|
228 | #--------------------------------------------------------------------#
|
---|
229 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
230 | #--------------------------------------------------------------------#
|
---|
231 | #
|
---|
232 | # Drop in the name of the target on a new line, and the previous target
|
---|
233 | # as a dependency. Also call the echo_message function.
|
---|
234 | # In the mount of kernel filesystems we need to set LFS
|
---|
235 | # and not to use chroot.
|
---|
236 | case "${this_script}" in
|
---|
237 | *kernfs) LUSER_wrt_target "${this_script}" "$PREV" ;;
|
---|
238 | *) CHROOT_wrt_target "${this_script}" "$PREV" ;;
|
---|
239 | esac
|
---|
240 |
|
---|
241 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
242 | # Insert instructions for unpacking the package and changing directories
|
---|
243 | if [ "$pkg_tarball" != "" ] ; then
|
---|
244 | # Touch timestamp file if installed files logs will be created.
|
---|
245 | # But only for the firt build when running iterative builds.
|
---|
246 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
247 | CHROOT_wrt_TouchTimestamp
|
---|
248 | fi
|
---|
249 | CHROOT_Unpack "$pkg_tarball"
|
---|
250 | # If the testsuites must be run, initialize the log file
|
---|
251 | case $name in
|
---|
252 | binutils | gcc | glibc | gmp | mpfr )
|
---|
253 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
254 | ;;
|
---|
255 | * )
|
---|
256 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
257 | ;;
|
---|
258 | esac
|
---|
259 | # If using optimizations, write the instructions
|
---|
260 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
261 | fi
|
---|
262 |
|
---|
263 | # In the mount of kernel filesystems we need to set LFS
|
---|
264 | # and not to use chroot.
|
---|
265 | case "${this_script}" in
|
---|
266 | *kernfs) wrt_RunAsRoot "$file" ;;
|
---|
267 | *) CHROOT_wrt_RunAsRoot "$file" ;;
|
---|
268 | esac
|
---|
269 |
|
---|
270 | # Write installed files log and remove the build directory(ies)
|
---|
271 | # except if the package build fails.
|
---|
272 | if [ "$pkg_tarball" != "" ] ; then
|
---|
273 | case "${name}" in
|
---|
274 | *xz-utils) CHROOT_wrt_RemoveBuildDirs "xz" ;;
|
---|
275 | *) CHROOT_wrt_RemoveBuildDirs "$name" ;;
|
---|
276 | esac
|
---|
277 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
278 | CHROOT_wrt_LogNewFiles "$name"
|
---|
279 | fi
|
---|
280 | fi
|
---|
281 |
|
---|
282 | # Include a touch of the target name so make can check
|
---|
283 | # if it's already been made.
|
---|
284 | wrt_touch
|
---|
285 | #
|
---|
286 | #--------------------------------------------------------------------#
|
---|
287 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
288 | #--------------------------------------------------------------------#
|
---|
289 |
|
---|
290 | # Keep the script file name for Makefile dependencies.
|
---|
291 | PREV=${this_script}
|
---|
292 | # Set system_build envar for iteration targets
|
---|
293 | system_build=$chapter6
|
---|
294 | done # end for file in chapter06/*
|
---|
295 | }
|
---|
296 |
|
---|
297 | #----------------------------#
|
---|
298 | chapter78_Makefiles() {
|
---|
299 | #----------------------------#
|
---|
300 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
|
---|
301 |
|
---|
302 | for file in chapter0{7,8}/* ; do
|
---|
303 | # Keep the script file name
|
---|
304 | this_script=`basename $file`
|
---|
305 |
|
---|
306 | # Grub must be configured manually.
|
---|
307 | # Handle fstab creation.
|
---|
308 | # If no .config file is supplied, the kernel build is skipped
|
---|
309 | case ${this_script} in
|
---|
310 | *grub) continue ;;
|
---|
311 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
312 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
313 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
314 | esac
|
---|
315 |
|
---|
316 | # First append each name of the script files to a list (this will become
|
---|
317 | # the names of the targets in the Makefile
|
---|
318 | chapter78="$chapter78 ${this_script}"
|
---|
319 |
|
---|
320 | #--------------------------------------------------------------------#
|
---|
321 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
322 | #--------------------------------------------------------------------#
|
---|
323 | #
|
---|
324 | # Drop in the name of the target on a new line, and the previous target
|
---|
325 | # as a dependency. Also call the echo_message function.
|
---|
326 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
327 |
|
---|
328 | # Find the bootscripts and kernel package names
|
---|
329 | case "${this_script}" in
|
---|
330 | *bootscripts)
|
---|
331 | name="lfs-bootscripts"
|
---|
332 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
333 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
334 | CHROOT_wrt_TouchTimestamp
|
---|
335 | fi
|
---|
336 | CHROOT_Unpack "$pkg_tarball"
|
---|
337 | ;;
|
---|
338 | *kernel)
|
---|
339 | name="linux"
|
---|
340 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
341 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
342 | CHROOT_wrt_TouchTimestamp
|
---|
343 | fi
|
---|
344 | CHROOT_Unpack "$pkg_tarball"
|
---|
345 | # If using optimizations, use MAKEFLAGS (unless blacklisted)
|
---|
346 | # no setting of CFLAGS and friends.
|
---|
347 | [[ "$OPTIMIZE" != "0" ]] && wrt_makeflags "$name"
|
---|
348 | ;;
|
---|
349 | esac
|
---|
350 |
|
---|
351 | # Check if we have a real /etc/fstab file
|
---|
352 | case "${this_script}" in
|
---|
353 | *fstab) if [[ -n $FSTAB ]]; then
|
---|
354 | CHROOT_wrt_CopyFstab
|
---|
355 | else
|
---|
356 | CHROOT_wrt_RunAsRoot "$file"
|
---|
357 | fi
|
---|
358 | ;;
|
---|
359 | *) CHROOT_wrt_RunAsRoot "$file"
|
---|
360 | ;;
|
---|
361 | esac
|
---|
362 |
|
---|
363 | case "${this_script}" in
|
---|
364 | *bootscripts) CHROOT_wrt_RemoveBuildDirs "dummy"
|
---|
365 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
366 | CHROOT_wrt_LogNewFiles "$name"
|
---|
367 | fi ;;
|
---|
368 | *kernel) CHROOT_wrt_RemoveBuildDirs "dummy"
|
---|
369 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
370 | CHROOT_wrt_LogNewFiles "$name"
|
---|
371 | fi ;;
|
---|
372 | esac
|
---|
373 |
|
---|
374 | # Include a touch of the target name so make can check
|
---|
375 | # if it's already been made.
|
---|
376 | wrt_touch
|
---|
377 | #
|
---|
378 | #--------------------------------------------------------------------#
|
---|
379 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
380 | #--------------------------------------------------------------------#
|
---|
381 |
|
---|
382 | # Keep the script file name for Makefile dependencies.
|
---|
383 | PREV=${this_script}
|
---|
384 | done # for file in chapter0{7,8}/*
|
---|
385 |
|
---|
386 | }
|
---|
387 |
|
---|
388 |
|
---|
389 |
|
---|
390 | #----------------------------#
|
---|
391 | build_Makefile() { #
|
---|
392 | #----------------------------#
|
---|
393 |
|
---|
394 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
395 |
|
---|
396 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
397 |
|
---|
398 | # Start with a clean Makefile.tmp file
|
---|
399 | >$MKFILE
|
---|
400 |
|
---|
401 | chapter4_Makefiles
|
---|
402 | chapter5_Makefiles
|
---|
403 | chapter6_Makefiles
|
---|
404 | # Add the iterations targets, if needed
|
---|
405 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
406 | chapter78_Makefiles
|
---|
407 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
408 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
409 | # Add the BLFS_TOOL targets, if needed
|
---|
410 | [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
|
---|
411 |
|
---|
412 | # Add a header, some variables and include the function file
|
---|
413 | # to the top of the real Makefile.
|
---|
414 | wrt_Makefile_header
|
---|
415 |
|
---|
416 | # Add chroot commands
|
---|
417 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
418 | i=1
|
---|
419 | for file in chapter06/*chroot* ; do
|
---|
420 | chroot=`cat $file | \
|
---|
421 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
422 | -e '/#!\/bin\/bash/d' \
|
---|
423 | -e 's@ \\\@ @g' | \
|
---|
424 | tr -d '\n' | \
|
---|
425 | sed -e 's/ */ /g' \
|
---|
426 | -e 's|\\$|&&|g' \
|
---|
427 | -e 's|exit||g' \
|
---|
428 | -e 's|$| -c|' \
|
---|
429 | -e 's|"$$LFS"|$(MOUNT_PT)|' \
|
---|
430 | -e 's|set -e||' \
|
---|
431 | -e 's|set +h||'`
|
---|
432 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
433 | i=`expr $i + 1`
|
---|
434 | done
|
---|
435 |
|
---|
436 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
437 | # as a dependency.
|
---|
438 | (
|
---|
439 | cat << EOF
|
---|
440 |
|
---|
441 | all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
442 | @sudo make do_housekeeping
|
---|
443 | @echo "$VERSION - jhalfs build" > lfs-release && \\
|
---|
444 | sudo mv lfs-release \$(MOUNT_PT)/etc
|
---|
445 | @\$(call echo_finished,$VERSION)
|
---|
446 |
|
---|
447 | ck_UID:
|
---|
448 | @if [ \`id -u\` = "0" ]; then \\
|
---|
449 | echo "--------------------------------------------------"; \\
|
---|
450 | echo "You cannot run this makefile from the root account"; \\
|
---|
451 | echo "--------------------------------------------------"; \\
|
---|
452 | exit 1; \\
|
---|
453 | fi
|
---|
454 |
|
---|
455 | ck_LFS:
|
---|
456 | @if [ \`echo \$(LFS)\`x = "x" ]; then \\
|
---|
457 | echo "--------------------------------------------------"; \\
|
---|
458 | echo "Enviroment variable LFS must be set"; \\
|
---|
459 | echo "--------------------------------------------------"; \\
|
---|
460 | exit 1; \
|
---|
461 | fi
|
---|
462 |
|
---|
463 | mk_SETUP:
|
---|
464 | @\$(call echo_SU_request)
|
---|
465 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
466 | @touch \$@
|
---|
467 |
|
---|
468 | mk_LUSER: mk_SETUP
|
---|
469 | @\$(call echo_SULUSER_request)
|
---|
470 | @( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
471 | @sudo make restore-luser-env
|
---|
472 | @touch \$@
|
---|
473 |
|
---|
474 | mk_SUDO: mk_LUSER
|
---|
475 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
476 | @touch \$@
|
---|
477 |
|
---|
478 | mk_CHROOT: mk_SUDO
|
---|
479 | @\$(call echo_CHROOT_request)
|
---|
480 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
481 | @touch \$@
|
---|
482 |
|
---|
483 | mk_BOOT: mk_CHROOT
|
---|
484 | @\$(call echo_CHROOT_request)
|
---|
485 | @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
486 | @touch \$@
|
---|
487 |
|
---|
488 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
489 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
490 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
491 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
492 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
493 | fi;
|
---|
494 | @touch \$@
|
---|
495 |
|
---|
496 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
497 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
498 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
499 | sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
|
---|
500 | (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
---|
501 | fi;
|
---|
502 | @touch \$@
|
---|
503 |
|
---|
504 | devices: ck_LFS ck_UID
|
---|
505 | sudo mount -v --bind /dev \$(LFS)/dev
|
---|
506 | sudo mount -vt devpts devpts \$(LFS)/dev/pts
|
---|
507 | sudo mount -vt tmpfs shm \$(LFS)/dev/shm
|
---|
508 | sudo mount -vt proc proc \$(LFS)/proc
|
---|
509 | sudo mount -vt sysfs sysfs \$(LFS)/sys
|
---|
510 |
|
---|
511 | teardown: ck_LFS
|
---|
512 | sudo umount -v \$(LFS)/sys
|
---|
513 | sudo umount -v \$(LFS)/proc
|
---|
514 | sudo umount -v \$(LFS)/dev/shm
|
---|
515 | sudo umount -v \$(LFS)/dev/pts
|
---|
516 | sudo umount -v \$(LFS)/dev
|
---|
517 |
|
---|
518 | chroot: devices
|
---|
519 | sudo /usr/sbin/chroot \$(LFS) /tools/bin/env -i \\
|
---|
520 | HOME=/root TERM=\$(TERM) PS1='\\u:\\w\\\$\$ ' \\
|
---|
521 | PATH=/bin:/usr/bin:/sbin:/usr/sbin \\
|
---|
522 | /tools/bin/bash --login
|
---|
523 | \$(MAKE) teardown
|
---|
524 |
|
---|
525 | SETUP: $chapter4
|
---|
526 | LUSER: $chapter5
|
---|
527 | SUDO: $runasroot
|
---|
528 | CHROOT: SHELL=/tools/bin/bash
|
---|
529 | CHROOT: $chapter6
|
---|
530 | BOOT: $chapter78
|
---|
531 | CUSTOM_TOOLS: $custom_list
|
---|
532 | BLFS_TOOL: $blfs_tool
|
---|
533 |
|
---|
534 |
|
---|
535 | create-sbu_du-report: mk_BOOT
|
---|
536 | @\$(call echo_message, Building)
|
---|
537 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
538 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
539 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
540 | fi;
|
---|
541 | @touch \$@
|
---|
542 |
|
---|
543 | restore-luser-env:
|
---|
544 | @\$(call echo_message, Building)
|
---|
545 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
546 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
547 | fi;
|
---|
548 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
549 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
550 | fi;
|
---|
551 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
|
---|
552 | @\$(call housekeeping)
|
---|
553 |
|
---|
554 | do_housekeeping:
|
---|
555 | @-umount \$(MOUNT_PT)/sys
|
---|
556 | @-umount \$(MOUNT_PT)/proc
|
---|
557 | @-umount \$(MOUNT_PT)/dev/shm
|
---|
558 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
559 | @-umount \$(MOUNT_PT)/dev
|
---|
560 | @-rm /tools
|
---|
561 | @-if [ ! -f luser-exist ]; then \\
|
---|
562 | userdel \$(LUSER); \\
|
---|
563 | rm -rf \$(LUSER_HOME); \\
|
---|
564 | fi;
|
---|
565 |
|
---|
566 |
|
---|
567 | EOF
|
---|
568 | ) >> $MKFILE
|
---|
569 |
|
---|
570 | # Bring over the items from the Makefile.tmp
|
---|
571 | cat $MKFILE.tmp >> $MKFILE
|
---|
572 | rm $MKFILE.tmp
|
---|
573 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
574 | }
|
---|