source: common/libs/func_wrt_Makefile@ ace8142

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

Looks like SHELL value need be exported for the progress_bar.sh test to work properly in all cases.

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