[9c9775f] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
| 5 | #=== MAKEFILE HEADER ===
|
---|
| 6 |
|
---|
| 7 | #----------------------------------#
|
---|
| 8 | wrt_Makefile_header() { #
|
---|
| 9 | #----------------------------------#
|
---|
| 10 | (
|
---|
| 11 | cat << EOF
|
---|
| 12 | # This file is automatically generated by jhalfs
|
---|
| 13 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
| 14 | #
|
---|
| 15 | # Generated on `date "+%F %X %Z"`
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | SHELL = /bin/bash
|
---|
| 19 |
|
---|
| 20 | SRC = /sources
|
---|
| 21 | MOUNT_PT = $BUILDDIR
|
---|
| 22 | PKG_LST = $PKG_LST
|
---|
| 23 | LUSER = $LUSER
|
---|
| 24 | LGROUP = $LGROUP
|
---|
| 25 | LHOME = $LHOME
|
---|
| 26 | SCRIPT_ROOT = $SCRIPT_ROOT
|
---|
| 27 |
|
---|
| 28 | BASEDIR = \$(MOUNT_PT)
|
---|
| 29 | SRCSDIR = \$(BASEDIR)/sources
|
---|
| 30 | CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
|
---|
| 31 | LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 32 | TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
| 33 |
|
---|
| 34 | crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
|
---|
| 35 | crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 36 | crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
| 37 | crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
|
---|
| 38 |
|
---|
| 39 | SU_LUSER = su - \$(LUSER) -c
|
---|
| 40 | LUSER_HOME = \$(LHOME)/\$(LUSER)
|
---|
| 41 |
|
---|
| 42 | ADD_REPORT = $REPORT
|
---|
| 43 | ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
|
---|
| 44 | ADD_BLFS_TOOLS = $BLFS_TOOL
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | export PATH := \${PATH}:/usr/sbin
|
---|
| 48 |
|
---|
| 49 | include makefile-functions
|
---|
| 50 |
|
---|
| 51 | EOF
|
---|
| 52 | ) > $MKFILE
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | #=======================
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | #==== TARGET HEADER ====
|
---|
| 59 |
|
---|
| 60 | #----------------------------------#
|
---|
[5a4f6a7] | 61 | LUSER_wrt_target() { # Create target and initialize envars file
|
---|
[9c9775f] | 62 | #----------------------------------#
|
---|
| 63 | local i=$1
|
---|
| 64 | local PREV=$2
|
---|
| 65 | (
|
---|
| 66 | cat << EOF
|
---|
| 67 |
|
---|
| 68 | $i: $PREV
|
---|
| 69 | @\$(call echo_message, Building)
|
---|
| 70 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[5a4f6a7] | 71 | @rm -f envars && touch envars
|
---|
[9c9775f] | 72 | EOF
|
---|
| 73 | ) >> $MKFILE.tmp
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | #----------------------------------#
|
---|
[5a4f6a7] | 77 | CHROOT_wrt_target() { #
|
---|
[9c9775f] | 78 | #----------------------------------#
|
---|
| 79 | local i=$1
|
---|
| 80 | local PREV=$2
|
---|
| 81 | (
|
---|
| 82 | cat << EOF
|
---|
| 83 |
|
---|
| 84 | $i: $PREV
|
---|
| 85 | @\$(call echo_message, Building)
|
---|
| 86 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
[5a4f6a7] | 87 | @rm -f envars && touch envars
|
---|
[9c9775f] | 88 | EOF
|
---|
| 89 | ) >> $MKFILE.tmp
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | #=======================
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | #===== TESTS LOGS ======
|
---|
| 96 |
|
---|
| 97 | #----------------------------------#
|
---|
| 98 | LUSER_wrt_test_log() { # Initialize testsuite log file
|
---|
| 99 | #----------------------------------#
|
---|
| 100 | local TESTLOGFILE=$1
|
---|
| 101 | (
|
---|
| 102 | cat << EOF
|
---|
| 103 | @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[5a4f6a7] | 104 | echo "\$(nl_)\`date\`\$(nl_)" > \$(TESTLOGDIR)/\$@
|
---|
[9c9775f] | 105 | EOF
|
---|
| 106 | ) >> $MKFILE.tmp
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | #----------------------------------#
|
---|
| 110 | CHROOT_wrt_test_log() { #
|
---|
| 111 | #----------------------------------#
|
---|
| 112 | local TESTLOGFILE=$1
|
---|
| 113 | (
|
---|
| 114 | cat << EOF
|
---|
| 115 | @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
---|
[5a4f6a7] | 116 | echo "\$(nl_)\`date\`\$(nl_)" > test-logs/\$@
|
---|
[9c9775f] | 117 | EOF
|
---|
| 118 | ) >> $MKFILE.tmp
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | #=======================
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | #======== RUN AS =======
|
---|
| 125 |
|
---|
| 126 | #----------------------------------#
|
---|
| 127 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 128 | #----------------------------------#
|
---|
| 129 | local MOUNT_ENV
|
---|
| 130 | local file=$1
|
---|
| 131 |
|
---|
| 132 | case ${PROGNAME} in
|
---|
| 133 | lfs ) MOUNT_ENV="LFS" ;;
|
---|
| 134 | clfs ) MOUNT_ENV="CLFS" ;;
|
---|
| 135 | clfs2 ) MOUNT_ENV="CLFS" ;;
|
---|
| 136 | clfs3 ) MOUNT_ENV="CLFS" ;;
|
---|
| 137 | hlfs ) MOUNT_ENV="HLFS" ;;
|
---|
| 138 | *) echo "undefined progname $PROGNAME"; exit 1 ;;
|
---|
| 139 | esac
|
---|
| 140 |
|
---|
| 141 | (
|
---|
| 142 | cat << EOF
|
---|
[5a4f6a7] | 143 | @export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ > logs/\$@ 2>&1
|
---|
[9c9775f] | 144 | EOF
|
---|
| 145 | ) >> $MKFILE.tmp
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | #----------------------------------#
|
---|
[5a4f6a7] | 149 | LUSER_wrt_RunAsUser() { #
|
---|
[9c9775f] | 150 | #----------------------------------#
|
---|
| 151 | local file=$1
|
---|
| 152 |
|
---|
| 153 | (
|
---|
| 154 | cat << EOF
|
---|
[5a4f6a7] | 155 | @source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
|
---|
[9c9775f] | 156 | EOF
|
---|
| 157 | ) >> $MKFILE.tmp
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | #----------------------------------#
|
---|
| 161 | CHROOT_wrt_RunAsRoot() { #
|
---|
| 162 | #----------------------------------#
|
---|
| 163 | local file=$1
|
---|
| 164 | (
|
---|
| 165 | cat << EOF
|
---|
[5a4f6a7] | 166 | @source envars && \$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
|
---|
[9c9775f] | 167 | EOF
|
---|
| 168 | ) >> $MKFILE.tmp
|
---|
| 169 |
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | #=======================
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | #====== COPY FSTAB =====
|
---|
| 176 |
|
---|
| 177 | #----------------------------------#
|
---|
| 178 | LUSER_wrt_CopyFstab() { #
|
---|
| 179 | #----------------------------------#
|
---|
| 180 | (
|
---|
| 181 | cat << EOF
|
---|
[5a4f6a7] | 182 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > logs/\$@ 2>&1
|
---|
[9c9775f] | 183 | EOF
|
---|
| 184 | ) >> $MKFILE.tmp
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | #----------------------------------#
|
---|
| 188 | CHROOT_wrt_CopyFstab() { #
|
---|
| 189 | #----------------------------------#
|
---|
| 190 | (
|
---|
| 191 | cat << EOF
|
---|
[5a4f6a7] | 192 | @cp -v /sources/fstab /etc/fstab > logs/\$@ 2>&1
|
---|
[9c9775f] | 193 | EOF
|
---|
| 194 | ) >> $MKFILE.tmp
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | #=======================
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | #==== INSTALLED FILES LOGS ====
|
---|
| 201 |
|
---|
| 202 | #----------------------------------#
|
---|
| 203 | LUSER_wrt_TouchTimestamp() { #
|
---|
| 204 | #----------------------------------#
|
---|
| 205 | (
|
---|
| 206 | cat << EOF
|
---|
| 207 | @\$(call touch_timestamp_LUSER)
|
---|
| 208 | EOF
|
---|
| 209 | ) >> $MKFILE.tmp
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | #----------------------------------#
|
---|
| 213 | CHROOT_wrt_TouchTimestamp() { #
|
---|
| 214 | #----------------------------------#
|
---|
| 215 | (
|
---|
| 216 | cat << EOF
|
---|
| 217 | @\$(call touch_timestamp)
|
---|
| 218 | EOF
|
---|
| 219 | ) >> $MKFILE.tmp
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | #----------------------------------#
|
---|
| 223 | LUSER_wrt_LogNewFiles() { #
|
---|
| 224 | #----------------------------------#
|
---|
| 225 | local name=$1
|
---|
| 226 | (
|
---|
| 227 | cat << EOF
|
---|
| 228 | @\$(call log_new_files_LUSER,$name)
|
---|
| 229 | EOF
|
---|
| 230 | ) >> $MKFILE.tmp
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | #----------------------------------#
|
---|
| 234 | CHROOT_wrt_LogNewFiles() { #
|
---|
| 235 | #----------------------------------#
|
---|
| 236 | local name=$1
|
---|
| 237 | (
|
---|
| 238 | cat << EOF
|
---|
| 239 | @\$(call log_new_files,$name)
|
---|
| 240 | EOF
|
---|
| 241 | ) >> $MKFILE.tmp
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | #=======================
|
---|
| 245 |
|
---|
| 246 |
|
---|
| 247 | #======== TOUCH ========
|
---|
| 248 |
|
---|
| 249 | #----------------------------------#
|
---|
| 250 | wrt_touch() { #
|
---|
| 251 | #----------------------------------#
|
---|
| 252 | (
|
---|
| 253 | cat << EOF
|
---|
| 254 | @\$(call housekeeping)
|
---|
| 255 | EOF
|
---|
| 256 | ) >> $MKFILE.tmp
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | #=======================
|
---|