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