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