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