[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
|
---|
[cacc6c5] | 47 | CPUSET = $CPUSET
|
---|
[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 | #==== TARGET HEADER ====
|
---|
| 62 |
|
---|
| 63 | #----------------------------------#
|
---|
| 64 | LUSER_wrt_target() { # Create target and initialize log file
|
---|
| 65 | #----------------------------------#
|
---|
| 66 | local i=$1
|
---|
| 67 | local PREV=$2
|
---|
[3cb4ef5b] | 68 | local version
|
---|
| 69 | if [ "$3" != "" ]; then
|
---|
| 70 | version=-$3
|
---|
| 71 | fi
|
---|
[fe30c61] | 72 | (
|
---|
| 73 | cat << EOF
|
---|
| 74 |
|
---|
| 75 | $i: $PREV
|
---|
| 76 | @\$(call echo_message, Building)
|
---|
[75d6d1c] | 77 | ${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[3cb4ef5b] | 78 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
|
---|
[2758d94] | 79 | @ : > envars
|
---|
[fe30c61] | 80 | EOF
|
---|
| 81 | ) >> $MKFILE.tmp
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | #----------------------------------#
|
---|
| 85 | CHROOT_wrt_target() { # Create target and initialize log file
|
---|
| 86 | #----------------------------------#
|
---|
| 87 | local i=$1
|
---|
| 88 | local PREV=$2
|
---|
[3cb4ef5b] | 89 | local version
|
---|
| 90 | if [ "$3" != "" ]; then
|
---|
| 91 | version=-$3
|
---|
| 92 | fi
|
---|
[fe30c61] | 93 | (
|
---|
| 94 | cat << EOF
|
---|
| 95 |
|
---|
| 96 | $i: $PREV
|
---|
| 97 | @\$(call echo_message, Building)
|
---|
[75d6d1c] | 98 | ${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[3cb4ef5b] | 99 | @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
|
---|
[2758d94] | 100 | @ : > envars
|
---|
[fe30c61] | 101 | EOF
|
---|
| 102 | ) >> $MKFILE.tmp
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | #=======================
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | #======== UNPACK =======
|
---|
| 109 |
|
---|
| 110 | #----------------------------------#
|
---|
| 111 | LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
| 112 | #----------------------------------#
|
---|
[0722dde] | 113 | local FILE="$1"
|
---|
| 114 | local optSAVE_PREVIOUS="$2"
|
---|
| 115 | local version
|
---|
| 116 | if [ "$3" != "" ]; then
|
---|
| 117 | version=-"$3"
|
---|
| 118 | fi
|
---|
[fe30c61] | 119 |
|
---|
| 120 | if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
|
---|
| 121 | (
|
---|
| 122 | cat << EOF
|
---|
| 123 | @\$(call remove_existing_dirs,$FILE)
|
---|
| 124 | EOF
|
---|
| 125 | ) >> $MKFILE.tmp
|
---|
| 126 | fi
|
---|
| 127 |
|
---|
| 128 | (
|
---|
| 129 | cat << EOF
|
---|
[2758d94] | 130 | @\$(PRT_DU) >>logs/\$@$version
|
---|
[fe30c61] | 131 | @\$(call unpack,$FILE)
|
---|
| 132 | @\$(call get_pkg_root_LUSER)
|
---|
| 133 | EOF
|
---|
| 134 | ) >> $MKFILE.tmp
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | #----------------------------------#
|
---|
| 138 | CHROOT_Unpack() { #
|
---|
| 139 | #----------------------------------#
|
---|
| 140 | local FILE=$1
|
---|
| 141 | local optSAVE_PREVIOUS=$2
|
---|
[0722dde] | 142 | local version
|
---|
| 143 | if [ "$3" != "" ]; then
|
---|
| 144 | version=-"$3"
|
---|
| 145 | fi
|
---|
[fe30c61] | 146 |
|
---|
| 147 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 148 | (
|
---|
| 149 | cat << EOF
|
---|
| 150 | @\$(call remove_existing_dirs2,$FILE)
|
---|
| 151 | EOF
|
---|
| 152 | ) >> $MKFILE.tmp
|
---|
| 153 | fi
|
---|
[2758d94] | 154 |
|
---|
[fe30c61] | 155 | (
|
---|
[2758d94] | 156 | cat << EOF
|
---|
| 157 | @\$(PRT_DU_CR) >>logs/\$@$version
|
---|
[1f81129] | 158 | @\$(call unpack2,$FILE)
|
---|
[fe30c61] | 159 | @\$(call get_pkg_root2)
|
---|
| 160 | EOF
|
---|
| 161 | ) >> $MKFILE.tmp
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | #=======================
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 | #===== TESTS LOGS ======
|
---|
| 168 |
|
---|
| 169 | #----------------------------------#
|
---|
| 170 | LUSER_wrt_test_log() { # Initialize testsuite log file
|
---|
| 171 | #----------------------------------#
|
---|
[3cb4ef5b] | 172 | local version
|
---|
| 173 | if [ "$2" != "" ]; then
|
---|
| 174 | version=-$2
|
---|
| 175 | fi
|
---|
| 176 | local TESTLOGFILE=$1$version
|
---|
[fe30c61] | 177 | (
|
---|
| 178 | cat << EOF
|
---|
[6bb080e] | 179 | @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[3cb4ef5b] | 180 | echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/$TESTLOGFILE
|
---|
[fe30c61] | 181 | EOF
|
---|
| 182 | ) >> $MKFILE.tmp
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | #----------------------------------#
|
---|
| 186 | CHROOT_wrt_test_log() { #
|
---|
| 187 | #----------------------------------#
|
---|
[3cb4ef5b] | 188 | local version
|
---|
| 189 | if [ "$2" != "" ]; then
|
---|
| 190 | version=-$2
|
---|
| 191 | fi
|
---|
| 192 | local TESTLOGFILE=$1$version
|
---|
[fe30c61] | 193 | (
|
---|
| 194 | cat << EOF
|
---|
[8f2c086] | 195 | @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[3cb4ef5b] | 196 | echo "\$(nl_)\`date\`\$(nl_)" >\$(crTESTLOGDIR)/$TESTLOGFILE
|
---|
[fe30c61] | 197 | EOF
|
---|
| 198 | ) >> $MKFILE.tmp
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | #=======================
|
---|
| 202 |
|
---|
| 203 |
|
---|
| 204 | #======== RUN AS =======
|
---|
| 205 |
|
---|
| 206 | #----------------------------------#
|
---|
| 207 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 208 | #----------------------------------#
|
---|
| 209 | local MOUNT_ENV
|
---|
[3cb4ef5b] | 210 | local version
|
---|
| 211 | if [ "$2" != "" ]; then
|
---|
| 212 | version=-$2
|
---|
| 213 | fi
|
---|
[8f2c086] | 214 | local file=$1
|
---|
[fe30c61] | 215 |
|
---|
| 216 | (
|
---|
| 217 | cat << EOF
|
---|
[0fa52f2] | 218 | @export LFS=\$(MOUNT_PT) && \\
|
---|
[2bd2fb8] | 219 | $COMMANDS/`dirname $file`/\$@ >>logs/\$@$version 2>&1
|
---|
[fe30c61] | 220 | EOF
|
---|
| 221 | ) >> $MKFILE.tmp
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 | #----------------------------------#
|
---|
[0210014] | 225 | LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
|
---|
[fe30c61] | 226 | #----------------------------------#
|
---|
| 227 | local file=$1
|
---|
[3cb4ef5b] | 228 | local version
|
---|
| 229 | if [ "$2" != "" ]; then
|
---|
| 230 | version=-$2
|
---|
| 231 | fi
|
---|
[fe30c61] | 232 |
|
---|
| 233 | (
|
---|
| 234 | cat << EOF
|
---|
[68713c9] | 235 | @source ~/.bashrc && \\
|
---|
[924a237] | 236 | \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1
|
---|
[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 && \\
|
---|
[924a237] | 252 | \$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1
|
---|
[fe30c61] | 253 | EOF
|
---|
| 254 | ) >> $MKFILE.tmp
|
---|
| 255 |
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | #=======================
|
---|
| 259 |
|
---|
| 260 |
|
---|
| 261 | #====== COPY FSTAB =====
|
---|
| 262 |
|
---|
| 263 | #----------------------------------#
|
---|
| 264 | LUSER_wrt_CopyFstab() { #
|
---|
| 265 | #----------------------------------#
|
---|
| 266 | (
|
---|
| 267 | cat << EOF
|
---|
[68713c9] | 268 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 269 | \$(PRT_DU) >>logs/\$@
|
---|
[fe30c61] | 270 | EOF
|
---|
| 271 | ) >> $MKFILE.tmp
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | #----------------------------------#
|
---|
| 275 | CHROOT_wrt_CopyFstab() { #
|
---|
| 276 | #----------------------------------#
|
---|
| 277 | (
|
---|
| 278 | cat << EOF
|
---|
[68713c9] | 279 | @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
|
---|
[0210014] | 280 | \$(PRT_DU_CR) >>logs/\$@
|
---|
[fe30c61] | 281 | EOF
|
---|
| 282 | ) >> $MKFILE.tmp
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | #=======================
|
---|
| 286 |
|
---|
| 287 |
|
---|
[93346ee] | 288 | #==== INSTALLED FILES LOGS ====
|
---|
| 289 |
|
---|
[f546320] | 290 | #----------------------------------#
|
---|
| 291 | LUSER_wrt_TouchTimestamp() { #
|
---|
| 292 | #----------------------------------#
|
---|
| 293 | (
|
---|
| 294 | cat << EOF
|
---|
| 295 | @\$(call touch_timestamp_LUSER)
|
---|
| 296 | EOF
|
---|
| 297 | ) >> $MKFILE.tmp
|
---|
| 298 | }
|
---|
| 299 |
|
---|
[93346ee] | 300 | #----------------------------------#
|
---|
| 301 | CHROOT_wrt_TouchTimestamp() { #
|
---|
| 302 | #----------------------------------#
|
---|
| 303 | (
|
---|
| 304 | cat << EOF
|
---|
| 305 | @\$(call touch_timestamp)
|
---|
| 306 | EOF
|
---|
| 307 | ) >> $MKFILE.tmp
|
---|
| 308 | }
|
---|
| 309 |
|
---|
[f546320] | 310 | #----------------------------------#
|
---|
| 311 | LUSER_wrt_LogNewFiles() { #
|
---|
| 312 | #----------------------------------#
|
---|
| 313 | (
|
---|
| 314 | cat << EOF
|
---|
[13e52a5] | 315 | @\$(call log_new_files_LUSER,$1)
|
---|
[f546320] | 316 | EOF
|
---|
| 317 | ) >> $MKFILE.tmp
|
---|
| 318 | }
|
---|
| 319 |
|
---|
[93346ee] | 320 | #----------------------------------#
|
---|
| 321 | CHROOT_wrt_LogNewFiles() { #
|
---|
| 322 | #----------------------------------#
|
---|
| 323 | (
|
---|
| 324 | cat << EOF
|
---|
[13e52a5] | 325 | @\$(call log_new_files,$1)
|
---|
[93346ee] | 326 | EOF
|
---|
| 327 | ) >> $MKFILE.tmp
|
---|
| 328 | }
|
---|
| 329 |
|
---|
| 330 | #=======================
|
---|
| 331 |
|
---|
| 332 |
|
---|
[fe30c61] | 333 | #==== RM BUILD DIRS ====
|
---|
| 334 |
|
---|
| 335 | #----------------------------------#
|
---|
| 336 | LUSER_RemoveBuildDirs() { #
|
---|
| 337 | #----------------------------------#
|
---|
[e639536] | 338 | local name=`echo ${1} | sed 's/[0-9]-//'`
|
---|
[fe30c61] | 339 | (
|
---|
| 340 | cat << EOF
|
---|
| 341 | @\$(call remove_build_dirs,$name)
|
---|
| 342 | EOF
|
---|
| 343 | ) >> $MKFILE.tmp
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | #----------------------------------#
|
---|
| 347 | CHROOT_wrt_RemoveBuildDirs() { #
|
---|
| 348 | #----------------------------------#
|
---|
[e639536] | 349 | local name=`echo ${1} | sed 's/[0-9]-//'`
|
---|
[fe30c61] | 350 | (
|
---|
| 351 | cat << EOF
|
---|
| 352 | @\$(call remove_build_dirs2,$name)
|
---|
| 353 | EOF
|
---|
| 354 | ) >> $MKFILE.tmp
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | #=======================
|
---|
| 358 |
|
---|
| 359 |
|
---|
| 360 | #======== TOUCH ========
|
---|
| 361 |
|
---|
| 362 | #----------------------------------#
|
---|
| 363 | wrt_touch() { #
|
---|
| 364 | #----------------------------------#
|
---|
| 365 | (
|
---|
| 366 | cat << EOF
|
---|
| 367 | @\$(call housekeeping)
|
---|
| 368 | EOF
|
---|
| 369 | ) >> $MKFILE.tmp
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | #=======================
|
---|