1 | #!/bin/bash
|
---|
2 | # $Id$
|
---|
3 |
|
---|
4 |
|
---|
5 | orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
|
---|
6 |
|
---|
7 |
|
---|
8 | #--------------------------------------#
|
---|
9 | host_prep_Makefiles() { #
|
---|
10 | #--------------------------------------#
|
---|
11 | local CLFS_HOST
|
---|
12 |
|
---|
13 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
|
---|
14 |
|
---|
15 | # defined here, only for ease of reading
|
---|
16 | CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
|
---|
17 | (
|
---|
18 | cat << EOF
|
---|
19 | 023-creatingtoolsdir:
|
---|
20 | @\$(call echo_message, Building)
|
---|
21 | @install -dv \$(MOUNT_PT)/tools && \\
|
---|
22 | rm -f /tools && \\
|
---|
23 | ln -s \$(MOUNT_PT)/tools /
|
---|
24 | @\$(call housekeeping)
|
---|
25 |
|
---|
26 | 024-creatingcrossdir: 023-creatingtoolsdir
|
---|
27 | @\$(call echo_message, Building)
|
---|
28 | @install -dv \$(MOUNT_PT)/cross-tools && \\
|
---|
29 | rm -f /cross-tools && \\
|
---|
30 | ln -s \$(MOUNT_PT)/cross-tools /
|
---|
31 | @\$(call housekeeping)
|
---|
32 |
|
---|
33 | 025-addinguser: 024-creatingcrossdir
|
---|
34 | @\$(call echo_message, Building)
|
---|
35 | @if [ ! -d \$(LUSER_HOME) ]; then \\
|
---|
36 | groupadd \$(LGROUP); \\
|
---|
37 | useradd -s /bin/bash -g \$(LGROUP) -d \$(LUSER_HOME) \$(LUSER); \\
|
---|
38 | mkdir -pv \$(LUSER_HOME); \\
|
---|
39 | chown -v \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
|
---|
40 | else \\
|
---|
41 | touch luser-exist; \\
|
---|
42 | fi
|
---|
43 | @chown -v \$(LUSER) \$(MOUNT_PT)/tools && \\
|
---|
44 | chown -v \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
|
---|
45 | chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
46 | chmod a+wt \$(SRCSDIR)
|
---|
47 | @\$(call housekeeping)
|
---|
48 |
|
---|
49 | 026-settingenvironment: 025-addinguser
|
---|
50 | @\$(call echo_message, Building)
|
---|
51 | @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
52 | mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
---|
53 | fi
|
---|
54 | @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
55 | mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
|
---|
56 | fi;
|
---|
57 | @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
|
---|
58 | echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
59 | echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
60 | echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
61 | echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
62 | echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
63 | echo "" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
64 | echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
65 | echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
66 | echo "" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
67 | EOF
|
---|
68 | ) >> $MKFILE.tmp
|
---|
69 | if ! [ -e final-preps/*variables ]; then
|
---|
70 | (
|
---|
71 | cat << EOF
|
---|
72 | echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
73 | echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
74 | echo "export CLFS_TARGET32=\"${TARGET32}\"" >> \$(LUSER_HOME)/.bashrc && \\
|
---|
75 | EOF
|
---|
76 | ) >> $MKFILE.tmp
|
---|
77 | fi
|
---|
78 | (
|
---|
79 | cat << EOF
|
---|
80 | echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
|
---|
81 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
|
---|
82 | chmod a+wt \$(MOUNT_PT) && \\
|
---|
83 | if [ -d \$(MOUNT_PT)/var ]; then \\
|
---|
84 | chown -R \$(LUSER) \$(MOUNT_PT)/var; \\
|
---|
85 | fi && \\
|
---|
86 | touch envars && \\
|
---|
87 | chown \$(LUSER):\$(LGROUP) envars
|
---|
88 | @\$(call housekeeping)
|
---|
89 | EOF
|
---|
90 | ) >> $MKFILE.tmp
|
---|
91 | host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
|
---|
92 |
|
---|
93 | }
|
---|
94 |
|
---|
95 | #--------------------------------------#
|
---|
96 | final_preps_Makefiles() {
|
---|
97 | #--------------------------------------#
|
---|
98 | echo "${tab_}${GREEN}Processing... ${L_arrow}variables ( LUSER ) ${R_arrow}"
|
---|
99 | for file in final-preps/* ; do
|
---|
100 | this_script=`basename $file`
|
---|
101 | case $this_script in
|
---|
102 | *variables )
|
---|
103 | ;;
|
---|
104 | *) continue; ;;
|
---|
105 | esac
|
---|
106 | # Set the dependency for the first target.
|
---|
107 | if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
|
---|
108 |
|
---|
109 | # First append each name of the script files to a list (this will become
|
---|
110 | # the names of the targets in the Makefile
|
---|
111 | final_preps="$final_preps $this_script"
|
---|
112 |
|
---|
113 | # No need to grab the package name
|
---|
114 |
|
---|
115 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
116 | LUSER_wrt_RunAsUser "${file}"
|
---|
117 | wrt_touch
|
---|
118 | PREV=$this_script
|
---|
119 | done # for file in ....
|
---|
120 | }
|
---|
121 |
|
---|
122 | #--------------------------------------#
|
---|
123 | cross_tools_Makefiles() { #
|
---|
124 | #--------------------------------------#
|
---|
125 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
126 |
|
---|
127 | for file in cross-tools/* ; do
|
---|
128 | # Keep the script file name
|
---|
129 | this_script=`basename $file`
|
---|
130 | #
|
---|
131 | # Skip this script...
|
---|
132 | case $this_script in
|
---|
133 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
134 | continue; ;;
|
---|
135 | *) ;;
|
---|
136 | esac
|
---|
137 | #
|
---|
138 | # Set the dependency for the first target.
|
---|
139 | if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
|
---|
140 |
|
---|
141 | # First append each name of the script files to a list (this will become
|
---|
142 | # the names of the targets in the Makefile
|
---|
143 | cross_tools="$cross_tools $this_script"
|
---|
144 |
|
---|
145 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
146 | # and binutils in chapter 5)
|
---|
147 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
148 | -e 's@-static@@' \
|
---|
149 | -e 's@-final@@' \
|
---|
150 | -e 's@-64@@' \
|
---|
151 | -e 's@-n32@@'`
|
---|
152 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
153 |
|
---|
154 | #--------------------------------------------------------------------#
|
---|
155 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
156 | #--------------------------------------------------------------------#
|
---|
157 | #
|
---|
158 | # Drop in the name of the target on a new line, and the previous target
|
---|
159 | # as a dependency. Also call the echo_message function.
|
---|
160 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
161 | #
|
---|
162 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
163 | #
|
---|
164 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
165 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = 3 ]] && wrt_makeflags "${name}"
|
---|
166 | #
|
---|
167 | LUSER_wrt_RunAsUser "${file}"
|
---|
168 | #
|
---|
169 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
170 | #
|
---|
171 | # Include a touch of the target name so make can check if it's already been made.
|
---|
172 | wrt_touch
|
---|
173 | #
|
---|
174 | #--------------------------------------------------------------------#
|
---|
175 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
176 | #--------------------------------------------------------------------#
|
---|
177 | #
|
---|
178 | # Keep the script file name for Makefile dependencies.
|
---|
179 | PREV=$this_script
|
---|
180 |
|
---|
181 | done # for file in ....
|
---|
182 | }
|
---|
183 |
|
---|
184 | #--------------------------------------#
|
---|
185 | temptools_Makefiles() { #
|
---|
186 | #--------------------------------------#
|
---|
187 | echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
|
---|
188 |
|
---|
189 | for file in temp-system/* ; do
|
---|
190 | # Keep the script file name
|
---|
191 | this_script=`basename $file`
|
---|
192 | #
|
---|
193 | # Deal with any odd scripts..
|
---|
194 | case $this_script in
|
---|
195 | *choose) # The choose script will fail if you cannot enter the new environment
|
---|
196 | # If the 'boot' build method was chosen don't run the script
|
---|
197 | [[ $METHOD = "boot" ]] && continue; ;;
|
---|
198 | *) ;;
|
---|
199 | esac
|
---|
200 |
|
---|
201 | #
|
---|
202 | # First append each name of the script files to a list (this will become
|
---|
203 | # the names of the targets in the Makefile
|
---|
204 | temptools="$temptools $this_script"
|
---|
205 |
|
---|
206 | #
|
---|
207 | # Grab the name of the target, strip id number, XXX-script
|
---|
208 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
209 | #
|
---|
210 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
211 |
|
---|
212 | #--------------------------------------------------------------------#
|
---|
213 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
214 | #--------------------------------------------------------------------#
|
---|
215 | #
|
---|
216 | # Drop in the name of the target on a new line, and the previous target
|
---|
217 | # as a dependency. Also call the echo_message function.
|
---|
218 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
219 | #
|
---|
220 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
221 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
222 | #
|
---|
223 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
224 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
225 | #
|
---|
226 | LUSER_wrt_RunAsUser "${file}"
|
---|
227 | #
|
---|
228 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
229 | #
|
---|
230 | # Include a touch of the target name so make can check if it's already been made.
|
---|
231 | wrt_touch
|
---|
232 | #
|
---|
233 | #--------------------------------------------------------------------#
|
---|
234 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
235 | #--------------------------------------------------------------------#
|
---|
236 | #
|
---|
237 | # Keep the script file name for Makefile dependencies.
|
---|
238 | PREV=$this_script
|
---|
239 | done # for file in ....
|
---|
240 | }
|
---|
241 |
|
---|
242 |
|
---|
243 | #--------------------------------------#
|
---|
244 | chroot_Makefiles() { #
|
---|
245 | #--------------------------------------#
|
---|
246 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
|
---|
247 |
|
---|
248 | for file in chroot/* ; do
|
---|
249 | # Keep the script file name
|
---|
250 | this_script=`basename $file`
|
---|
251 | #
|
---|
252 | # Skipping scripts is done now and not included in the build tree.
|
---|
253 | case $this_script in
|
---|
254 | *chroot*) continue ;;
|
---|
255 | esac
|
---|
256 |
|
---|
257 | #
|
---|
258 | # First append each name of the script files to a list (this will become
|
---|
259 | # the names of the targets in the Makefile
|
---|
260 | case "${this_script}" in
|
---|
261 | *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
---|
262 | *) chroottools="$chroottools $this_script" ;;
|
---|
263 | esac
|
---|
264 |
|
---|
265 | # Grab the name of the target, strip id number, XXX-script
|
---|
266 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
267 |
|
---|
268 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
269 |
|
---|
270 | # This is very ugly:: util-linux is in /chroot but must be run under LUSER
|
---|
271 | # Same for e2fsprogs (in CLFS 1.1.0)
|
---|
272 | # .. Customized makefile entry
|
---|
273 | case "${this_script}" in
|
---|
274 | *util-linux)
|
---|
275 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
276 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
277 | [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
278 | LUSER_wrt_RunAsUser "${file}"
|
---|
279 | LUSER_RemoveBuildDirs "${name}"
|
---|
280 | wrt_touch
|
---|
281 | temptools="$temptools $this_script"
|
---|
282 | continue ;;
|
---|
283 | *util-linux-ng)
|
---|
284 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
285 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
286 | [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
287 | LUSER_wrt_RunAsUser "${file}"
|
---|
288 | LUSER_RemoveBuildDirs "${name}"
|
---|
289 | wrt_touch
|
---|
290 | temptools="$temptools $this_script"
|
---|
291 | continue ;;
|
---|
292 | *util-linux-libs)
|
---|
293 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
294 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
295 | [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
296 | LUSER_wrt_RunAsUser "${file}"
|
---|
297 | LUSER_RemoveBuildDirs "${name}"
|
---|
298 | wrt_touch
|
---|
299 | temptools="$temptools $this_script"
|
---|
300 | continue ;;
|
---|
301 | *e2fsprogs)
|
---|
302 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
303 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
304 | [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
305 | LUSER_wrt_RunAsUser "${file}"
|
---|
306 | LUSER_RemoveBuildDirs "${name}"
|
---|
307 | wrt_touch
|
---|
308 | temptools="$temptools $this_script"
|
---|
309 | continue ;;
|
---|
310 | *e2fsprogs-libs)
|
---|
311 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
312 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
313 | [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
314 | LUSER_wrt_RunAsUser "${file}"
|
---|
315 | LUSER_RemoveBuildDirs "${name}"
|
---|
316 | wrt_touch
|
---|
317 | temptools="$temptools $this_script"
|
---|
318 | continue ;;
|
---|
319 | esac
|
---|
320 |
|
---|
321 |
|
---|
322 | #--------------------------------------------------------------------#
|
---|
323 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
324 | #--------------------------------------------------------------------#
|
---|
325 | #
|
---|
326 | # Drop in the name of the target on a new line, and the previous target
|
---|
327 | # as a dependency. Also call the echo_message function.
|
---|
328 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
329 | #
|
---|
330 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
331 | # Insert instructions for unpacking the package and changing directories
|
---|
332 | #
|
---|
333 | if [ "$pkg_tarball" != "" ] ; then
|
---|
334 | CHROOT_Unpack "$pkg_tarball"
|
---|
335 | [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
336 | fi
|
---|
337 | #
|
---|
338 | # Select a script execution method
|
---|
339 | case $this_script in
|
---|
340 | *kernfs) wrt_RunAsRoot "${file}" ;;
|
---|
341 | *) CHROOT_wrt_RunAsRoot "${file}" ;;
|
---|
342 | esac
|
---|
343 | #
|
---|
344 | # Housekeeping...remove the build directory(ies), except if the package build fails.
|
---|
345 | [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
346 | #
|
---|
347 | # Include a touch of the target name so make can check if it's already been made.
|
---|
348 | wrt_touch
|
---|
349 | #
|
---|
350 | #--------------------------------------------------------------------#
|
---|
351 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
352 | #--------------------------------------------------------------------#
|
---|
353 | #
|
---|
354 | # Keep the script file name for Makefile dependencies.
|
---|
355 | PREV=$this_script
|
---|
356 |
|
---|
357 | done # for file in...
|
---|
358 | }
|
---|
359 |
|
---|
360 |
|
---|
361 | #--------------------------------------#
|
---|
362 | boot_Makefiles() { #
|
---|
363 | #--------------------------------------#
|
---|
364 |
|
---|
365 | echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
|
---|
366 | #
|
---|
367 | # Create a target bootable partition containing a compile environment. Later
|
---|
368 | # on we boot into this environment and contine the build.
|
---|
369 | #
|
---|
370 | for file in boot/* ; do
|
---|
371 | # Keep the script file name
|
---|
372 | this_script=`basename $file`
|
---|
373 |
|
---|
374 | # A little housekeeping on the scripts
|
---|
375 | case $this_script in
|
---|
376 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *introduction ) continue ;;
|
---|
377 | *how-to-view*) continue ;;
|
---|
378 | *whatnext*) continue ;;
|
---|
379 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
380 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
381 | [[ -z $CONFIG ]] && continue
|
---|
382 | # Copy the config file to /sources with a standardized name
|
---|
383 | cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
|
---|
384 | ;;
|
---|
385 | esac
|
---|
386 | #
|
---|
387 | # First append each name of the script files to a list (this will become
|
---|
388 | # the names of the targets in the Makefile). Those names differ depending
|
---|
389 | # on the version of the book. What makes the difference between those
|
---|
390 | # versions is the presence of "how-to-view" in the boot chapter.
|
---|
391 | if [ -f boot/*how-to-view ]; then
|
---|
392 | case "${this_script}" in
|
---|
393 | *changingowner)
|
---|
394 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
395 | ;;
|
---|
396 | *creatingdirs)
|
---|
397 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
398 | ;;
|
---|
399 | *createfiles)
|
---|
400 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
401 | ;;
|
---|
402 | *devices)
|
---|
403 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
404 | ;;
|
---|
405 | *flags)
|
---|
406 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
407 | ;;
|
---|
408 | *fstab)
|
---|
409 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
410 | ;;
|
---|
411 | *pwdgroup)
|
---|
412 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
413 | ;;
|
---|
414 | *settingenvironment)
|
---|
415 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
416 | ;;
|
---|
417 | *)
|
---|
418 | boottools="$boottools $this_script"
|
---|
419 | ;;
|
---|
420 | esac
|
---|
421 | else
|
---|
422 | case "${this_script}" in
|
---|
423 | *changingowner)
|
---|
424 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
425 | ;;
|
---|
426 | *devices)
|
---|
427 | orphan_scripts="${orphan_scripts} ${this_script}"
|
---|
428 | ;;
|
---|
429 | *)
|
---|
430 | boottools="$boottools $this_script"
|
---|
431 | ;;
|
---|
432 | esac
|
---|
433 | fi
|
---|
434 | #
|
---|
435 | # Grab the name of the target, strip id number and misc words.
|
---|
436 | case $this_script in
|
---|
437 | *kernel) name=linux ;;
|
---|
438 | *bootscripts) name="bootscripts-cross-lfs" ;;
|
---|
439 | *boot-scripts) name="boot-scripts-cross-lfs" ;;
|
---|
440 | *udev-rules) name="udev-cross-lfs" ;;
|
---|
441 | *grub-build) name=grub ;;
|
---|
442 | *-aboot-build) name=aboot ;;
|
---|
443 | *yaboot-build) name=yaboot ;;
|
---|
444 | *colo-build) name=colo ;;
|
---|
445 | *silo-build) name=silo ;;
|
---|
446 | *arcload-build) name=arcload ;;
|
---|
447 | *lilo-build) name=lilo ;;
|
---|
448 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
449 | esac
|
---|
450 | # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
|
---|
451 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
452 |
|
---|
453 | #--------------------------------------------------------------------#
|
---|
454 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
455 | #--------------------------------------------------------------------#
|
---|
456 | #
|
---|
457 | # Drop in the name of the target on a new line, and the previous target
|
---|
458 | # as a dependency. Also call the echo_message function.
|
---|
459 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
460 | #
|
---|
461 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
462 | # Insert instructions for unpacking the package and changing directories
|
---|
463 | #
|
---|
464 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
465 | [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
466 | #
|
---|
467 | # Select a script execution method
|
---|
468 | if [ -f boot/*how-to-view ]; then
|
---|
469 | case $this_script in
|
---|
470 | # The following 8 scripts are defined in the /boot directory but need
|
---|
471 | # to be run as a root user. Set them up here but run them in another
|
---|
472 | # phase
|
---|
473 | *changingowner) wrt_RunAsRoot "${file}" ;;
|
---|
474 | *creatingdirs) wrt_RunAsRoot "${file}" ;;
|
---|
475 | *createfiles) wrt_RunAsRoot "${file}" ;;
|
---|
476 | *devices) wrt_RunAsRoot "${file}" ;;
|
---|
477 | *flags) wrt_RunAsRoot "${file}" ;;
|
---|
478 | *fstab)
|
---|
479 | if [[ -n "$FSTAB" ]]; then
|
---|
480 | LUSER_wrt_CopyFstab
|
---|
481 | else
|
---|
482 | wrt_RunAsRoot "${file}"
|
---|
483 | fi
|
---|
484 | ;;
|
---|
485 | *pwdgroup) wrt_RunAsRoot "${file}" ;;
|
---|
486 | *settingenvironment) wrt_RunAsRoot "${file}" ;;
|
---|
487 | *) LUSER_wrt_RunAsUser "${file}" ;;
|
---|
488 | esac
|
---|
489 | else
|
---|
490 | case $this_script in
|
---|
491 | # The following 2 scripts are defined in the /boot directory but need
|
---|
492 | # to be run as a root user. Set them up here but run them in another
|
---|
493 | # phase
|
---|
494 | *changingowner) wrt_RunAsRoot "${file}" ;;
|
---|
495 | *devices) wrt_RunAsRoot "${file}" ;;
|
---|
496 | *fstab)
|
---|
497 | if [[ -n "$FSTAB" ]]; then
|
---|
498 | LUSER_wrt_CopyFstab
|
---|
499 | else
|
---|
500 | LUSER_wrt_RunAsUser "${file}"
|
---|
501 | fi
|
---|
502 | ;;
|
---|
503 | *) LUSER_wrt_RunAsUser "${file}" ;;
|
---|
504 | esac
|
---|
505 | fi
|
---|
506 | #
|
---|
507 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
508 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
509 | #
|
---|
510 | # Include a touch of the target name so make can check if it's already been made.
|
---|
511 | wrt_touch
|
---|
512 | #
|
---|
513 | #--------------------------------------------------------------------#
|
---|
514 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
515 | #--------------------------------------------------------------------#
|
---|
516 | #
|
---|
517 | # Keep the script file name for Makefile dependencies.
|
---|
518 | PREV=$this_script
|
---|
519 |
|
---|
520 | done
|
---|
521 | }
|
---|
522 |
|
---|
523 |
|
---|
524 | #--------------------------------------#
|
---|
525 | testsuite_tools_Makefiles() { #
|
---|
526 | #--------------------------------------#
|
---|
527 |
|
---|
528 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
529 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
|
---|
530 | else
|
---|
531 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
|
---|
532 | PREV=""
|
---|
533 | fi
|
---|
534 |
|
---|
535 | for file in testsuite-tools/* ; do
|
---|
536 | # Keep the script file name
|
---|
537 | this_script=`basename $file`
|
---|
538 |
|
---|
539 | # First append each name of the script files to a list (this will become
|
---|
540 | # the names of the targets in the Makefile
|
---|
541 | testsuitetools="$testsuitetools $this_script"
|
---|
542 |
|
---|
543 | # Grab the name of the target, strip id number, XXX-script
|
---|
544 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
545 | -e 's@-64bit@@' \
|
---|
546 | -e 's@-64@@' \
|
---|
547 | -e 's@64@@' \
|
---|
548 | -e 's@n32@@'`
|
---|
549 |
|
---|
550 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
551 |
|
---|
552 | #--------------------------------------------------------------------#
|
---|
553 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
554 | #--------------------------------------------------------------------#
|
---|
555 | #
|
---|
556 | # Drop in the name of the target on a new line, and the previous target
|
---|
557 | # as a dependency. Also call the echo_message function.
|
---|
558 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
559 | #
|
---|
560 | CHROOT_Unpack "$pkg_tarball"
|
---|
561 | [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
562 | #
|
---|
563 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
564 | #
|
---|
565 | CHROOT_wrt_RemoveBuildDirs "${name}"
|
---|
566 | #
|
---|
567 | # Include a touch of the target name so make can check if it's already been made.
|
---|
568 | wrt_touch
|
---|
569 | #
|
---|
570 | #--------------------------------------------------------------------#
|
---|
571 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
572 | #--------------------------------------------------------------------#
|
---|
573 | #
|
---|
574 | # Keep the script file name for Makefile dependencies.
|
---|
575 | PREV=$this_script
|
---|
576 |
|
---|
577 | done
|
---|
578 | }
|
---|
579 |
|
---|
580 |
|
---|
581 | #--------------------------------------#
|
---|
582 | final_system_Makefiles() { #
|
---|
583 | #--------------------------------------#
|
---|
584 | # Set envars and scripts for iteration targets
|
---|
585 | if [[ -z "$1" ]] ; then
|
---|
586 | local N=""
|
---|
587 | # In boot method the makesys phase was initiated in testsuite_tools_makefile
|
---|
588 | [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
|
---|
589 | else
|
---|
590 | local N=-build_$1
|
---|
591 | local basicsystem=""
|
---|
592 | mkdir final-system$N
|
---|
593 | cp final-system/* final-system$N
|
---|
594 | for script in final-system$N/* ; do
|
---|
595 | # Overwrite existing symlinks, files, and dirs
|
---|
596 | sed -e 's/ln -sv/&f/g' \
|
---|
597 | -e 's/mv -v/&f/g' \
|
---|
598 | -e 's/mkdir -v/&p/g' -i ${script}
|
---|
599 | # Rename the scripts
|
---|
600 | mv ${script} ${script}$N
|
---|
601 | done
|
---|
602 | # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
|
---|
603 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
|
---|
604 | # Delete *old Readline libraries just after make install
|
---|
605 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
|
---|
606 | fi
|
---|
607 |
|
---|
608 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
609 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
|
---|
610 | else
|
---|
611 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
|
---|
612 | fi
|
---|
613 |
|
---|
614 | for file in final-system$N/* ; do
|
---|
615 | # Keep the script file name
|
---|
616 | this_script=`basename $file`
|
---|
617 |
|
---|
618 | # Test if the stripping phase must be skipped.
|
---|
619 | # Skip also temp-perl for iterative runs
|
---|
620 | case $this_script in
|
---|
621 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
622 | *temp-perl*) [[ -n "$N" ]] && continue ;;
|
---|
623 | esac
|
---|
624 |
|
---|
625 | # Grab the name of the target, strip id number, XXX-script.
|
---|
626 | # name1 is partially stripped and should be used for logging files.
|
---|
627 | # name is completely stripped and is used for grabbing
|
---|
628 | # the package name.
|
---|
629 | name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
630 | -e 's,'$N',,'`
|
---|
631 | name=`echo $name1 | sed -e 's@temp-@@' \
|
---|
632 | -e 's@-64bit@@' \
|
---|
633 | -e 's@-64@@' \
|
---|
634 | -e 's@64@@' \
|
---|
635 | -e 's@n32@@'`
|
---|
636 |
|
---|
637 | # Find the version of the command files, if it corresponds with the building of
|
---|
638 | # a specific package. We need this here to can skip scripts not needed for
|
---|
639 | # iterations rebuilds
|
---|
640 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
641 |
|
---|
642 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
643 | case "${this_script}" in
|
---|
644 | *stripping*) ;;
|
---|
645 | *) continue ;;
|
---|
646 | esac
|
---|
647 | fi
|
---|
648 |
|
---|
649 | # Append each name of the script files to a list (this will become
|
---|
650 | # the names of the targets in the Makefile
|
---|
651 | basicsystem="$basicsystem ${this_script}"
|
---|
652 |
|
---|
653 | #--------------------------------------------------------------------#
|
---|
654 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
655 | #--------------------------------------------------------------------#
|
---|
656 | #
|
---|
657 | # Drop in the name of the target on a new line, and the previous target
|
---|
658 | # as a dependency. Also call the echo_message function.
|
---|
659 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
660 |
|
---|
661 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
662 | if [ "$pkg_tarball" != "" ] ; then
|
---|
663 | # Touch timestamp file if installed files logs will be created.
|
---|
664 | # But only for the firt build when running iterative builds.
|
---|
665 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
666 | CHROOT_wrt_TouchTimestamp
|
---|
667 | fi
|
---|
668 | CHROOT_Unpack "$pkg_tarball"
|
---|
669 | # If the testsuites must be run, initialize the log file
|
---|
670 | case $name in
|
---|
671 | binutils | gcc | glibc | eglibc | gmp | mpfr | mpc | isl | cloog )
|
---|
672 | [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
673 | ;;
|
---|
674 | * )
|
---|
675 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
|
---|
676 | ;;
|
---|
677 | esac
|
---|
678 | # If using optimizations, write the instructions
|
---|
679 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
680 | fi
|
---|
681 | #
|
---|
682 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
683 | #
|
---|
684 | # Write installed files log and remove the build directory(ies)
|
---|
685 | # except if the package build fails.
|
---|
686 | if [ "$pkg_tarball" != "" ] ; then
|
---|
687 | CHROOT_wrt_RemoveBuildDirs "$name"
|
---|
688 | if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
|
---|
689 | CHROOT_wrt_LogNewFiles "$name1"
|
---|
690 | fi
|
---|
691 | fi
|
---|
692 | #
|
---|
693 | # Include a touch of the target name so make can check
|
---|
694 | # if it's already been made.
|
---|
695 | wrt_touch
|
---|
696 | #
|
---|
697 | #--------------------------------------------------------------------#
|
---|
698 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
699 | #--------------------------------------------------------------------#
|
---|
700 | #
|
---|
701 | # Keep the script file name for Makefile dependencies.
|
---|
702 | PREV=${this_script}
|
---|
703 | # Set system_build envar for iteration targets
|
---|
704 | system_build=$basicsystem
|
---|
705 | done # for file in final-system/* ...
|
---|
706 | }
|
---|
707 |
|
---|
708 | #--------------------------------------#
|
---|
709 | bootscripts_Makefiles() { #
|
---|
710 | #--------------------------------------#
|
---|
711 |
|
---|
712 | # New versions of the book do not have bootscripts anymore
|
---|
713 | # (use systemd configuration files)
|
---|
714 | # Define a variable to be used for the right script directory to parse
|
---|
715 | if [ -d bootscripts ]; then
|
---|
716 | config="bootscripts"
|
---|
717 | else
|
---|
718 | config="system-config"
|
---|
719 | fi
|
---|
720 |
|
---|
721 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
722 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) $config ( CHROOT ) ${R_arrow}"
|
---|
723 | else
|
---|
724 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) $config ( ROOT ) ${R_arrow}"
|
---|
725 | fi
|
---|
726 |
|
---|
727 | for file in $config/* ; do
|
---|
728 | # Keep the script file name
|
---|
729 | this_script=`basename $file`
|
---|
730 |
|
---|
731 | case $this_script in
|
---|
732 | *udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
---|
733 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
734 | *) ;;
|
---|
735 | esac
|
---|
736 |
|
---|
737 | # First append each name of the script files to a list (this will become
|
---|
738 | # the names of the targets in the Makefile
|
---|
739 | bootscripttools="$bootscripttools $this_script"
|
---|
740 |
|
---|
741 | # Grab the name of the target, strip id number, XXX-script.
|
---|
742 | # name1 is partially stripped and should be used for logging files.
|
---|
743 | # name is completely stripped and is used for grabbing
|
---|
744 | # the package name.
|
---|
745 | name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
746 | name=`echo $name1 | sed -e 's@-64bit@@' \
|
---|
747 | -e 's@-64@@' \
|
---|
748 | -e 's@64@@' \
|
---|
749 | -e 's@n32@@'`
|
---|
750 | case $name in
|
---|
751 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
752 | *udev-rules) name=udev-cross-lfs ;;
|
---|
753 | esac
|
---|
754 |
|
---|
755 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
756 |
|
---|
757 | #--------------------------------------------------------------------#
|
---|
758 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
759 | #--------------------------------------------------------------------#
|
---|
760 | #
|
---|
761 | # Drop in the name of the target on a new line, and the previous target
|
---|
762 | # as a dependency. Also call the echo_message function.
|
---|
763 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
764 | #
|
---|
765 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
766 | #
|
---|
767 | if [ "$pkg_tarball" != "" ] ; then
|
---|
768 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
769 | CHROOT_wrt_TouchTimestamp
|
---|
770 | fi
|
---|
771 | CHROOT_Unpack "$pkg_tarball"
|
---|
772 | fi
|
---|
773 | #
|
---|
774 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
775 | #
|
---|
776 | # Write installed files log and remove the build directory(ies)
|
---|
777 | # except if the package build fails.
|
---|
778 | if [ "$pkg_tarball" != "" ] ; then
|
---|
779 | CHROOT_wrt_RemoveBuildDirs "$name"
|
---|
780 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
781 | CHROOT_wrt_LogNewFiles "$name1"
|
---|
782 | fi
|
---|
783 | fi
|
---|
784 | #
|
---|
785 | # Include a touch of the target name so make can check if it's already been made.
|
---|
786 | wrt_touch
|
---|
787 | #
|
---|
788 | #--------------------------------------------------------------------#
|
---|
789 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
790 | #--------------------------------------------------------------------#
|
---|
791 | #
|
---|
792 | # Keep the script file name for Makefile dependencies.
|
---|
793 | PREV=$this_script
|
---|
794 |
|
---|
795 | done # for file in bootscripts/* ...
|
---|
796 | }
|
---|
797 |
|
---|
798 | #--------------------------------------#
|
---|
799 | network_Makefiles() { #
|
---|
800 | #--------------------------------------#
|
---|
801 |
|
---|
802 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
803 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) network ( CHROOT ) ${R_arrow}"
|
---|
804 | else
|
---|
805 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) network ( ROOT ) ${R_arrow}"
|
---|
806 | fi
|
---|
807 |
|
---|
808 | for file in network/* ; do
|
---|
809 | # Keep the script file name
|
---|
810 | this_script=`basename $file`
|
---|
811 |
|
---|
812 | case $this_script in
|
---|
813 | *choose) continue ;; # This is not a script but a commentary.
|
---|
814 | *dhcp) continue ;; # Assume static networking.
|
---|
815 | *dhcpcd) continue ;; # Assume static networking.
|
---|
816 | *) ;;
|
---|
817 | esac
|
---|
818 |
|
---|
819 | # First append each name of the script files to a list (this will become
|
---|
820 | # the names of the targets in the Makefile
|
---|
821 | networktools="$networktools $this_script"
|
---|
822 |
|
---|
823 | # Grab the name of the target, strip id number, XXX-script
|
---|
824 | # name1 is partially stripped and should be used for logging files.
|
---|
825 | # name is completely stripped and is used for grabbing
|
---|
826 | # the package name.
|
---|
827 | name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
828 | name=`echo $name1 | sed -e 's@-64bit@@' \
|
---|
829 | -e 's@-64@@' \
|
---|
830 | -e 's@64@@' \
|
---|
831 | -e 's@n32@@'`
|
---|
832 | case $name in
|
---|
833 | network-scripts) name=clfs-network-scripts ;;
|
---|
834 | esac
|
---|
835 |
|
---|
836 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
837 |
|
---|
838 | #--------------------------------------------------------------------#
|
---|
839 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
840 | #--------------------------------------------------------------------#
|
---|
841 | #
|
---|
842 | # Drop in the name of the target on a new line, and the previous target
|
---|
843 | # as a dependency. Also call the echo_message function.
|
---|
844 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
845 | #
|
---|
846 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
847 | #
|
---|
848 | if [ "$pkg_tarball" != "" ] ; then
|
---|
849 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
850 | CHROOT_wrt_TouchTimestamp
|
---|
851 | fi
|
---|
852 | CHROOT_Unpack "$pkg_tarball"
|
---|
853 | fi
|
---|
854 | #
|
---|
855 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
856 | #
|
---|
857 | # Write installed files log and remove the build directory(ies)
|
---|
858 | # except if the package build fails.
|
---|
859 | if [ "$pkg_tarball" != "" ] ; then
|
---|
860 | CHROOT_wrt_RemoveBuildDirs "$name"
|
---|
861 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
862 | CHROOT_wrt_LogNewFiles "$name1"
|
---|
863 | fi
|
---|
864 | fi
|
---|
865 | #
|
---|
866 | # Include a touch of the target name so make can check if it's already been made.
|
---|
867 | wrt_touch
|
---|
868 | #
|
---|
869 | #--------------------------------------------------------------------#
|
---|
870 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
871 | #--------------------------------------------------------------------#
|
---|
872 | #
|
---|
873 | # Keep the script file name for Makefile dependencies.
|
---|
874 | PREV=$this_script
|
---|
875 |
|
---|
876 | done # for file in network/* ...
|
---|
877 | }
|
---|
878 |
|
---|
879 | #--------------------------------------#
|
---|
880 | bootable_Makefiles() { #
|
---|
881 | #--------------------------------------#
|
---|
882 |
|
---|
883 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
884 | echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
|
---|
885 | else
|
---|
886 | echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
|
---|
887 | fi
|
---|
888 |
|
---|
889 |
|
---|
890 | for file in bootable/* ; do
|
---|
891 | # Keep the script file name
|
---|
892 | this_script=`basename $file`
|
---|
893 |
|
---|
894 | # A little housekeeping on the scripts
|
---|
895 | case $this_script in
|
---|
896 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
897 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
898 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
899 | [[ -z $CONFIG ]] && continue
|
---|
900 | # Copy the config file to /sources with a standardized name
|
---|
901 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
902 | ;;
|
---|
903 | esac
|
---|
904 | #
|
---|
905 | # First append each name of the script files to a list (this will become
|
---|
906 | # the names of the targets in the Makefile
|
---|
907 | bootabletools="$bootabletools $this_script"
|
---|
908 | #
|
---|
909 | # Grab the name of the target, strip id number and misc words.
|
---|
910 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
911 | case $this_script in
|
---|
912 | *kernel*) name=linux
|
---|
913 | ;;
|
---|
914 | esac
|
---|
915 |
|
---|
916 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
917 |
|
---|
918 | #--------------------------------------------------------------------#
|
---|
919 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
920 | #--------------------------------------------------------------------#
|
---|
921 | #
|
---|
922 | # Drop in the name of the target on a new line, and the previous target
|
---|
923 | # as a dependency. Also call the echo_message function.
|
---|
924 | CHROOT_wrt_target "${this_script}" "$PREV"
|
---|
925 | #
|
---|
926 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
927 | # Insert instructions for unpacking the package and changing directories
|
---|
928 | #
|
---|
929 | if [ "$pkg_tarball" != "" ] ; then
|
---|
930 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
931 | CHROOT_wrt_TouchTimestamp
|
---|
932 | fi
|
---|
933 | CHROOT_Unpack "$pkg_tarball"
|
---|
934 | fi
|
---|
935 | #
|
---|
936 | # Select a script execution method
|
---|
937 | case $this_script in
|
---|
938 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
939 | CHROOT_wrt_CopyFstab
|
---|
940 | else
|
---|
941 | CHROOT_wrt_RunAsRoot "${file}"
|
---|
942 | fi
|
---|
943 | ;;
|
---|
944 | *) CHROOT_wrt_RunAsRoot "${file}"
|
---|
945 | ;;
|
---|
946 | esac
|
---|
947 | #
|
---|
948 | # Write installed files log and remove the build directory(ies)
|
---|
949 | # except if the package build fails.
|
---|
950 | if [ "$pkg_tarball" != "" ] ; then
|
---|
951 | CHROOT_wrt_RemoveBuildDirs "$name"
|
---|
952 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
953 | CHROOT_wrt_LogNewFiles "$name"
|
---|
954 | fi
|
---|
955 | fi
|
---|
956 | #
|
---|
957 | # Include a touch of the target name so make can check if it's already been made.
|
---|
958 | wrt_touch
|
---|
959 | #
|
---|
960 | #--------------------------------------------------------------------#
|
---|
961 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
962 | #--------------------------------------------------------------------#
|
---|
963 | #
|
---|
964 | # Keep the script file name for Makefile dependencies.
|
---|
965 | PREV=$this_script
|
---|
966 |
|
---|
967 | done
|
---|
968 |
|
---|
969 | }
|
---|
970 |
|
---|
971 |
|
---|
972 | #--------------------------------------#
|
---|
973 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
974 | #--------------------------------------#
|
---|
975 |
|
---|
976 | echo "...Creating Makefile... ${BOLD}START${OFF}"
|
---|
977 |
|
---|
978 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
979 | # Start with clean files
|
---|
980 | >$MKFILE
|
---|
981 | >$MKFILE.tmp
|
---|
982 |
|
---|
983 | method_cmds=${METHOD}_Makefiles
|
---|
984 |
|
---|
985 | host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
|
---|
986 | final_preps_Makefiles # mk_F_PREPS (LUSER) $final_preps
|
---|
987 | cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
|
---|
988 | temptools_Makefiles # mk_TEMP (LUSER) $temptools
|
---|
989 | $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
|
---|
990 | if [[ ! $TEST = "0" ]]; then
|
---|
991 | testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
|
---|
992 | fi
|
---|
993 | final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
|
---|
994 | # Add the iterations targets, if needed
|
---|
995 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets
|
---|
996 | bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
|
---|
997 | if [ -d network ]; then
|
---|
998 | network_Makefiles # If present, process network setup.
|
---|
999 | fi
|
---|
1000 | bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
|
---|
1001 |
|
---|
1002 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
1003 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
1004 |
|
---|
1005 | # Add a header, some variables and include the function file
|
---|
1006 | # to the top of the real Makefile.
|
---|
1007 | wrt_Makefile_header
|
---|
1008 |
|
---|
1009 | # Add chroot commands
|
---|
1010 | if [ "$METHOD" = "chroot" ] ; then
|
---|
1011 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
1012 | chroot=`cat chroot/???-chroot | \
|
---|
1013 | sed -e "s@chroot@$CHROOT_LOC@" \
|
---|
1014 | -e '/#!\/bin\/bash/d' \
|
---|
1015 | -e '/^export/d' \
|
---|
1016 | -e '/^logout/d' \
|
---|
1017 | -e 's@ \\\@ @g' | \
|
---|
1018 | tr -d '\n' | \
|
---|
1019 | sed -e 's/ */ /g' \
|
---|
1020 | -e 's|\\$|&&|g' \
|
---|
1021 | -e 's|exit||g' \
|
---|
1022 | -e 's|$| -c|' \
|
---|
1023 | -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
|
---|
1024 | -e 's|set -e||' \
|
---|
1025 | -e 's|set +h||'`
|
---|
1026 | echo -e "CHROOT1= $chroot\n" >> $MKFILE
|
---|
1027 | fi
|
---|
1028 |
|
---|
1029 | ################## CHROOT ####################
|
---|
1030 |
|
---|
1031 | if [[ "${METHOD}" = "chroot" ]]; then
|
---|
1032 | (
|
---|
1033 | cat << EOF
|
---|
1034 |
|
---|
1035 | all: ck_UID mk_SETUP mk_F_PREPS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
1036 | @sudo make do-housekeeping
|
---|
1037 | @echo "$VERSION - jhalfs build" > clfs-release && \\
|
---|
1038 | sudo mv clfs-release \$(MOUNT_PT)/etc && \\
|
---|
1039 | sudo chown root:root \$(MOUNT_PT)/etc/clfs-release
|
---|
1040 | @\$(call echo_finished,$VERSION)
|
---|
1041 |
|
---|
1042 | ck_UID:
|
---|
1043 | @if [ \`id -u\` = "0" ]; then \\
|
---|
1044 | echo "+--------------------------------------------------+"; \\
|
---|
1045 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
1046 | echo "+--------------------------------------------------+"; \\
|
---|
1047 | exit 1; \\
|
---|
1048 | fi
|
---|
1049 |
|
---|
1050 | #---------------AS ROOT
|
---|
1051 | mk_SETUP:
|
---|
1052 | @\$(call echo_SU_request)
|
---|
1053 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
1054 | @touch \$@
|
---|
1055 |
|
---|
1056 | #---------------AS LUSER
|
---|
1057 | mk_F_PREPS: mk_SETUP
|
---|
1058 | @\$(call echo_PHASE,Final Preparations Cross and Temporary Tools)
|
---|
1059 | @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
|
---|
1060 | @sudo make restore-luser-env
|
---|
1061 | @touch \$@
|
---|
1062 |
|
---|
1063 | mk_SUDO: mk_F_PREPS
|
---|
1064 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
1065 | @touch \$@
|
---|
1066 |
|
---|
1067 | #---------------CHROOT JAIL
|
---|
1068 | mk_SYSTOOLS: mk_SUDO
|
---|
1069 | @\$(call echo_CHROOT_request)
|
---|
1070 | @\$(call echo_PHASE, CHROOT JAIL )
|
---|
1071 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
|
---|
1072 | @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
|
---|
1073 | @touch \$@
|
---|
1074 |
|
---|
1075 | mk_BLFS_TOOL: create-sbu_du-report
|
---|
1076 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
1077 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
1078 | (sudo \$(CHROOT1) "make -C $BLFS_ROOT/work"); \\
|
---|
1079 | fi;
|
---|
1080 | @touch \$@
|
---|
1081 |
|
---|
1082 | mk_CUSTOM_TOOLS: mk_BLFS_TOOL
|
---|
1083 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
1084 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
1085 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
1086 | (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
1087 | fi;
|
---|
1088 | @touch \$@
|
---|
1089 |
|
---|
1090 | SETUP: $host_prep
|
---|
1091 | AS_LUSER: $final_preps $cross_tools $temptools
|
---|
1092 | SUDO: $orphan_scripts
|
---|
1093 | PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
|
---|
1094 | PREP_CHROOT_JAIL: ${chroottools}
|
---|
1095 | CHROOT_JAIL: SHELL=/tools/bin/bash
|
---|
1096 | CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
1097 | CUSTOM_TOOLS: $custom_list
|
---|
1098 |
|
---|
1099 |
|
---|
1100 | create-sbu_du-report: mk_SYSTOOLS
|
---|
1101 | @\$(call echo_message, Building)
|
---|
1102 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
1103 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
1104 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
1105 | fi;
|
---|
1106 | @touch \$@
|
---|
1107 |
|
---|
1108 | do-housekeeping:
|
---|
1109 | @-umount \$(MOUNT_PT)/dev/pts
|
---|
1110 | @-if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
|
---|
1111 | link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
|
---|
1112 | umount \$(MOUNT_PT)/\$\$link; \\
|
---|
1113 | unset link; \\
|
---|
1114 | else \\
|
---|
1115 | umount \$(MOUNT_PT)/dev/shm; \\
|
---|
1116 | fi
|
---|
1117 | @-umount \$(MOUNT_PT)/dev
|
---|
1118 | @-umount \$(MOUNT_PT)/sys
|
---|
1119 | @-umount \$(MOUNT_PT)/proc
|
---|
1120 | @-rm /tools /cross-tools
|
---|
1121 | @-if [ ! -f luser-exist ]; then \\
|
---|
1122 | userdel \$(LUSER); \\
|
---|
1123 | rm -rf \$(LUSER_HOME); \\
|
---|
1124 | fi;
|
---|
1125 |
|
---|
1126 | EOF
|
---|
1127 | ) >> $MKFILE
|
---|
1128 |
|
---|
1129 | fi
|
---|
1130 |
|
---|
1131 | ################### BOOT #####################
|
---|
1132 |
|
---|
1133 | if [[ "${METHOD}" = "boot" ]]; then
|
---|
1134 | (
|
---|
1135 | cat << EOF
|
---|
1136 |
|
---|
1137 | all: ck_UID mk_SETUP mk_F_PREPS mk_SUDO
|
---|
1138 | @sudo make restore-luser-env
|
---|
1139 | @sudo make do-housekeeping
|
---|
1140 | @\$(call echo_boot_finished,$VERSION)
|
---|
1141 |
|
---|
1142 | makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
|
---|
1143 | @echo "$VERSION - jhalfs build" > /etc/clfs-release
|
---|
1144 | @\$(call echo_finished,$VERSION)
|
---|
1145 |
|
---|
1146 |
|
---|
1147 | ck_UID:
|
---|
1148 | @if [ \`id -u\` = "0" ]; then \\
|
---|
1149 | echo "+--------------------------------------------------+"; \\
|
---|
1150 | echo "|You cannot run this makefile from the root account|"; \\
|
---|
1151 | echo "|However, if this is the boot environment |"; \\
|
---|
1152 | echo "| the command you are looking for is |"; \\
|
---|
1153 | echo "| make makesys |"; \\
|
---|
1154 | echo "| to complete the build |"; \\
|
---|
1155 | echo "+--------------------------------------------------+"; \\
|
---|
1156 | exit 1; \\
|
---|
1157 | fi
|
---|
1158 |
|
---|
1159 | #---------------AS ROOT
|
---|
1160 |
|
---|
1161 | mk_SETUP:
|
---|
1162 | @\$(call echo_SU_request)
|
---|
1163 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
1164 | @touch \$@
|
---|
1165 |
|
---|
1166 | #---------------AS LUSER
|
---|
1167 |
|
---|
1168 | mk_F_PREPS: mk_SETUP
|
---|
1169 | @\$(call echo_PHASE,Final Preparations and Cross Tools)
|
---|
1170 | @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
|
---|
1171 | @touch \$@
|
---|
1172 |
|
---|
1173 | mk_SUDO: mk_F_PREPS
|
---|
1174 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
1175 | @touch \$@
|
---|
1176 |
|
---|
1177 | #---------------AS ROOT
|
---|
1178 |
|
---|
1179 | mk_FINAL:
|
---|
1180 | @\$(call echo_PHASE,Final System)
|
---|
1181 | @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
|
---|
1182 | @touch \$@
|
---|
1183 |
|
---|
1184 | mk_BLFS_TOOL: mk_FINAL
|
---|
1185 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
1186 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
1187 | ( make -C $BLFS_ROOT/work ); \\
|
---|
1188 | fi;
|
---|
1189 | @touch \$@
|
---|
1190 |
|
---|
1191 | mk_CUSTOM_TOOLS: mk_BLFS_TOOL
|
---|
1192 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
1193 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
1194 | mkdir -p ${TRACKING_DIR}; \\
|
---|
1195 | ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
|
---|
1196 | fi;
|
---|
1197 | @touch \$@
|
---|
1198 |
|
---|
1199 | SETUP: $host_prep
|
---|
1200 | AS_LUSER: $final_preps $cross_tools $temptools ${boottools}
|
---|
1201 | SUDO: $orphan_scripts
|
---|
1202 | AS_ROOT: SHELL=/tools/bin/bash
|
---|
1203 | AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
|
---|
1204 | CUSTOM_TOOLS: $custom_list
|
---|
1205 |
|
---|
1206 | do-housekeeping:
|
---|
1207 | @-rm /tools /cross-tools
|
---|
1208 | @-if [ ! -f luser-exist ]; then \\
|
---|
1209 | userdel \$(LUSER); \\
|
---|
1210 | rm -rf \$(LUSER_HOME); \\
|
---|
1211 | fi;
|
---|
1212 |
|
---|
1213 | EOF
|
---|
1214 | ) >> $MKFILE
|
---|
1215 | fi
|
---|
1216 |
|
---|
1217 | (
|
---|
1218 | cat << EOF
|
---|
1219 |
|
---|
1220 | restore-luser-env:
|
---|
1221 | @\$(call echo_message, Building)
|
---|
1222 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
1223 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
1224 | fi;
|
---|
1225 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
1226 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
1227 | fi;
|
---|
1228 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
|
---|
1229 | touch \$@ && \\
|
---|
1230 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
1231 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
1232 |
|
---|
1233 | ########################################################
|
---|
1234 |
|
---|
1235 |
|
---|
1236 | EOF
|
---|
1237 | ) >> $MKFILE
|
---|
1238 |
|
---|
1239 | # Bring over the items from the Makefile.tmp
|
---|
1240 | cat $MKFILE.tmp >> $MKFILE
|
---|
1241 | rm $MKFILE.tmp
|
---|
1242 |
|
---|
1243 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
1244 | }
|
---|