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