source: common/libs/func_wrt_Makefile@ 3917eca

2.4
Last change on this file since 3917eca was 3917eca, checked in by Pierre Labastie <pierre@…>, 7 years ago

Allow non-numeric version in glibc

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