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