Commit 3cb4d9ae authored by Michael Shigorin's avatar Michael Shigorin

introduce QUIET variable

This one reduces the amount of output that's only interesting when one is actually watching the console during builds (at least the early stage) -- these tend to look boilerplate and be useless when inspecting the output of a large batch build like [[regular]] one.
parent ec3d40cc
......@@ -56,8 +56,12 @@ SHELL = /bin/bash
say "** goal: $@ [$$n/$(NUM_TARGETS)]"; \
fi; \
for ARCH in $(ARCHES); do \
if [ "$$ARCH" != "$(firstword $(ARCHES))" ]; then say; fi; \
say "** ARCH: $$ARCH"; \
if [ -z "$(QUIET)" ]; then \
if [ "$$ARCH" != "$(firstword $(ARCHES))" ]; then \
say; \
fi; \
say "** ARCH: $$ARCH"; \
fi; \
if $(MAKE) -f main.mk ARCH=$$ARCH $@ $(POSTPROC); then \
if [ -n "$$REPORT" ]; then \
$(MAKE) -f reports.mk ARCH=$$ARCH; \
......
......@@ -70,6 +70,11 @@
** значение: пусто (по умолчанию) либо любая строка
** см. lib/build.mk
* QUIET
** отключает поясняющие сообщения при сборке (например, под cron)
** значение: пусто (по умолчанию) либо любая строка
** см. Makefile, lib/build.mk, lib/clean.mk, lib/profile.mk
* REPORT
** запрашивает создание отчётов о собранном образе
** значение: пусто (по умолчанию) либо любая строка
......
......@@ -2,6 +2,7 @@
ANSI_OK ?= 1;32
ANSI_FAIL ?= 1;31
MAX_LINES = 200
MAX_ERRORS = 5
GOTCHA := ^(((\*\* )?(E:|[Ee]rror|[Ww]arning).*)|(.* (FAILURE|FATAL|ERROR|conflicts|Depends:) .*)|(.* (Stop|failed|not found)\.))$$
......@@ -52,28 +53,38 @@ build-image: profile/populate
echo "$(TIME) skipping actual image build (CHECK is set)"; \
exit; \
fi; \
echo -n "$(TIME) starting image build"; \
if [ -n "$(DEBUG)" ]; then \
echo ": tail -f $(BUILDLOG)" $(SHORTEN); \
else \
echo " (coffee time)"; \
if [ -z "$(QUIET)" ]; then \
echo -n "$(TIME) starting image build"; \
if [ -n "$(DEBUG)" ]; then \
echo ": tail -f $(BUILDLOG)" $(SHORTEN); \
else \
echo " (coffee time)"; \
fi; \
fi; \
if $(START) $(MAKE) -C $(BUILDDIR)/ $(LOG); then \
echo "$(TIME) done (`tail -1 $(BUILDLOG) | cut -f1 -d.`)"; \
tail -200 "$(BUILDLOG)" $(SHORTEN) \
| GREP_COLOR="$(ANSI_OK)" GREP_OPTIONS="--color=auto" \
grep '^\*\* image: .*$$' ||:; \
DURATION="(`tail -1 $(BUILDLOG) | cut -f1 -d.`)"; \
tail -n $(MAX_LINES) "$(BUILDLOG)" $(SHORTEN) \
| if [ -z "$(QUIET)" ]; then \
echo "$(TIME) done $$DURATION"; \
GREP_COLOR="$(ANSI_OK)" GREP_OPTIONS="--color=auto" \
grep '^\*\* image: .*$$' ||:; \
else \
echo -n "$(TIME) $$DURATION "; \
sed -rn 's/^\*\* image: (.*)$$/\1/p'; \
fi; \
RETVAL=0; \
else \
RETVAL=$$?; \
echo -n "$(TIME) failed, see log"; \
if [ -z "$(DEBUG)" ]; then \
if [ -z "$(DEBUG)" -o -n "$(QUIET)" ]; then \
echo ": $(BUILDLOG)" $(SHORTEN); \
echo "$(TIME) (you might want to rerun with DEBUG=1)"; \
else \
echo " above"; \
fi; \
tail -200 "$(BUILDLOG)" \
if [ -z "$(DEBUG)" ]; then \
echo "$(TIME) (you might want to rerun with DEBUG=1)"; \
fi; \
tail -n $(MAX_LINES) "$(BUILDLOG)" \
| GREP_COLOR="$(ANSI_FAIL)" GREP_OPTIONS="--color=auto" \
egrep -m "$(MAX_ERRORS)" "$(GOTCHA)"; \
df -P $(BUILDDIR) | awk 'END { if ($$4 < $(LOWSPACE)) \
......
......@@ -24,7 +24,9 @@ clean:
@{ \
find -name '*~' -delete >&/dev/null ||:; \
if [ -L "$(SYMLINK)" -a -d "$(SYMLINK)"/ ]; then \
echo "$(TIME) cleaning up $(WARNING)"; \
if [ -z "$(QUIET)" ]; then \
echo "$(TIME) cleaning up $(WARNING)"; \
fi; \
$(MAKE) -C "$(SYMLINK)" $@ \
GLOBAL_BUILDDIR="$(realpath $(SYMLINK))" $(LOG) ||:; \
fi; \
......@@ -61,7 +63,9 @@ postclean: build-image
-o ! -t 1 \
-o ! -L "$(SYMLINK)" ]; \
then \
echo "$(TIME) cleaning up after build"; \
if [ -z "$(QUIET)" ]; then \
echo "$(TIME) cleaning up after build"; \
fi; \
$(MAKE) -C "$(BUILDDIR)" distclean \
GLOBAL_BUILDDIR="$(BUILDDIR)" $(LOG) ||:; \
rm -rf "$(BUILDDIR)"; \
......
......@@ -37,7 +37,9 @@ profile/init: distclean
echo "$(TIME) ERROR: invalid BUILDDIR: \`$(BUILDDIR)'"; \
exit 128; \
fi; \
echo -n "$(TIME) initializing BUILDDIR: "; \
if [ -z $(QUIET) ]; then \
echo -n "$(TIME) initializing BUILDDIR: "; \
fi; \
rsync -qaxH --delete-after image.in/ "$(BUILDDIR)"/; \
mkdir "$(BUILDDIR)"/.mki; \
} >&2
......@@ -71,16 +73,22 @@ profile/init: distclean
if [ -w . ]; then \
rm -f "$(SYMLINK)" && \
ln -s "$(BUILDDIR)" "$(SYMLINK)" && \
echo "$(SYMLINK)/"; \
if [ -z $(QUIET) ]; then \
echo "$(SYMLINK)/"; \
fi; \
else \
echo "$(BUILDDIR)/"; \
if [ -z $(QUIET) ]; then \
echo "$(BUILDDIR)/"; \
fi; \
fi $(SHORTEN); \
} >&2
profile/bare: profile/init
@{ \
NOTE="$${GLOBAL_VERBOSE:+: $(CONFIG)}"; \
echo "$(TIME) preparing distro config$$NOTE" $(SHORTEN); \
if [ -z "$(QUIET)" ]; then \
echo "$(TIME) preparing distro config$$NOTE" $(SHORTEN); \
fi; \
} >&2
@$(call try,MKIMAGE_PREFIX,/usr/share/mkimage)
@$(call try,GLOBAL_VERBOSE,)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment