source: common/libs/func_wrt_Makefile@ f3a7f3b

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since f3a7f3b was 3c38ab0, checked in by George Boudreau <georgeb@…>, 18 years ago

Adapted to clfs bootscript naming convention

  • Property mode set to 100644
File size: 7.2 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
17
18SRC = /sources
19MOUNT_PT = $BUILDDIR
20PKG_LST = $PKG_LST
21LUSER = $LUSER
22LGROUP = $LGROUP
23SCRIPT_ROOT = $SCRIPT_ROOT
24
25BASEDIR = \$(MOUNT_PT)
26SRCSDIR = \$(BASEDIR)/sources
27CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
28LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs
29TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs
30
31crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
32crLOGDIR = /\$(SCRIPT_ROOT)/logs
33crTESTLOGDIR = /\$(SCRIPT_ROOT)/test-logs
34
35SU_LUSER = su - \$(LUSER) -c
36LUSER_HOME = /home/\$(LUSER)
37PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
38PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found / \`\n"
39
[1838bc7]40ADD_REPORT = $REPORT
41ADD_BLFS_TOOLS = $BLFS_TOOL
42
43
[195ed9f]44export PATH := \${PATH}:/usr/sbin
45
46include makefile-functions
47
48EOF
49) > $MKFILE
50}
[fe30c61]51
52#=======================
53
54
55#==== PACKAGES NAMES ===
56
57#----------------------------------#
58get_package_tarball_name() { #
59#----------------------------------#
60 local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
61
62 # The use of 'head' is necessary to limit the return value to the FIRST match..
63 # hopefully this will not cause problems.
64 #
65 case $script_name in
66 tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
67 ;;
[3c38ab0]68 uClibc)
69 if [[ "${PROGNAME}" = "clfs3" ]]; then
70 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
71 else
72 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
73 fi
74 ;;
[fe30c61]75 linux-headers)
[62d690d]76 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] ; then
[fe30c61]77 # Uses kernel headers directly
78 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
79 else
[62d690d]80 # CLFS{,2,3} use massaged headers package
[fe30c61]81 echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
82 fi
83 ;;
84 *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
85 ;;
86 esac
87
88}
89
90#=======================
91
92
93#==== TARGET HEADER ====
94
95#----------------------------------#
96LUSER_wrt_target() { # Create target and initialize log file
97#----------------------------------#
98 local i=$1
99 local PREV=$2
100(
101cat << EOF
102
103$i: $PREV
104 @\$(call echo_message, Building)
105 @./progress_bar.sh \$@ \$\$PPID &
106 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
107 @\$(PRT_DU) >>logs/\$@
108EOF
109) >> $MKFILE.tmp
110}
111
112#----------------------------------#
113CHROOT_wrt_target() { # Create target and initialize log file
114#----------------------------------#
115 local i=$1
116 local PREV=$2
117 case $i in
118 iteration* ) local LOGFILE="${this_script}.log" ;;
119 * ) local LOGFILE="\$@" ;;
120 esac
121(
122cat << EOF
123
124$i: $PREV
125 @\$(call echo_message, Building)
126 @./progress_bar.sh \$@ \$\$PPID &
127 @echo "\$(nl_)\`date\`\$(nl_)" >logs/$LOGFILE
128 @\$(PRT_DU_CR) >>logs/$LOGFILE
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
[1f81129]175 @\$(call unpack2,$FILE)
[fe30c61]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/$TESTLOGFILE
194EOF
195) >> $MKFILE.tmp
196}
197
198#----------------------------------#
199CHROOT_wrt_test_log() { #
200#----------------------------------#
201 local TESTLOGFILE=$1
202(
203cat << EOF
[8f2c086]204 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[fe30c61]205 echo "\$(nl_)\`date\`\$(nl_)" >test-logs/$TESTLOGFILE
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
[8f2c086]219 local file=$1
[fe30c61]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
[8f2c086]257 @( time { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
[fe30c61]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.