source: common/libs/func_wrt_Makefile@ 9c1838b

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

Now HLFS is using kernel headers.

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