[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 | LUSER = $LUSER
|
---|
| 23 | LGROUP = $LGROUP
|
---|
| 24 | LHOME = $LHOME
|
---|
| 25 | SCRIPT_ROOT = $SCRIPT_ROOT
|
---|
| 26 |
|
---|
| 27 | BASEDIR = \$(MOUNT_PT)
|
---|
| 28 | SRCSDIR = \$(BASEDIR)/sources
|
---|
| 29 | CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
|
---|
| 30 | LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 31 | TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
| 32 |
|
---|
| 33 | crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
|
---|
| 34 | crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
|
---|
| 35 | crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
---|
| 36 | crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
|
---|
| 37 |
|
---|
| 38 | SU_LUSER = su - \$(LUSER) -c
|
---|
| 39 | LUSER_HOME = \$(LHOME)/\$(LUSER)
|
---|
| 40 |
|
---|
| 41 | ADD_REPORT = $REPORT
|
---|
| 42 | ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
|
---|
| 43 | ADD_BLFS_TOOLS = $BLFS_TOOL
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | export PATH := \${PATH}:/usr/sbin
|
---|
| 47 |
|
---|
| 48 | include makefile-functions
|
---|
| 49 |
|
---|
| 50 | EOF
|
---|
| 51 | ) > $MKFILE
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | #=======================
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | #==== TARGET HEADER ====
|
---|
| 58 |
|
---|
| 59 | #----------------------------------#
|
---|
[f5f857d] | 60 | LUSER_wrt_target() { # Create target
|
---|
[9c9775f] | 61 | #----------------------------------#
|
---|
| 62 | local i=$1
|
---|
| 63 | local PREV=$2
|
---|
| 64 | (
|
---|
| 65 | cat << EOF
|
---|
| 66 |
|
---|
| 67 | $i: $PREV
|
---|
| 68 | @\$(call echo_message, Building)
|
---|
| 69 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
| 70 | EOF
|
---|
| 71 | ) >> $MKFILE.tmp
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | #----------------------------------#
|
---|
[5a4f6a7] | 75 | CHROOT_wrt_target() { #
|
---|
[9c9775f] | 76 | #----------------------------------#
|
---|
| 77 | local i=$1
|
---|
| 78 | local PREV=$2
|
---|
| 79 | (
|
---|
| 80 | cat << EOF
|
---|
| 81 |
|
---|
| 82 | $i: $PREV
|
---|
| 83 | @\$(call echo_message, Building)
|
---|
| 84 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
| 85 | EOF
|
---|
| 86 | ) >> $MKFILE.tmp
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | #=======================
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | #======== RUN AS =======
|
---|
| 93 |
|
---|
| 94 | #----------------------------------#
|
---|
| 95 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
| 96 | #----------------------------------#
|
---|
| 97 | local MOUNT_ENV
|
---|
| 98 | local file=$1
|
---|
| 99 |
|
---|
| 100 | case ${PROGNAME} in
|
---|
| 101 | lfs ) MOUNT_ENV="LFS" ;;
|
---|
| 102 | clfs ) MOUNT_ENV="CLFS" ;;
|
---|
| 103 | clfs2 ) MOUNT_ENV="CLFS" ;;
|
---|
| 104 | clfs3 ) MOUNT_ENV="CLFS" ;;
|
---|
| 105 | hlfs ) MOUNT_ENV="HLFS" ;;
|
---|
| 106 | *) echo "undefined progname $PROGNAME"; exit 1 ;;
|
---|
| 107 | esac
|
---|
| 108 |
|
---|
| 109 | (
|
---|
| 110 | cat << EOF
|
---|
[111d25a] | 111 | @export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
|
---|
[9c9775f] | 112 | EOF
|
---|
| 113 | ) >> $MKFILE.tmp
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | #----------------------------------#
|
---|
[5a4f6a7] | 117 | LUSER_wrt_RunAsUser() { #
|
---|
[9c9775f] | 118 | #----------------------------------#
|
---|
| 119 | local file=$1
|
---|
| 120 |
|
---|
| 121 | (
|
---|
| 122 | cat << EOF
|
---|
[111d25a] | 123 | @\$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
|
---|
[9c9775f] | 124 | EOF
|
---|
| 125 | ) >> $MKFILE.tmp
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | #----------------------------------#
|
---|
| 129 | CHROOT_wrt_RunAsRoot() { #
|
---|
| 130 | #----------------------------------#
|
---|
| 131 | local file=$1
|
---|
| 132 | (
|
---|
| 133 | cat << EOF
|
---|
[111d25a] | 134 | @\$(crCMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
|
---|
[9c9775f] | 135 | EOF
|
---|
| 136 | ) >> $MKFILE.tmp
|
---|
| 137 |
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | #=======================
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | #====== COPY FSTAB =====
|
---|
| 144 |
|
---|
| 145 | #----------------------------------#
|
---|
| 146 | LUSER_wrt_CopyFstab() { #
|
---|
| 147 | #----------------------------------#
|
---|
| 148 | (
|
---|
| 149 | cat << EOF
|
---|
[111d25a] | 150 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > $LOGDIRBASE/\$@ 2>&1
|
---|
[9c9775f] | 151 | EOF
|
---|
| 152 | ) >> $MKFILE.tmp
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | #----------------------------------#
|
---|
| 156 | CHROOT_wrt_CopyFstab() { #
|
---|
| 157 | #----------------------------------#
|
---|
| 158 | (
|
---|
| 159 | cat << EOF
|
---|
[111d25a] | 160 | @cp -v /sources/fstab /etc/fstab > $LOGDIRBASE/\$@ 2>&1
|
---|
[9c9775f] | 161 | EOF
|
---|
| 162 | ) >> $MKFILE.tmp
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | #=======================
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | #==== INSTALLED FILES LOGS ====
|
---|
| 169 |
|
---|
| 170 | #----------------------------------#
|
---|
| 171 | LUSER_wrt_TouchTimestamp() { #
|
---|
| 172 | #----------------------------------#
|
---|
| 173 | (
|
---|
| 174 | cat << EOF
|
---|
| 175 | @\$(call touch_timestamp_LUSER)
|
---|
| 176 | EOF
|
---|
| 177 | ) >> $MKFILE.tmp
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | #----------------------------------#
|
---|
| 181 | CHROOT_wrt_TouchTimestamp() { #
|
---|
| 182 | #----------------------------------#
|
---|
| 183 | (
|
---|
| 184 | cat << EOF
|
---|
| 185 | @\$(call touch_timestamp)
|
---|
| 186 | EOF
|
---|
| 187 | ) >> $MKFILE.tmp
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | #----------------------------------#
|
---|
| 191 | LUSER_wrt_LogNewFiles() { #
|
---|
| 192 | #----------------------------------#
|
---|
| 193 | local name=$1
|
---|
| 194 | (
|
---|
| 195 | cat << EOF
|
---|
| 196 | @\$(call log_new_files_LUSER,$name)
|
---|
| 197 | EOF
|
---|
| 198 | ) >> $MKFILE.tmp
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | #----------------------------------#
|
---|
| 202 | CHROOT_wrt_LogNewFiles() { #
|
---|
| 203 | #----------------------------------#
|
---|
| 204 | local name=$1
|
---|
| 205 | (
|
---|
| 206 | cat << EOF
|
---|
| 207 | @\$(call log_new_files,$name)
|
---|
| 208 | EOF
|
---|
| 209 | ) >> $MKFILE.tmp
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | #=======================
|
---|
| 213 |
|
---|
| 214 |
|
---|
| 215 | #======== TOUCH ========
|
---|
| 216 |
|
---|
| 217 | #----------------------------------#
|
---|
| 218 | wrt_touch() { #
|
---|
| 219 | #----------------------------------#
|
---|
| 220 | (
|
---|
| 221 | cat << EOF
|
---|
| 222 | @\$(call housekeeping)
|
---|
| 223 | EOF
|
---|
| 224 | ) >> $MKFILE.tmp
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | #=======================
|
---|