source: common/libs/func_wrt_Makefile@ fe30c61

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

Splitted common-functions.

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