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