Commit 878abab5 authored by Michael Shigorin's avatar Michael Shigorin

clean.mk and friends: introduced CLEAN control variable

make CLEAN=1 will prune workdirs after packing their results, so disk (or preferably tmpfs) usage will be lower
parent 20844de7
......@@ -3,8 +3,18 @@
# drop stock predefined rules
.DEFAULT:
# tmpfs-sparing extra rule: cleanup workdir after completing each stage
# (as packed results are saved this only lowers RAM pressure)
ifdef CLEAN
export GLOBAL_CLEAN_WORKDIR = clean-current
ifdef DEBUG
WARNING = (both CLEAN and DEBUG defined, debug options will be limited)
endif
endif
# ordinary clean: destroys workdirs but not the corresponding results
clean:
@echo '** cleaning up'
@echo '** cleaning up $(WARNING)'
@find -name '*~' -delete >&/dev/null
@if [ -L build -a -d build/ ]; then \
$(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG); \
......
### sample ~/.mkimage/profiles.mk
# ARCH is defined in/for metaprofile's toplevel Makefile, not here
APTCONF = ~/apt/apt.conf.$(ARCH)
### where to look for apt.conf; system one used by default
#APTCONF = ~/apt/apt.conf.$(ARCH)
# can be defined here but passing DEBUG=1 is preferred
#GLOBAL_VERBOSE = 1
### turns on GLOBAL_VERBOSE and prettier output
#DEBUG = 1
# spares tmpfs, quite recommended unless you need raw workdir chroots
#CLEAN = 1
При запуске на сборку принимается ряд переменных
(см. тж. profiles.mk.sample):
- APTCONF
+ задаёт путь к требуемому apt.conf
+ значение: пусто (по умолчанию системный) либо строка
+ см. image.in/Makefile
- ARCH
+ определяет целевую архитектуру образа
+ значение: пусто (по умолчанию авто), i586 или x86_64
+ см. iso.mk
- BUILDDIR
+ определяет каталог генерируемого профиля и сборки
+ значение: пусто (по умолчанию авто) либо строка
+ см. profile.mk
- CLEAN
+ экономия RAM при сборке в tmpfs, иначе места на диске
+ очистка рабочего каталога после успешной сборки очередной стадии
+ может помешать использовать некоторые варианты отладки
+ значение: любая строка, по умолчанию пусто
+ см. clean.mk
- DEBUG
+ включение средств отладки
+ значение: пусто (по умолчанию), 1 или 2
+ см. log.mk
......@@ -32,7 +32,8 @@ endif
include $(MKIMAGE_PREFIX)/targets.mk
all: prep copy-subdirs copy-tree run-scripts pack-image
all: $(GLOBAL_DEBUG) prep copy-subdirs copy-tree run-scripts pack-image \
$(GLOBAL_CLEAN_WORKDIR)
# Metadata/ needed only for installer (and not for e.g. syslinux.iso)
ifeq "$(INSTALLER_KFLAVOUR)$(KFLAVOURS)" ""
......
......@@ -11,6 +11,8 @@ BUILDLOG ?= $(BUILDDIR)/build.log
# LOG holds a postprocessor
ifdef DEBUG
# 1) makefile target; 2) also passed to script hooks
GLOBAL_DEBUG := debug
GLOBAL_VERBOSE ?= $(DEBUG)
ifeq (2,$(DEBUG))
SHELL += -x
......@@ -19,8 +21,6 @@ LOG = >>$(BUILDLOG) 2>&1
else
MAKE += -s
LOG = 2>>$(BUILDLOG) >/dev/null
# 1) makefile target; 2) also passed to script hooks
GLOBAL_DEBUG := debug
endif
DATE = $(shell date +%Y%m%d)
......
......@@ -2,7 +2,7 @@
# this could have come from environment;
# if not, can be symlinked if r/w, or made anew
# NB: immediate assignment
# NB: immediate assignment matters
ifndef BUILDDIR
BUILDDIR := $(shell [ -s build ] \
&& realpath build \
......
......@@ -32,4 +32,9 @@ MKI_PACK_RESULTS = squash:altinst
include $(MKIMAGE_PREFIX)/targets.mk
all: | build-image run-image-scripts pack-image
all: | $(GLOBAL_DEBUG) build-image run-image-scripts pack-image \
$(GLOBAL_CLEAN_WORKDIR)
debug:
@echo "** install2: IMAGE_PACKAGES: $(IMAGE_PACKAGES)"
@echo "** install2: IMAGE_PACKAGES_REGEXP: $(IMAGE_PACKAGES_REGEXP)"
......@@ -25,7 +25,7 @@ MKI_PACK_RESULTS = data
include $(MKIMAGE_PREFIX)/targets.mk
all: $(GLOBAL_DEBUG) copy-packages pack-image
all: $(GLOBAL_DEBUG) copy-packages pack-image $(GLOBAL_CLEAN_WORKDIR)
debug:
@echo "** main: IMAGE_PACKAGES: $(IMAGE_PACKAGES)"
......
......@@ -41,7 +41,7 @@ CHROOT_PACKAGES = $(STAGE1_PACKAGES) $(COMMON_PACKAGES)
# scripts prepare bootloader configuration, too
# NB: we pass tested squashfs options for ../install2/Makefile
all: | debug prepare-workdir copy-tree run-scripts build-propagator \
copy-$(BOOTLOADER) pack-image
copy-$(BOOTLOADER) pack-image $(GLOBAL_CLEAN_WORKDIR)
@cp $(OUTDIR)/squashcfg.mk $(GLOBAL_BUILDDIR)/
debug:
......
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