source: CLFS2/master.sh@ 6222f2f

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 6222f2f was 3673dc1, checked in by George Boudreau <georgeb@…>, 18 years ago

Minor corrections to CLFS-sysroot. Removed existance test for file and groff

  • Property mode set to 100644
File size: 17.6 KB
RevLine 
[91ff6a9]1#!/bin/bash
[7432834]2# $Id$
3
4###################################
5### FUNCTIONS ###
6###################################
7
8
9#----------------------------#
10host_prep_Makefiles() { # Initialization of the system
11#----------------------------#
12 local CLFS_HOST
13
[045b2dc]14 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
[7432834]15
16 # defined here, only for ease of reading
17 CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
18(
19cat << EOF
20023-creatingtoolsdir:
21 @\$(call echo_message, Building)
22 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
23 mkdir \$(MOUNT_PT)/sources; \\
24 fi;
25 @chmod a+wt \$(MOUNT_PT)/sources
26 @touch \$@ && \\
27 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
28 echo --------------------------------------------------------------------------------\$(WHITE)
29
30025-addinguser: 023-creatingtoolsdir
31 @\$(call echo_message, Building)
[6ad5a2f]32 @if [ ! -d /home/\$(LUSER) ]; then \\
33 groupadd \$(LGROUP); \\
34 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
[7432834]35 else \\
[6ad5a2f]36 touch luser-exist; \\
[7432834]37 fi;
[045b2dc]38 @chown -R \$(LUSER) \$(MOUNT_PT) && \\
[6ad5a2f]39 chown \$(LUSER) \$(MOUNT_PT)/sources
[7432834]40 @touch \$@ && \\
41 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
42 echo --------------------------------------------------------------------------------\$(WHITE)
43
44026-settingenvironment: 025-addinguser
45 @\$(call echo_message, Building)
[6ad5a2f]46 @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
47 mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
[7432834]48 fi;
[6ad5a2f]49 @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
50 mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
[7432834]51 fi;
[6ad5a2f]52 @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
53 echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
54 echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
55 echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
56 echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
57 echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
58 echo "" >> /home/\$(LUSER)/.bashrc && \\
59 echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
60 echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
61 echo "" >> /home/\$(LUSER)/.bashrc && \\
62 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
63 echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
64 echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
65 echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
66 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
[045b2dc]67 touch envars && \\
68 chown \$(LUSER):\$(LGROUP) envars && \\
69 chmod -R a+wt \$(MOUNT_PT)
[7432834]70 @touch \$@ && \\
71 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
72 echo --------------------------------------------------------------------------------\$(WHITE)
73
74027-create-directories: 026-settingenvironment
75 @\$(call echo_message, Building)
76
77 @mkdir -p \$(MOUNT_PT)/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
78 @mkdir -p \$(MOUNT_PT)/{proc,media/{floppy,cdrom},sbin,srv,sys}
79 @mkdir -p \$(MOUNT_PT)/var/{lock,log,mail,run,spool}
80 @mkdir -p \$(MOUNT_PT)/var/{opt,cache,lib/{misc,locate},local}
81 @install -d -m 0750 \$(MOUNT_PT)/root
82 @install -d -m 1777 \$(MOUNT_PT){/var,}/tmp
83 @mkdir -p \$(MOUNT_PT)/usr/{,local/}{bin,include,lib,sbin,src}
84 @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{doc,info,locale,man}
85 @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{misc,terminfo,zoneinfo}
86 @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
87 @for dir in \$(MOUNT_PT)/usr{,/local}; do \\
88 ln -s share/{man,doc,info} \$\$dir ; \\
89 done
90
91 @touch \$@ && \\
92 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
93 echo --------------------------------------------------------------------------------\$(WHITE)
94
95028-creating-sysfile: 027-create-directories
96 @\$(call echo_message, Building)
97
98 @touch \$(MOUNT_PT)/etc/mtab
99 @echo "root::0:0:root:/root:/bin/bash" >> \$(MOUNT_PT)/etc/passwd
100 @echo "root:x:0:" >> \$(MOUNT_PT)/etc/group
101 @echo "bin:x:1:" >> \$(MOUNT_PT)/etc/group
102 @echo "sys:x:2:" >> \$(MOUNT_PT)/etc/group
103 @echo "kmem:x:3" >> \$(MOUNT_PT)/etc/group
104 @echo "tty:x:4:" >> \$(MOUNT_PT)/etc/group
105 @echo "tape:x:5:" >> \$(MOUNT_PT)/etc/group
106 @echo "daemon:x:6:" >> \$(MOUNT_PT)/etc/group
107 @echo "floppy:x:7:" >> \$(MOUNT_PT)/etc/group
108 @echo "disk:x:8:" >> \$(MOUNT_PT)/etc/group
109 @echo "lp:x:9:" >> \$(MOUNT_PT)/etc/group
110 @echo "dialout:x:10:" >> \$(MOUNT_PT)/etc/group
111 @echo "audio:x:11:" >> \$(MOUNT_PT)/etc/group
112 @echo "video:x:12:" >> \$(MOUNT_PT)/etc/group
113 @echo "utmp:x:13:" >> \$(MOUNT_PT)/etc/group
114 @echo "usb:x:14:" >> \$(MOUNT_PT)/etc/group
115 @echo "cdrom:x:15:" >> \$(MOUNT_PT)/etc/group
116
117 @touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
118 @chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
[6ad5a2f]119 @chown -R \$(LUSER) \$(MOUNT_PT)
[7432834]120
121 @touch \$@ && \\
122 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
123 echo --------------------------------------------------------------------------------\$(WHITE)
124
125EOF
126) >> $MKFILE.tmp
[045b2dc]127
128 host_prep=" 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
[7432834]129}
130
131
132#-----------------------------#
133cross_tools_Makefiles() { #
134#-----------------------------#
[045b2dc]135 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
[7432834]136
137 for file in cross-tools/* ; do
138 # Keep the script file name
139 this_script=`basename $file`
140 #
141 # Skip this script...
142 case $this_script in
143 *cflags* | *variables* ) # work done in host_prep_Makefiles
[6ad5a2f]144 continue ;;
[7432834]145 *) ;;
146 esac
[6ad5a2f]147
[7432834]148 #
149 # Set the dependency for the first target.
[f3fcecc]150 if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
[7432834]151
152 # First append each name of the script files to a list (this will become
153 # the names of the targets in the Makefile
154 cross_tools="$cross_tools $this_script"
155
156 # Grab the name of the target (minus the -headers or -cross in the case of gcc
157 # and binutils in chapter 5)
158 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
159 -e 's@-static@@' \
160 -e 's@-final@@' \
161 -e 's@-64@@' \
162 -e 's@-n32@@'`
163 case $name in
164 glibc-headers) name="glibc" ;;
165 esac
166 pkg_tarball=$(get_package_tarball_name $name)
167 #--------------------------------------------------------------------#
168 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
169 #--------------------------------------------------------------------#
170 #
171 # Drop in the name of the target on a new line, and the previous target
172 # as a dependency. Also call the echo_message function.
[045b2dc]173 LUSER_wrt_target "${this_script}" "$PREV"
[7432834]174 #
175 # If $pkg_tarball isn't empty, we've got a package...
176 if [ "$pkg_tarball" != "" ] ; then
[045b2dc]177 LUSER_wrt_unpack "$pkg_tarball"
[7432834]178 # If using optimizations, write the instructions
179 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
180 fi
181 #
[045b2dc]182 LUSER_wrt_RunAsUser "${file}"
[7432834]183 #
[045b2dc]184 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[7432834]185 #
186 # Include a touch of the target name so make can check if it's already been made.
187 wrt_touch
188 #
189 #--------------------------------------------------------------------#
190 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
191 #--------------------------------------------------------------------#
192 #
193 # Keep the script file name for Makefile dependencies.
194 PREV=$this_script
195
196 done # for file in ....
197}
198
199
200
201#-----------------------------#
202final_system_Makefiles() { #
203#-----------------------------#
[045b2dc]204 echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
[7432834]205
[2dd88c4]206 for file in final-system/* ; do
[7432834]207 # Keep the script file name
208 this_script=`basename $file`
209
210 # Test if the stripping phase must be skipped.
211 # Skip alsp temp-perl for iterative runs
212 case $this_script in
[401f81e]213 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
[7432834]214 esac
215
216 # Grab the name of the target, strip id number, XXX-script
217 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
218 -e 's@temp-@@' \
219 -e 's@-64bit@@' \
220 -e 's@-64@@' \
221 -e 's@64@@' \
222 -e 's@n32@@'`
223
224 # Find the version of the command files, if it corresponds with the building of
[2dd88c4]225 # a specific package.
[7432834]226 pkg_tarball=$(get_package_tarball_name $name)
227
228 # Append each name of the script files to a list (this will become
229 # the names of the targets in the Makefile
[2dd88c4]230 basicsystem="$basicsystem ${this_script}"
[7432834]231
232 #--------------------------------------------------------------------#
233 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
234 #--------------------------------------------------------------------#
235 #
236 # Drop in the name of the target on a new line, and the previous target
237 # as a dependency. Also call the echo_message function.
[045b2dc]238 LUSER_wrt_target "${this_script}" "$PREV"
[7432834]239 #
240 # If $pkg_tarball isn't empty, we've got a package...
241 if [ "$pkg_tarball" != "" ] ; then
[045b2dc]242 LUSER_wrt_unpack "$pkg_tarball"
[7432834]243 # If using optimizations, write the instructions
244 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
245 fi
246 #
[045b2dc]247 LUSER_wrt_RunAsUser "${file}"
[7432834]248 #
[045b2dc]249 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[7432834]250 #
251 # Include a touch of the target name so make can check if it's already been made.
252 wrt_touch
253 #
254 #--------------------------------------------------------------------#
255 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
256 #--------------------------------------------------------------------#
257 #
258 # Keep the script file name for Makefile dependencies.
[2dd88c4]259 PREV=${this_script}
[7432834]260 done # for file in final-system/* ...
261}
262
263
264
265#-----------------------------#
266bootscripts_Makefiles() { #
267#-----------------------------#
[045b2dc]268 echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
[7432834]269
270 for file in bootscripts/* ; do
271 # Keep the script file name
272 this_script=`basename $file`
273
274 case $this_script in
275 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
276 *console*) continue ;; # Use the files that came with the bootscripts
[31e78bd]277 *network*) continue ;; # Manually create these files
[7432834]278 *) ;;
279 esac
280
281 # First append each name of the script files to a list (this will become
282 # the names of the targets in the Makefile
283 bootscripttools="$bootscripttools $this_script"
284
285 # Grab the name of the target, strip id number, XXX-script
286 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
287 -e 's@-64bit@@' \
288 -e 's@-64@@' \
289 -e 's@64@@' \
290 -e 's@n32@@'`
291 case $name in
292 *bootscripts*) name=bootscripts-cross-lfs ;;
293 *udev-rules) name=udev-cross-lfs ;;
294 esac
295
296 pkg_tarball=$(get_package_tarball_name $name)
297
298 #--------------------------------------------------------------------#
299 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
300 #--------------------------------------------------------------------#
301 #
302 # Drop in the name of the target on a new line, and the previous target
303 # as a dependency. Also call the echo_message function.
[045b2dc]304 LUSER_wrt_target "${this_script}" "$PREV"
[7432834]305 #
306 # If $pkg_tarball isn't empty, we've got a package...
[045b2dc]307 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
[7432834]308 #
[045b2dc]309 LUSER_wrt_RunAsUser "${file}"
[7432834]310 #
[045b2dc]311 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[7432834]312 #
313 # Include a touch of the target name so make can check if it's already been made.
314 wrt_touch
315 #
316 #--------------------------------------------------------------------#
317 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
318 #--------------------------------------------------------------------#
319 #
320 # Keep the script file name for Makefile dependencies.
321 PREV=$this_script
322
323 done # for file in bootscripts/* ...
324
325}
326
327
328#-----------------------------#
329bootable_Makefiles() { #
330#-----------------------------#
[045b2dc]331 echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
[7432834]332
333 for file in bootable/* ; do
334 # Keep the script file name
335 this_script=`basename $file`
336
337 # A little housekeeping on the scripts
338 case $this_script in
339 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
[045b2dc]340 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
[7432834]341 *kernel) # if there is no kernel config file do not build the kernel
342 [[ -z $CONFIG ]] && continue
343 # Copy the config file to /sources with a standardized name
344 cp $CONFIG $BUILDDIR/sources/kernel-config
345 ;;
346 esac
347 #
348 # First append each name of the script files to a list (this will become
349 # the names of the targets in the Makefile
[045b2dc]350 # NOTE: new makfile format forces the last script, *chowning, into a separate
351 # phase.
352 case ${this_script} in
353 *chowning) chowning=${this_script} ;;
354 *) bootable="$bootable $this_script" ;;
355 esac
[7432834]356 #
357 # Grab the name of the target, strip id number and misc words.
358 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
359 case $this_script in
360 *kernel*) name=linux
361 ;;
362 esac
363
364 pkg_tarball=$(get_package_tarball_name $name)
365
366 #--------------------------------------------------------------------#
367 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
368 #--------------------------------------------------------------------#
369 #
370 # Drop in the name of the target on a new line, and the previous target
371 # as a dependency. Also call the echo_message function.
[045b2dc]372 LUSER_wrt_target "${this_script}" "$PREV"
[7432834]373 #
374 # If $pkg_tarball isn't empty, we've got a package...
[045b2dc]375 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
[7432834]376 #
377 # Select a script execution method
378 case $this_script in
379 *fstab*) if [[ -n "$FSTAB" ]]; then
[045b2dc]380 LUSER_wrt_CopyFstab
[7432834]381 else
[045b2dc]382 LUSER_wrt_RunAsUser "${file}"
[7432834]383 fi
384 ;;
[8f2c086]385 *chowning) wrt_RunAsRoot "${file}"
[6ad5a2f]386 ;;
[045b2dc]387 *) LUSER_wrt_RunAsUser "${file}"
[6ad5a2f]388 ;;
[7432834]389 esac
390 #
391 # Housekeeping...remove any build directory(ies) except if the package build fails.
[045b2dc]392 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[7432834]393 #
394 # Include a touch of the target name so make can check if it's already been made.
395 wrt_touch
396 #
397 #--------------------------------------------------------------------#
398 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
399 #--------------------------------------------------------------------#
400 #
401 # Keep the script file name for Makefile dependencies.
402 PREV=$this_script
403
404 done
405
406}
407
408
409#-----------------------------#
410build_Makefile() { # Construct a Makefile from the book scripts
411#-----------------------------#
412 echo "Creating Makefile... ${BOLD}START${OFF}"
413
414 cd $JHALFSDIR/${PROGNAME}-commands
415 # Start with a clean Makefile.tmp file
416 >$MKFILE.tmp
417
418 host_prep_Makefiles
419 cross_tools_Makefiles # $cross_tools
420 final_system_Makefiles # $basicsystem
421 bootscripts_Makefiles # $bootscripttools
422 bootable_Makefiles # $bootable
423
424 # Add a header, some variables and include the function file
425 # to the top of the real Makefile.
[195ed9f]426 wrt_Makefile_header
[7432834]427
428 # Drop in the main target 'all:' and the chapter targets with each sub-target
429 # as a dependency.
430(
[045b2dc]431cat << EOF
432
433all: ck_UID mk_SETUP mk_LUSER mk_ROOT create-sbu_du-report
434 @sudo make do-housekeeping
[7432834]435 @\$(call echo_finished,$VERSION)
436
[045b2dc]437ck_UID:
438 @if [ \`id -u\` = "0" ]; then \\
439 echo "--------------------------------------------------"; \\
440 echo "You cannot run this makefile from the root account"; \\
441 echo "--------------------------------------------------"; \\
442 exit 1; \\
443 fi
[7432834]444
[045b2dc]445mk_SETUP:
446 @\$(call echo_SU_request)
[a2133cb]447 @sudo make SHELL=/bin/bash SETUP
[045b2dc]448 @touch \$@
[7432834]449
[045b2dc]450mk_LUSER: mk_SETUP
451 @\$(call echo_SULUSER_request)
[a2133cb]452 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash LUSER" )
[045b2dc]453 @sudo make restore-luser-env
454 @touch \$@
[7432834]455
[045b2dc]456mk_ROOT:
[a2133cb]457 @sudo make SHELL=/bin/bash ROOT
[045b2dc]458 @touch \$@
[7432834]459
[045b2dc]460SETUP: $host_prep
[1838bc7]461LUSER: $cross_tools $basicsystem $bootscripttools $bootable
462ROOT: $chowning
[7432834]463
464
[1838bc7]465create-sbu_du-report: ROOT
466 @\$(call echo_message, Building)
467 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
468 ./create-sbu_du-report.sh logs $VERSION; \\
469 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
470 fi;
471 @touch \$@
[7432834]472
[6ad5a2f]473restore-luser-env:
[7432834]474 @\$(call echo_message, Building)
[6ad5a2f]475 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
476 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
[7432834]477 fi;
[6ad5a2f]478 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
479 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
[7432834]480 fi;
[6ad5a2f]481 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
[7432834]482 touch \$@ && \\
483 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
484 echo --------------------------------------------------------------------------------\$(WHITE)
485
486do-housekeeping:
[6ad5a2f]487 @-if [ ! -f luser-exist ]; then \\
488 userdel \$(LUSER); \\
489 rm -rf /home/\$(LUSER); \\
[7432834]490 fi;
491
492EOF
493) >> $MKFILE
494
495 # Bring over the items from the Makefile.tmp
496 cat $MKFILE.tmp >> $MKFILE
497 rm $MKFILE.tmp
498 echo "Creating Makefile... ${BOLD}DONE${OFF}"
499
500}
Note: See TracBrowser for help on using the repository browser.