better output directory and results structuring

Following m-p-d, a more involved default output directory
structure is feasible now:

  ~/out/name/date/name-date-arch.type

instead of plain

  ~/out/name-date-arch.type

This particular behaviour can be achieved by passing
SORTDIR='$(IMAGE_NAME)/$(DATE)'; note the single quotes.

Reports are also saved in this resulting structure
albeit the place is still highly debatable.
This commit is contained in:
Michael Shigorin 2012-04-23 21:56:35 +03:00
parent c692da6a06
commit 6e6f572b43
3 changed files with 46 additions and 19 deletions

View File

@ -89,6 +89,12 @@
- fast: gzip/lzo (быстрее запаковывается и распаковывается, меньше степень) - fast: gzip/lzo (быстрее запаковывается и распаковывается, меньше степень)
+ см. ../features.in/stage2/stage1/scripts.d/03-test-kernel + см. ../features.in/stage2/stage1/scripts.d/03-test-kernel
- SORTDIR
+ дополнительно структурирует каталог собранных образов
+ значение: пусто (по умолчанию) либо строка
- например, '$(IMAGE_NAME)/$(DATE)'
+ см. ../image.in/Makefile
пример пример
~~~~~~ ~~~~~~
make DEBUG=1 CLEAN=1 distro/syslinux.iso make DEBUG=1 CLEAN=1 distro/syslinux.iso

View File

