source: common/libs/func_wrt_Makefile@ 3834b6e

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

Added support for host that place home dirs under a directory othen than /home.
Request and partial patch from Mario Lang.

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