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