2011-10-06 12:46:31 +04:00
# step 4 is kicked off here but actually done by image.in/Makefile
2011-11-21 14:08:33 +04:00
ANSI_OK ?= 1; 32
ANSI_FAIL ?= 1; 31
2011-10-06 12:46:31 +04:00
2012-04-10 18:48:27 +04:00
GOTCHA := ^( ( ( \* \* ) ?( E:| [ Ee] rror| [ Ww] arning) .*) | ( .* ( Stop| failed) \. ) ) $$
2011-10-06 12:46:31 +04:00
i f n d e f M K I M A G E _ P R O F I L E S
$( error this makefile is designed to be included in toplevel one )
2011-06-12 19:06:36 +04:00
e n d i f
2011-05-11 23:40:47 +04:00
2011-11-04 17:53:06 +04:00
# try not to bog down the system, both CPU and I/O wise
i f d e f N I C E
START := nice $( shell ionice -c3 echo "ionice -c3" 2>/dev/null)
e n d i f
2011-11-04 22:44:25 +04:00
# in kilobytes (a kilometer is 1024 meters, you know)
LOWSPACE = 1024
2011-11-04 17:53:06 +04:00
# it's also nice to know how long and much it takes
START += time -f "%E %PCPU %Mk"
# /usr/bin/{i586,x86_64} are setarch(8) symlinks
START += $( ARCH)
2011-12-30 14:46:58 +04:00
# to be passed into distcfg.mk; suggestions are welcome
IMAGEDIR ?= $( shell \
if [ -d " $$ HOME/out " -a -w " $$ HOME/out " ] ; then \
echo " $$ HOME/out " ; \
else \
dir = " `dirname $( BUILDDIR) `/out " ; \
mkdir -p " $$ dir " && echo " $$ dir " || echo "/tmp" ; \
fi ; \
)
2010-09-27 23:02:57 +04:00
2011-12-30 14:46:58 +04:00
# actual build starter
2012-03-19 15:42:10 +04:00
# NB: our output MUST go into stderr to escape POSTPROC
2011-12-30 14:46:58 +04:00
build-image : profile /populate
2012-03-19 15:42:10 +04:00
@{ \
if [ -n " $( CHECK) " ] ; then \
2011-12-05 21:13:33 +04:00
echo " $( TIME) skipping actual image build (CHECK is set) " ; \
exit; \
fi ; \
echo -n " $( TIME) starting image build " ; \
if [ -n " $( DEBUG) " ] ; then \
2011-06-12 22:27:49 +04:00
echo " : tail -f $( BUILDLOG) " $( SHORTEN) ; \
2011-05-11 23:40:47 +04:00
else \
2011-12-30 14:46:58 +04:00
echo " (coffee time)" ; \
2011-12-05 21:13:33 +04:00
fi ; \
if $( START) $( MAKE) -C $( BUILDDIR) / $( LOG) ; then \
2011-11-04 22:44:25 +04:00
echo " $( TIME) done (`tail -1 $( BUILDLOG) | cut -f1 -d.`) " ; \
2011-12-08 11:30:06 +04:00
tail -200 " $( BUILDLOG) " $( SHORTEN) \
2012-01-05 00:30:56 +04:00
| GREP_COLOR = " $( ANSI_OK) " GREP_OPTIONS = "--color=auto" \
2012-04-10 18:48:27 +04:00
grep '^\*\* image: .*$$' || :; \
2011-05-11 23:40:47 +04:00
else \
2011-12-30 14:46:58 +04:00
echo -n " $( TIME) failed, see log " ; \
2011-09-14 20:37:29 +04:00
if [ -z " $( DEBUG) " ] ; then \
2011-12-30 14:46:58 +04:00
echo " : $( BUILDLOG) " $( SHORTEN) ; \
echo " $( TIME) (you might want to rerun with DEBUG=1) " ; \
else \
echo " above" ; \
2011-05-11 23:40:47 +04:00
fi ; \
2011-11-21 14:08:33 +04:00
tail -200 " $( BUILDLOG) " \
2012-01-05 00:30:56 +04:00
| GREP_COLOR = " $( ANSI_FAIL) " GREP_OPTIONS = "--color=auto" \
2012-04-10 18:48:27 +04:00
egrep " $( GOTCHA) " ; \
2011-11-04 22:44:25 +04:00
df -P $( BUILDDIR) | awk ' END { if ( $$ 4 < $( LOWSPACE) ) \
2011-11-04 15:26:31 +04:00
{ print "NB: low space on " $$ 6" (" $$ 5" used)" } } ' ; \
2011-12-05 21:13:33 +04:00
fi ; \
2012-03-19 15:42:10 +04:00
if [ -n " $( BELL) " ] ; then echo -ne '\a' ; fi ; \
} >& 2