source: common/libs/func_wrt_Makefile@ 5a4f6a7

experimental
Last change on this file since 5a4f6a7 was 5a4f6a7, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Revising func_wrt_Makefile

  • Property mode set to 100644
File size: 5.1 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5#=== MAKEFILE HEADER ===
6
7#----------------------------------#
8wrt_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
18SHELL = /bin/bash
19
20SRC = /sources
21MOUNT_PT = $BUILDDIR
22PKG_LST = $PKG_LST
23LUSER = $LUSER
24LGROUP = $LGROUP
25LHOME = $LHOME
26SCRIPT_ROOT = $SCRIPT_ROOT
27
28BASEDIR = \$(MOUNT_PT)
29SRCSDIR = \$(BASEDIR)/sources
30CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
31LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
32TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
33
34crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
35crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
36crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
37crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
38
39SU_LUSER = su - \$(LUSER) -c
40LUSER_HOME = \$(LHOME)/\$(LUSER)
41
42ADD_REPORT = $REPORT
43ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
44ADD_BLFS_TOOLS = $BLFS_TOOL
45
46
47export PATH := \${PATH}:/usr/sbin
48
49include makefile-functions
50
51EOF
52) > $MKFILE
53}
54
55#=======================
56
57
58#==== TARGET HEADER ====
59
60#----------------------------------#
61LUSER_wrt_target() { # Create target and initialize envars file
62#----------------------------------#
63 local i=$1
64 local PREV=$2
65(
66cat << EOF
67
68$i: $PREV
69 @\$(call echo_message, Building)
70 @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
71 @rm -f envars && touch envars
72EOF
73) >> $MKFILE.tmp
74}
75
76#----------------------------------#
77CHROOT_wrt_target() { #
78#----------------------------------#
79 local i=$1
80 local PREV=$2
81(
82cat << EOF
83
84$i: $PREV
85 @\$(call echo_message, Building)
86 @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
87 @rm -f envars && touch envars
88EOF
89) >> $MKFILE.tmp
90}
91
92#=======================
93
94
95#===== TESTS LOGS ======
96
97#----------------------------------#
98LUSER_wrt_test_log() { # Initialize testsuite log file
99#----------------------------------#
100 local TESTLOGFILE=$1
101(
102cat << EOF
103 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
104 echo "\$(nl_)\`date\`\$(nl_)" > \$(TESTLOGDIR)/\$@
105EOF
106) >> $MKFILE.tmp
107}
108
109#----------------------------------#
110CHROOT_wrt_test_log() { #
111#----------------------------------#
112 local TESTLOGFILE=$1
113(
114cat << EOF
115 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
116 echo "\$(nl_)\`date\`\$(nl_)" > test-logs/\$@
117EOF
118) >> $MKFILE.tmp
119}
120
121#=======================
122
123
124#======== RUN AS =======
125
126#----------------------------------#
127wrt_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(
142cat << EOF
143 @export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ > logs/\$@ 2>&1
144EOF
145) >> $MKFILE.tmp
146}
147
148#----------------------------------#
149LUSER_wrt_RunAsUser() { #
150#----------------------------------#
151 local file=$1
152
153(
154cat << EOF
155 @source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
156EOF
157) >> $MKFILE.tmp
158}
159
160#----------------------------------#
161CHROOT_wrt_RunAsRoot() { #
162#----------------------------------#
163 local file=$1
164(
165cat << EOF
166 @source envars && \$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
167EOF
168) >> $MKFILE.tmp
169
170}
171
172#=======================
173
174
175#====== COPY FSTAB =====
176
177#----------------------------------#
178LUSER_wrt_CopyFstab() { #
179#----------------------------------#
180(
181cat << EOF
182 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > logs/\$@ 2>&1
183EOF
184) >> $MKFILE.tmp
185}
186
187#----------------------------------#
188CHROOT_wrt_CopyFstab() { #
189#----------------------------------#
190(
191cat << EOF
192 @cp -v /sources/fstab /etc/fstab > logs/\$@ 2>&1
193EOF
194) >> $MKFILE.tmp
195}
196
197#=======================
198
199
200#==== INSTALLED FILES LOGS ====
201
202#----------------------------------#
203LUSER_wrt_TouchTimestamp() { #
204#----------------------------------#
205(
206cat << EOF
207 @\$(call touch_timestamp_LUSER)
208EOF
209) >> $MKFILE.tmp
210}
211
212#----------------------------------#
213CHROOT_wrt_TouchTimestamp() { #
214#----------------------------------#
215(
216cat << EOF
217 @\$(call touch_timestamp)
218EOF
219) >> $MKFILE.tmp
220}
221
222#----------------------------------#
223LUSER_wrt_LogNewFiles() { #
224#----------------------------------#
225 local name=$1
226(
227cat << EOF
228 @\$(call log_new_files_LUSER,$name)
229EOF
230) >> $MKFILE.tmp
231}
232
233#----------------------------------#
234CHROOT_wrt_LogNewFiles() { #
235#----------------------------------#
236 local name=$1
237(
238cat << EOF
239 @\$(call log_new_files,$name)
240EOF
241) >> $MKFILE.tmp
242}
243
244#=======================
245
246
247#======== TOUCH ========
248
249#----------------------------------#
250wrt_touch() { #
251#----------------------------------#
252(
253cat << EOF
254 @\$(call housekeeping)
255EOF
256) >> $MKFILE.tmp
257}
258
259#=======================
Note: See TracBrowser for help on using the repository browser.