source: common/libs/func_wrt_Makefile@ 203a64c

ablfs-more legacy trunk
Last change on this file since 203a64c 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
Line 
1#!/bin/bash
2
3# $Id$
4
5#=== MAKEFILE HEADER ===
6
7#----------------------------------#
8wrt_Makefile_header() { #
9#----------------------------------#
10(
11 cat << EOF
12# This file is automatically generated by jhalfs
13# DO NOT EDIT THIS FILE MANUALLY
14#
15# Generated on `date "+%F %X %Z"`
16
17
18SHELL = /bin/bash
19
20SRC = /sources
21MOUNT_PT = $BUILDDIR
22PKG_LST = $PKG_LST
23LUSER = $LUSER
24LGROUP = $LGROUP
25LHOME = $LHOME
26SCRIPT_ROOT = $SCRIPT_ROOT
27
28BASEDIR = \$(MOUNT_PT)
29SRCSDIR = \$(BASEDIR)/sources
30CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
31LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
32TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
33
34crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
35crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
36crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
37crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
38
39SU_LUSER = sudo -u \$(LUSER) -i sh -c
40LUSER_HOME = \$(LHOME)/\$(LUSER)
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 --exclude /var/lib / \`\n"
43
44ADD_REPORT = $REPORT
45ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
46ADD_BLFS_TOOLS = $BLFS_TOOL
47PKGMNGT = $PKGMNGT
48WRAP_INSTALL = $WRAP_INSTALL
49
50
51export PATH := \${PATH}:/usr/sbin
52
53include makefile-functions
54
55EOF
56) > $MKFILE
57}
58
59#=======================
60
61
62#==== PACKAGES NAMES AND VERSIONS ====
63
64#----------------------------------#
65get_package_tarball_name() { #
66#----------------------------------#
67 local script_name=`echo ${1} | sed -e 's@^[0-9]\{1\}-@@'`
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 ;;
75 iputils) echo $(grep "^iputils" $JHALFSDIR/pkg_tarball_list | head -n1 )
76 ;;
77 powerpc-utils) echo $(grep "^powerpc-utils" $JHALFSDIR/pkg_tarball_list | head -n1 )
78 ;;
79 uClibc)
80 if [[ "${PROGNAME}" = "clfs3" ]]; then
81 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
82 else
83 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
84 fi
85 ;;
86 linux-headers)
87 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] || [[ "${PROGNAME}" = "clfs" ]]; then
88 # Uses kernel headers directly
89 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
90 else
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 )
94 fi
95 ;;
96 expect) echo $(grep "^expect" $JHALFSDIR/pkg_tarball_list | head -n1 )
97 ;;
98 e2fsprogs-libs) echo $(grep "^e2fsprogs" $JHALFSDIR/pkg_tarball_list | head -n1 )
99 ;;
100 libcap) echo $(grep "^libcap" $JHALFSDIR/pkg_tarball_list | head -n1 )
101 ;;
102 util-linux-libs | util-linux-pass1) echo $(grep "^util-linux" $JHALFSDIR/pkg_tarball_list | head -n1 )
103 ;;
104 xz-utils) echo $(grep "^xz" $JHALFSDIR/pkg_tarball_list | head -n1 )
105 ;;
106 sqlite) echo $(grep "^sqlite" $JHALFSDIR/pkg_tarball_list | head -n1 )
107 ;;
108 udev) echo $(grep "^systemd" $JHALFSDIR/pkg_tarball_list | head -n1 )
109 ;;
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 ;;
114 glibc) echo $(grep "^glibc" $JHALFSDIR/pkg_tarball_list | head -n1 )
115 ;;
116 *) echo $(grep "^$script_name[_-][[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
117 ;;
118 esac
119
120}
121
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 ;;
139 glibc*) echo ${1} | sed -e 's@^[^-]*-@@' \
140 -e 's@\.tar.*@@'
141 ;;
142 LVM*) echo ${1} | sed -e 's@^[^.]*\.@@' \
143 -e 's@\.tgz.*@@'
144 ;;
145 iproute*) echo ${1} | sed -e 's@^[^-]*-@@' \
146 -e 's@\.tar.*@@'
147 ;;
148 pkg*|udev*|Singular*|XML*)
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}
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
170 local version
171 if [ "$3" != "" ]; then
172 version=-$3
173 fi
174(
175cat << EOF
176
177$i: $PREV
178 @\$(call echo_message, Building)
179${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
180 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
181 @\$(PRT_DU) >>logs/\$@$version
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
191 local version
192 if [ "$3" != "" ]; then
193 version=-$3
194 fi
195(
196cat << EOF
197
198$i: $PREV
199 @\$(call echo_message, Building)
200${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
201 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
202 @\$(PRT_DU_CR) >>logs/\$@$version
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
249 @\$(call unpack2,$FILE)
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#----------------------------------#
263 local version
264 if [ "$2" != "" ]; then
265 version=-$2
266 fi
267 local TESTLOGFILE=$1$version
268(
269cat << EOF
270 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
271 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/$TESTLOGFILE
272EOF
273) >> $MKFILE.tmp
274}
275
276#----------------------------------#
277CHROOT_wrt_test_log() { #
278#----------------------------------#
279 local version
280 if [ "$2" != "" ]; then
281 version=-$2
282 fi
283 local TESTLOGFILE=$1$version
284(
285cat << EOF
286 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
287 echo "\$(nl_)\`date\`\$(nl_)" >\$(crTESTLOGDIR)/$TESTLOGFILE
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
301 local version
302 if [ "$2" != "" ]; then
303 version=-$2
304 fi
305 local file=$1
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
318 @export ${MOUNT_ENV}=\$(MOUNT_PT) && \\
319 ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@$version 2>&1 && \\
320 \$(PRT_DU) >>logs/\$@$version
321EOF
322) >> $MKFILE.tmp
323}
324
325#----------------------------------#
326LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
327#----------------------------------#
328 local file=$1
329 local version
330 if [ "$2" != "" ]; then
331 version=-$2
332 fi
333
334(
335cat << EOF
336 @source ~/.bashrc && \\
337 \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@$version 2>&1 && \\
338 \$(PRT_DU) >>logs/\$@$version
339EOF
340) >> $MKFILE.tmp
341}
342
343#----------------------------------#
344CHROOT_wrt_RunAsRoot() { #
345#----------------------------------#
346 local file=$1
347 local version
348 if [ "$2" != "" ]; then
349 version=-$2
350 fi
351(
352cat << EOF
353 @source envars && \\
354 \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@$version 2>&1 && \\
355 \$(PRT_DU_CR) >>logs/\$@$version
356EOF
357) >> $MKFILE.tmp
358
359}
360
361#=======================
362
363
364#====== COPY FSTAB =====
365
366#----------------------------------#
367LUSER_wrt_CopyFstab() { #
368#----------------------------------#
369(
370cat << EOF
371 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
372 \$(PRT_DU) >>logs/\$@
373EOF
374) >> $MKFILE.tmp
375}
376
377#----------------------------------#
378CHROOT_wrt_CopyFstab() { #
379#----------------------------------#
380(
381cat << EOF
382 @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
383 \$(PRT_DU_CR) >>logs/\$@
384EOF
385) >> $MKFILE.tmp
386}
387
388#=======================
389
390
391#==== INSTALLED FILES LOGS ====
392
393#----------------------------------#
394LUSER_wrt_TouchTimestamp() { #
395#----------------------------------#
396(
397cat << EOF
398 @\$(call touch_timestamp_LUSER)
399EOF
400) >> $MKFILE.tmp
401}
402
403#----------------------------------#
404CHROOT_wrt_TouchTimestamp() { #
405#----------------------------------#
406(
407cat << EOF
408 @\$(call touch_timestamp)
409EOF
410) >> $MKFILE.tmp
411}
412
413#----------------------------------#
414LUSER_wrt_LogNewFiles() { #
415#----------------------------------#
416 local name=`echo ${1} | sed 's/[0-9]-//'`
417(
418cat << EOF
419 @\$(call log_new_files_LUSER,$name)
420EOF
421) >> $MKFILE.tmp
422}
423
424#----------------------------------#
425CHROOT_wrt_LogNewFiles() { #
426#----------------------------------#
427 local name=`echo ${1} | sed 's/[0-9]-//'`
428(
429cat << EOF
430 @\$(call log_new_files,$name)
431EOF
432) >> $MKFILE.tmp
433}
434
435#=======================
436
437
438#==== RM BUILD DIRS ====
439
440#----------------------------------#
441LUSER_RemoveBuildDirs() { #
442#----------------------------------#
443 local name=`echo ${1} | sed 's/[0-9]-//'`
444(
445cat << EOF
446 @\$(call remove_build_dirs,$name)
447EOF
448) >> $MKFILE.tmp
449}
450
451#----------------------------------#
452CHROOT_wrt_RemoveBuildDirs() { #
453#----------------------------------#
454 local name=`echo ${1} | sed 's/[0-9]-//'`
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.