@ -11,6 +11,7 @@ MKI_VER_OPTIMAL = 0.2.0
include distcfg.mk include distcfg.mk
include functions.mk include functions.mk
# check the build environment
ifeq (,$(realpath $(MKIMAGE_PREFIX)/config.mk)) ifeq (,$(realpath $(MKIMAGE_PREFIX)/config.mk))
$(error please apt-get install mkimage and have a look at QUICKSTART as well) $(error please apt-get install mkimage and have a look at QUICKSTART as well)
endif endif
@ -26,9 +27,19 @@ $(info warning: mkimage-$(MKI_VERSION) is suboptimal, consider upgrading)
$(warning consider upgrading mkimage to $(MKI_VER_OPTIMAL) or better) $(warning consider upgrading mkimage to $(MKI_VER_OPTIMAL) or better)
endif endif
# additional means to reduce havoc in IMAGEDIR
IMAGE_SORTDIR := $(SORTDIR)
# reconstruct instead of passing yet another variable # reconstruct instead of passing yet another variable
IMAGE_LINK := $(IMAGE_NAME).$(IMAGE_TYPE) IMAGE_OUTDIR := $(IMAGEDIR)$(IMAGE_SORTDIR:%=/%)
IMAGE_OUTFILE := $(IMAGE_NAME)-$(DATE)-$(ARCH).$(IMAGE_TYPE) 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) MKI_PACK_RESULTS = $(IMAGE_PACKTYPE):$(IMAGE_OUTFILE)
# these get opied over as is # these get opied over as is
@ -44,7 +55,7 @@ include lib/*.mk
include $(MKIMAGE_PREFIX)/targets.mk include $(MKIMAGE_PREFIX)/targets.mk
# specified only for the final image (target-specific) # specified only for the final image (target-specific)
pack-image: OUTDIR = $(IMAGEDIR) pack-image: OUTDIR = $(IMAGE_OUTDIR)
pack-image: imagedir pack-image: imagedir
copy-tree: $(SAVE_PROFILE:%=save-profile) copy-tree: $(SAVE_PROFILE:%=save-profile)
@ -57,18 +68,18 @@ save-profile:
.PHONY: imagedir postprocess debug .PHONY: imagedir postprocess debug
imagedir: imagedir:
@mkdir -p "$(IMAGEDIR)" @mkdir -p "$(IMAGE_OUTDIR)"
postprocess: | $(addprefix postprocess-,$(sort $(POSTPROCESS_TARGETS))) postprocess: | $(addprefix postprocess-,$(sort $(POSTPROCESS_TARGETS)))
@OUTPATH="$(IMAGEDIR)/$(IMAGE_OUTFILE)"; \ @OUTSIZE="`ls -lh "$(IMAGE_OUTPATH)" | cut -f5 -d' '`"; \
OUTSIZE="`ls -lh "$$OUTPATH" | cut -f5 -d' '`"; \ echo "** image: $(IMAGE_OUTPATH) [$$OUTSIZE]" >&2 && \
echo "** image: $$OUTPATH [$$OUTSIZE]" >&2 && \ echo "IMAGE_OUTPATH = $(IMAGE_OUTPATH)" && \
ln -sf "$(IMAGE_OUTFILE)" "$(IMAGEDIR)/$(IMAGE_LINK)" && \ ln -sf "$(IMAGE_RELPATH)" "$(IMAGE_LINKPATH)" && \
ln -sf "$${IMAGEDIR#`pwd`/}" "$(OUT_LINK)"; \ ln -sf "$(IMAGE_RELDIR)" "$(OUT_LINK)" && \
ln -sf "$(IMAGE_LINK)" $(OUT_LINK)/"$(CURRENT_LINK).$(IMAGE_TYPE)"; \ ln -sf "$(IMAGE_LINK)" "$(IMAGEDIR)/$(CURRENT_LINK).$(IMAGE_TYPE)"; \
if [ -n "$(GLOBAL_DEBUG)" ]; then \ if [ -n "$(GLOBAL_DEBUG)" ]; then \
cp -a build.log "$$OUTPATH.log"; \ cp -a build.log "$(IMAGE_OUTPATH).log"; \
cp -a distcfg.mk "$$OUTPATH.cfg"; \ cp -a distcfg.mk "$(IMAGE_OUTPATH).cfg"; \
fi fi
debug: debug:

View File

@ -2,20 +2,30 @@
ifneq (,$(REPORT)) ifneq (,$(REPORT))
BUILDDIR := $(shell sed -n 's/^.* BUILDDIR = \(.*\)/\1/p' "$(REPORT_PATH)")
include lib/common.mk 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 all: reports/targets reports/scripts
@cp -a $(REPORTDIR) $(IMAGE_OUTPATH).reports
reports/prep: reports/prep:
@mkdir -p "$(BUILDDIR)/reports/" @mkdir -p "$(REPORTDIR)"
reports/scripts: reports/prep reports/scripts: reports/prep
@grep "^mki.*scripts: Run: " $(BUILDDIR)/$(BUILD_LOG) \ @grep "^mki.*scripts: Run: " $(BUILDLOG) \
| sed -rn "s,^.*($(BUILDDIR)|$(SYMLINK))/(.*)'$$,\2,p" \ | sed -rn "s,^.*($(BUILDDIR)|$(SYMLINK))/(.*)'$$,\2,p" \
> "$(BUILDDIR)/$@.log" \ > "$(REPORTDIR)/$*.log" \
&& echo "** scripts report: $(BUILDDIR)/$@.log" $(SHORTEN) && echo "** scripts report: $(BUILDDIR)/$(@F).log" $(SHORTEN)
reports/targets: reports/prep reports/targets: reports/prep
@if ! [ -n "$(REPORT_PATH)" -a -s "$(REPORT_PATH)" ]; then \ @if ! [ -n "$(REPORT_PATH)" -a -s "$(REPORT_PATH)" ]; then \
@ -32,7 +42,7 @@ reports/targets: reports/prep
&& echo "** graphviz missing, " \ && echo "** graphviz missing, " \
"target graph dot file: $$REPORT_DOT"; \ "target graph dot file: $$REPORT_DOT"; \
fi $(SHORTEN); \ fi $(SHORTEN); \
mv "$(REPORT_PATH)" "$(BUILDDIR)/$@.log" mv "$(REPORT_PATH)" "$(REPORTDIR)/$(@F).log"
else else
all:; @: all:; @: