source: common/libs/func_wrt_Makefile@ 5267879

2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 5267879 was 7072e1f, checked in by Thomas Pegg <thomasp@…>, 13 years ago

Commit Pierre Labastie's patch for including package management support in jhalfs. NOTE: Package management is by default disabled.

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