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