[fe30c61] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | #=== MAKEFILE HEADER ===
|
---|
| 4 |
|
---|
[195ed9f] | 5 | #----------------------------------#
|
---|
| 6 | wrt_Makefile_header() { #
|
---|
| 7 | #----------------------------------#
|
---|
| 8 | (
|
---|
| 9 | cat << EOF
|
---|
| 10 | # This file is automatically generated by jhalfs
|
---|
[fe30c61] | 11 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
| 12 | #
|
---|
[195ed9f] | 13 | # Generated on `date "+%F %X %Z"`
|
---|
| 14 |
|
---|
[aec4483] | 15 |
|
---|
| 16 | SHELL = /bin/bash
|
---|
[195ed9f] | 17 |
|
---|
| 18 | SRC = /sources
|
---|
| 19 | MOUNT_PT = $BUILDDIR
|
---|
| 20 | PKG_LST = $PKG_LST
|
---|
| 21 | LUSER = $LUSER
|
---|
| 22 | LGROUP = $LGROUP
|
---|
[962793a] | 23 | LHOME = $LHOME
|
---|
[195ed9f] | 24 | SCRIPT_ROOT = $SCRIPT_ROOT
|
---|
| 25 |
|
---|
| 26 | BASEDIR = \$(MOUNT_PT)
|
---|
| 27 | SRCSDIR = \$(BASEDIR)/sources
|
---|
[2bd2fb8] | 28 | CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$COMMANDS
|
---|
[93346ee] | 29 | LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 30 | TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
[195ed9f] | 31 |
|
---|
[2bd2fb8] | 32 | crCMDSDIR = /\$(SCRIPT_ROOT)/$COMMANDS
|
---|
[93346ee] | 33 | crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 34 | crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
| 35 | crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
|
---|
[195ed9f] | 36 |
|
---|
[0835a10] | 37 | SU_LUSER = sudo -H -u \$(LUSER) sh -c
|
---|
[962793a] | 38 | LUSER_HOME = \$(LHOME)/\$(LUSER)
|
---|
[195ed9f] | 39 | PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
|
---|
[9bbb9c8] | 40 | PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found --exclude /var/lib / \`\n"
|
---|
[195ed9f] | 41 |
|
---|
[3e7ceed] | 42 | ADD_REPORT = $REPORT
|
---|
| 43 | ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
|
---|
| 44 | ADD_BLFS_TOOLS = $BLFS_TOOL
|
---|
[7072e1f] | 45 | PKGMNGT = $PKGMNGT
|
---|
[322226d] | 46 | WRAP_INSTALL = $WRAP_INSTALL
|
---|
[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 | #==== TARGET HEADER ====
|
---|
| 61 |
|
---|
| 62 | #----------------------------------#
|
---|
| 63 | LUSER_wrt_target() { # Create target and initialize log file
|
---|
| 64 | #----------------------------------#
|
---|
| 65 | local i=$1
|
---|
| 66 | local PREV=$2
|
---|
[3cb4ef5b] | 67 | local version
|
---|
| 68 | if [ "$3" != "" ]; then
|
---|
| 69 | version=-$3
|
---|
| 70 | fi
|
---|
[fe30c61] | 71 | (
|
---|
| 72 | cat << EOF
|
---|
| 73 |
|
---|
| 74 | $i: $PREV
|
---|
| 75 | @\$(call echo_message, Building)
|
---|
[75d6d1c] | 76 | ${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[3cb4ef5b] | 77 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
|
---|
[2758d94] | 78 | @ : > envars
|
---|
[fe30c61] | 79 | EOF
|
---|
| 80 | ) >> $MKFILE.tmp
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | #----------------------------------#
|
---|
| 84 | CHROOT_wrt_target() { # Create target and initialize log file
|
---|
| 85 | #----------------------------------#
|
---|
| 86 | local i=$1
|
---|
| 87 | local PREV=$2
|
---|
[3cb4ef5b] | 88 | local version
|
---|
| 89 | if [ "$3" != "" ]; then
|
---|
| 90 | version=-$3
|
---|
| 91 | fi
|
---|
[fe30c61] | 92 | (
|
---|
| 93 | cat << EOF
|
---|
| 94 |
|
---|
| 95 | $i: $PREV
|
---|
| 96 | @\$(call echo_message, Building)
|
---|
[75d6d1c] | 97 | ${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[3cb4ef5b] | 98 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
|
---|
[2758d94] | 99 | @ : > envars
|
---|
[fe30c61] | 100 | EOF
|
---|
| 101 | ) >> $MKFILE.tmp
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | #=======================
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | #======== UNPACK =======
|
---|
| 108 |
|
---|
| 109 | #----------------------------------#
|
---|
| 110 | LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
| 111 | #----------------------------------#
|
---|
[0722dde] | 112 | local FILE="$1"
|
---|
| 113 | local optSAVE_PREVIOUS="$2"
|
---|
| 114 | local version
|
---|
| 115 | if [ "$3" != "" ]; then
|
---|
| 116 | version=-"$3"
|
---|
| 117 | fi
|
---|
[fe30c61] | 118 |
|
---|
| 119 | if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
|
---|
| 120 | (
|
---|
| 121 | cat << EOF
|
---|
| 122 | @\$(call remove_existing_dirs,$FILE)
|
---|
| 123 | EOF
|
---|
| 124 | ) >> $MKFILE.tmp
|
---|
| 125 | fi
|
---|
| 126 |
|
---|
| 127 | (
|
---|
| 128 | cat << EOF
|
---|
[2758d94] | 129 | @\$(PRT_DU) >>logs/\$@$version
|
---|
[fe30c61] | 130 | @\$(call unpack,$FILE)
|
---|
| 131 | @\$(call get_pkg_root_LUSER)
|
---|
| 132 | EOF
|
---|
| 133 | ) >> $MKFILE.tmp
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | #----------------------------------#
|
---|
| 137 | CHROOT_Unpack() { #
|
---|
| 138 | #----------------------------------#
|
---|
| 139 | local FILE=$1
|
---|
| 140 | local optSAVE_PREVIOUS=$2
|
---|
[0722dde] | 141 | local version
|
---|
| 142 | if [ "$3" != "" ]; then
|
---|
| 143 | version=-"$3"
|
---|
| 144 | fi
|
---|
[fe30c61] | 145 |
|
---|
| 146 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 147 | (
|
---|
| 148 | cat << EOF
|
---|
| 149 | @\$(call remove_existing_dirs2,$FILE)
|
---|
| 150 | EOF
|
---|
| 151 | ) >> $MKFILE.tmp
|
---|
| 152 | fi
|
---|
[2758d94] | 153 |
|
---|
[fe30c61] | 154 | (
|
---|
[2758d94] | 155 | cat << EOF
|
---|
| 156 | @\$(PRT_DU_CR) >>logs/\$@$version
|
---|
[1f81129] | 157 | @\$(call unpack2,$FILE)
|
---|
[fe30c61] | 158 | @\$(call get_pkg_root2)
|
---|
| 159 | EOF
|
---|
| 160 | ) >> $MKFILE.tmp
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | #=======================
|
---|
| 164 |
|
---|
| 165 |
|
---|
| 166 | #===== TESTS LOGS ======
|
---|
| 167 |
|
---|
| 168 | #----------------------------------#
|
---|
| 169 | LUSER_wrt_test_log() { # Initialize testsuite log file
|
---|
| 170 | #----------------------------------#
|
---|
[3cb4ef5b] | 171 | local version
|
---|
| 172 | if [ "$2" != "" ]; then
|
---|
| 173 | version=-$2
|
---|
| 174 | fi
|
---|
| 175 | local TESTLOGFILE=$1$version
|
---|
[fe30c61] | 176 | (
|
---|
| 177 | cat << EOF
|
---|
[6bb080e] | 178 | @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[3cb4ef5b] | 179 | echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/$TESTLOGFILE
|
---|
[fe30c61] | 180 | EOF
|
---|
| 181 | ) >> $MKFILE.tmp
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | #----------------------------------#
|
---|
| 185 | CHROOT_wrt_test_log() { #
|
---|
| 186 | #----------------------------------#
|
---|
[3cb4ef5b] | 187 | local version
|
---|
| 188 | if [ "$2" != "" ]; then
|
---|
| 189 | version=-$2
|
---|
| 190 | fi
|
---|
| 191 | local TESTLOGFILE=$1$version
|
---|
[fe30c61] | 192 | (
|
---|
| 193 | cat << EOF
|
---|
[8f2c086] | 194 | @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[3cb4ef5b] | 195 | echo "\$(nl_)\`date\`\$(nl_)" >\$(crTESTLOGDIR)/$TESTLOGFILE
|
---|
[fe30c61] | 196 | EOF
|
---|
| 197 | ) >> $MKFILE.tmp
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | #=======================
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | #======== RUN AS =======
|
---|
| 204 |
|
---|
| 205 | #----------------------------------#
|
---|
| 206 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 207 | #----------------------------------#
|
---|
| 208 | local MOUNT_ENV
|
---|
[3cb4ef5b] | 209 | local version
|
---|
| 210 | if [ "$2" != "" ]; then
|
---|
| 211 | version=-$2
|
---|
| 212 | fi
|
---|
[8f2c086] | 213 | local file=$1
|
---|
[fe30c61] | 214 |
|
---|
| 215 | (
|
---|
| 216 | cat << EOF
|
---|
[0fa52f2] | 217 | @export LFS=\$(MOUNT_PT) && \\
|
---|
[2bd2fb8] | 218 | $COMMANDS/`dirname $file`/\$@ >>logs/\$@$version 2>&1
|
---|
[fe30c61] | 219 | EOF
|
---|
| 220 | ) >> $MKFILE.tmp
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | #----------------------------------#
|
---|
[0210014] | 224 | LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
|
---|
[fe30c61] | 225 | #----------------------------------#
|
---|
| 226 | local file=$1
|
---|
[3cb4ef5b] | 227 | local version
|
---|
| 228 | if [ "$2" != "" ]; then
|
---|
| 229 | version=-$2
|
---|
| 230 | fi
|
---|
[fe30c61] | 231 |
|
---|
| 232 | (
|
---|
| 233 | cat << EOF
|
---|
[68713c9] | 234 | @source ~/.bashrc && \\
|
---|
[2758d94] | 235 | \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1 && \\
|
---|
| 236 | if [ "${PROGNAME}" != lfs ]; then \$(PRT_DU) >>logs/\$@$version; fi
|
---|
[fe30c61] | 237 | EOF
|
---|
| 238 | ) >> $MKFILE.tmp
|
---|
| 239 | }
|
---|
| 240 |
|
---|
| 241 | #----------------------------------#
|
---|
| 242 | CHROOT_wrt_RunAsRoot() { #
|
---|
| 243 | #----------------------------------#
|
---|
| 244 | local file=$1
|
---|
[3cb4ef5b] | 245 | local version
|
---|
| 246 | if [ "$2" != "" ]; then
|
---|
| 247 | version=-$2
|
---|
| 248 | fi
|
---|
[fe30c61] | 249 | (
|
---|
| 250 | cat << EOF
|
---|
[68713c9] | 251 | @source envars && \\
|
---|
[2758d94] | 252 | \$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1 && \\
|
---|
| 253 | if [ "${PROGNAME}" != lfs ]; then \$(PRT_DU_CR) >>logs/\$@$version; fi
|
---|
[fe30c61] | 254 | EOF
|
---|
| 255 | ) >> $MKFILE.tmp
|
---|
| 256 |
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | #=======================
|
---|
| 260 |
|
---|
| 261 |
|
---|
| 262 | #====== COPY FSTAB =====
|
---|
| 263 |
|
---|
| 264 | #----------------------------------#
|
---|
| 265 | LUSER_wrt_CopyFstab() { #
|
---|
| 266 | #----------------------------------#
|
---|
| 267 | (
|
---|
| 268 | cat << EOF
|
---|
[68713c9] | 269 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 270 | \$(PRT_DU) >>logs/\$@
|
---|
[fe30c61] | 271 | EOF
|
---|
| 272 | ) >> $MKFILE.tmp
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 | #----------------------------------#
|
---|
| 276 | CHROOT_wrt_CopyFstab() { #
|
---|
| 277 | #----------------------------------#
|
---|
| 278 | (
|
---|
| 279 | cat << EOF
|
---|
[68713c9] | 280 | @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 281 | \$(PRT_DU_CR) >>logs/\$@
|
---|
[fe30c61] | 282 | EOF
|
---|
| 283 | ) >> $MKFILE.tmp
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 | #=======================
|
---|
| 287 |
|
---|
| 288 |
|
---|
[93346ee] | 289 | #==== INSTALLED FILES LOGS ====
|
---|
| 290 |
|
---|
[f546320] | 291 | #----------------------------------#
|
---|
| 292 | LUSER_wrt_TouchTimestamp() { #
|
---|
| 293 | #----------------------------------#
|
---|
| 294 | (
|
---|
| 295 | cat << EOF
|
---|
| 296 | @\$(call touch_timestamp_LUSER)
|
---|
| 297 | EOF
|
---|
| 298 | ) >> $MKFILE.tmp
|
---|
| 299 | }
|
---|
| 300 |
|
---|
[93346ee] | 301 | #----------------------------------#
|
---|
| 302 | CHROOT_wrt_TouchTimestamp() { #
|
---|
| 303 | #----------------------------------#
|
---|
| 304 | (
|
---|
| 305 | cat << EOF
|
---|
| 306 | @\$(call touch_timestamp)
|
---|
| 307 | EOF
|
---|
| 308 | ) >> $MKFILE.tmp
|
---|
| 309 | }
|
---|
| 310 |
|
---|
[f546320] | 311 | #----------------------------------#
|
---|
| 312 | LUSER_wrt_LogNewFiles() { #
|
---|
| 313 | #----------------------------------#
|
---|
| 314 | (
|
---|
| 315 | cat << EOF
|
---|
[13e52a5] | 316 | @\$(call log_new_files_LUSER,$1)
|
---|
[f546320] | 317 | EOF
|
---|
| 318 | ) >> $MKFILE.tmp
|
---|
| 319 | }
|
---|
| 320 |
|
---|
[93346ee] | 321 | #----------------------------------#
|
---|
| 322 | CHROOT_wrt_LogNewFiles() { #
|
---|
| 323 | #----------------------------------#
|
---|
| 324 | (
|
---|
| 325 | cat << EOF
|
---|
[13e52a5] | 326 | @\$(call log_new_files,$1)
|
---|
[93346ee] | 327 | EOF
|
---|
| 328 | ) >> $MKFILE.tmp
|
---|
| 329 | }
|
---|
| 330 |
|
---|
| 331 | #=======================
|
---|
| 332 |
|
---|
| 333 |
|
---|
[fe30c61] | 334 | #==== RM BUILD DIRS ====
|
---|
| 335 |
|
---|
| 336 | #----------------------------------#
|
---|
| 337 | LUSER_RemoveBuildDirs() { #
|
---|
| 338 | #----------------------------------#
|
---|
[e639536] | 339 | local name=`echo ${1} | sed 's/[0-9]-//'`
|
---|
[fe30c61] | 340 | (
|
---|
| 341 | cat << EOF
|
---|
| 342 | @\$(call remove_build_dirs,$name)
|
---|
| 343 | EOF
|
---|
| 344 | ) >> $MKFILE.tmp
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | #----------------------------------#
|
---|
| 348 | CHROOT_wrt_RemoveBuildDirs() { #
|
---|
| 349 | #----------------------------------#
|
---|
[e639536] | 350 | local name=`echo ${1} | sed 's/[0-9]-//'`
|
---|
[fe30c61] | 351 | (
|
---|
| 352 | cat << EOF
|
---|
| 353 | @\$(call remove_build_dirs2,$name)
|
---|
| 354 | EOF
|
---|
| 355 | ) >> $MKFILE.tmp
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | #=======================
|
---|
| 359 |
|
---|
| 360 |
|
---|
| 361 | #======== TOUCH ========
|
---|
| 362 |
|
---|
| 363 | #----------------------------------#
|
---|
| 364 | wrt_touch() { #
|
---|
| 365 | #----------------------------------#
|
---|
| 366 | (
|
---|
| 367 | cat << EOF
|
---|
| 368 | @\$(call housekeeping)
|
---|
| 369 | EOF
|
---|
| 370 | ) >> $MKFILE.tmp
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | #=======================
|
---|