source: common/libs/func_wrt_Makefile@ 9bbf240

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

Ported CUSTOM_TOOLS support to all books.

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