source: common/libs/func_wrt_Makefile@ 5932971

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

More compare and related fixes.
Test build in progress.

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