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