source: common/libs/func_wrt_Makefile@ fbdd1a8

2.4 ablfs-more legacy trunk
Last change on this file since fbdd1a8 was 3d96a65, checked in by Pierre Labastie <pierre@…>, 10 years ago

Fix version extraction for XML-Parser

  • Property mode set to 100644
File size: 11.5 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
[ef32ce5]39SU_LUSER = sudo -u \$(LUSER) -i sh -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
[7072e1f]47PKGMNGT = $PKGMNGT
[1838bc7]48
49
[195ed9f]50export PATH := \${PATH}:/usr/sbin
51
52include makefile-functions
53
54EOF
55) > $MKFILE
56}
[fe30c61]57
58#=======================
59
60
[3cb4ef5b]61#==== PACKAGES NAMES AND VERSIONS ====
[fe30c61]62
63#----------------------------------#
64get_package_tarball_name() { #
65#----------------------------------#
[659be15]66 local script_name=`echo ${1} | sed -e 's@^[0-9]\{1\}-@@'`
[fe30c61]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 ;;
[608fbe1]74 iputils) echo $(grep "^iputils" $JHALFSDIR/pkg_tarball_list | head -n1 )
75 ;;
[7214dad]76 powerpc-utils) echo $(grep "^powerpc-utils" $JHALFSDIR/pkg_tarball_list | head -n1 )
77 ;;
[3c38ab0]78 uClibc)
79 if [[ "${PROGNAME}" = "clfs3" ]]; then
80 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]81 else
[3c38ab0]82 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
[7214dad]83 fi
84 ;;
[fe30c61]85 linux-headers)
[31a37db]86 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] || [[ "${PROGNAME}" = "clfs" ]]; then
[fe30c61]87 # Uses kernel headers directly
88 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
89 else
[608fbe1]90 # CLFS{2,3} used to use massaged headers package
91 # echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
92 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
[fe30c61]93 fi
94 ;;
[d8006a00]95 expect) echo $(grep "^expect" $JHALFSDIR/pkg_tarball_list | head -n1 )
96 ;;
[608fbe1]97 e2fsprogs-libs) echo $(grep "^e2fsprogs" $JHALFSDIR/pkg_tarball_list | head -n1 )
98 ;;
[f0a31de]99 libcap) echo $(grep "^libcap" $JHALFSDIR/pkg_tarball_list | head -n1 )
100 ;;
[82808d1]101 util-linux-libs | util-linux-pass1) echo $(grep "^util-linux" $JHALFSDIR/pkg_tarball_list | head -n1 )
[608fbe1]102 ;;
[4b54394]103 xz-utils) echo $(grep "^xz" $JHALFSDIR/pkg_tarball_list | head -n1 )
[083e2fd]104 ;;
[7072e1f]105 sqlite) echo $(grep "^sqlite" $JHALFSDIR/pkg_tarball_list | head -n1 )
[083e2fd]106 ;;
107 udev) echo $(grep "^systemd" $JHALFSDIR/pkg_tarball_list | head -n1 )
108 ;;
[8099885]109 xml-parser) echo $(grep "^XML" $JHALFSDIR/pkg_tarball_list | head -n1 )
110 ;;
111 libdbus) echo $(grep "^dbus" $JHALFSDIR/pkg_tarball_list | head -n1 )
112 ;;
[7072e1f]113 *) echo $(grep "^$script_name[_-][[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
[fe30c61]114 ;;
115 esac
116
117}
118
[3cb4ef5b]119#----------------------------------#
120get_package_version() { #
121#----------------------------------#
122# Those hacks may change depending on the invention of devs for tarball names.
123# Normally, we expect -digit to signal the beginning of the version field
124# but it may happen that there is no '-' (tcl, expect), that the version
125# field is ddd-d (pkg-config-lite-028-1, since sed is greedy, it finds only
126# the second dash) or that the first character of the version is not a digit
127# (iputils-s20121221)...
128 case ${1} in
129 tcl*|expect*|tzdata*|xmlts*|unzip*|lynx*)
130 echo ${1} | sed -e 's@^[^[:digit:]]*@@' \
131 -e 's@\(-src\)*\.tar.*@@'
132 ;;
133 iputils*) echo ${1} | sed -e 's@^.*-@@' \
134 -e 's@\.tar.*@@'
135 ;;
136 LVM*) echo ${1} | sed -e 's@^[^.]*\.@@' \
137 -e 's@\.tgz.*@@'
138 ;;
139 iproute*) echo ${1} | sed -e 's@^[^-]*-@@' \
140 -e 's@\.tar.*@@'
141 ;;
[3d96a65]142 pkg*|udev*|Singular*|XML*)
[3cb4ef5b]143 echo ${1} | sed -e 's@^.*[a-z]-\([[:digit:]]\)@\1@' \
144 -e 's@\.tar.*@@' \
145 -e 's@\.zip.*@@'
146 ;;
147 *) echo ${1} | sed -e 's@^.*[-_]\([[:digit:]]\)@\1@' \
148 -e 's@\.tar.*@@' \
149 -e 's@\.zip.*@@'
150 ;;
151 esac
152
153}
[fe30c61]154#=======================
155
156
157#==== TARGET HEADER ====
158
159#----------------------------------#
160LUSER_wrt_target() { # Create target and initialize log file
161#----------------------------------#
162 local i=$1
163 local PREV=$2
[3cb4ef5b]164 local version
165 if [ "$3" != "" ]; then
166 version=-$3
167 fi
[fe30c61]168(
169cat << EOF
170
171$i: $PREV
172 @\$(call echo_message, Building)
[75d6d1c]173${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[3cb4ef5b]174 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
175 @\$(PRT_DU) >>logs/\$@$version
[fe30c61]176EOF
177) >> $MKFILE.tmp
178}
179
180#----------------------------------#
181CHROOT_wrt_target() { # Create target and initialize log file
182#----------------------------------#
183 local i=$1
184 local PREV=$2
[3cb4ef5b]185 local version
186 if [ "$3" != "" ]; then
187 version=-$3
188 fi
[fe30c61]189(
190cat << EOF
191
192$i: $PREV
193 @\$(call echo_message, Building)
[75d6d1c]194${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[3cb4ef5b]195 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
196 @\$(PRT_DU_CR) >>logs/\$@$version
[fe30c61]197EOF
198) >> $MKFILE.tmp
199}
200
201#=======================
202
203
204#======== UNPACK =======
205
206#----------------------------------#
207LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
208#----------------------------------#
209 local FILE=$1
210 local optSAVE_PREVIOUS=$2
211
212 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
213(
214cat << EOF
215 @\$(call remove_existing_dirs,$FILE)
216EOF
217) >> $MKFILE.tmp
218 fi
219
220(
221cat << EOF
222 @\$(call unpack,$FILE)
223 @\$(call get_pkg_root_LUSER)
224EOF
225) >> $MKFILE.tmp
226}
227
228#----------------------------------#
229CHROOT_Unpack() { #
230#----------------------------------#
231 local FILE=$1
232 local optSAVE_PREVIOUS=$2
233
234 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
235(
236cat << EOF
237 @\$(call remove_existing_dirs2,$FILE)
238EOF
239) >> $MKFILE.tmp
240 fi
241(
242cat << EOF
[1f81129]243 @\$(call unpack2,$FILE)
[fe30c61]244 @\$(call get_pkg_root2)
245EOF
246) >> $MKFILE.tmp
247}
248
249#=======================
250
251
252#===== TESTS LOGS ======
253
254#----------------------------------#
255LUSER_wrt_test_log() { # Initialize testsuite log file
256#----------------------------------#
[3cb4ef5b]257 local version
258 if [ "$2" != "" ]; then
259 version=-$2
260 fi
261 local TESTLOGFILE=$1$version
[fe30c61]262(
263cat << EOF
[6bb080e]264 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[3cb4ef5b]265 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/$TESTLOGFILE
[fe30c61]266EOF
267) >> $MKFILE.tmp
268}
269
270#----------------------------------#
271CHROOT_wrt_test_log() { #
272#----------------------------------#
[3cb4ef5b]273 local version
274 if [ "$2" != "" ]; then
275 version=-$2
276 fi
277 local TESTLOGFILE=$1$version
[fe30c61]278(
279cat << EOF
[8f2c086]280 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[3cb4ef5b]281 echo "\$(nl_)\`date\`\$(nl_)" >\$(crTESTLOGDIR)/$TESTLOGFILE
[fe30c61]282EOF
283) >> $MKFILE.tmp
284}
285
286#=======================
287
288
289#======== RUN AS =======
290
291#----------------------------------#
292wrt_RunAsRoot() { # Some scripts must be run as root..
293#----------------------------------#
294 local MOUNT_ENV
[3cb4ef5b]295 local version
296 if [ "$2" != "" ]; then
297 version=-$2
298 fi
[8f2c086]299 local file=$1
[fe30c61]300
301 case ${PROGNAME} in
302 lfs ) MOUNT_ENV="LFS" ;;
303 clfs ) MOUNT_ENV="CLFS" ;;
304 clfs2 ) MOUNT_ENV="CLFS" ;;
305 clfs3 ) MOUNT_ENV="CLFS" ;;
306 hlfs ) MOUNT_ENV="HLFS" ;;
307 *) echo "undefined progname $PROGNAME"; exit 1 ;;
308 esac
309
310(
311cat << EOF
[68713c9]312 @export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
[3cb4ef5b]313 ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@$version 2>&1 && \\
314 \$(PRT_DU) >>logs/\$@$version
[fe30c61]315EOF
316) >> $MKFILE.tmp
317}
318
319#----------------------------------#
[0210014]320LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
[fe30c61]321#----------------------------------#
322 local file=$1
[3cb4ef5b]323 local version
324 if [ "$2" != "" ]; then
325 version=-$2
326 fi
[fe30c61]327
328(
329cat << EOF
[68713c9]330 @source ~/.bashrc && \\
[3cb4ef5b]331 \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@$version 2>&1 && \\
332 \$(PRT_DU) >>logs/\$@$version
[fe30c61]333EOF
334) >> $MKFILE.tmp
335}
336
337#----------------------------------#
338CHROOT_wrt_RunAsRoot() { #
339#----------------------------------#
340 local file=$1
[3cb4ef5b]341 local version
342 if [ "$2" != "" ]; then
343 version=-$2
344 fi
[fe30c61]345(
346cat << EOF
[68713c9]347 @source envars && \\
[3cb4ef5b]348 \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@$version 2>&1 && \\
349 \$(PRT_DU_CR) >>logs/\$@$version
[fe30c61]350EOF
351) >> $MKFILE.tmp
352
353}
354
355#=======================
356
357
358#====== COPY FSTAB =====
359
360#----------------------------------#
361LUSER_wrt_CopyFstab() { #
362#----------------------------------#
363(
364cat << EOF
[68713c9]365 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]366 \$(PRT_DU) >>logs/\$@
[fe30c61]367EOF
368) >> $MKFILE.tmp
369}
370
371#----------------------------------#
372CHROOT_wrt_CopyFstab() { #
373#----------------------------------#
374(
375cat << EOF
[68713c9]376 @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]377 \$(PRT_DU_CR) >>logs/\$@
[fe30c61]378EOF
379) >> $MKFILE.tmp
380}
381
382#=======================
383
384
[93346ee]385#==== INSTALLED FILES LOGS ====
386
[f546320]387#----------------------------------#
388LUSER_wrt_TouchTimestamp() { #
389#----------------------------------#
390(
391cat << EOF
392 @\$(call touch_timestamp_LUSER)
393EOF
394) >> $MKFILE.tmp
395}
396
[93346ee]397#----------------------------------#
398CHROOT_wrt_TouchTimestamp() { #
399#----------------------------------#
400(
401cat << EOF
402 @\$(call touch_timestamp)
403EOF
404) >> $MKFILE.tmp
405}
406
[f546320]407#----------------------------------#
408LUSER_wrt_LogNewFiles() { #
409#----------------------------------#
[e639536]410 local name=`echo ${1} | sed 's/[0-9]-//'`
[f546320]411(
412cat << EOF
413 @\$(call log_new_files_LUSER,$name)
414EOF
415) >> $MKFILE.tmp
416}
417
[93346ee]418#----------------------------------#
419CHROOT_wrt_LogNewFiles() { #
420#----------------------------------#
[e639536]421 local name=`echo ${1} | sed 's/[0-9]-//'`
[93346ee]422(
423cat << EOF
424 @\$(call log_new_files,$name)
425EOF
426) >> $MKFILE.tmp
427}
428
429#=======================
430
431
[fe30c61]432#==== RM BUILD DIRS ====
433
434#----------------------------------#
435LUSER_RemoveBuildDirs() { #
436#----------------------------------#
[e639536]437 local name=`echo ${1} | sed 's/[0-9]-//'`
[fe30c61]438(
439cat << EOF
440 @\$(call remove_build_dirs,$name)
441EOF
442) >> $MKFILE.tmp
443}
444
445#----------------------------------#
446CHROOT_wrt_RemoveBuildDirs() { #
447#----------------------------------#
[e639536]448 local name=`echo ${1} | sed 's/[0-9]-//'`
[fe30c61]449(
450cat << EOF
451 @\$(call remove_build_dirs2,$name)
452EOF
453) >> $MKFILE.tmp
454}
455
456#=======================
457
458
459#======== TOUCH ========
460
461#----------------------------------#
462wrt_touch() { #
463#----------------------------------#
464(
465cat << EOF
466 @\$(call housekeeping)
467EOF
468) >> $MKFILE.tmp
469}
470
471#=======================
Note: See TracBrowser for help on using the repository browser.