source: common/libs/func_wrt_Makefile@ d035526

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

Ported INSTALL_LOG support to all books.

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