Commit d93989a3 authored by Michael Shigorin's avatar Michael Shigorin

initial logging subsystem

Now we don't dump all the gory details onto thee but rather log them handsomely and present only the most important details by default; use DEBUG=1 and/or BUILDLOG=/path/to/file to tweak. Also introduced IMAGEDIR and IMAGENAME. The rest: - ovz-smp is no more - base-l10n pkglist (suggested by Alexander Kuprin) - clean.mk: + fixed an oversight: the test result erroneously applied only to the first command of several ones that should be run iff build/ is a symlink + drop implicit rules (it's no C code) - Makefile: more reasonable iso names - image.in/Makefile: .disk/date too
parent e96e2e78
......@@ -9,12 +9,7 @@
all help:
@echo '** available distribution targets:'
@echo $(DISTROS) | fmt -sw65 | column -t
include clean.mk
include distro.mk
include profile.mk
include iso.mk
@echo $(DISTROS) | fmt -sw"$$((COLUMNS>>1))" | column -t
# this could have come from environment;
# if not, can be symlinked if r/w, or made anew (NB: immediate assignment)
......@@ -23,16 +18,33 @@ PREFIX := mkimage-profiles.build
BUILDDIR := $(shell [ -s build ] && realpath build || bin/mktmpdir $(PREFIX))
endif
ifdef DEBUG
GLOBAL_VERBOSE ?= 1
SHELL += -x
endif
# most of the actual work done elsewhere
include clean.mk
include distro.mk
include profile.mk
include log.mk
include iso.mk
# we can't use implicit rules for top-level targets, only for prereqs
CONFIGS := $(shell sed -n 's,^distro/\([^:.]\+\):.*$$,\1,p' distro.mk)
DISTROS := $(addsuffix .iso,$(CONFIGS))
ARCH ?= $(shell arch | sed 's/i686/i586/')
DATE = $(shell date +%Y%m%d)
export ARCH BUILDDIR DATE SHELL
export ARCH BUILDDIR DEBUG GLOBAL_VERBOSE SHELL
# to be passed into .config.mk
IMAGEDIR ?= $(shell [ -d "$$HOME/out" -a -w "$$HOME/out" ] \
&& echo "$$HOME/out" \
|| echo "$(BUILDDIR)/out" )
IMAGENAME ?= mkimage-profiles-$(ARCH).iso
$(DISTROS): %.iso: | profile/init distro/% boot/isolinux profile/populate iso
@# TODO: run automated tests (e.g. iso size)
@OUTNAME="$(@:.iso=)-$(DATE)-$(ARCH).iso"; \
test -s "$(IMAGEDIR)/$(IMAGENAME)" && \
mv "$(IMAGEDIR)/"{$(IMAGENAME),$$OUTNAME} && \
echo "** image: $(IMAGEDIR)/$$OUTNAME" && \
ln -sf "$$OUTNAME" "$(IMAGEDIR)/$@" && \
ln -sf "$@" "$(IMAGEDIR)/mkimage-profiles.iso"
### TODO: copy build.log as well for successful builds?
......@@ -50,3 +50,10 @@ configurables: ~/.mkimage/metaconf.mk, see distro.mk
NB: следует крайне осторожно пользоваться COMMON_PACKAGES,
т.к. указанные пакеты попадут во все стадии (в т.ч.
stage1 и install2, чувствительные к объёму).
Результат:
- при успешном завершении сборки образ называется сообразно
дистрибутиву и укладывается в $(IMAGEDIR):
+ указанный явно,
+ либо ~/out/ (если возможно),
+ или $(BUILDDIR)/out/ иначе
# this makefile can be used standalone
# drop stock predefined rules
.DEFAULT:
clean:
@echo '** cleaning up...'
@echo '** cleaning up'
@find -name '*~' -delete >&/dev/null
@[ -d build/ ] && \
$(MAKE) -C build/ $@ GLOBAL_BUILDDIR=$(shell readlink build) \
||:
@if test -L build; then \
$(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG); \
fi
# there can be some sense in writing log here even if normally
# $(BUILDDIR)/ gets purged: make might have failed,
# and BUILDLOG can be specified by hand either
distclean: clean
@[ -d build/ ] && \
@if test -L build; then \
rm -rf build/.git; \
$(MAKE) -C build/ $@ GLOBAL_BUILDDIR=$(shell readlink build) && \
$(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG) && \
rm -r $(shell readlink build) && \
rm build \
||:
rm build; \
fi
# this makefile is designed to be included in toplevel one
ifdef BUILDDIR
# step 2: build up distribution's configuration
#
# NB: distro/ targets should be defined here,
# see toplevel Makefile's $(DISTRO) assignment
CONFIG = $(BUILDDIR)/.config.mk
......@@ -7,7 +10,7 @@ CONFIG = $(BUILDDIR)/.config.mk
# source initial feature snippets
-include features.in/*/config.mk
# put(), add(), set(), tags()
# put(), add(), set(), try(), tags(): see functions.mk
#
# package list names are considered relative to pkg/lists/
#
......@@ -26,9 +29,11 @@ sub/%:
# initalize config from scratch, put some sane defaults in
distro/.init:
@echo "** starting distro configuration build process"
@echo "** preparing distro configuration$${DEBUG:+: see $(CONFIG)}"
@$(call try,MKIMAGE_PREFIX,/usr/share/mkimage)
@$(call try,GLOBAL_VERBOSE,)
@$(call try,IMAGEDIR,$(IMAGEDIR))
@$(call try,IMAGENAME,$(IMAGENAME))
# NB: the last flavour in KFLAVOURS gets to be the default one;
# the kernel packages regexp evaluation has to take place at build stage
......@@ -49,7 +54,7 @@ distro/server-base: distro/installer sub/main use/syslinux/ui-menu use/memtest
distro/server-light: distro/server-base use/hdt
@$(call set,BRANDING,sisyphus-server-light)
@$(call set,KFLAVOURS,ovz-smp el-smp) # override default
@$(call set,KFLAVOURS,ovz-el el-smp) # override default
@$(call add,KMODULES,igb ipset kvm ndiswrapper pf_ring rtl8192 xtables-addons)
@$(call add,DISK_LISTS,kernel-wifi)
@$(call add,BASE_LISTS,$(call tags,base server))
......@@ -72,3 +77,5 @@ distro/.metaconf:
boot/%: distro/.init
@$(call set,BOOTLOADER,$*)
endif
use/hdt: use/syslinux
@$(call add,STAGE1_PACKAGES,pciids)
@$(call add,SYSLINUX_MODULES,hdt)
# might be /usr/share/pci.ids if usig hwdatabase
@$(call add,SYSLINUX_FILES,/usr/share/misc/pci.ids)
label harddisk
menu label ^Continue as usual
menu label ^Boot from HDD (as usual)
localboot 0x80
label linux
menu label ^Normal install
menu label ^Install ALT Linux
kernel alt0/vmlinuz
append initrd=alt0/full.cz changedisk vga=0x314 quiet=1 showopts automatic=method:cdrom
label noapic
menu label ^FailSafe(TM) install
menu label ^Install ALT Linux (failsafe)
kernel alt0/vmlinuz
append initrd=alt0/full.cz changedisk vga=0x314 showopts nolapic noapic acpi=off
append initrd=alt0/full.cz changedisk showopts nolapic noapic
label rescue
menu label ^Rescue
menu label ^Rescue LiveCD
kernel alt0/vmlinuz
append initrd=alt0/full.cz live fastboot stagename=rescue
# NB: don"t use ANY quotes ('/") for put()/add()/set() arguments!
# shell will get confused by ' or args get spammed with "
# pay attention to the context in which functions get called:
# pay attention to the context functions get called in:
# e.g. features.in/syslinux/config.mk introduces conditionals
# this one adds whatever is given as an argument
......
......@@ -12,10 +12,13 @@ SUBDIRS = $(SUBPROFILES)
# "main" subprofile needs genbasedir
CHROOT_PACKAGES = apt-utils
###
MKI_PACK_RESULTS = isoboot:mkimage-profiles.iso
MKI_PACK_RESULTS = isoboot:$(IMAGENAME)
COPY_TREE = ./files
BOOT_TYPE = isolinux
# outdir shouldn't be wiped clean before use
CLEANUP_OUTDIR =
ifeq "$(wildcard $(APTCONF))" ""
GLOBAL_HSH_APT_CONFIG = /etc/apt/apt.conf
else
......@@ -27,7 +30,13 @@ include $(MKIMAGE_PREFIX)/targets.mk
all: prep copy-subdirs copy-tree run-scripts pack-image
# FIXME: scripts.d/?
prep: debug dot-disk metadata
prep: debug dot-disk metadata $(IMAGEDIR)
$(IMAGEDIR):
mkdir -p "$(IMAGEDIR)"
# specified only for the final image, not for the subparts
pack-image: OUTDIR = $(IMAGEDIR)
debug:
ifdef DEBUG
......@@ -40,6 +49,7 @@ dot-disk:
@mkdir -p files/.disk
@echo "ALT Linux based" >files/.disk/info
@echo "$(ARCH)" >files/.disk/arch
@echo "$(DATE)" >files/.disk/date
@type -t git >&/dev/null && ( \
cd $(TOPDIR) && \
git show-ref --head --dereference -s -- HEAD 2>/dev/null; \
......
# this makefile is designed to be included in toplevel one
ifdef BUILDDIR
# step 4 is kicked off here but actually done by image.in/Makefile
#
# adding boot/isolinux to prereqs is too late here,
......@@ -6,5 +9,24 @@
# NB: /usr/bin/{i586,x86_64} are setarch(8) symlinks
iso:
@echo "** starting image build process"
$(ARCH) $(MAKE) -C $(BUILDDIR)/ GLOBAL_BUILDDIR=$(BUILDDIR)
@echo -n "** starting image build"
@if test -n "$(DEBUG)"; then \
echo ": see $(BUILDLOG)"; \
else \
echo " (coffee time)"; \
fi
@if time $(ARCH) \
$(MAKE) -C $(BUILDDIR)/ GLOBAL_BUILDDIR=$(BUILDDIR) $(LOG); \
then \
echo "** build done (`tail -2 $(BUILDLOG) \
| sed -n 's,^.* \([0-9:]\+\)\...elapsed.*$$,\1,p' \
|| echo "no log"`)"; \
else \
echo "** build failed, see log: $(BUILDLOG)"; \
if test -z "$(DEBUG)"; then \
echo " (you might want to re-run with DEBUG=1)"; \
fi; \
tail -100 "$(BUILDLOG)" | grep "^E:"; \
fi
endif
# this makefile is designed to be included in toplevel one
ifdef BUILDDIR
# simple logging switch inspired by netch@'s advice:
# you can add plain $(LOG) to a rule recipe line to moderate it
# (logfile is automatically truncated during profile/init)
BUILDLOG ?= $(BUILDDIR)/build.log
ifdef DEBUG
GLOBAL_VERBOSE ?= $(DEBUG)
ifeq (2,$(DEBUG))
SHELL += -x
endif
LOG = >>$(BUILDLOG) 2>&1
else
MAKE += -s
LOG = 2>>$(BUILDLOG) >/dev/null
endif
export BUILDLOG DEBUG GLOBAL_VERBOSE LOG MAKE SHELL
endif
glibc-locales
glibc-gconv-modules
# this makefile is designed to be included in toplevel one
ifdef BUILDDIR
# step 1: initialize the off-tree mkimage profile
profile/init:
@echo "** BUILDDIR: $(BUILDDIR)"
profile/init: distclean
@echo -n "** initializing BUILDDIR: "
@rsync -qaH --delete image.in/ "$(BUILDDIR)"/
@:> "$(BUILDDIR)"/.config.mk
@:> "$(BUILDLOG)"
@mkdir "$(BUILDDIR)"/.mki # mkimage toplevel marker
@type -t git >&/dev/null && \
cd $(BUILDDIR) && \
......@@ -11,14 +15,16 @@ profile/init:
git commit -qam 'init'
@rm -f build
@if [ -w . ]; then \
ln -sf "$(BUILDDIR)" build; \
ln -sf "$(BUILDDIR)" build && \
echo "build/"; \
else \
echo "** profile directory readonly: skipping symlinks, env only"; \
echo "$(BUILDDIR)/"; \
fi
# this is done after step 2, see toplevel Makefile
profile/populate: profile/init distro/.metaconf
@for dir in sub.in features.in pkg.in; do \
$(MAKE) -C $$dir; \
$(MAKE) -C $$dir $(LOG); \
done
endif
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