source: common/libs/func_wrt_Makefile@ d8006a00

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since d8006a00 was d8006a00, checked in by Matthew Burgess <matthew@…>, 14 years ago

Fix Expect tarball name detection for Expect 5.45.

  • Property mode set to 100644
File size: 8.3 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 powerpc-utils) echo $(grep "^powerpc-utils" $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" ]] || [[ "${PROGNAME}" = "clfs" ]]; 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 expect) echo $(grep "^expect" $JHALFSDIR/pkg_tarball_list | head -n1 )
92 ;;
93 *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
94 ;;
95 esac
96
97}
98
99#=======================
100
101
102#==== TARGET HEADER ====
103
104#----------------------------------#
105LUSER_wrt_target() { # Create target and initialize log file
106#----------------------------------#
107 local i=$1
108 local PREV=$2
109(
110cat << EOF
111
112$i: $PREV
113 @\$(call echo_message, Building)
114${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
115 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
116 @\$(PRT_DU) >>logs/\$@
117EOF
118) >> $MKFILE.tmp
119}
120
121#----------------------------------#
122CHROOT_wrt_target() { # Create target and initialize log file
123#----------------------------------#
124 local i=$1
125 local PREV=$2
126(
127cat << EOF
128
129$i: $PREV
130 @\$(call echo_message, Building)
131${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
132 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
133 @\$(PRT_DU_CR) >>logs/\$@
134EOF
135) >> $MKFILE.tmp
136}
137
138#=======================
139
140
141#======== UNPACK =======
142
143#----------------------------------#
144LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
145#----------------------------------#
146 local FILE=$1
147 local optSAVE_PREVIOUS=$2
148
149 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
150(
151cat << EOF
152 @\$(call remove_existing_dirs,$FILE)
153EOF
154) >> $MKFILE.tmp
155 fi
156
157(
158cat << EOF
159 @\$(call unpack,$FILE)
160 @\$(call get_pkg_root_LUSER)
161EOF
162) >> $MKFILE.tmp
163}
164
165#----------------------------------#
166CHROOT_Unpack() { #
167#----------------------------------#
168 local FILE=$1
169 local optSAVE_PREVIOUS=$2
170
171 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
172(
173cat << EOF
174 @\$(call remove_existing_dirs2,$FILE)
175EOF
176) >> $MKFILE.tmp
177 fi
178(
179cat << EOF
180 @\$(call unpack2,$FILE)
181 @\$(call get_pkg_root2)
182EOF
183) >> $MKFILE.tmp
184}
185
186#=======================
187
188
189#===== TESTS LOGS ======
190
191#----------------------------------#
192LUSER_wrt_test_log() { # Initialize testsuite log file
193#----------------------------------#
194 local TESTLOGFILE=$1
195(
196cat << EOF
197 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
198 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/\$@
199EOF
200) >> $MKFILE.tmp
201}
202
203#----------------------------------#
204CHROOT_wrt_test_log() { #
205#----------------------------------#
206 local TESTLOGFILE=$1
207(
208cat << EOF
209 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
210 echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
211EOF
212) >> $MKFILE.tmp
213}
214
215#=======================
216
217
218#======== RUN AS =======
219
220#----------------------------------#
221wrt_RunAsRoot() { # Some scripts must be run as root..
222#----------------------------------#
223 local MOUNT_ENV
224 local file=$1
225
226 case ${PROGNAME} in
227 lfs ) MOUNT_ENV="LFS" ;;
228 clfs ) MOUNT_ENV="CLFS" ;;
229 clfs2 ) MOUNT_ENV="CLFS" ;;
230 clfs3 ) MOUNT_ENV="CLFS" ;;
231 hlfs ) MOUNT_ENV="HLFS" ;;
232 *) echo "undefined progname $PROGNAME"; exit 1 ;;
233 esac
234
235(
236cat << EOF
237 @export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
238 ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
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 @source ~/.bashrc && \\
252 \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1 && \\
253 \$(PRT_DU) >>logs/\$@
254EOF
255) >> $MKFILE.tmp
256}
257
258#----------------------------------#
259CHROOT_wrt_RunAsRoot() { #
260#----------------------------------#
261 local file=$1
262(
263cat << EOF
264 @source envars && \\
265 \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
266 \$(PRT_DU_CR) >>logs/\$@
267EOF
268) >> $MKFILE.tmp
269
270}
271
272#=======================
273
274
275#====== COPY FSTAB =====
276
277#----------------------------------#
278LUSER_wrt_CopyFstab() { #
279#----------------------------------#
280(
281cat << EOF
282 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
283 \$(PRT_DU) >>logs/\$@
284EOF
285) >> $MKFILE.tmp
286}
287
288#----------------------------------#
289CHROOT_wrt_CopyFstab() { #
290#----------------------------------#
291(
292cat << EOF
293 @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
294 \$(PRT_DU_CR) >>logs/\$@
295EOF
296) >> $MKFILE.tmp
297}
298
299#=======================
300
301
302#==== INSTALLED FILES LOGS ====
303
304#----------------------------------#
305LUSER_wrt_TouchTimestamp() { #
306#----------------------------------#
307(
308cat << EOF
309 @\$(call touch_timestamp_LUSER)
310EOF
311) >> $MKFILE.tmp
312}
313
314#----------------------------------#
315CHROOT_wrt_TouchTimestamp() { #
316#----------------------------------#
317(
318cat << EOF
319 @\$(call touch_timestamp)
320EOF
321) >> $MKFILE.tmp
322}
323
324#----------------------------------#
325LUSER_wrt_LogNewFiles() { #
326#----------------------------------#
327 local name=$1
328(
329cat << EOF
330 @\$(call log_new_files_LUSER,$name)
331EOF
332) >> $MKFILE.tmp
333}
334
335#----------------------------------#
336CHROOT_wrt_LogNewFiles() { #
337#----------------------------------#
338 local name=$1
339(
340cat << EOF
341 @\$(call log_new_files,$name)
342EOF
343) >> $MKFILE.tmp
344}
345
346#=======================
347
348
349#==== RM BUILD DIRS ====
350
351#----------------------------------#
352LUSER_RemoveBuildDirs() { #
353#----------------------------------#
354 local name=$1
355(
356cat << EOF
357 @\$(call remove_build_dirs,$name)
358EOF
359) >> $MKFILE.tmp
360}
361
362#----------------------------------#
363CHROOT_wrt_RemoveBuildDirs() { #
364#----------------------------------#
365 local name=$1
366(
367cat << EOF
368 @\$(call remove_build_dirs2,$name)
369EOF
370) >> $MKFILE.tmp
371}
372
373#=======================
374
375
376#======== TOUCH ========
377
378#----------------------------------#
379wrt_touch() { #
380#----------------------------------#
381(
382cat << EOF
383 @\$(call housekeeping)
384EOF
385) >> $MKFILE.tmp
386}
387
388#=======================
Note: See TracBrowser for help on using the repository browser.