[91ff6a9] | 1 | #!/bin/bash
|
---|
[7432834] | 2 | # $Id$
|
---|
| 3 |
|
---|
| 4 | ###################################
|
---|
| 5 | ### FUNCTIONS ###
|
---|
| 6 | ###################################
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | #----------------------------#
|
---|
| 10 | host_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 | (
|
---|
| 19 | cat << EOF
|
---|
| 20 |
|
---|
[9ae0875] | 21 | 025-addinguser:
|
---|
[7432834] | 22 | @\$(call echo_message, Building)
|
---|
[962793a] | 23 | @if [ ! -d \$(LUSER_HOME) ]; then \\
|
---|
[6ad5a2f] | 24 | groupadd \$(LGROUP); \\
|
---|
| 25 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
[7432834] | 26 | else \\
|
---|
[6ad5a2f] | 27 | touch luser-exist; \\
|
---|
[7432834] | 28 | fi;
|
---|
[dbcdfd7] | 29 | @\$(call housekeeping)
|
---|
[7432834] | 30 |
|
---|
| 31 | 026-settingenvironment: 025-addinguser
|
---|
| 32 | @\$(call echo_message, Building)
|
---|
[962793a] | 33 | @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 34 | mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
---|
[7432834] | 35 | fi;
|
---|
[962793a] | 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; \\
|
---|
[7432834] | 38 | fi;
|
---|
[962793a] | 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 && \\
|
---|
[045b2dc] | 53 | touch envars && \\
|
---|
[9ae0875] | 54 | chown \$(LUSER):\$(LGROUP) envars
|
---|
[dbcdfd7] | 55 | @\$(call housekeeping)
|
---|
[7432834] | 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
|
---|
[dbcdfd7] | 73 | @\$(call housekeeping)
|
---|
[7432834] | 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
|
---|
[de22e80] | 99 | @chown -R \$(LUSER) \$(MOUNT_PT) && \\
|
---|
[535fd45] | 100 | chmod -R a+w \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
| 101 | chmod -R a+w \$(SRCSDIR)
|
---|
[dbcdfd7] | 102 | @\$(call housekeeping)
|
---|
[7432834] | 103 |
|
---|
| 104 | EOF
|
---|
| 105 | ) >> $MKFILE.tmp
|
---|
[045b2dc] | 106 |
|
---|
[9ae0875] | 107 | host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
|
---|
[7432834] | 108 | }
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 | #-----------------------------#
|
---|
| 112 | cross_tools_Makefiles() { #
|
---|
| 113 | #-----------------------------#
|
---|
[045b2dc] | 114 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 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
|
---|
[6ad5a2f] | 123 | continue ;;
|
---|
[7432834] | 124 | *) ;;
|
---|
| 125 | esac
|
---|
[6ad5a2f] | 126 |
|
---|
[7432834] | 127 | #
|
---|
| 128 | # Set the dependency for the first target.
|
---|
[f3fcecc] | 129 | if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
|
---|
[7432834] | 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.
|
---|
[045b2dc] | 152 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 153 | #
|
---|
| 154 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 155 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[045b2dc] | 156 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[7432834] | 157 | # If using optimizations, write the instructions
|
---|
| 158 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 159 | fi
|
---|
| 160 | #
|
---|
[045b2dc] | 161 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 162 | #
|
---|
[045b2dc] | 163 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
[7432834] | 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 | #-----------------------------#
|
---|
[045b2dc] | 183 | echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 184 |
|
---|
[2dd88c4] | 185 | for file in final-system/* ; do
|
---|
[7432834] | 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
|
---|
[401f81e] | 192 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
[7432834] | 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
|
---|
[2dd88c4] | 204 | # a specific package.
|
---|
[7432834] | 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
|
---|
[2dd88c4] | 209 | basicsystem="$basicsystem ${this_script}"
|
---|
[7432834] | 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.
|
---|
[045b2dc] | 217 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 218 | #
|
---|
| 219 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 220 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[f546320] | 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
|
---|
[045b2dc] | 226 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
[7432834] | 227 | # If using optimizations, write the instructions
|
---|
| 228 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 229 | fi
|
---|
| 230 | #
|
---|
[045b2dc] | 231 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 232 | #
|
---|
[f546320] | 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
|
---|
[7432834] | 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.
|
---|
[2dd88c4] | 250 | PREV=${this_script}
|
---|
[7432834] | 251 | done # for file in final-system/* ...
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 |
|
---|
| 255 |
|
---|
| 256 | #-----------------------------#
|
---|
| 257 | bootscripts_Makefiles() { #
|
---|
| 258 | #-----------------------------#
|
---|
[045b2dc] | 259 | echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 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
|
---|
[31e78bd] | 268 | *network*) continue ;; # Manually create these files
|
---|
[7432834] | 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.
|
---|
[045b2dc] | 295 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 296 | #
|
---|
| 297 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[f546320] | 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
|
---|
[7432834] | 304 | #
|
---|
[045b2dc] | 305 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 306 | #
|
---|
[f546320] | 307 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 308 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 309 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 310 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 311 | fi
|
---|
| 312 | fi
|
---|
[7432834] | 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 | #-----------------------------#
|
---|
[045b2dc] | 332 | echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
|
---|
[7432834] | 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 ;;
|
---|
[045b2dc] | 341 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
[7432834] | 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
|
---|
[045b2dc] | 351 | # NOTE: new makfile format forces the last script, *chowning, into a separate
|
---|
| 352 | # phase.
|
---|
| 353 | case ${this_script} in
|
---|
[936efa8] | 354 | *chowning) chowning=" ${this_script}" ;;
|
---|
[045b2dc] | 355 | *) bootable="$bootable $this_script" ;;
|
---|
| 356 | esac
|
---|
[7432834] | 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.
|
---|
[045b2dc] | 373 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
[7432834] | 374 | #
|
---|
| 375 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
[f546320] | 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
|
---|
[7432834] | 382 | #
|
---|
| 383 | # Select a script execution method
|
---|
| 384 | case $this_script in
|
---|
| 385 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
[045b2dc] | 386 | LUSER_wrt_CopyFstab
|
---|
[7432834] | 387 | else
|
---|
[045b2dc] | 388 | LUSER_wrt_RunAsUser "${file}"
|
---|
[7432834] | 389 | fi
|
---|
| 390 | ;;
|
---|
[8f2c086] | 391 | *chowning) wrt_RunAsRoot "${file}"
|
---|
[6ad5a2f] | 392 | ;;
|
---|
[045b2dc] | 393 | *) LUSER_wrt_RunAsUser "${file}"
|
---|
[6ad5a2f] | 394 | ;;
|
---|
[7432834] | 395 | esac
|
---|
| 396 | #
|
---|
| 397 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
[f546320] | 398 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 399 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 400 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 401 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 402 | fi
|
---|
| 403 | fi
|
---|
[7432834] | 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
|
---|
[3e7ceed] | 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
|
---|
[7432834] | 438 |
|
---|
| 439 | # Add a header, some variables and include the function file
|
---|
| 440 | # to the top of the real Makefile.
|
---|
[195ed9f] | 441 | wrt_Makefile_header
|
---|
[7432834] | 442 |
|
---|
| 443 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 444 | # as a dependency.
|
---|
| 445 | (
|
---|
[045b2dc] | 446 | cat << EOF
|
---|
| 447 |
|
---|
[3bc6078] | 448 | all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL mk_ROOT
|
---|
[cd4466f] | 449 | @sudo make restore-luser-env
|
---|
[045b2dc] | 450 | @sudo make do-housekeeping
|
---|
[7432834] | 451 | @\$(call echo_finished,$VERSION)
|
---|
| 452 |
|
---|
[045b2dc] | 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
|
---|
[7432834] | 460 |
|
---|
[045b2dc] | 461 | mk_SETUP:
|
---|
| 462 | @\$(call echo_SU_request)
|
---|
[dbcdfd7] | 463 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[045b2dc] | 464 | @touch \$@
|
---|
[7432834] | 465 |
|
---|
[045b2dc] | 466 | mk_LUSER: mk_SETUP
|
---|
| 467 | @\$(call echo_SULUSER_request)
|
---|
[dbcdfd7] | 468 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
[045b2dc] | 469 | @touch \$@
|
---|
[7432834] | 470 |
|
---|
[3e7ceed] | 471 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
[b4cf321] | 472 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 473 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
[3e7ceed] | 474 | (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
|
---|
[dbcdfd7] | 475 | (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
[3e7ceed] | 476 | fi;
|
---|
| 477 | @touch \$@
|
---|
| 478 |
|
---|
| 479 | mk_BLFS_TOOL: mk_CUSTOM_TOOLS
|
---|
| 480 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 481 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
[cd4466f] | 482 | (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
|
---|
[dbcdfd7] | 483 | (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
|
---|
[cd4466f] | 484 | fi;
|
---|
| 485 | @touch \$@
|
---|
| 486 |
|
---|
[ddca240] | 487 | mk_ROOT: create-sbu_du-report
|
---|
[3e7ceed] | 488 | @\$(call echo_SU_request)
|
---|
[de22e80] | 489 | @echo "$VERSION-sysroot - jhalfs build" > clfs-release && \\
|
---|
| 490 | sudo mv clfs-release \$(MOUNT_PT)/etc
|
---|
[dbcdfd7] | 491 | @sudo make BREAKPOINT=\$(BREAKPOINT) ROOT
|
---|
[045b2dc] | 492 | @touch \$@
|
---|
[7432834] | 493 |
|
---|
[3e7ceed] | 494 | SETUP: $host_prep
|
---|
| 495 | LUSER: $cross_tools $basicsystem $bootscripttools $bootable
|
---|
| 496 | CUSTOM_TOOLS: $custom_list
|
---|
| 497 | BLFS_TOOL: $blfs_tool
|
---|
| 498 | ROOT: $chowning
|
---|
[7432834] | 499 |
|
---|
| 500 |
|
---|
[cd4466f] | 501 | create-sbu_du-report: mk_LUSER
|
---|
[1838bc7] | 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 \$@
|
---|
[7432834] | 508 |
|
---|
[6ad5a2f] | 509 | restore-luser-env:
|
---|
[7432834] | 510 | @\$(call echo_message, Building)
|
---|
[962793a] | 511 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 512 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
[7432834] | 513 | fi;
|
---|
[962793a] | 514 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
| 515 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
[7432834] | 516 | fi;
|
---|
[962793a] | 517 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
|
---|
[7432834] | 518 | touch \$@ && \\
|
---|
| 519 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 520 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 521 |
|
---|
| 522 | do-housekeeping:
|
---|
[6ad5a2f] | 523 | @-if [ ! -f luser-exist ]; then \\
|
---|
| 524 | userdel \$(LUSER); \\
|
---|
[962793a] | 525 | rm -rf \$(LUSER_HOME); \\
|
---|
[7432834] | 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 | }
|
---|