[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 | ;;
|
---|
[d8006a00] | 91 | expect) echo $(grep "^expect" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 92 | ;;
|
---|
[4b54394] | 93 | xz-utils) echo $(grep "^xz" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 94 | ;;
|
---|
[fe30c61] | 95 | *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
---|
| 96 | ;;
|
---|
| 97 | esac
|
---|
| 98 |
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | #=======================
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | #==== TARGET HEADER ====
|
---|
| 105 |
|
---|
| 106 | #----------------------------------#
|
---|
| 107 | LUSER_wrt_target() { # Create target and initialize log file
|
---|
| 108 | #----------------------------------#
|
---|
| 109 | local i=$1
|
---|
| 110 | local PREV=$2
|
---|
| 111 | (
|
---|
| 112 | cat << EOF
|
---|
| 113 |
|
---|
| 114 | $i: $PREV
|
---|
| 115 | @\$(call echo_message, Building)
|
---|
[75d6d1c] | 116 | ${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[fe30c61] | 117 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
|
---|
| 118 | @\$(PRT_DU) >>logs/\$@
|
---|
| 119 | EOF
|
---|
| 120 | ) >> $MKFILE.tmp
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | #----------------------------------#
|
---|
| 124 | CHROOT_wrt_target() { # Create target and initialize log file
|
---|
| 125 | #----------------------------------#
|
---|
| 126 | local i=$1
|
---|
| 127 | local PREV=$2
|
---|
| 128 | (
|
---|
| 129 | cat << EOF
|
---|
| 130 |
|
---|
| 131 | $i: $PREV
|
---|
| 132 | @\$(call echo_message, Building)
|
---|
[75d6d1c] | 133 | ${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[6bb080e] | 134 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
|
---|
| 135 | @\$(PRT_DU_CR) >>logs/\$@
|
---|
[fe30c61] | 136 | EOF
|
---|
| 137 | ) >> $MKFILE.tmp
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | #=======================
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | #======== UNPACK =======
|
---|
| 144 |
|
---|
| 145 | #----------------------------------#
|
---|
| 146 | LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
| 147 | #----------------------------------#
|
---|
| 148 | local FILE=$1
|
---|
| 149 | local optSAVE_PREVIOUS=$2
|
---|
| 150 |
|
---|
| 151 | if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
|
---|
| 152 | (
|
---|
| 153 | cat << EOF
|
---|
| 154 | @\$(call remove_existing_dirs,$FILE)
|
---|
| 155 | EOF
|
---|
| 156 | ) >> $MKFILE.tmp
|
---|
| 157 | fi
|
---|
| 158 |
|
---|
| 159 | (
|
---|
| 160 | cat << EOF
|
---|
| 161 | @\$(call unpack,$FILE)
|
---|
| 162 | @\$(call get_pkg_root_LUSER)
|
---|
| 163 | EOF
|
---|
| 164 | ) >> $MKFILE.tmp
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | #----------------------------------#
|
---|
| 168 | CHROOT_Unpack() { #
|
---|
| 169 | #----------------------------------#
|
---|
| 170 | local FILE=$1
|
---|
| 171 | local optSAVE_PREVIOUS=$2
|
---|
| 172 |
|
---|
| 173 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 174 | (
|
---|
| 175 | cat << EOF
|
---|
| 176 | @\$(call remove_existing_dirs2,$FILE)
|
---|
| 177 | EOF
|
---|
| 178 | ) >> $MKFILE.tmp
|
---|
| 179 | fi
|
---|
| 180 | (
|
---|
| 181 | cat << EOF
|
---|
[1f81129] | 182 | @\$(call unpack2,$FILE)
|
---|
[fe30c61] | 183 | @\$(call get_pkg_root2)
|
---|
| 184 | EOF
|
---|
| 185 | ) >> $MKFILE.tmp
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | #=======================
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | #===== TESTS LOGS ======
|
---|
| 192 |
|
---|
| 193 | #----------------------------------#
|
---|
| 194 | LUSER_wrt_test_log() { # Initialize testsuite log file
|
---|
| 195 | #----------------------------------#
|
---|
| 196 | local TESTLOGFILE=$1
|
---|
| 197 | (
|
---|
| 198 | cat << EOF
|
---|
[6bb080e] | 199 | @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[10c8b78] | 200 | echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/\$@
|
---|
[fe30c61] | 201 | EOF
|
---|
| 202 | ) >> $MKFILE.tmp
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | #----------------------------------#
|
---|
| 206 | CHROOT_wrt_test_log() { #
|
---|
| 207 | #----------------------------------#
|
---|
| 208 | local TESTLOGFILE=$1
|
---|
| 209 | (
|
---|
| 210 | cat << EOF
|
---|
[8f2c086] | 211 | @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[6bb080e] | 212 | echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
|
---|
[fe30c61] | 213 | EOF
|
---|
| 214 | ) >> $MKFILE.tmp
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | #=======================
|
---|
| 218 |
|
---|
| 219 |
|
---|
| 220 | #======== RUN AS =======
|
---|
| 221 |
|
---|
| 222 | #----------------------------------#
|
---|
| 223 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 224 | #----------------------------------#
|
---|
| 225 | local MOUNT_ENV
|
---|
[8f2c086] | 226 | local file=$1
|
---|
[fe30c61] | 227 |
|
---|
| 228 | case ${PROGNAME} in
|
---|
| 229 | lfs ) MOUNT_ENV="LFS" ;;
|
---|
| 230 | clfs ) MOUNT_ENV="CLFS" ;;
|
---|
| 231 | clfs2 ) MOUNT_ENV="CLFS" ;;
|
---|
| 232 | clfs3 ) MOUNT_ENV="CLFS" ;;
|
---|
| 233 | hlfs ) MOUNT_ENV="HLFS" ;;
|
---|
| 234 | *) echo "undefined progname $PROGNAME"; exit 1 ;;
|
---|
| 235 | esac
|
---|
| 236 |
|
---|
| 237 | (
|
---|
| 238 | cat << EOF
|
---|
[68713c9] | 239 | @export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
|
---|
[0210014] | 240 | ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
|
---|
[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
|
---|
[68713c9] | 253 | @source ~/.bashrc && \\
|
---|
[0210014] | 254 | \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1 && \\
|
---|
| 255 | \$(PRT_DU) >>logs/\$@
|
---|
[fe30c61] | 256 | EOF
|
---|
| 257 | ) >> $MKFILE.tmp
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | #----------------------------------#
|
---|
| 261 | CHROOT_wrt_RunAsRoot() { #
|
---|
| 262 | #----------------------------------#
|
---|
| 263 | local file=$1
|
---|
| 264 | (
|
---|
| 265 | cat << EOF
|
---|
[68713c9] | 266 | @source envars && \\
|
---|
[0210014] | 267 | \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
|
---|
[fe30c61] | 268 | \$(PRT_DU_CR) >>logs/\$@
|
---|
| 269 | EOF
|
---|
| 270 | ) >> $MKFILE.tmp
|
---|
| 271 |
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | #=======================
|
---|
| 275 |
|
---|
| 276 |
|
---|
| 277 | #====== COPY FSTAB =====
|
---|
| 278 |
|
---|
| 279 | #----------------------------------#
|
---|
| 280 | LUSER_wrt_CopyFstab() { #
|
---|
| 281 | #----------------------------------#
|
---|
| 282 | (
|
---|
| 283 | cat << EOF
|
---|
[68713c9] | 284 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 285 | \$(PRT_DU) >>logs/\$@
|
---|
[fe30c61] | 286 | EOF
|
---|
| 287 | ) >> $MKFILE.tmp
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | #----------------------------------#
|
---|
| 291 | CHROOT_wrt_CopyFstab() { #
|
---|
| 292 | #----------------------------------#
|
---|
| 293 | (
|
---|
| 294 | cat << EOF
|
---|
[68713c9] | 295 | @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 296 | \$(PRT_DU_CR) >>logs/\$@
|
---|
[fe30c61] | 297 | EOF
|
---|
| 298 | ) >> $MKFILE.tmp
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | #=======================
|
---|
| 302 |
|
---|
| 303 |
|
---|
[93346ee] | 304 | #==== INSTALLED FILES LOGS ====
|
---|
| 305 |
|
---|
[f546320] | 306 | #----------------------------------#
|
---|
| 307 | LUSER_wrt_TouchTimestamp() { #
|
---|
| 308 | #----------------------------------#
|
---|
| 309 | (
|
---|
| 310 | cat << EOF
|
---|
| 311 | @\$(call touch_timestamp_LUSER)
|
---|
| 312 | EOF
|
---|
| 313 | ) >> $MKFILE.tmp
|
---|
| 314 | }
|
---|
| 315 |
|
---|
[93346ee] | 316 | #----------------------------------#
|
---|
| 317 | CHROOT_wrt_TouchTimestamp() { #
|
---|
| 318 | #----------------------------------#
|
---|
| 319 | (
|
---|
| 320 | cat << EOF
|
---|
| 321 | @\$(call touch_timestamp)
|
---|
| 322 | EOF
|
---|
| 323 | ) >> $MKFILE.tmp
|
---|
| 324 | }
|
---|
| 325 |
|
---|
[f546320] | 326 | #----------------------------------#
|
---|
| 327 | LUSER_wrt_LogNewFiles() { #
|
---|
| 328 | #----------------------------------#
|
---|
| 329 | local name=$1
|
---|
| 330 | (
|
---|
| 331 | cat << EOF
|
---|
| 332 | @\$(call log_new_files_LUSER,$name)
|
---|
| 333 | EOF
|
---|
| 334 | ) >> $MKFILE.tmp
|
---|
| 335 | }
|
---|
| 336 |
|
---|
[93346ee] | 337 | #----------------------------------#
|
---|
| 338 | CHROOT_wrt_LogNewFiles() { #
|
---|
| 339 | #----------------------------------#
|
---|
| 340 | local name=$1
|
---|
| 341 | (
|
---|
| 342 | cat << EOF
|
---|
| 343 | @\$(call log_new_files,$name)
|
---|
| 344 | EOF
|
---|
| 345 | ) >> $MKFILE.tmp
|
---|
| 346 | }
|
---|
| 347 |
|
---|
| 348 | #=======================
|
---|
| 349 |
|
---|
| 350 |
|
---|
[fe30c61] | 351 | #==== RM BUILD DIRS ====
|
---|
| 352 |
|
---|
| 353 | #----------------------------------#
|
---|
| 354 | LUSER_RemoveBuildDirs() { #
|
---|
| 355 | #----------------------------------#
|
---|
| 356 | local name=$1
|
---|
| 357 | (
|
---|
| 358 | cat << EOF
|
---|
| 359 | @\$(call remove_build_dirs,$name)
|
---|
| 360 | EOF
|
---|
| 361 | ) >> $MKFILE.tmp
|
---|
| 362 | }
|
---|
| 363 |
|
---|
| 364 | #----------------------------------#
|
---|
| 365 | CHROOT_wrt_RemoveBuildDirs() { #
|
---|
| 366 | #----------------------------------#
|
---|
| 367 | local name=$1
|
---|
| 368 | (
|
---|
| 369 | cat << EOF
|
---|
| 370 | @\$(call remove_build_dirs2,$name)
|
---|
| 371 | EOF
|
---|
| 372 | ) >> $MKFILE.tmp
|
---|
| 373 | }
|
---|
| 374 |
|
---|
| 375 | #=======================
|
---|
| 376 |
|
---|
| 377 |
|
---|
| 378 | #======== TOUCH ========
|
---|
| 379 |
|
---|
| 380 | #----------------------------------#
|
---|
| 381 | wrt_touch() { #
|
---|
| 382 | #----------------------------------#
|
---|
| 383 | (
|
---|
| 384 | cat << EOF
|
---|
| 385 | @\$(call housekeeping)
|
---|
| 386 | EOF
|
---|
| 387 | ) >> $MKFILE.tmp
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 | #=======================
|
---|