source: common/libs/func_wrt_Makefile@ c5f4ef3

ablfs-more trunk
Last change on this file since c5f4ef3 was cacc6c5, checked in by Pierre Labastie <pierre.labastie@…>, 12 months ago

Allow users to pass a cpuset

If using a new book, MAKEFLAGS is set to -j$(nproc), so that if
we want to easure timings with 4 processors and our computer has
more than that, we need to restrict the number of processors.
Jhalfs allows to do that using th cpuset cgroup controller, so that
it only restrits the make job and not the whole machine. For that
use a small scripts written by Xi Ruoyao that restarts make this
the cpuset set.

  • Property mode set to 100644
File size: 7.3 KB
RevLine 
[fe30c61]1#!/bin/bash
2
3#=== MAKEFILE HEADER ===
4
[195ed9f]5#----------------------------------#
6wrt_Makefile_header() { #
7#----------------------------------#
8(
9 cat << EOF
10# This file is automatically generated by jhalfs
[fe30c61]11# DO NOT EDIT THIS FILE MANUALLY
12#
[195ed9f]13# Generated on `date "+%F %X %Z"`
14
[aec4483]15
16SHELL = /bin/bash
[195ed9f]17
18SRC = /sources
19MOUNT_PT = $BUILDDIR
20PKG_LST = $PKG_LST
21LUSER = $LUSER
22LGROUP = $LGROUP
[962793a]23LHOME = $LHOME
[195ed9f]24SCRIPT_ROOT = $SCRIPT_ROOT
25
26BASEDIR = \$(MOUNT_PT)
27SRCSDIR = \$(BASEDIR)/sources
[2bd2fb8]28CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$COMMANDS
[93346ee]29LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
30TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
[195ed9f]31
[2bd2fb8]32crCMDSDIR = /\$(SCRIPT_ROOT)/$COMMANDS
[93346ee]33crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
34crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
35crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
[195ed9f]36
[0835a10]37SU_LUSER = sudo -H -u \$(LUSER) sh -c
[962793a]38LUSER_HOME = \$(LHOME)/\$(LUSER)
[195ed9f]39PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
[9bbb9c8]40PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found --exclude /var/lib / \`\n"
[195ed9f]41
[3e7ceed]42ADD_REPORT = $REPORT
43ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
44ADD_BLFS_TOOLS = $BLFS_TOOL
[7072e1f]45PKGMNGT = $PKGMNGT
[322226d]46WRAP_INSTALL = $WRAP_INSTALL
[cacc6c5]47CPUSET = $CPUSET
[1838bc7]48
49
[195ed9f]50export PATH := \${PATH}:/usr/sbin
51
52include makefile-functions
53
54EOF
55) > $MKFILE
56}
[fe30c61]57
58#=======================
59
60
61#==== TARGET HEADER ====
62
63#----------------------------------#
64LUSER_wrt_target() { # Create target and initialize log file
65#----------------------------------#
66 local i=$1
67 local PREV=$2
[3cb4ef5b]68 local version
69 if [ "$3" != "" ]; then
70 version=-$3
71 fi
[fe30c61]72(
73cat << EOF
74
75$i: $PREV
76 @\$(call echo_message, Building)
[75d6d1c]77${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[3cb4ef5b]78 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
[2758d94]79 @ : > envars
[fe30c61]80EOF
81) >> $MKFILE.tmp
82}
83
84#----------------------------------#
85CHROOT_wrt_target() { # Create target and initialize log file
86#----------------------------------#
87 local i=$1
88 local PREV=$2
[3cb4ef5b]89 local version
90 if [ "$3" != "" ]; then
91 version=-$3
92 fi
[fe30c61]93(
94cat << EOF
95
96$i: $PREV
97 @\$(call echo_message, Building)
[75d6d1c]98${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
[3cb4ef5b]99 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
[2758d94]100 @ : > envars
[fe30c61]101EOF
102) >> $MKFILE.tmp
103}
104
105#=======================
106
107
108#======== UNPACK =======
109
110#----------------------------------#
111LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
112#----------------------------------#
[0722dde]113 local FILE="$1"
114 local optSAVE_PREVIOUS="$2"
115 local version
116 if [ "$3" != "" ]; then
117 version=-"$3"
118 fi
[fe30c61]119
120 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
121(
122cat << EOF
123 @\$(call remove_existing_dirs,$FILE)
124EOF
125) >> $MKFILE.tmp
126 fi
127
128(
129cat << EOF
[2758d94]130 @\$(PRT_DU) >>logs/\$@$version
[fe30c61]131 @\$(call unpack,$FILE)
132 @\$(call get_pkg_root_LUSER)
133EOF
134) >> $MKFILE.tmp
135}
136
137#----------------------------------#
138CHROOT_Unpack() { #
139#----------------------------------#
140 local FILE=$1
141 local optSAVE_PREVIOUS=$2
[0722dde]142 local version
143 if [ "$3" != "" ]; then
144 version=-"$3"
145 fi
[fe30c61]146
147 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
148(
149cat << EOF
150 @\$(call remove_existing_dirs2,$FILE)
151EOF
152) >> $MKFILE.tmp
153 fi
[2758d94]154
[fe30c61]155(
[2758d94]156cat << EOF
157 @\$(PRT_DU_CR) >>logs/\$@$version
[1f81129]158 @\$(call unpack2,$FILE)
[fe30c61]159 @\$(call get_pkg_root2)
160EOF
161) >> $MKFILE.tmp
162}
163
164#=======================
165
166
167#===== TESTS LOGS ======
168
169#----------------------------------#
170LUSER_wrt_test_log() { # Initialize testsuite log file
171#----------------------------------#
[3cb4ef5b]172 local version
173 if [ "$2" != "" ]; then
174 version=-$2
175 fi
176 local TESTLOGFILE=$1$version
[fe30c61]177(
178cat << EOF
[6bb080e]179 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[3cb4ef5b]180 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/$TESTLOGFILE
[fe30c61]181EOF
182) >> $MKFILE.tmp
183}
184
185#----------------------------------#
186CHROOT_wrt_test_log() { #
187#----------------------------------#
[3cb4ef5b]188 local version
189 if [ "$2" != "" ]; then
190 version=-$2
191 fi
192 local TESTLOGFILE=$1$version
[fe30c61]193(
194cat << EOF
[8f2c086]195 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[3cb4ef5b]196 echo "\$(nl_)\`date\`\$(nl_)" >\$(crTESTLOGDIR)/$TESTLOGFILE
[fe30c61]197EOF
198) >> $MKFILE.tmp
199}
200
201#=======================
202
203
204#======== RUN AS =======
205
206#----------------------------------#
207wrt_RunAsRoot() { # Some scripts must be run as root..
208#----------------------------------#
209 local MOUNT_ENV
[3cb4ef5b]210 local version
211 if [ "$2" != "" ]; then
212 version=-$2
213 fi
[8f2c086]214 local file=$1
[fe30c61]215
216(
217cat << EOF
[0fa52f2]218 @export LFS=\$(MOUNT_PT) && \\
[2bd2fb8]219 $COMMANDS/`dirname $file`/\$@ >>logs/\$@$version 2>&1
[fe30c61]220EOF
221) >> $MKFILE.tmp
222}
223
224#----------------------------------#
[0210014]225LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
[fe30c61]226#----------------------------------#
227 local file=$1
[3cb4ef5b]228 local version
229 if [ "$2" != "" ]; then
230 version=-$2
231 fi
[fe30c61]232
233(
234cat << EOF
[68713c9]235 @source ~/.bashrc && \\
[924a237]236 \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1
[fe30c61]237EOF
238) >> $MKFILE.tmp
239}
240
241#----------------------------------#
242CHROOT_wrt_RunAsRoot() { #
243#----------------------------------#
244 local file=$1
[3cb4ef5b]245 local version
246 if [ "$2" != "" ]; then
247 version=-$2
248 fi
[fe30c61]249(
250cat << EOF
[68713c9]251 @source envars && \\
[924a237]252 \$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1
[fe30c61]253EOF
254) >> $MKFILE.tmp
255
256}
257
258#=======================
259
260
261#====== COPY FSTAB =====
262
263#----------------------------------#
264LUSER_wrt_CopyFstab() { #
265#----------------------------------#
266(
267cat << EOF
[68713c9]268 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]269 \$(PRT_DU) >>logs/\$@
[fe30c61]270EOF
271) >> $MKFILE.tmp
272}
273
274#----------------------------------#
275CHROOT_wrt_CopyFstab() { #
276#----------------------------------#
277(
278cat << EOF
[68713c9]279 @cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
[0210014]280 \$(PRT_DU_CR) >>logs/\$@
[fe30c61]281EOF
282) >> $MKFILE.tmp
283}
284
285#=======================
286
287
[93346ee]288#==== INSTALLED FILES LOGS ====
289
[f546320]290#----------------------------------#
291LUSER_wrt_TouchTimestamp() { #
292#----------------------------------#
293(
294cat << EOF
295 @\$(call touch_timestamp_LUSER)
296EOF
297) >> $MKFILE.tmp
298}
299
[93346ee]300#----------------------------------#
301CHROOT_wrt_TouchTimestamp() { #
302#----------------------------------#
303(
304cat << EOF
305 @\$(call touch_timestamp)
306EOF
307) >> $MKFILE.tmp
308}
309
[f546320]310#----------------------------------#
311LUSER_wrt_LogNewFiles() { #
312#----------------------------------#
313(
314cat << EOF
[13e52a5]315 @\$(call log_new_files_LUSER,$1)
[f546320]316EOF
317) >> $MKFILE.tmp
318}
319
[93346ee]320#----------------------------------#
321CHROOT_wrt_LogNewFiles() { #
322#----------------------------------#
323(
324cat << EOF
[13e52a5]325 @\$(call log_new_files,$1)
[93346ee]326EOF
327) >> $MKFILE.tmp
328}
329
330#=======================
331
332
[fe30c61]333#==== RM BUILD DIRS ====
334
335#----------------------------------#
336LUSER_RemoveBuildDirs() { #
337#----------------------------------#
[e639536]338 local name=`echo ${1} | sed 's/[0-9]-//'`
[fe30c61]339(
340cat << EOF
341 @\$(call remove_build_dirs,$name)
342EOF
343) >> $MKFILE.tmp
344}
345
346#----------------------------------#
347CHROOT_wrt_RemoveBuildDirs() { #
348#----------------------------------#
[e639536]349 local name=`echo ${1} | sed 's/[0-9]-//'`
[fe30c61]350(
351cat << EOF
352 @\$(call remove_build_dirs2,$name)
353EOF
354) >> $MKFILE.tmp
355}
356
357#=======================
358
359
360#======== TOUCH ========
361
362#----------------------------------#
363wrt_touch() { #
364#----------------------------------#
365(
366cat << EOF
367 @\$(call housekeeping)
368EOF
369) >> $MKFILE.tmp
370}
371
372#=======================
Note: See TracBrowser for help on using the repository browser.