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
RevLine 
[fe30c61]1#!/bin/bash
2
3# $Id$
4
5#=== MAKEFILE HEADER ===
6
[195ed9f]7#----------------------------------#
8wrt_Makefile_header() { #
9#----------------------------------#
10(
11 cat << EOF
12# This file is automatically generated by jhalfs
[fe30c61]13# DO NOT EDIT THIS FILE MANUALLY
14#
[195ed9f]15# Generated on `date "+%F %X %Z"`
16
[aec4483]17
18SHELL = /bin/bash
[195ed9f]19
20SRC = /sources
21MOUNT_PT = $BUILDDIR
22PKG_LST = $PKG_LST
23LUSER = $LUSER
24LGROUP = $LGROUP
[962793a]25LHOME = $LHOME
[195ed9f]26SCRIPT_ROOT = $SCRIPT_ROOT
27
28BASEDIR = \$(MOUNT_PT)
29SRCSDIR = \$(BASEDIR)/sources
30CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
[93346ee]31LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
32TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
[195ed9f]33
34crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
[93346ee]35crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
36crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
37crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
[195ed9f]38
39SU_LUSER = su - \$(LUSER) -c
[962793a]40LUSER_HOME = \$(LHOME)/\$(LUSER)
[195ed9f]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
[3e7ceed]44ADD_REPORT = $REPORT
45ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
46ADD_BLFS_TOOLS = $BLFS_TOOL
[1838bc7]47
48
[195ed9f]49export PATH := \${PATH}:/usr/sbin
50
51include makefile-functions
52
53EOF
54) > $MKFILE
55}
[fe30c61]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 ;;
[7214dad]73 powerpc-utils) echo $(grep "^powerpc-utils" $JHALFSDIR/pkg_tarball_list | head -n1 )
74 ;;
[3c38ab0]75 uClibc)
76 if [[ "${PROGNAME}" = "clfs3" ]]; then
77 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]78 else
[3c38ab0]79 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]80 fi
81 ;;
[fe30c61]82 linux-headers)
[31a37db]83 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] || [[ "${PROGNAME}" = "clfs" ]]; then
[fe30c61]84 # Uses kernel headers directly
85 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
86 else
[31a37db]87 # CLFS{2,3} use massaged headers package
[fe30c61]88 echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
89 fi
90 ;;
[d8006a00]91 expect) echo $(grep "^expect" $JHALFSDIR/pkg_tarball_list | head -n1 )
92 ;;
[fe30c61]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)
[75d6d1c]114${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[fe30c61]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)
[75d6d1c]131${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[6bb080e]132 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
133 @\$(PRT_DU_CR) >>logs/\$@
[fe30c61]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
[1f81129]180 @\$(call unpack2,$FILE)
[fe30c61]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
[6bb080e]197 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[10c8b78]198 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/\$@
[fe30c61]199EOF
200) >> $MKFILE.tmp
201}
202
203#----------------------------------#
204CHROOT_wrt_test_log() { #
205#----------------------------------#
206 local TESTLOGFILE=$1
207(
208cat << EOF
[8f2c086]209 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[6bb080e]210 echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
[fe30c61]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
[8f2c086]224 local file=$1
[fe30c61]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
[68713c9]237 @export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
[0210014]238 ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
[fe30c61]239 \$(PRT_DU) >>logs/\$@
240EOF
241) >> $MKFILE.tmp
242}
243
244#----------------------------------#
[0210014]245LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
[fe30c61]246#----------------------------------#
247 local file=$1
248
249(
250cat << EOF
[68713c9]251 @source ~/.bashrc && \\
[0210014]252 \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1 && \\
253 \$(PRT_DU) >>logs/\$@
[fe30c61]254EOF
255) >> $MKFILE.tmp
256}
257
258#----------------------------------#
259CHROOT_wrt_RunAsRoot() { #
260#----------------------------------#
261 local file=$1
262(
263cat << EOF
[68713c9]264 @source envars && \\
[0210014]265 \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
[fe30c61]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
[68713c9]282 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]283 \$(PRT_DU) >>logs/\$@
[fe30c61]284EOF
285) >> $MKFILE.tmp
286}
287
288#----------------------------------#
289CHROOT_wrt_CopyFstab() { #
290#----------------------------------#
291(
292cat << EOF
[68713c9]293 @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]294 \$(PRT_DU_CR) >>logs/\$@
[fe30c61]295EOF
296) >> $MKFILE.tmp
297}
298
299#=======================
300
301
[93346ee]302#==== INSTALLED FILES LOGS ====
303
[f546320]304#----------------------------------#
305LUSER_wrt_TouchTimestamp() { #
306#----------------------------------#
307(
308cat << EOF
309 @\$(call touch_timestamp_LUSER)
310EOF
311) >> $MKFILE.tmp
312}
313
[93346ee]314#----------------------------------#
315CHROOT_wrt_TouchTimestamp() { #
316#----------------------------------#
317(
318cat << EOF
319 @\$(call touch_timestamp)
320EOF
321) >> $MKFILE.tmp
322}
323
[f546320]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
[93346ee]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
[fe30c61]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.