source: common/libs/func_wrt_Makefile@ dd08e14

ablfs-more legacy trunk
Last change on this file since dd08e14 was 203a64c, checked in by Pierre Labastie <pierre@…>, 7 years ago

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