source: common/libs/func_wrt_Makefile@ 3938ff2

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 3938ff2 was 7214dad, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Fixed iisue with powerpc-utils package name.

  • Property mode set to 100644
File size: 8.7 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"
[0210014]43TIME_MARK = \`date +%s.%N\`
44BUILD_TIME = perl -e "printf \"\nTotalseconds: %.3f\", ('\$\$end' - '\$\$start')"
[195ed9f]45
[3e7ceed]46ADD_REPORT = $REPORT
47ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
48ADD_BLFS_TOOLS = $BLFS_TOOL
[1838bc7]49
50
[195ed9f]51export PATH := \${PATH}:/usr/sbin
52
53include makefile-functions
54
55EOF
56) > $MKFILE
57}
[fe30c61]58
59#=======================
60
61
62#==== PACKAGES NAMES ===
63
64#----------------------------------#
65get_package_tarball_name() { #
66#----------------------------------#
67 local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
68
69 # The use of 'head' is necessary to limit the return value to the FIRST match..
70 # hopefully this will not cause problems.
71 #
72 case $script_name in
73 tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
74 ;;
[7214dad]75 powerpc-utils) echo $(grep "^powerpc-utils" $JHALFSDIR/pkg_tarball_list | head -n1 )
76 ;;
[3c38ab0]77 uClibc)
78 if [[ "${PROGNAME}" = "clfs3" ]]; then
79 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]80 else
[3c38ab0]81 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]82 fi
83 ;;
[fe30c61]84 linux-headers)
[62d690d]85 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] ; then
[fe30c61]86 # Uses kernel headers directly
87 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
88 else
[62d690d]89 # CLFS{,2,3} use massaged headers package
[fe30c61]90 echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
91 fi
92 ;;
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)
[c180dec]114 @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)
[c180dec]131 @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
[0210014]237 @start=\$(TIME_MARK) && \\
238 export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
239 ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
240 end=\$(TIME_MARK) && \$(BUILD_TIME) >>logs/\$@ && \\
[fe30c61]241 \$(PRT_DU) >>logs/\$@
242EOF
243) >> $MKFILE.tmp
244}
245
246#----------------------------------#
[0210014]247LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
[fe30c61]248#----------------------------------#
249 local file=$1
250
251(
252cat << EOF
[0210014]253 @start=\$(TIME_MARK) && \\
254 source ~/.bashrc && \\
255 \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1 && \\
256 end=\$(TIME_MARK) && \$(BUILD_TIME) >>logs/\$@ && \\
257 \$(PRT_DU) >>logs/\$@
[fe30c61]258EOF
259) >> $MKFILE.tmp
260}
261
262#----------------------------------#
263CHROOT_wrt_RunAsRoot() { #
264#----------------------------------#
265 local file=$1
266(
267cat << EOF
[0210014]268 @start=\$(TIME_MARK) && \\
269 source envars && \\
270 \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
271 end=\$(TIME_MARK) && \$(BUILD_TIME) >>logs/\$@ && \\
[fe30c61]272 \$(PRT_DU_CR) >>logs/\$@
273EOF
274) >> $MKFILE.tmp
275
276}
277
278#=======================
279
280
281#====== COPY FSTAB =====
282
283#----------------------------------#
284LUSER_wrt_CopyFstab() { #
285#----------------------------------#
286(
287cat << EOF
[0210014]288 @start=\$(TIME_MARK) && \\
289 cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
290 end=\$(TIME_MARK) && \$(BUILD_TIME) >>logs/\$@ && \\
291 \$(PRT_DU) >>logs/\$@
[fe30c61]292EOF
293) >> $MKFILE.tmp
294}
295
296#----------------------------------#
297CHROOT_wrt_CopyFstab() { #
298#----------------------------------#
299(
300cat << EOF
[0210014]301 @start=\$(TIME_MARK) && \\
302 cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
303 end=\$(TIME_MARK) && \$(BUILD_TIME) >>logs/\$@ && \\
304 \$(PRT_DU_CR) >>logs/\$@
[fe30c61]305EOF
306) >> $MKFILE.tmp
307}
308
309#=======================
310
311
[93346ee]312#==== INSTALLED FILES LOGS ====
313
[f546320]314#----------------------------------#
315LUSER_wrt_TouchTimestamp() { #
316#----------------------------------#
317(
318cat << EOF
319 @\$(call touch_timestamp_LUSER)
320EOF
321) >> $MKFILE.tmp
322}
323
[93346ee]324#----------------------------------#
325CHROOT_wrt_TouchTimestamp() { #
326#----------------------------------#
327(
328cat << EOF
329 @\$(call touch_timestamp)
330EOF
331) >> $MKFILE.tmp
332}
333
[f546320]334#----------------------------------#
335LUSER_wrt_LogNewFiles() { #
336#----------------------------------#
337 local name=$1
338(
339cat << EOF
340 @\$(call log_new_files_LUSER,$name)
341EOF
342) >> $MKFILE.tmp
343}
344
[93346ee]345#----------------------------------#
346CHROOT_wrt_LogNewFiles() { #
347#----------------------------------#
348 local name=$1
349(
350cat << EOF
351 @\$(call log_new_files,$name)
352EOF
353) >> $MKFILE.tmp
354}
355
356#=======================
357
358
[fe30c61]359#==== RM BUILD DIRS ====
360
361#----------------------------------#
362LUSER_RemoveBuildDirs() { #
363#----------------------------------#
364 local name=$1
365(
366cat << EOF
367 @\$(call remove_build_dirs,$name)
368EOF
369) >> $MKFILE.tmp
370}
371
372#----------------------------------#
373CHROOT_wrt_RemoveBuildDirs() { #
374#----------------------------------#
375 local name=$1
376(
377cat << EOF
378 @\$(call remove_build_dirs2,$name)
379EOF
380) >> $MKFILE.tmp
381}
382
383#=======================
384
385
386#======== TOUCH ========
387
388#----------------------------------#
389wrt_touch() { #
390#----------------------------------#
391(
392cat << EOF
393 @\$(call housekeeping)
394EOF
395) >> $MKFILE.tmp
396}
397
398#=======================
Note: See TracBrowser for help on using the repository browser.