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