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