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