diff --git a/doc/variables.txt b/doc/variables.txt index 49902f65..135b2ab0 100644 --- a/doc/variables.txt +++ b/doc/variables.txt @@ -89,6 +89,12 @@ - fast: gzip/lzo (быстрее запаковывается и распаковывается, меньше степень) + см. ../features.in/stage2/stage1/scripts.d/03-test-kernel +- SORTDIR + + дополнительно структурирует каталог собранных образов + + значение: пусто (по умолчанию) либо строка + - например, '$(IMAGE_NAME)/$(DATE)' + + см. ../image.in/Makefile + пример ~~~~~~ make DEBUG=1 CLEAN=1 distro/syslinux.iso diff --git a/image.in/Makefile b/image.in/Makefile index 52ba326d..be68ddf2 100644 --- a/image.in/Makefile +++ b/image.in/Makefile @@ -11,6 +11,7 @@ MKI_VER_OPTIMAL = 0.2.0 include distcfg.mk include functions.mk +# check the build environment ifeq (,$(realpath $(MKIMAGE_PREFIX)/config.mk)) $(error please apt-get install mkimage and have a look at QUICKSTART as well) endif @@ -26,9 +27,19 @@ $(info warning: mkimage-$(MKI_VERSION) is suboptimal, consider upgrading) $(warning consider upgrading mkimage to $(MKI_VER_OPTIMAL) or better) endif +# additional means to reduce havoc in IMAGEDIR +IMAGE_SORTDIR := $(SORTDIR) + # reconstruct instead of passing yet another variable -IMAGE_LINK := $(IMAGE_NAME).$(IMAGE_TYPE) -IMAGE_OUTFILE := $(IMAGE_NAME)-$(DATE)-$(ARCH).$(IMAGE_TYPE) +IMAGE_OUTDIR := $(IMAGEDIR)$(IMAGE_SORTDIR:%=/%) +IMAGE_OUTFILE := $(IMAGE_NAME)-$(DATE)-$(ARCH).$(IMAGE_TYPE) +IMAGE_OUTPATH := $(IMAGE_OUTDIR)/$(IMAGE_OUTFILE) +IMAGE_RELPATH := $(IMAGE_SORTDIR:%=%/)$(IMAGE_OUTFILE) +IMAGE_RELDIR := $(IMAGE_OUTDIR:$(GLOBAL_BUILDDIR)/%=%) +IMAGE_LINK := $(IMAGE_NAME).$(IMAGE_TYPE) +IMAGE_LINKPATH := $(IMAGEDIR)/$(IMAGE_LINK) + +### multi-pack can be useful (think netinst iso/tree) MKI_PACK_RESULTS = $(IMAGE_PACKTYPE):$(IMAGE_OUTFILE) # these get opied over as is @@ -44,7 +55,7 @@ include lib/*.mk include $(MKIMAGE_PREFIX)/targets.mk # specified only for the final image (target-specific) -pack-image: OUTDIR = $(IMAGEDIR) +pack-image: OUTDIR = $(IMAGE_OUTDIR) pack-image: imagedir copy-tree: $(SAVE_PROFILE:%=save-profile) @@ -57,18 +68,18 @@ save-profile: .PHONY: imagedir postprocess debug imagedir: - @mkdir -p "$(IMAGEDIR)" + @mkdir -p "$(IMAGE_OUTDIR)" postprocess: | $(addprefix postprocess-,$(sort $(POSTPROCESS_TARGETS))) - @OUTPATH="$(IMAGEDIR)/$(IMAGE_OUTFILE)"; \ - OUTSIZE="`ls -lh "$$OUTPATH" | cut -f5 -d' '`"; \ - echo "** image: $$OUTPATH [$$OUTSIZE]" >&2 && \ - ln -sf "$(IMAGE_OUTFILE)" "$(IMAGEDIR)/$(IMAGE_LINK)" && \ - ln -sf "$${IMAGEDIR#`pwd`/}" "$(OUT_LINK)"; \ - ln -sf "$(IMAGE_LINK)" $(OUT_LINK)/"$(CURRENT_LINK).$(IMAGE_TYPE)"; \ + @OUTSIZE="`ls -lh "$(IMAGE_OUTPATH)" | cut -f5 -d' '`"; \ + echo "** image: $(IMAGE_OUTPATH) [$$OUTSIZE]" >&2 && \ + echo "IMAGE_OUTPATH = $(IMAGE_OUTPATH)" && \ + ln -sf "$(IMAGE_RELPATH)" "$(IMAGE_LINKPATH)" && \ + ln -sf "$(IMAGE_RELDIR)" "$(OUT_LINK)" && \ + ln -sf "$(IMAGE_LINK)" "$(IMAGEDIR)/$(CURRENT_LINK).$(IMAGE_TYPE)"; \ if [ -n "$(GLOBAL_DEBUG)" ]; then \ - cp -a build.log "$$OUTPATH.log"; \ - cp -a distcfg.mk "$$OUTPATH.cfg"; \ + cp -a build.log "$(IMAGE_OUTPATH).log"; \ + cp -a distcfg.mk "$(IMAGE_OUTPATH).cfg"; \ fi debug: diff --git a/reports.mk b/reports.mk index 08c07d6b..227329a4 100644 --- a/reports.mk +++ b/reports.mk @@ -2,20 +2,30 @@ ifneq (,$(REPORT)) -BUILDDIR := $(shell sed -n 's/^.* BUILDDIR = \(.*\)/\1/p' "$(REPORT_PATH)") - include lib/common.mk +BUILDDIR := $(shell sed -n 's/^.* BUILDDIR = \(.*\)/\1/p' "$(REPORT_PATH)") +BUILDLOG := $(BUILDDIR)/$(BUILD_LOG) +REPORTDIR := $(BUILDDIR)/reports/ +IMAGE_OUTPATH := $(shell sed -n 's/^IMAGE_OUTPATH = \(.*\)/\1/p' $(BUILDLOG)) + +# for a multi-image build there's no sense to refer to buildroot +# contained reports as these are very ephemeral between builds +ifneq (1,$(NUM_TARGETS)) +SHORTEN := >/dev/null +endif + all: reports/targets reports/scripts + @cp -a $(REPORTDIR) $(IMAGE_OUTPATH).reports reports/prep: - @mkdir -p "$(BUILDDIR)/reports/" + @mkdir -p "$(REPORTDIR)" reports/scripts: reports/prep - @grep "^mki.*scripts: Run: " $(BUILDDIR)/$(BUILD_LOG) \ + @grep "^mki.*scripts: Run: " $(BUILDLOG) \ | sed -rn "s,^.*($(BUILDDIR)|$(SYMLINK))/(.*)'$$,\2,p" \ - > "$(BUILDDIR)/$@.log" \ - && echo "** scripts report: $(BUILDDIR)/$@.log" $(SHORTEN) + > "$(REPORTDIR)/$*.log" \ + && echo "** scripts report: $(BUILDDIR)/$(@F).log" $(SHORTEN) reports/targets: reports/prep @if ! [ -n "$(REPORT_PATH)" -a -s "$(REPORT_PATH)" ]; then \ @@ -32,7 +42,7 @@ reports/targets: reports/prep && echo "** graphviz missing, " \ "target graph dot file: $$REPORT_DOT"; \ fi $(SHORTEN); \ - mv "$(REPORT_PATH)" "$(BUILDDIR)/$@.log" + mv "$(REPORT_PATH)" "$(REPORTDIR)/$(@F).log" else all:; @: