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