source: common/libs/func_wrt_Makefile@ 93346ee

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 93346ee was 93346ee, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

LFS: Added support for installed files logs.
Should be ported to other books when verified that works as expected.

  • Property mode set to 100644
File size: 7.8 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)
41PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
42PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found / \`\n"
43
44ADD_REPORT = $REPORT
45ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
46ADD_BLFS_TOOLS = $BLFS_TOOL
47
48
49export PATH := \${PATH}:/usr/sbin
50
51include makefile-functions
52
53EOF
54) > $MKFILE
55}
56
57#=======================
58
59
60#==== PACKAGES NAMES ===
61
62#----------------------------------#
63get_package_tarball_name() { #
64#----------------------------------#
65 local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
66
67 # The use of 'head' is necessary to limit the return value to the FIRST match..
68 # hopefully this will not cause problems.
69 #
70 case $script_name in
71 tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
72 ;;
73 uClibc)
74 if [[ "${PROGNAME}" = "clfs3" ]]; then
75 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
76 else
77 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
78 fi
79 ;;
80 linux-headers)
81 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] ; then
82 # Uses kernel headers directly
83 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
84 else
85 # CLFS{,2,3} use massaged headers package
86 echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
87 fi
88 ;;
89 *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
90 ;;
91 esac
92
93}
94
95#=======================
96
97
98#==== TARGET HEADER ====
99
100#----------------------------------#
101LUSER_wrt_target() { # Create target and initialize log file
102#----------------------------------#
103 local i=$1
104 local PREV=$2
105(
106cat << EOF
107
108$i: $PREV
109 @\$(call echo_message, Building)
110 @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
111 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
112 @\$(PRT_DU) >>logs/\$@
113EOF
114) >> $MKFILE.tmp
115}
116
117#----------------------------------#
118CHROOT_wrt_target() { # Create target and initialize log file
119#----------------------------------#
120 local i=$1
121 local PREV=$2
122(
123cat << EOF
124
125$i: $PREV
126 @\$(call echo_message, Building)
127 @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
128 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
129 @\$(PRT_DU_CR) >>logs/\$@
130EOF
131) >> $MKFILE.tmp
132}
133
134#=======================
135
136
137#======== UNPACK =======
138
139#----------------------------------#
140LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
141#----------------------------------#
142 local FILE=$1
143 local optSAVE_PREVIOUS=$2
144
145 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
146(
147cat << EOF
148 @\$(call remove_existing_dirs,$FILE)
149EOF
150) >> $MKFILE.tmp
151 fi
152
153(
154cat << EOF
155 @\$(call unpack,$FILE)
156 @\$(call get_pkg_root_LUSER)
157EOF
158) >> $MKFILE.tmp
159}
160
161#----------------------------------#
162CHROOT_Unpack() { #
163#----------------------------------#
164 local FILE=$1
165 local optSAVE_PREVIOUS=$2
166
167 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
168(
169cat << EOF
170 @\$(call remove_existing_dirs2,$FILE)
171EOF
172) >> $MKFILE.tmp
173 fi
174(
175cat << EOF
176 @\$(call unpack2,$FILE)
177 @\$(call get_pkg_root2)
178EOF
179) >> $MKFILE.tmp
180}
181
182#=======================
183
184
185#===== TESTS LOGS ======
186
187#----------------------------------#
188LUSER_wrt_test_log() { # Initialize testsuite log file
189#----------------------------------#
190 local TESTLOGFILE=$1
191(
192cat << EOF
193 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
194 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/\$@
195EOF
196) >> $MKFILE.tmp
197}
198
199#----------------------------------#
200CHROOT_wrt_test_log() { #
201#----------------------------------#
202 local TESTLOGFILE=$1
203(
204cat << EOF
205 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
206 echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
207EOF
208) >> $MKFILE.tmp
209}
210
211#=======================
212
213
214#======== RUN AS =======
215
216#----------------------------------#
217wrt_RunAsRoot() { # Some scripts must be run as root..
218#----------------------------------#
219 local MOUNT_ENV
220 local file=$1
221
222 case ${PROGNAME} in
223 lfs ) MOUNT_ENV="LFS" ;;
224 clfs ) MOUNT_ENV="CLFS" ;;
225 clfs2 ) MOUNT_ENV="CLFS" ;;
226 clfs3 ) MOUNT_ENV="CLFS" ;;
227 hlfs ) MOUNT_ENV="HLFS" ;;
228 *) echo "undefined progname $PROGNAME"; exit 1 ;;
229 esac
230
231(
232cat << EOF
233 @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
234 \$(PRT_DU) >>logs/\$@
235EOF
236) >> $MKFILE.tmp
237}
238
239#----------------------------------#
240LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
241#----------------------------------#
242 local file=$1
243
244(
245cat << EOF
246 @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
247 \$(PRT_DU) >> logs/\$@
248EOF
249) >> $MKFILE.tmp
250}
251
252#----------------------------------#
253CHROOT_wrt_RunAsRoot() { #
254#----------------------------------#
255 local file=$1
256(
257cat << EOF
258 @( time { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
259 \$(PRT_DU_CR) >>logs/\$@
260EOF
261) >> $MKFILE.tmp
262
263}
264
265#=======================
266
267
268#====== COPY FSTAB =====
269
270#----------------------------------#
271LUSER_wrt_CopyFstab() { #
272#----------------------------------#
273(
274cat << EOF
275 @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
276EOF
277) >> $MKFILE.tmp
278}
279
280#----------------------------------#
281CHROOT_wrt_CopyFstab() { #
282#----------------------------------#
283(
284cat << EOF
285 @( time { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
286EOF
287) >> $MKFILE.tmp
288}
289
290#=======================
291
292
293#==== INSTALLED FILES LOGS ====
294
295#----------------------------------#
296CHROOT_wrt_TouchTimestamp() { #
297#----------------------------------#
298 local name=$1
299(
300cat << EOF
301 @\$(call touch_timestamp)
302EOF
303) >> $MKFILE.tmp
304}
305
306#----------------------------------#
307CHROOT_wrt_LogNewFiles() { #
308#----------------------------------#
309 local name=$1
310(
311cat << EOF
312 @\$(call log_new_files,$name)
313EOF
314) >> $MKFILE.tmp
315}
316
317#=======================
318
319
320#==== RM BUILD DIRS ====
321
322#----------------------------------#
323LUSER_RemoveBuildDirs() { #
324#----------------------------------#
325 local name=$1
326(
327cat << EOF
328 @\$(call remove_build_dirs,$name)
329EOF
330) >> $MKFILE.tmp
331}
332
333#----------------------------------#
334CHROOT_wrt_RemoveBuildDirs() { #
335#----------------------------------#
336 local name=$1
337(
338cat << EOF
339 @\$(call remove_build_dirs2,$name)
340EOF
341) >> $MKFILE.tmp
342}
343
344#=======================
345
346
347#======== TOUCH ========
348
349#----------------------------------#
350wrt_touch() { #
351#----------------------------------#
352(
353cat << EOF
354 @\$(call housekeeping)
355EOF
356) >> $MKFILE.tmp
357}
358
359#=======================
Note: See TracBrowser for help on using the repository browser.