[3b63c8c] | 1 | #!/bin/sh
|
---|
| 2 | # $Id$
|
---|
| 3 |
|
---|
| 4 | ###################################
|
---|
| 5 | ### FUNCTIONS ###
|
---|
| 6 | ###################################
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | #----------------------------#
|
---|
| 10 | host_prep_Makefiles() { # Initialization of the system
|
---|
| 11 | #----------------------------#
|
---|
| 12 | local CLFS_HOST
|
---|
| 13 |
|
---|
[50fb011] | 14 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
|
---|
[3b63c8c] | 15 |
|
---|
| 16 | # defined here, only for ease of reading
|
---|
| 17 | CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
|
---|
| 18 | (
|
---|
| 19 | cat << EOF
|
---|
| 20 | 023-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 |
|
---|
| 30 | 025-addinguser: 023-creatingtoolsdir
|
---|
| 31 | @\$(call echo_message, Building)
|
---|
[9485eba] | 32 | @if [ ! -d /home/\$(LUSER) ]; then \\
|
---|
| 33 | groupadd \$(LGROUP); \\
|
---|
| 34 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
[3b63c8c] | 35 | else \\
|
---|
[30737ea8] | 36 | touch luser-exist; \\
|
---|
[3b63c8c] | 37 | fi;
|
---|
[50fb011] | 38 | @chown -R \$(LUSER) \$(MOUNT_PT) && \\
|
---|
[9485eba] | 39 | chown \$(LUSER) \$(MOUNT_PT)/sources
|
---|
[3b63c8c] | 40 | @touch \$@ && \\
|
---|
| 41 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 42 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 43 |
|
---|
| 44 | 026-settingenvironment: 025-addinguser
|
---|
| 45 | @\$(call echo_message, Building)
|
---|
[9485eba] | 46 | @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
| 47 | mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
---|
[3b63c8c] | 48 | fi;
|
---|
[9485eba] | 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; \\
|
---|
[3b63c8c] | 51 | fi;
|
---|
[9485eba] | 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 && \\
|
---|
[50fb011] | 67 | touch envars && \\
|
---|
[7d4cc81] | 68 | chown \$(LUSER):\$(LGROUP) envars && \\
|
---|
| 69 | chmod -R a+wt \$(MOUNT_PT)
|
---|
[3b63c8c] | 70 | @touch \$@ && \\
|
---|
| 71 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 72 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 73 |
|
---|
| 74 | 027-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 |
|
---|
| 95 | 028-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
|
---|
[9485eba] | 119 | @chown -R \$(LUSER) \$(MOUNT_PT)
|
---|
[3b63c8c] | 120 |
|
---|
| 121 | @touch \$@ && \\
|
---|
| 122 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 123 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 124 |
|
---|
| 125 | EOF
|
---|
| 126 | ) >> $MKFILE.tmp
|
---|
[50fb011] | 127 |
|
---|
| 128 | host_prep=" 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
|
---|
[3b63c8c] | 129 | }
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 | #-----------------------------#
|
---|
| 133 | cross_tools_Makefiles() { #
|
---|
| 134 | #-----------------------------#
|
---|
[50fb011] | 135 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
[3b63c8c] | 136 |
|
---|
| 137 | for file in cross-tools/* ; do
|
---|
| 138 | # Keep the script file name
|
---|
| 139 | this_script=`basename $file`
|
---|
| 140 | #
|
---|
| 141 | # Skip this script...
|
---|
[0e97a6a] | 142 | # NOTE.. the book indicated you only needed to install groff or file if the host
|
---|
| 143 | # had older versions. The packages would be installed in the target directory
|
---|
| 144 | # and not the host.
|
---|
[3b63c8c] | 145 | case $this_script in
|
---|
| 146 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
[bd52fd3] | 147 | continue ;;
|
---|
[0e97a6a] | 148 | *file ) FileVer=`file --version | head -n1 | cut -d " " -f1`
|
---|
| 149 | [[ "$FileVer" = "file-4.17" ]] && continue
|
---|
| 150 | ;;
|
---|
| 151 | *groff) GroffVer=`groff --version | head -n1 | cut -d " " -f4`
|
---|
| 152 | [[ "$GroffVer" = "1.19.2" ]] && continue
|
---|
| 153 | ;;
|
---|
[3b63c8c] | 154 | *) ;;
|
---|
| 155 | esac
|
---|
[03b3eba] | 156 |
|
---|
[3b63c8c] | 157 | #
|
---|
| 158 | # Set the dependency for the first target.
|
---|
[d39035c] | 159 | if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
|
---|
[3b63c8c] | 160 |
|
---|
| 161 | # First append each name of the script files to a list (this will become
|
---|
| 162 | # the names of the targets in the Makefile
|
---|
| 163 | cross_tools="$cross_tools $this_script"
|
---|
| 164 |
|
---|
| 165 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 166 | # and binutils in chapter 5)
|
---|
| 167 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 168 | -e 's@-static@@' \
|
---|
| 169 | -e 's@-final@@' \
|
---|
| 170 | -e 's@-64@@' \
|
---|
| 171 | -e 's@-n32@@'`
|
---|
| 172 | case $name in
|
---|
| 173 | glibc-headers) name="glibc" ;;
|
---|
| 174 | esac
|
---|
| 175 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 176 | #--------------------------------------------------------------------#
|
---|
| 177 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 178 | #--------------------------------------------------------------------#
|
---|
| 179 | #
|
---|
| 180 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 181 | # as a dependency. Also call the echo_message function.
|
---|
[50fb011] | 182 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[3b63c8c] | 183 | #
|
---|
| 184 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 185 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[50fb011] | 186 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[3b63c8c] | 187 | # If using optimizations, write the instructions
|
---|
| 188 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 189 | fi
|
---|
| 190 | #
|
---|
[50fb011] | 191 | LUSER_wrt_RunAsUser "${file}"
|
---|
[3b63c8c] | 192 | #
|
---|
[50fb011] | 193 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[3b63c8c] | 194 | #
|
---|
| 195 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 196 | wrt_touch
|
---|
| 197 | #
|
---|
| 198 | #--------------------------------------------------------------------#
|
---|
| 199 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 200 | #--------------------------------------------------------------------#
|
---|
| 201 | #
|
---|
| 202 | # Keep the script file name for Makefile dependencies.
|
---|
| 203 | PREV=$this_script
|
---|
| 204 |
|
---|
| 205 | done # for file in ....
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 | #-----------------------------#
|
---|
| 211 | final_system_Makefiles() { #
|
---|
| 212 | #-----------------------------#
|
---|
[50fb011] | 213 | echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
|
---|
[f28e4bd] | 214 |
|
---|
| 215 | for file in final-system/* ; do
|
---|
[3b63c8c] | 216 | # Keep the script file name
|
---|
| 217 | this_script=`basename $file`
|
---|
| 218 |
|
---|
| 219 | # Test if the stripping phase must be skipped.
|
---|
| 220 | # Skip alsp temp-perl for iterative runs
|
---|
| 221 | case $this_script in
|
---|
[47fddc8] | 222 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
[3b63c8c] | 223 | esac
|
---|
| 224 |
|
---|
| 225 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 226 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 227 | -e 's@temp-@@' \
|
---|
| 228 | -e 's@-64bit@@' \
|
---|
| 229 | -e 's@-64@@' \
|
---|
| 230 | -e 's@64@@' \
|
---|
| 231 | -e 's@n32@@'`
|
---|
| 232 |
|
---|
| 233 | # Find the version of the command files, if it corresponds with the building of
|
---|
[f28e4bd] | 234 | # a specific package.
|
---|
[3b63c8c] | 235 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 236 |
|
---|
| 237 | # Append each name of the script files to a list (this will become
|
---|
| 238 | # the names of the targets in the Makefile
|
---|
[f28e4bd] | 239 | basicsystem="$basicsystem ${this_script}"
|
---|
[3b63c8c] | 240 |
|
---|
| 241 | #--------------------------------------------------------------------#
|
---|
| 242 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 243 | #--------------------------------------------------------------------#
|
---|
| 244 | #
|
---|
| 245 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 246 | # as a dependency. Also call the echo_message function.
|
---|
[50fb011] | 247 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[3b63c8c] | 248 | #
|
---|
| 249 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 250 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[50fb011] | 251 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[3b63c8c] | 252 | # If using optimizations, write the instructions
|
---|
| 253 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 254 | fi
|
---|
| 255 | #
|
---|
[50fb011] | 256 | LUSER_wrt_RunAsUser "${file}"
|
---|
[3b63c8c] | 257 | #
|
---|
[50fb011] | 258 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[3b63c8c] | 259 | #
|
---|
| 260 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 261 | wrt_touch
|
---|
| 262 | #
|
---|
| 263 | #--------------------------------------------------------------------#
|
---|
| 264 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 265 | #--------------------------------------------------------------------#
|
---|
| 266 | #
|
---|
| 267 | # Keep the script file name for Makefile dependencies.
|
---|
[f28e4bd] | 268 | PREV=${this_script}
|
---|
[3b63c8c] | 269 | done # for file in final-system/* ...
|
---|
| 270 | }
|
---|
| 271 |
|
---|
| 272 |
|
---|
| 273 |
|
---|
| 274 | #-----------------------------#
|
---|
| 275 | bootscripts_Makefiles() { #
|
---|
| 276 | #-----------------------------#
|
---|
[50fb011] | 277 | echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
|
---|
[3b63c8c] | 278 |
|
---|
| 279 | for file in bootscripts/* ; do
|
---|
| 280 | # Keep the script file name
|
---|
| 281 | this_script=`basename $file`
|
---|
| 282 |
|
---|
| 283 | case $this_script in
|
---|
| 284 | *udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
---|
| 285 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
[398a037] | 286 | *network*) continue ;; # Manually create these files
|
---|
[3b63c8c] | 287 | *) ;;
|
---|
| 288 | esac
|
---|
| 289 |
|
---|
| 290 | # First append each name of the script files to a list (this will become
|
---|
| 291 | # the names of the targets in the Makefile
|
---|
| 292 | bootscripttools="$bootscripttools $this_script"
|
---|
| 293 |
|
---|
| 294 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 295 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 296 | -e 's@-64bit@@' \
|
---|
| 297 | -e 's@-64@@' \
|
---|
| 298 | -e 's@64@@' \
|
---|
| 299 | -e 's@n32@@'`
|
---|
| 300 | case $name in
|
---|
| 301 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
| 302 | *udev-rules) name=udev-cross-lfs ;;
|
---|
| 303 | esac
|
---|
| 304 |
|
---|
| 305 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 306 |
|
---|
| 307 | #--------------------------------------------------------------------#
|
---|
| 308 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 309 | #--------------------------------------------------------------------#
|
---|
| 310 | #
|
---|
| 311 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 312 | # as a dependency. Also call the echo_message function.
|
---|
[50fb011] | 313 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[3b63c8c] | 314 | #
|
---|
| 315 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[50fb011] | 316 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
[3b63c8c] | 317 | #
|
---|
[50fb011] | 318 | LUSER_wrt_RunAsUser "${file}"
|
---|
[3b63c8c] | 319 | #
|
---|
[50fb011] | 320 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[3b63c8c] | 321 | #
|
---|
| 322 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 323 | wrt_touch
|
---|
| 324 | #
|
---|
| 325 | #--------------------------------------------------------------------#
|
---|
| 326 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 327 | #--------------------------------------------------------------------#
|
---|
| 328 | #
|
---|
| 329 | # Keep the script file name for Makefile dependencies.
|
---|
| 330 | PREV=$this_script
|
---|
| 331 |
|
---|
| 332 | done # for file in bootscripts/* ...
|
---|
| 333 |
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 |
|
---|
| 337 | #-----------------------------#
|
---|
| 338 | bootable_Makefiles() { #
|
---|
| 339 | #-----------------------------#
|
---|
[50fb011] | 340 | echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
|
---|
[3b63c8c] | 341 |
|
---|
| 342 | for file in bootable/* ; do
|
---|
| 343 | # Keep the script file name
|
---|
| 344 | this_script=`basename $file`
|
---|
| 345 |
|
---|
| 346 | # A little housekeeping on the scripts
|
---|
| 347 | case $this_script in
|
---|
| 348 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
[50fb011] | 349 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[3b63c8c] | 350 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 351 | [[ -z $CONFIG ]] && continue
|
---|
| 352 | # Copy the config file to /sources with a standardized name
|
---|
| 353 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 354 | ;;
|
---|
| 355 | esac
|
---|
| 356 | #
|
---|
| 357 | # First append each name of the script files to a list (this will become
|
---|
| 358 | # the names of the targets in the Makefile
|
---|
[50fb011] | 359 | # NOTE: new makfile format forces the last script, *chowning, into a separate
|
---|
| 360 | # phase.
|
---|
| 361 | case ${this_script} in
|
---|
| 362 | *chowning) chowning=${this_script} ;;
|
---|
[03b3eba] | 363 | *) bootable="$bootable $this_script" ;;
|
---|
[50fb011] | 364 | esac
|
---|
[3b63c8c] | 365 | #
|
---|
| 366 | # Grab the name of the target, strip id number and misc words.
|
---|
| 367 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
| 368 | case $this_script in
|
---|
| 369 | *kernel*) name=linux
|
---|
| 370 | ;;
|
---|
| 371 | esac
|
---|
| 372 |
|
---|
| 373 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 374 |
|
---|
| 375 | #--------------------------------------------------------------------#
|
---|
| 376 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 377 | #--------------------------------------------------------------------#
|
---|
| 378 | #
|
---|
| 379 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 380 | # as a dependency. Also call the echo_message function.
|
---|
[50fb011] | 381 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[3b63c8c] | 382 | #
|
---|
| 383 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[50fb011] | 384 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
[3b63c8c] | 385 | #
|
---|
| 386 | # Select a script execution method
|
---|
| 387 | case $this_script in
|
---|
| 388 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
[50fb011] | 389 | LUSER_wrt_CopyFstab
|
---|
[3b63c8c] | 390 | else
|
---|
[50fb011] | 391 | LUSER_wrt_RunAsUser "${file}"
|
---|
[3b63c8c] | 392 | fi
|
---|
| 393 | ;;
|
---|
[f28e4bd] | 394 | *chowning) wrt_RunAsRoot "${this_script}" "${file}"
|
---|
[9485eba] | 395 | ;;
|
---|
[50fb011] | 396 | *) LUSER_wrt_RunAsUser "${file}"
|
---|
[3b63c8c] | 397 | ;;
|
---|
| 398 | esac
|
---|
| 399 | #
|
---|
| 400 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
[50fb011] | 401 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[3b63c8c] | 402 | #
|
---|
| 403 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 404 | wrt_touch
|
---|
| 405 | #
|
---|
| 406 | #--------------------------------------------------------------------#
|
---|
| 407 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 408 | #--------------------------------------------------------------------#
|
---|
| 409 | #
|
---|
| 410 | # Keep the script file name for Makefile dependencies.
|
---|
| 411 | PREV=$this_script
|
---|
| 412 |
|
---|
| 413 | done
|
---|
| 414 |
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 |
|
---|
| 418 | #-----------------------------#
|
---|
| 419 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 420 | #-----------------------------#
|
---|
| 421 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 422 |
|
---|
| 423 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 424 | # Start with a clean Makefile.tmp file
|
---|
| 425 | >$MKFILE.tmp
|
---|
| 426 |
|
---|
| 427 | host_prep_Makefiles
|
---|
| 428 | cross_tools_Makefiles # $cross_tools
|
---|
| 429 | final_system_Makefiles # $basicsystem
|
---|
| 430 | bootscripts_Makefiles # $bootscripttools
|
---|
| 431 | bootable_Makefiles # $bootable
|
---|
| 432 |
|
---|
| 433 | # Add a header, some variables and include the function file
|
---|
| 434 | # to the top of the real Makefile.
|
---|
| 435 | (
|
---|
| 436 | cat << EOF
|
---|
| 437 | $HEADER
|
---|
| 438 |
|
---|
[398a037] | 439 | SRC = /sources
|
---|
| 440 | MOUNT_PT = $BUILDDIR
|
---|
| 441 | PKG_LST = $PKG_LST
|
---|
| 442 | LUSER = $LUSER
|
---|
| 443 | LGROUP = $LGROUP
|
---|
| 444 | SCRIPT_ROOT = $SCRIPT_ROOT
|
---|
| 445 |
|
---|
| 446 | BASEDIR = \$(MOUNT_PT)
|
---|
| 447 | SRCSDIR = \$(BASEDIR)/sources
|
---|
| 448 | CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
|
---|
| 449 | LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs
|
---|
| 450 | TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs
|
---|
| 451 |
|
---|
| 452 | SU_LUSER = su - \$(LUSER) -c
|
---|
| 453 | PRT_DU = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n"
|
---|
| 454 | LUSER_HOME = /home/\$(LUSER)
|
---|
[3b63c8c] | 455 |
|
---|
[80f0ea1] | 456 | export PATH := \${PATH}:/usr/sbin
|
---|
| 457 |
|
---|
[3b63c8c] | 458 | include makefile-functions
|
---|
| 459 |
|
---|
| 460 | EOF
|
---|
| 461 | ) > $MKFILE
|
---|
| 462 |
|
---|
| 463 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 464 | # as a dependency.
|
---|
| 465 | (
|
---|
[50fb011] | 466 | cat << EOF
|
---|
| 467 |
|
---|
[621f01f] | 468 | all: ck_UID mk_SETUP mk_LUSER mk_ROOT create-sbu_du-report
|
---|
[df0277b] | 469 | @sudo make do-housekeeping
|
---|
[3b63c8c] | 470 | @\$(call echo_finished,$VERSION)
|
---|
| 471 |
|
---|
[7d4cc81] | 472 | ck_UID:
|
---|
| 473 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 474 | echo "--------------------------------------------------"; \\
|
---|
| 475 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 476 | echo "--------------------------------------------------"; \\
|
---|
| 477 | exit 1; \\
|
---|
| 478 | fi
|
---|
| 479 |
|
---|
[50fb011] | 480 | mk_SETUP:
|
---|
| 481 | @\$(call echo_SU_request)
|
---|
| 482 | @sudo make SETUP
|
---|
| 483 | @touch \$@
|
---|
[03b3eba] | 484 |
|
---|
[50fb011] | 485 | mk_LUSER: mk_SETUP
|
---|
| 486 | @\$(call echo_SULUSER_request)
|
---|
[7d4cc81] | 487 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
|
---|
[df0277b] | 488 | @sudo make restore-luser-env
|
---|
[50fb011] | 489 | @touch \$@
|
---|
[3b63c8c] | 490 |
|
---|
[50fb011] | 491 | mk_ROOT:
|
---|
| 492 | @sudo make ROOT
|
---|
| 493 | @touch \$@
|
---|
[3b63c8c] | 494 |
|
---|
[50fb011] | 495 | SETUP: $host_prep
|
---|
[3b63c8c] | 496 |
|
---|
[50fb011] | 497 | LUSER: $cross_tools $basicsystem $bootscripttools $bootable
|
---|
[3b63c8c] | 498 |
|
---|
[50fb011] | 499 | ROOT: $chowning
|
---|
[3b63c8c] | 500 |
|
---|
| 501 |
|
---|
| 502 | restart:
|
---|
[03b3eba] | 503 | @echo "This feature does not exist for the CLFS-2 makefile. (yet)"
|
---|
[3b63c8c] | 504 |
|
---|
[30737ea8] | 505 | restore-luser-env:
|
---|
[3b63c8c] | 506 | @\$(call echo_message, Building)
|
---|
[9485eba] | 507 | @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
| 508 | mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
---|
[3b63c8c] | 509 | fi;
|
---|
[9485eba] | 510 | @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
| 511 | mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
---|
[3b63c8c] | 512 | fi;
|
---|
[9485eba] | 513 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
---|
[3b63c8c] | 514 | touch \$@ && \\
|
---|
| 515 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 516 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 517 |
|
---|
| 518 | do-housekeeping:
|
---|
[30737ea8] | 519 | @-if [ ! -f luser-exist ]; then \\
|
---|
[9485eba] | 520 | userdel \$(LUSER); \\
|
---|
| 521 | rm -rf /home/\$(LUSER); \\
|
---|
[3b63c8c] | 522 | fi;
|
---|
| 523 |
|
---|
| 524 | EOF
|
---|
| 525 | ) >> $MKFILE
|
---|
| 526 |
|
---|
[621f01f] | 527 | # Add SBU-disk_usage report target
|
---|
| 528 | echo "create-sbu_du-report:" >> $MKFILE
|
---|
| 529 | if [[ "$REPORT" = "y" ]] ; then
|
---|
| 530 | (
|
---|
| 531 | cat << EOF
|
---|
| 532 | @\$(call echo_message, Building)
|
---|
| 533 | @./create-sbu_du-report.sh logs $VERSION
|
---|
| 534 | @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
|
---|
| 535 | @touch \$@
|
---|
| 536 |
|
---|
| 537 |
|
---|
| 538 | EOF
|
---|
| 539 | ) >> $MKFILE
|
---|
| 540 | else echo -e "\t@true\n\n" >> $MKFILE; fi
|
---|
| 541 |
|
---|
[3b63c8c] | 542 | # Bring over the items from the Makefile.tmp
|
---|
| 543 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 544 | rm $MKFILE.tmp
|
---|
| 545 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 546 |
|
---|
| 547 | }
|
---|
| 548 |
|
---|