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