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