[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 | #----------------------------------#
|
---|
[f5f857d] | 61 | LUSER_wrt_target() { # Create target
|
---|
[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 &
|
---|
| 71 | EOF
|
---|
| 72 | ) >> $MKFILE.tmp
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | #----------------------------------#
|
---|
[5a4f6a7] | 76 | CHROOT_wrt_target() { #
|
---|
[9c9775f] | 77 | #----------------------------------#
|
---|
| 78 | local i=$1
|
---|
| 79 | local PREV=$2
|
---|
| 80 | (
|
---|
| 81 | cat << EOF
|
---|
| 82 |
|
---|
| 83 | $i: $PREV
|
---|
| 84 | @\$(call echo_message, Building)
|
---|
| 85 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
| 86 | EOF
|
---|
| 87 | ) >> $MKFILE.tmp
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | #=======================
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | #======== RUN AS =======
|
---|
| 94 |
|
---|
| 95 | #----------------------------------#
|
---|
| 96 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 97 | #----------------------------------#
|
---|
| 98 | local MOUNT_ENV
|
---|
| 99 | local file=$1
|
---|
| 100 |
|
---|
| 101 | case ${PROGNAME} in
|
---|
| 102 | lfs ) MOUNT_ENV="LFS" ;;
|
---|
| 103 | clfs ) MOUNT_ENV="CLFS" ;;
|
---|
| 104 | clfs2 ) MOUNT_ENV="CLFS" ;;
|
---|
| 105 | clfs3 ) MOUNT_ENV="CLFS" ;;
|
---|
| 106 | hlfs ) MOUNT_ENV="HLFS" ;;
|
---|
| 107 | *) echo "undefined progname $PROGNAME"; exit 1 ;;
|
---|
| 108 | esac
|
---|
| 109 |
|
---|
| 110 | (
|
---|
| 111 | cat << EOF
|
---|
[5a4f6a7] | 112 | @export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ > logs/\$@ 2>&1
|
---|
[9c9775f] | 113 | EOF
|
---|
| 114 | ) >> $MKFILE.tmp
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | #----------------------------------#
|
---|
[5a4f6a7] | 118 | LUSER_wrt_RunAsUser() { #
|
---|
[9c9775f] | 119 | #----------------------------------#
|
---|
| 120 | local file=$1
|
---|
| 121 |
|
---|
| 122 | (
|
---|
| 123 | cat << EOF
|
---|
[f5f857d] | 124 | @\$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
|
---|
[9c9775f] | 125 | EOF
|
---|
| 126 | ) >> $MKFILE.tmp
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | #----------------------------------#
|
---|
| 130 | CHROOT_wrt_RunAsRoot() { #
|
---|
| 131 | #----------------------------------#
|
---|
| 132 | local file=$1
|
---|
| 133 | (
|
---|
| 134 | cat << EOF
|
---|
[f5f857d] | 135 | @\$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
|
---|
[9c9775f] | 136 | EOF
|
---|
| 137 | ) >> $MKFILE.tmp
|
---|
| 138 |
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | #=======================
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | #====== COPY FSTAB =====
|
---|
| 145 |
|
---|
| 146 | #----------------------------------#
|
---|
| 147 | LUSER_wrt_CopyFstab() { #
|
---|
| 148 | #----------------------------------#
|
---|
| 149 | (
|
---|
| 150 | cat << EOF
|
---|
[5a4f6a7] | 151 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > logs/\$@ 2>&1
|
---|
[9c9775f] | 152 | EOF
|
---|
| 153 | ) >> $MKFILE.tmp
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | #----------------------------------#
|
---|
| 157 | CHROOT_wrt_CopyFstab() { #
|
---|
| 158 | #----------------------------------#
|
---|
| 159 | (
|
---|
| 160 | cat << EOF
|
---|
[5a4f6a7] | 161 | @cp -v /sources/fstab /etc/fstab > logs/\$@ 2>&1
|
---|
[9c9775f] | 162 | EOF
|
---|
| 163 | ) >> $MKFILE.tmp
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | #=======================
|
---|
| 167 |
|
---|
| 168 |
|
---|
| 169 | #==== INSTALLED FILES LOGS ====
|
---|
| 170 |
|
---|
| 171 | #----------------------------------#
|
---|
| 172 | LUSER_wrt_TouchTimestamp() { #
|
---|
| 173 | #----------------------------------#
|
---|
| 174 | (
|
---|
| 175 | cat << EOF
|
---|
| 176 | @\$(call touch_timestamp_LUSER)
|
---|
| 177 | EOF
|
---|
| 178 | ) >> $MKFILE.tmp
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | #----------------------------------#
|
---|
| 182 | CHROOT_wrt_TouchTimestamp() { #
|
---|
| 183 | #----------------------------------#
|
---|
| 184 | (
|
---|
| 185 | cat << EOF
|
---|
| 186 | @\$(call touch_timestamp)
|
---|
| 187 | EOF
|
---|
| 188 | ) >> $MKFILE.tmp
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | #----------------------------------#
|
---|
| 192 | LUSER_wrt_LogNewFiles() { #
|
---|
| 193 | #----------------------------------#
|
---|
| 194 | local name=$1
|
---|
| 195 | (
|
---|
| 196 | cat << EOF
|
---|
| 197 | @\$(call log_new_files_LUSER,$name)
|
---|
| 198 | EOF
|
---|
| 199 | ) >> $MKFILE.tmp
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | #----------------------------------#
|
---|
| 203 | CHROOT_wrt_LogNewFiles() { #
|
---|
| 204 | #----------------------------------#
|
---|
| 205 | local name=$1
|
---|
| 206 | (
|
---|
| 207 | cat << EOF
|
---|
| 208 | @\$(call log_new_files,$name)
|
---|
| 209 | EOF
|
---|
| 210 | ) >> $MKFILE.tmp
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | #=======================
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | #======== TOUCH ========
|
---|
| 217 |
|
---|
| 218 | #----------------------------------#
|
---|
| 219 | wrt_touch() { #
|
---|
| 220 | #----------------------------------#
|
---|
| 221 | (
|
---|
| 222 | cat << EOF
|
---|
| 223 | @\$(call housekeeping)
|
---|
| 224 | EOF
|
---|
| 225 | ) >> $MKFILE.tmp
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | #=======================
|
---|