source: common/libs/func_wrt_Makefile@ 4b54394

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 4b54394 was 4b54394, checked in by Thomas Pegg <thomasp@…>, 14 years ago

Add handling for the different name of the xz-utils tarball

  • Property mode set to 100644
File size: 8.4 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"
43
[3e7ceed]44ADD_REPORT = $REPORT
45ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
46ADD_BLFS_TOOLS = $BLFS_TOOL
[1838bc7]47
48
[195ed9f]49export PATH := \${PATH}:/usr/sbin
50
51include makefile-functions
52
53EOF
54) > $MKFILE
55}
[fe30c61]56
57#=======================
58
59
60#==== PACKAGES NAMES ===
61
62#----------------------------------#
63get_package_tarball_name() { #
64#----------------------------------#
65 local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
66
67 # The use of 'head' is necessary to limit the return value to the FIRST match..
68 # hopefully this will not cause problems.
69 #
70 case $script_name in
71 tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
72 ;;
[7214dad]73 powerpc-utils) echo $(grep "^powerpc-utils" $JHALFSDIR/pkg_tarball_list | head -n1 )
74 ;;
[3c38ab0]75 uClibc)
76 if [[ "${PROGNAME}" = "clfs3" ]]; then
77 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]78 else
[3c38ab0]79 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]80 fi
81 ;;
[fe30c61]82 linux-headers)
[31a37db]83 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] || [[ "${PROGNAME}" = "clfs" ]]; then
[fe30c61]84 # Uses kernel headers directly
85 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
86 else
[31a37db]87 # CLFS{2,3} use massaged headers package
[fe30c61]88 echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
89 fi
90 ;;
[d8006a00]91 expect) echo $(grep "^expect" $JHALFSDIR/pkg_tarball_list | head -n1 )
92 ;;
[4b54394]93 xz-utils) echo $(grep "^xz" $JHALFSDIR/pkg_tarball_list | head -n1 )
94 ;;
[fe30c61]95 *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
96 ;;
97 esac
98
99}
100
101#=======================
102
103
104#==== TARGET HEADER ====
105
106#----------------------------------#
107LUSER_wrt_target() { # Create target and initialize log file
108#----------------------------------#
109 local i=$1
110 local PREV=$2
111(
112cat << EOF
113
114$i: $PREV
115 @\$(call echo_message, Building)
[75d6d1c]116${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[fe30c61]117 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
118 @\$(PRT_DU) >>logs/\$@
119EOF
120) >> $MKFILE.tmp
121}
122
123#----------------------------------#
124CHROOT_wrt_target() { # Create target and initialize log file
125#----------------------------------#
126 local i=$1
127 local PREV=$2
128(
129cat << EOF
130
131$i: $PREV
132 @\$(call echo_message, Building)
[75d6d1c]133${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[6bb080e]134 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
135 @\$(PRT_DU_CR) >>logs/\$@
[fe30c61]136EOF
137) >> $MKFILE.tmp
138}
139
140#=======================
141
142
143#======== UNPACK =======
144
145#----------------------------------#
146LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
147#----------------------------------#
148 local FILE=$1
149 local optSAVE_PREVIOUS=$2
150
151 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
152(
153cat << EOF
154 @\$(call remove_existing_dirs,$FILE)
155EOF
156) >> $MKFILE.tmp
157 fi
158
159(
160cat << EOF
161 @\$(call unpack,$FILE)
162 @\$(call get_pkg_root_LUSER)
163EOF
164) >> $MKFILE.tmp
165}
166
167#----------------------------------#
168CHROOT_Unpack() { #
169#----------------------------------#
170 local FILE=$1
171 local optSAVE_PREVIOUS=$2
172
173 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
174(
175cat << EOF
176 @\$(call remove_existing_dirs2,$FILE)
177EOF
178) >> $MKFILE.tmp
179 fi
180(
181cat << EOF
[1f81129]182 @\$(call unpack2,$FILE)
[fe30c61]183 @\$(call get_pkg_root2)
184EOF
185) >> $MKFILE.tmp
186}
187
188#=======================
189
190
191#===== TESTS LOGS ======
192
193#----------------------------------#
194LUSER_wrt_test_log() { # Initialize testsuite log file
195#----------------------------------#
196 local TESTLOGFILE=$1
197(
198cat << EOF
[6bb080e]199 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[10c8b78]200 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/\$@
[fe30c61]201EOF
202) >> $MKFILE.tmp
203}
204
205#----------------------------------#
206CHROOT_wrt_test_log() { #
207#----------------------------------#
208 local TESTLOGFILE=$1
209(
210cat << EOF
[8f2c086]211 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[6bb080e]212 echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
[fe30c61]213EOF
214) >> $MKFILE.tmp
215}
216
217#=======================
218
219
220#======== RUN AS =======
221
222#----------------------------------#
223wrt_RunAsRoot() { # Some scripts must be run as root..
224#----------------------------------#
225 local MOUNT_ENV
[8f2c086]226 local file=$1
[fe30c61]227
228 case ${PROGNAME} in
229 lfs ) MOUNT_ENV="LFS" ;;
230 clfs ) MOUNT_ENV="CLFS" ;;
231 clfs2 ) MOUNT_ENV="CLFS" ;;
232 clfs3 ) MOUNT_ENV="CLFS" ;;
233 hlfs ) MOUNT_ENV="HLFS" ;;
234 *) echo "undefined progname $PROGNAME"; exit 1 ;;
235 esac
236
237(
238cat << EOF
[68713c9]239 @export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
[0210014]240 ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
[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
[68713c9]253 @source ~/.bashrc && \\
[0210014]254 \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1 && \\
255 \$(PRT_DU) >>logs/\$@
[fe30c61]256EOF
257) >> $MKFILE.tmp
258}
259
260#----------------------------------#
261CHROOT_wrt_RunAsRoot() { #
262#----------------------------------#
263 local file=$1
264(
265cat << EOF
[68713c9]266 @source envars && \\
[0210014]267 \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 && \\
[fe30c61]268 \$(PRT_DU_CR) >>logs/\$@
269EOF
270) >> $MKFILE.tmp
271
272}
273
274#=======================
275
276
277#====== COPY FSTAB =====
278
279#----------------------------------#
280LUSER_wrt_CopyFstab() { #
281#----------------------------------#
282(
283cat << EOF
[68713c9]284 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]285 \$(PRT_DU) >>logs/\$@
[fe30c61]286EOF
287) >> $MKFILE.tmp
288}
289
290#----------------------------------#
291CHROOT_wrt_CopyFstab() { #
292#----------------------------------#
293(
294cat << EOF
[68713c9]295 @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]296 \$(PRT_DU_CR) >>logs/\$@
[fe30c61]297EOF
298) >> $MKFILE.tmp
299}
300
301#=======================
302
303
[93346ee]304#==== INSTALLED FILES LOGS ====
305
[f546320]306#----------------------------------#
307LUSER_wrt_TouchTimestamp() { #
308#----------------------------------#
309(
310cat << EOF
311 @\$(call touch_timestamp_LUSER)
312EOF
313) >> $MKFILE.tmp
314}
315
[93346ee]316#----------------------------------#
317CHROOT_wrt_TouchTimestamp() { #
318#----------------------------------#
319(
320cat << EOF
321 @\$(call touch_timestamp)
322EOF
323) >> $MKFILE.tmp
324}
325
[f546320]326#----------------------------------#
327LUSER_wrt_LogNewFiles() { #
328#----------------------------------#
329 local name=$1
330(
331cat << EOF
332 @\$(call log_new_files_LUSER,$name)
333EOF
334) >> $MKFILE.tmp
335}
336
[93346ee]337#----------------------------------#
338CHROOT_wrt_LogNewFiles() { #
339#----------------------------------#
340 local name=$1
341(
342cat << EOF
343 @\$(call log_new_files,$name)
344EOF
345) >> $MKFILE.tmp
346}
347
348#=======================
349
350
[fe30c61]351#==== RM BUILD DIRS ====
352
353#----------------------------------#
354LUSER_RemoveBuildDirs() { #
355#----------------------------------#
356 local name=$1
357(
358cat << EOF
359 @\$(call remove_build_dirs,$name)
360EOF
361) >> $MKFILE.tmp
362}
363
364#----------------------------------#
365CHROOT_wrt_RemoveBuildDirs() { #
366#----------------------------------#
367 local name=$1
368(
369cat << EOF
370 @\$(call remove_build_dirs2,$name)
371EOF
372) >> $MKFILE.tmp
373}
374
375#=======================
376
377
378#======== TOUCH ========
379
380#----------------------------------#
381wrt_touch() { #
382#----------------------------------#
383(
384cat << EOF
385 @\$(call housekeeping)
386EOF
387) >> $MKFILE.tmp
388}
389
390#=======================
Note: See TracBrowser for help on using the repository browser.