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