[fd48886] | 1 | #!/bin/bash
|
---|
| 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 |
|
---|
| 21 | 025-addinguser:
|
---|
| 22 | @\$(call echo_message, Building)
|
---|
| 23 | @if [ ! -d \$(LUSER_HOME) ]; then \\
|
---|
| 24 | groupadd \$(LGROUP); \\
|
---|
| 25 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
| 26 | else \\
|
---|
| 27 | touch luser-exist; \\
|
---|
| 28 | fi;
|
---|
| 29 | @\$(call housekeeping)
|
---|
| 30 |
|
---|
| 31 | 026-settingenvironment: 025-addinguser
|
---|
| 32 | @\$(call echo_message, Building)
|
---|
| 33 | @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 34 | mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
|
---|
| 35 | fi;
|
---|
| 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; \\
|
---|
| 38 | fi;
|
---|
| 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 && \\
|
---|
| 55 | touch envars && \\
|
---|
| 56 | chown \$(LUSER):\$(LGROUP) envars
|
---|
| 57 | @\$(call housekeeping)
|
---|
| 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
|
---|
| 75 | @\$(call housekeeping)
|
---|
| 76 |
|
---|
| 77 | 028-creating-sysfile: 027-create-directories
|
---|
| 78 | @\$(call echo_message, Building)
|
---|
| 79 |
|
---|
| 80 | @touch \$(MOUNT_PT)/etc/mtab
|
---|
| 81 | @echo "root::0:0:root:/root:/bin/ash" >> \$(MOUNT_PT)/etc/passwd
|
---|
| 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
|
---|
| 101 | @chown -R \$(LUSER) \$(MOUNT_PT) && \\
|
---|
| 102 | chmod -R a+w \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
---|
| 103 | chmod -R a+w \$(SRCSDIR)
|
---|
| 104 | @\$(call housekeeping)
|
---|
| 105 |
|
---|
| 106 | EOF
|
---|
| 107 | ) >> $MKFILE.tmp
|
---|
| 108 |
|
---|
| 109 | host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | #-----------------------------#
|
---|
| 113 | systemprep_Makefiles() { #
|
---|
| 114 | #-----------------------------#
|
---|
| 115 | echo "${tab_}${GREEN}Processing... ${L_arrow}system prep tools ( LUSER ) ${R_arrow}"
|
---|
| 116 |
|
---|
| 117 | for file in systemprep/* ; do
|
---|
| 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 |
|
---|
| 163 |
|
---|
| 164 | #-----------------------------#
|
---|
| 165 | cross_tools_Makefiles() { #
|
---|
| 166 | #-----------------------------#
|
---|
| 167 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
| 168 |
|
---|
| 169 | for file in cross-tools/* ; do
|
---|
| 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
|
---|
| 178 | *cflags* | *variables* | *abi | *toolchain*) # work done in host_prep_Makefiles
|
---|
| 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 | # Touch timestamp file if installed files logs will be created.
|
---|
| 214 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 215 | LUSER_wrt_TouchTimestamp
|
---|
| 216 | fi
|
---|
| 217 | # If using optimizations, write the instructions
|
---|
| 218 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 219 | fi
|
---|
| 220 | #
|
---|
| 221 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 222 | #
|
---|
| 223 | # Write installed files log and remove the build directory(ies)
|
---|
| 224 | # except if the package build fails.
|
---|
| 225 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 226 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 227 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 228 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 229 | fi
|
---|
| 230 | fi
|
---|
| 231 | #
|
---|
| 232 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 233 | wrt_touch
|
---|
| 234 | #
|
---|
| 235 | #--------------------------------------------------------------------#
|
---|
| 236 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 237 | #--------------------------------------------------------------------#
|
---|
| 238 | #
|
---|
| 239 | # Keep the script file name for Makefile dependencies.
|
---|
| 240 | PREV=$this_script
|
---|
| 241 |
|
---|
| 242 | done # for file in ....
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 |
|
---|
| 246 |
|
---|
| 247 | #-----------------------------#
|
---|
| 248 | final_system_Makefiles() { #
|
---|
| 249 | #-----------------------------#
|
---|
| 250 | echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
|
---|
| 251 |
|
---|
| 252 | for file in final-system/* ; do
|
---|
| 253 | # Keep the script file name
|
---|
| 254 | this_script=`basename $file`
|
---|
| 255 |
|
---|
| 256 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 257 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
| 258 | -e 's@temp-@@' \
|
---|
| 259 | -e 's@-64bit@@' \
|
---|
| 260 | -e 's@-64@@' \
|
---|
| 261 | -e 's@64@@' \
|
---|
| 262 | -e 's@n32@@'`
|
---|
| 263 |
|
---|
| 264 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 265 | # a specific package.
|
---|
| 266 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 267 |
|
---|
| 268 | # Append each name of the script files to a list (this will become
|
---|
| 269 | # the names of the targets in the Makefile
|
---|
| 270 | basicsystem="$basicsystem ${this_script}"
|
---|
| 271 |
|
---|
| 272 | #--------------------------------------------------------------------#
|
---|
| 273 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 274 | #--------------------------------------------------------------------#
|
---|
| 275 | #
|
---|
| 276 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 277 | # as a dependency. Also call the echo_message function.
|
---|
| 278 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
| 279 | #
|
---|
| 280 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 281 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 282 | # Touch timestamp file if installed files logs will be created.
|
---|
| 283 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 284 | LUSER_wrt_TouchTimestamp
|
---|
| 285 | fi
|
---|
| 286 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 287 | # If using optimizations, write the instructions
|
---|
| 288 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 289 | fi
|
---|
| 290 | #
|
---|
| 291 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 292 | #
|
---|
| 293 | # Write installed files log and remove the build directory(ies)
|
---|
| 294 | # except if the package build fails.
|
---|
| 295 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 296 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 297 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 298 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 299 | fi
|
---|
| 300 | fi
|
---|
| 301 | #
|
---|
| 302 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 303 | wrt_touch
|
---|
| 304 | #
|
---|
| 305 | #--------------------------------------------------------------------#
|
---|
| 306 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 307 | #--------------------------------------------------------------------#
|
---|
| 308 | #
|
---|
| 309 | # Keep the script file name for Makefile dependencies.
|
---|
| 310 | PREV=${this_script}
|
---|
| 311 | done # for file in final-system/* ...
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 |
|
---|
| 315 |
|
---|
| 316 | #-----------------------------#
|
---|
| 317 | bootscripts_Makefiles() { #
|
---|
| 318 | #-----------------------------#
|
---|
| 319 | echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
|
---|
| 320 |
|
---|
| 321 | for file in bootscripts/* ; do
|
---|
| 322 | # Keep the script file name
|
---|
| 323 | this_script=`basename $file`
|
---|
| 324 |
|
---|
| 325 | case $this_script in
|
---|
| 326 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
| 327 | *network*) continue ;; # Manually create these files
|
---|
| 328 | *) ;;
|
---|
| 329 | esac
|
---|
| 330 |
|
---|
| 331 | # First append each name of the script files to a list (this will become
|
---|
| 332 | # the names of the targets in the Makefile
|
---|
| 333 | bootscripttools="$bootscripttools $this_script"
|
---|
| 334 |
|
---|
| 335 | # Grab the name of the target, strip id number, XXX-script
|
---|
| 336 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
| 337 | -e 's@-64bit@@' \
|
---|
| 338 | -e 's@-64@@' \
|
---|
| 339 | -e 's@64@@' \
|
---|
| 340 | -e 's@n32@@'`
|
---|
| 341 | case $name in
|
---|
| 342 | *bootscripts*) name=clfs-embedded-bootscripts ;;
|
---|
| 343 | esac
|
---|
| 344 |
|
---|
| 345 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 346 |
|
---|
| 347 | #--------------------------------------------------------------------#
|
---|
| 348 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 349 | #--------------------------------------------------------------------#
|
---|
| 350 | #
|
---|
| 351 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 352 | # as a dependency. Also call the echo_message function.
|
---|
| 353 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
| 354 | #
|
---|
| 355 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 356 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 357 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 358 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 359 | LUSER_wrt_TouchTimestamp
|
---|
| 360 | fi
|
---|
| 361 | fi
|
---|
| 362 | #
|
---|
| 363 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 364 | #
|
---|
| 365 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 366 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 367 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 368 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 369 | fi
|
---|
| 370 | fi
|
---|
| 371 | #
|
---|
| 372 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 373 | wrt_touch
|
---|
| 374 | #
|
---|
| 375 | #--------------------------------------------------------------------#
|
---|
| 376 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 377 | #--------------------------------------------------------------------#
|
---|
| 378 | #
|
---|
| 379 | # Keep the script file name for Makefile dependencies.
|
---|
| 380 | PREV=$this_script
|
---|
| 381 |
|
---|
| 382 | done # for file in bootscripts/* ...
|
---|
| 383 |
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 |
|
---|
| 387 | #-----------------------------#
|
---|
| 388 | bootable_Makefiles() { #
|
---|
| 389 | #-----------------------------#
|
---|
| 390 | echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
|
---|
| 391 |
|
---|
| 392 | for file in bootable/* ; do
|
---|
| 393 | # Keep the script file name
|
---|
| 394 | this_script=`basename $file`
|
---|
| 395 |
|
---|
| 396 | # A little housekeeping on the scripts
|
---|
| 397 | case $this_script in
|
---|
| 398 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
| 399 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
| 400 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
| 401 | [[ -z $CONFIG ]] && continue
|
---|
| 402 | # Copy the config file to /sources with a standardized name
|
---|
| 403 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 404 | ;;
|
---|
| 405 | esac
|
---|
| 406 | #
|
---|
| 407 | # First append each name of the script files to a list (this will become
|
---|
| 408 | # the names of the targets in the Makefile
|
---|
| 409 | # NOTE: new makfile format forces the last script, *chowning, into a separate
|
---|
| 410 | # phase.
|
---|
| 411 | case ${this_script} in
|
---|
| 412 | *chowning) chowning=${this_script} ;;
|
---|
| 413 | *) bootable="$bootable $this_script" ;;
|
---|
| 414 | esac
|
---|
| 415 | #
|
---|
| 416 | # Grab the name of the target, strip id number and misc words.
|
---|
| 417 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
| 418 | case $this_script in
|
---|
| 419 | *kernel*) name=linux
|
---|
| 420 | ;;
|
---|
| 421 | esac
|
---|
| 422 |
|
---|
| 423 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
| 424 |
|
---|
| 425 | #--------------------------------------------------------------------#
|
---|
| 426 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 427 | #--------------------------------------------------------------------#
|
---|
| 428 | #
|
---|
| 429 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 430 | # as a dependency. Also call the echo_message function.
|
---|
| 431 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
| 432 | #
|
---|
| 433 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 434 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 435 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
| 436 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 437 | LUSER_wrt_TouchTimestamp
|
---|
| 438 | fi
|
---|
| 439 | fi
|
---|
| 440 | #
|
---|
| 441 | # Select a script execution method
|
---|
| 442 | case $this_script in
|
---|
| 443 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
| 444 | LUSER_wrt_CopyFstab
|
---|
| 445 | else
|
---|
| 446 | LUSER_wrt_RunAsUser "${file}"
|
---|
| 447 | fi
|
---|
| 448 | ;;
|
---|
| 449 | *chowning) wrt_RunAsRoot "${file}"
|
---|
| 450 | ;;
|
---|
| 451 | *) LUSER_wrt_RunAsUser "${file}"
|
---|
| 452 | ;;
|
---|
| 453 | esac
|
---|
| 454 | #
|
---|
| 455 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
| 456 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 457 | LUSER_RemoveBuildDirs "${name}"
|
---|
| 458 | if [ "${INSTALL_LOG}" = "y" ] ; then
|
---|
| 459 | LUSER_wrt_LogNewFiles "$name"
|
---|
| 460 | fi
|
---|
| 461 | fi
|
---|
| 462 | #
|
---|
| 463 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 464 | wrt_touch
|
---|
| 465 | #
|
---|
| 466 | #--------------------------------------------------------------------#
|
---|
| 467 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 468 | #--------------------------------------------------------------------#
|
---|
| 469 | #
|
---|
| 470 | # Keep the script file name for Makefile dependencies.
|
---|
| 471 | PREV=$this_script
|
---|
| 472 |
|
---|
| 473 | done
|
---|
| 474 |
|
---|
| 475 | }
|
---|
| 476 |
|
---|
| 477 |
|
---|
| 478 | #-----------------------------#
|
---|
| 479 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 480 | #-----------------------------#
|
---|
| 481 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 482 |
|
---|
| 483 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 484 | # Start with a clean Makefile.tmp file
|
---|
| 485 | >$MKFILE.tmp
|
---|
| 486 |
|
---|
| 487 | host_prep_Makefiles
|
---|
| 488 | [[ "${PLATFORM% -*}" = "WRT" ]] && systemprep_Makefiles # $cross_tools
|
---|
| 489 | cross_tools_Makefiles # $cross_tools
|
---|
| 490 | final_system_Makefiles # $basicsystem
|
---|
| 491 | bootscripts_Makefiles # $bootscripttools
|
---|
| 492 | bootable_Makefiles # $bootable
|
---|
| 493 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 494 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
| 495 |
|
---|
| 496 | # Add a header, some variables and include the function file
|
---|
| 497 | # to the top of the real Makefile.
|
---|
| 498 | wrt_Makefile_header
|
---|
| 499 |
|
---|
| 500 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 501 | # as a dependency.
|
---|
| 502 | (
|
---|
| 503 | cat << EOF
|
---|
| 504 |
|
---|
| 505 | all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_ROOT
|
---|
| 506 | @sudo make restore-luser-env
|
---|
| 507 | @sudo make do-housekeeping
|
---|
| 508 | @\$(call echo_finished,$VERSION)
|
---|
| 509 |
|
---|
| 510 | ck_UID:
|
---|
| 511 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 512 | echo "--------------------------------------------------"; \\
|
---|
| 513 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 514 | echo "--------------------------------------------------"; \\
|
---|
| 515 | exit 1; \\
|
---|
| 516 | fi
|
---|
| 517 |
|
---|
| 518 | mk_SETUP:
|
---|
| 519 | @\$(call echo_SU_request)
|
---|
| 520 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
| 521 | @touch \$@
|
---|
| 522 |
|
---|
| 523 | mk_LUSER: mk_SETUP
|
---|
| 524 | @\$(call echo_SULUSER_request)
|
---|
| 525 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
|
---|
| 526 | @touch \$@
|
---|
| 527 |
|
---|
| 528 | mk_CUSTOM_TOOLS: create-sbu_du-report
|
---|
| 529 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
| 530 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
| 531 | (sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
|
---|
| 532 | (sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
| 533 | fi;
|
---|
| 534 | @touch \$@
|
---|
| 535 |
|
---|
| 536 | mk_ROOT:
|
---|
| 537 | @\$(call echo_SU_request)
|
---|
| 538 | @echo "$VERSION-embedded - jhalfs build" > clfs-release && \\
|
---|
| 539 | sudo mv clfs-release \$(MOUNT_PT)/etc
|
---|
| 540 | @sudo make BREAKPOINT=\$(BREAKPOINT) ROOT
|
---|
| 541 | @touch \$@
|
---|
| 542 |
|
---|
| 543 |
|
---|
| 544 | SETUP: $host_prep
|
---|
| 545 | LUSER: $cross_tools $basicsystem $bootscripttools $bootable
|
---|
| 546 | CUSTOM_TOOLS: $custom_list
|
---|
| 547 | ROOT: $chowning
|
---|
| 548 |
|
---|
| 549 |
|
---|
| 550 | create-sbu_du-report: mk_LUSER
|
---|
| 551 | @\$(call echo_message, Building)
|
---|
| 552 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
| 553 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
| 554 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
| 555 | fi;
|
---|
| 556 | @touch \$@
|
---|
| 557 |
|
---|
| 558 | restore-luser-env:
|
---|
| 559 | @\$(call echo_message, Building)
|
---|
| 560 | @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
|
---|
| 561 | mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
|
---|
| 562 | fi;
|
---|
| 563 | @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
|
---|
| 564 | mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
|
---|
| 565 | fi;
|
---|
| 566 | @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
|
---|
| 567 | touch \$@ && \\
|
---|
| 568 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 569 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 570 |
|
---|
| 571 | do-housekeeping:
|
---|
| 572 | @-if [ ! -f luser-exist ]; then \\
|
---|
| 573 | userdel \$(LUSER); \\
|
---|
| 574 | rm -rf \$(LUSER_HOME); \\
|
---|
| 575 | fi;
|
---|
| 576 |
|
---|
| 577 | EOF
|
---|
| 578 | ) >> $MKFILE
|
---|
| 579 |
|
---|
| 580 | # Bring over the items from the Makefile.tmp
|
---|
| 581 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 582 | rm $MKFILE.tmp
|
---|
| 583 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 584 |
|
---|
| 585 | }
|
---|
| 586 |
|
---|