[fe30c61] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
| 5 | #=== MAKEFILE HEADER ===
|
---|
| 6 |
|
---|
[195ed9f] | 7 | #----------------------------------#
|
---|
| 8 | wrt_Makefile_header() { #
|
---|
| 9 | #----------------------------------#
|
---|
| 10 | (
|
---|
| 11 | cat << EOF
|
---|
| 12 | # This file is automatically generated by jhalfs
|
---|
[fe30c61] | 13 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
| 14 | #
|
---|
[195ed9f] | 15 | # Generated on `date "+%F %X %Z"`
|
---|
| 16 |
|
---|
[aec4483] | 17 |
|
---|
| 18 | SHELL = /bin/bash
|
---|
[195ed9f] | 19 |
|
---|
| 20 | SRC = /sources
|
---|
| 21 | MOUNT_PT = $BUILDDIR
|
---|
| 22 | PKG_LST = $PKG_LST
|
---|
| 23 | LUSER = $LUSER
|
---|
| 24 | LGROUP = $LGROUP
|
---|
[962793a] | 25 | LHOME = $LHOME
|
---|
[195ed9f] | 26 | SCRIPT_ROOT = $SCRIPT_ROOT
|
---|
| 27 |
|
---|
| 28 | BASEDIR = \$(MOUNT_PT)
|
---|
| 29 | SRCSDIR = \$(BASEDIR)/sources
|
---|
| 30 | CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
|
---|
[93346ee] | 31 | LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 32 | TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
[195ed9f] | 33 |
|
---|
| 34 | crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
|
---|
[93346ee] | 35 | crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 36 | crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
| 37 | crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
|
---|
[195ed9f] | 38 |
|
---|
| 39 | SU_LUSER = su - \$(LUSER) -c
|
---|
[962793a] | 40 | LUSER_HOME = \$(LHOME)/\$(LUSER)
|
---|
[195ed9f] | 41 | PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
|
---|
| 42 | PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found / \`\n"
|
---|
| 43 |
|
---|
[3e7ceed] | 44 | ADD_REPORT = $REPORT
|
---|
| 45 | ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
|
---|
| 46 | ADD_BLFS_TOOLS = $BLFS_TOOL
|
---|
[1838bc7] | 47 |
|
---|
| 48 |
|
---|
[195ed9f] | 49 | export PATH := \${PATH}:/usr/sbin
|
---|
| 50 |
|
---|
| 51 | include makefile-functions
|
---|
| 52 |
|
---|
| 53 | EOF
|
---|
| 54 | ) > $MKFILE
|
---|
| 55 | }
|
---|
[fe30c61] | 56 |
|
---|
| 57 | #=======================
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | #==== PACKAGES NAMES ===
|
---|
| 61 |
|
---|
| 62 | #----------------------------------#
|
---|
| 63 | get_package_tarball_name() { #
|
---|
| 64 | #----------------------------------#
|
---|
| 65 | local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
|
---|
| 66 |
|
---|
| 67 | # The use of 'head' is necessary to limit the return value to the FIRST match..
|
---|
| 68 | # hopefully this will not cause problems.
|
---|
| 69 | #
|
---|
| 70 | case $script_name in
|
---|
| 71 | tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 72 | ;;
|
---|
[7214dad] | 73 | powerpc-utils) echo $(grep "^powerpc-utils" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 74 | ;;
|
---|
[3c38ab0] | 75 | uClibc)
|
---|
| 76 | if [[ "${PROGNAME}" = "clfs3" ]]; then
|
---|
| 77 | echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
[7214dad] | 78 | else
|
---|
[3c38ab0] | 79 | echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
[7214dad] | 80 | fi
|
---|
| 81 | ;;
|
---|
[fe30c61] | 82 | linux-headers)
|
---|
[31a37db] | 83 | if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] || [[ "${PROGNAME}" = "clfs" ]]; then
|
---|
[fe30c61] | 84 | # Uses kernel headers directly
|
---|
| 85 | echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 86 | else
|
---|
[31a37db] | 87 | # CLFS{2,3} use massaged headers package
|
---|
[fe30c61] | 88 | echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 89 | fi
|
---|
| 90 | ;;
|
---|
| 91 | *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 92 | ;;
|
---|
| 93 | esac
|
---|
| 94 |
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | #=======================
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | #==== TARGET HEADER ====
|
---|
| 101 |
|
---|
| 102 | #----------------------------------#
|
---|
| 103 | LUSER_wrt_target() { # Create target and initialize log file
|
---|
| 104 | #----------------------------------#
|
---|
| 105 | local i=$1
|
---|
| 106 | local PREV=$2
|
---|
| 107 | (
|
---|
| 108 | cat << EOF
|
---|
| 109 |
|
---|
| 110 | $i: $PREV
|
---|
| 111 | @\$(call echo_message, Building)
|
---|
[c180dec] | 112 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[fe30c61] | 113 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
|
---|
| 114 | @\$(PRT_DU) >>logs/\$@
|
---|
| 115 | EOF
|
---|
| 116 | ) >> $MKFILE.tmp
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | #----------------------------------#
|
---|
| 120 | CHROOT_wrt_target() { # Create target and initialize log file
|
---|
| 121 | #----------------------------------#
|
---|
| 122 | local i=$1
|
---|
| 123 | local PREV=$2
|
---|
| 124 | (
|
---|
| 125 | cat << EOF
|
---|
| 126 |
|
---|
| 127 | $i: $PREV
|
---|
| 128 | @\$(call echo_message, Building)
|
---|
[c180dec] | 129 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[6bb080e] | 130 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
|
---|
| 131 | @\$(PRT_DU_CR) >>logs/\$@
|
---|
[fe30c61] | 132 | EOF
|
---|
| 133 | ) >> $MKFILE.tmp
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | #=======================
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | #======== UNPACK =======
|
---|
| 140 |
|
---|
| 141 | #----------------------------------#
|
---|
| 142 | LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
| 143 | #----------------------------------#
|
---|
| 144 | local FILE=$1
|
---|
| 145 | local optSAVE_PREVIOUS=$2
|
---|
| 146 |
|
---|
| 147 | if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
|
---|
| 148 | (
|
---|
| 149 | cat << EOF
|
---|
| 150 | @\$(call remove_existing_dirs,$FILE)
|
---|
| 151 | EOF
|
---|
| 152 | ) >> $MKFILE.tmp
|
---|
| 153 | fi
|
---|
| 154 |
|
---|
| 155 | (
|
---|
| 156 | cat << EOF
|
---|
| 157 | @\$(call unpack,$FILE)
|
---|
| 158 | @\$(call get_pkg_root_LUSER)
|
---|
| 159 | EOF
|
---|
| 160 | ) >> $MKFILE.tmp
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | #----------------------------------#
|
---|
| 164 | CHROOT_Unpack() { #
|
---|
| 165 | #----------------------------------#
|
---|
| 166 | local FILE=$1
|
---|
| 167 | local optSAVE_PREVIOUS=$2
|
---|
| 168 |
|
---|
| 169 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 170 | (
|
---|
| 171 | cat << EOF
|
---|
| 172 | @\$(call remove_existing_dirs2,$FILE)
|
---|
| 173 | EOF
|
---|
| 174 | ) >> $MKFILE.tmp
|
---|
| 175 | fi
|
---|
| 176 | (
|
---|
| 177 | cat << EOF
|
---|
[1f81129] | 178 | @\$(call unpack2,$FILE)
|
---|
[fe30c61] | 179 | @\$(call get_pkg_root2)
|
---|
| 180 | EOF
|
---|
| 181 | ) >> $MKFILE.tmp
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | #=======================
|
---|
| 185 |
|
---|
| 186 |
|
---|
| 187 | #===== TESTS LOGS ======
|
---|
| 188 |
|
---|
| 189 | #----------------------------------#
|
---|
| 190 | LUSER_wrt_test_log() { # Initialize testsuite log file
|
---|
| 191 | #----------------------------------#
|
---|
| 192 | local TESTLOGFILE=$1
|
---|
| 193 | (
|
---|
| 194 | cat << EOF
|
---|
[6bb080e] | 195 | @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[10c8b78] | 196 | echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/\$@
|
---|
[fe30c61] | 197 | EOF
|
---|
| 198 | ) >> $MKFILE.tmp
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | #----------------------------------#
|
---|
| 202 | CHROOT_wrt_test_log() { #
|
---|
| 203 | #----------------------------------#
|
---|
| 204 | local TESTLOGFILE=$1
|
---|
| 205 | (
|
---|
| 206 | cat << EOF
|
---|
[8f2c086] | 207 | @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[6bb080e] | 208 | echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
|
---|
[fe30c61] | 209 | EOF
|
---|
| 210 | ) >> $MKFILE.tmp
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | #=======================
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | #======== RUN AS =======
|
---|
| 217 |
|
---|
| 218 | #----------------------------------#
|
---|
| 219 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 220 | #----------------------------------#
|
---|
| 221 | local MOUNT_ENV
|
---|
[8f2c086] | 222 | local file=$1
|
---|
[fe30c61] | 223 |
|
---|
| 224 | case ${PROGNAME} in
|
---|
| 225 | lfs ) MOUNT_ENV="LFS" ;;
|
---|
| 226 | clfs ) MOUNT_ENV="CLFS" ;;
|
---|
| 227 | clfs2 ) MOUNT_ENV="CLFS" ;;
|
---|
| 228 | clfs3 ) MOUNT_ENV="CLFS" ;;
|
---|
| 229 | hlfs ) MOUNT_ENV="HLFS" ;;
|
---|
| 230 | *) echo "undefined progname $PROGNAME"; exit 1 ;;
|
---|
| 231 | esac
|
---|
| 232 |
|
---|
| 233 | (
|
---|
| 234 | cat << EOF
|
---|
[68713c9] | 235 | @export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
|
---|
[0210014] | 236 | ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
|
---|
[fe30c61] | 237 | \$(PRT_DU) >>logs/\$@
|
---|
| 238 | EOF
|
---|
| 239 | ) >> $MKFILE.tmp
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | #----------------------------------#
|
---|
[0210014] | 243 | LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
|
---|
[fe30c61] | 244 | #----------------------------------#
|
---|
| 245 | local file=$1
|
---|
| 246 |
|
---|
| 247 | (
|
---|
| 248 | cat << EOF
|
---|
[68713c9] | 249 | @source ~/.bashrc && \\
|
---|
[0210014] | 250 | \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1 && \\
|
---|
| 251 | \$(PRT_DU) >>logs/\$@
|
---|
[fe30c61] | 252 | EOF
|
---|
| 253 | ) >> $MKFILE.tmp
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | #----------------------------------#
|
---|
| 257 | CHROOT_wrt_RunAsRoot() { #
|
---|
| 258 | #----------------------------------#
|
---|
| 259 | local file=$1
|
---|
| 260 | (
|
---|
| 261 | cat << EOF
|
---|
[68713c9] | 262 | @source envars && \\
|
---|
[0210014] | 263 | \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
|
---|
[fe30c61] | 264 | \$(PRT_DU_CR) >>logs/\$@
|
---|
| 265 | EOF
|
---|
| 266 | ) >> $MKFILE.tmp
|
---|
| 267 |
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | #=======================
|
---|
| 271 |
|
---|
| 272 |
|
---|
| 273 | #====== COPY FSTAB =====
|
---|
| 274 |
|
---|
| 275 | #----------------------------------#
|
---|
| 276 | LUSER_wrt_CopyFstab() { #
|
---|
| 277 | #----------------------------------#
|
---|
| 278 | (
|
---|
| 279 | cat << EOF
|
---|
[68713c9] | 280 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 281 | \$(PRT_DU) >>logs/\$@
|
---|
[fe30c61] | 282 | EOF
|
---|
| 283 | ) >> $MKFILE.tmp
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 | #----------------------------------#
|
---|
| 287 | CHROOT_wrt_CopyFstab() { #
|
---|
| 288 | #----------------------------------#
|
---|
| 289 | (
|
---|
| 290 | cat << EOF
|
---|
[68713c9] | 291 | @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 292 | \$(PRT_DU_CR) >>logs/\$@
|
---|
[fe30c61] | 293 | EOF
|
---|
| 294 | ) >> $MKFILE.tmp
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | #=======================
|
---|
| 298 |
|
---|
| 299 |
|
---|
[93346ee] | 300 | #==== INSTALLED FILES LOGS ====
|
---|
| 301 |
|
---|
[f546320] | 302 | #----------------------------------#
|
---|
| 303 | LUSER_wrt_TouchTimestamp() { #
|
---|
| 304 | #----------------------------------#
|
---|
| 305 | (
|
---|
| 306 | cat << EOF
|
---|
| 307 | @\$(call touch_timestamp_LUSER)
|
---|
| 308 | EOF
|
---|
| 309 | ) >> $MKFILE.tmp
|
---|
| 310 | }
|
---|
| 311 |
|
---|
[93346ee] | 312 | #----------------------------------#
|
---|
| 313 | CHROOT_wrt_TouchTimestamp() { #
|
---|
| 314 | #----------------------------------#
|
---|
| 315 | (
|
---|
| 316 | cat << EOF
|
---|
| 317 | @\$(call touch_timestamp)
|
---|
| 318 | EOF
|
---|
| 319 | ) >> $MKFILE.tmp
|
---|
| 320 | }
|
---|
| 321 |
|
---|
[f546320] | 322 | #----------------------------------#
|
---|
| 323 | LUSER_wrt_LogNewFiles() { #
|
---|
| 324 | #----------------------------------#
|
---|
| 325 | local name=$1
|
---|
| 326 | (
|
---|
| 327 | cat << EOF
|
---|
| 328 | @\$(call log_new_files_LUSER,$name)
|
---|
| 329 | EOF
|
---|
| 330 | ) >> $MKFILE.tmp
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[93346ee] | 333 | #----------------------------------#
|
---|
| 334 | CHROOT_wrt_LogNewFiles() { #
|
---|
| 335 | #----------------------------------#
|
---|
| 336 | local name=$1
|
---|
| 337 | (
|
---|
| 338 | cat << EOF
|
---|
| 339 | @\$(call log_new_files,$name)
|
---|
| 340 | EOF
|
---|
| 341 | ) >> $MKFILE.tmp
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | #=======================
|
---|
| 345 |
|
---|
| 346 |
|
---|
[fe30c61] | 347 | #==== RM BUILD DIRS ====
|
---|
| 348 |
|
---|
| 349 | #----------------------------------#
|
---|
| 350 | LUSER_RemoveBuildDirs() { #
|
---|
| 351 | #----------------------------------#
|
---|
| 352 | local name=$1
|
---|
| 353 | (
|
---|
| 354 | cat << EOF
|
---|
| 355 | @\$(call remove_build_dirs,$name)
|
---|
| 356 | EOF
|
---|
| 357 | ) >> $MKFILE.tmp
|
---|
| 358 | }
|
---|
| 359 |
|
---|
| 360 | #----------------------------------#
|
---|
| 361 | CHROOT_wrt_RemoveBuildDirs() { #
|
---|
| 362 | #----------------------------------#
|
---|
| 363 | local name=$1
|
---|
| 364 | (
|
---|
| 365 | cat << EOF
|
---|
| 366 | @\$(call remove_build_dirs2,$name)
|
---|
| 367 | EOF
|
---|
| 368 | ) >> $MKFILE.tmp
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | #=======================
|
---|
| 372 |
|
---|
| 373 |
|
---|
| 374 | #======== TOUCH ========
|
---|
| 375 |
|
---|
| 376 | #----------------------------------#
|
---|
| 377 | wrt_touch() { #
|
---|
| 378 | #----------------------------------#
|
---|
| 379 | (
|
---|
| 380 | cat << EOF
|
---|
| 381 | @\$(call housekeeping)
|
---|
| 382 | EOF
|
---|
| 383 | ) >> $MKFILE.tmp
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | #=======================
|
---|