From c83cc111a6fd09ef44058b727f2b450fde36c5ff Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Tue, 8 May 2012 17:59:57 +0300 Subject: [PATCH] initial kernel and metadata features This further refines the modular build by making metadata being a clearly separated feature rather than having to rely on runtime tests, and also by moving the code which cares for kernel bits of base installation (.base list) in a feature of its own. There's more to it but let's get the ball rolling first. --- .../lib/{branding.mk => 20-branding.mk} | 0 .../{build-distro.mk => 90-build-distro.mk} | 26 +------------ .../lib/{build-ve.mk => 90-build-ve.mk} | 0 features.in/install2/config.mk | 2 +- .../{build-isohybrid.mk => 80-isohybrid.mk} | 0 .../{build-isomd5sum.mk => 89-isomd5sum.mk} | 0 features.in/kernel/config.mk | 4 ++ features.in/kernel/lib/10-kernel.mk | 4 ++ features.in/metadata/README | 3 ++ features.in/metadata/config.mk | 2 + features.in/metadata/lib/50-metadata.mk | 37 +++++++++++++++++++ .../{build-genbasedir.mk => 50-genbasedir.mk} | 0 image.in/functions.mk | 10 +++-- lib/distro.mk | 3 +- pkg.in/lists/Makefile | 24 ------------ 15 files changed, 60 insertions(+), 55 deletions(-) rename features.in/branding/lib/{branding.mk => 20-branding.mk} (100%) rename features.in/build-distro/lib/{build-distro.mk => 90-build-distro.mk} (52%) rename features.in/build-ve/lib/{build-ve.mk => 90-build-ve.mk} (100%) rename features.in/isohybrid/lib/{build-isohybrid.mk => 80-isohybrid.mk} (100%) rename features.in/isomd5sum/lib/{build-isomd5sum.mk => 89-isomd5sum.mk} (100%) create mode 100644 features.in/kernel/config.mk create mode 100644 features.in/kernel/lib/10-kernel.mk create mode 100644 features.in/metadata/README create mode 100644 features.in/metadata/config.mk create mode 100644 features.in/metadata/lib/50-metadata.mk rename features.in/repo/lib/{build-genbasedir.mk => 50-genbasedir.mk} (100%) diff --git a/features.in/branding/lib/branding.mk b/features.in/branding/lib/20-branding.mk similarity index 100% rename from features.in/branding/lib/branding.mk rename to features.in/branding/lib/20-branding.mk diff --git a/features.in/build-distro/lib/build-distro.mk b/features.in/build-distro/lib/90-build-distro.mk similarity index 52% rename from features.in/build-distro/lib/build-distro.mk rename to features.in/build-distro/lib/90-build-distro.mk index 72dc469b..8c1b0da2 100644 --- a/features.in/build-distro/lib/build-distro.mk +++ b/features.in/build-distro/lib/90-build-distro.mk @@ -16,36 +16,14 @@ BOOT_ABST := $(META_ABSTRACT) BOOT_TYPE := isolinux -# Metadata/ needed only for installers (and not for e.g. syslinux.iso) -# FIXME: installable live needs it too, don't move to install2 feature -### see also .../pkg.in/lists/Makefile -ifneq (,$(findstring install2,$(FEATURES))) -METADATA = metadata -endif - # see also ../scripts.d/01-isosort; needs mkimage-0.2.2+ MKI_SORTFILE := /tmp/isosort all: $(GLOBAL_DEBUG) prep copy-subdirs copy-tree run-scripts pack-image \ postprocess $(GLOBAL_CLEAN_WORKDIR) -prep: $(GLOBAL_DEBUG) dot-disk $(METADATA) imagedir - -metadata: dot-base - @mkdir -p files/Metadata - @rm -f files/Metadata/pkg-groups.tar -# see also alterator-pkg (backend3/pkg-install); we only tar up what's up to it - @tar -cvf files/Metadata/pkg-groups.tar -C $(PKGDIR) \ - $$(echo $(call list,$(MAIN_GROUPS) .base) \ - $(call group,$(MAIN_GROUPS)) \ - | sed 's,$(PKGDIR)/*,,g') - -dot-base: - @p="$(call kpackages,$(THE_KMODULES) $(BASE_KMODULES),$(KFLAVOURS))"; \ - echo -e "\n## added by build-distro.mk\n$$p" >> $(call list,.base); \ - if [ -n "$$DOT_BASE" ]; then \ - echo -e "\n## DOT_BASE\n$$DOT_BASE" >> $(call list,.base); \ - fi +prep: $(GLOBAL_DEBUG) dot-disk $(WHATEVER) imagedir +#prep: $(GLOBAL_DEBUG) dot-disk metadata imagedir dot-disk: @mkdir -p files/.disk diff --git a/features.in/build-ve/lib/build-ve.mk b/features.in/build-ve/lib/90-build-ve.mk similarity index 100% rename from features.in/build-ve/lib/build-ve.mk rename to features.in/build-ve/lib/90-build-ve.mk diff --git a/features.in/install2/config.mk b/features.in/install2/config.mk index 25c8ea92..8f983ace 100644 --- a/features.in/install2/config.mk +++ b/features.in/install2/config.mk @@ -1,4 +1,4 @@ -use/install2: use/stage2 sub/stage2/install2 use/cleanup/installer +use/install2: use/stage2 sub/stage2/install2 use/metadata use/cleanup/installer @$(call add_feature) @$(call set,INSTALL2_PACKAGES,installer-distro-$$(INSTALLER)-stage2) @$(call add,INSTALL2_PACKAGES,branding-$$(BRANDING)-alterator) diff --git a/features.in/isohybrid/lib/build-isohybrid.mk b/features.in/isohybrid/lib/80-isohybrid.mk similarity index 100% rename from features.in/isohybrid/lib/build-isohybrid.mk rename to features.in/isohybrid/lib/80-isohybrid.mk diff --git a/features.in/isomd5sum/lib/build-isomd5sum.mk b/features.in/isomd5sum/lib/89-isomd5sum.mk similarity index 100% rename from features.in/isomd5sum/lib/build-isomd5sum.mk rename to features.in/isomd5sum/lib/89-isomd5sum.mk diff --git a/features.in/kernel/config.mk b/features.in/kernel/config.mk new file mode 100644 index 00000000..c74cf3f5 --- /dev/null +++ b/features.in/kernel/config.mk @@ -0,0 +1,4 @@ +### +use/kernel: + @$(call add_feature) + @$(call set,KFLAVOURS,std-def) diff --git a/features.in/kernel/lib/10-kernel.mk b/features.in/kernel/lib/10-kernel.mk new file mode 100644 index 00000000..76c69786 --- /dev/null +++ b/features.in/kernel/lib/10-kernel.mk @@ -0,0 +1,4 @@ +# step 4: build the distribution image +# take care for kernel bits + +DOT_BASE += $(call kpackages,$(THE_KMODULES) $(BASE_KMODULES),$(KFLAVOURS)) diff --git a/features.in/metadata/README b/features.in/metadata/README new file mode 100644 index 00000000..7670eec0 --- /dev/null +++ b/features.in/metadata/README @@ -0,0 +1,3 @@ +Эта фича занимается метаданными в составе образов -- +в первую очередь инсталяционных и пригодных к установке +"живых". diff --git a/features.in/metadata/config.mk b/features.in/metadata/config.mk new file mode 100644 index 00000000..47257862 --- /dev/null +++ b/features.in/metadata/config.mk @@ -0,0 +1,2 @@ +use/metadata: + @$(call add_feature) diff --git a/features.in/metadata/lib/50-metadata.mk b/features.in/metadata/lib/50-metadata.mk new file mode 100644 index 00000000..4af99503 --- /dev/null +++ b/features.in/metadata/lib/50-metadata.mk @@ -0,0 +1,37 @@ +# step 4: build the distribution image + +# package lists are needed for installer and live-install images +METADIR := files/Metadata + +# preparation targets of ../../build-distro/lib/build-distro.mk +WHATEVER += metadata + +# args: name, suffix, command +define dump-THEM +if [ -n "$($(1)_$(2))" ]; then echo -e "\n## $(1)_$(2)"; $(3) $($(1)_$(2)); fi; +endef + +dump-PACKAGES = $(call dump-THEM,$(1),PACKAGES,echo) +dump-LISTS = $(call dump-THEM,$(1),LISTS,cat) + +# BASE_PACKAGES, BASE_LISTS and whatever else goes into base install; +# thus construct requisite .base packagelist for alterator-pkg +metadata-.base: + @cd $(call list,/); \ + { \ + echo "## generated by features.in/metadata/lib/metadata.mk"; \ + $(foreach p,SYSTEM COMMON THE BASE,$(call dump-PACKAGES,$(p))) \ + $(foreach l,THE BASE,$(call dump-LISTS,$(l))) \ + if [ -n "$(DOT_BASE)" ]; then \ + echo -e "\n## DOT_BASE\n$(DOT_BASE)"; \ + fi; \ + } | sed -re '/^[^[:space:]#]/ s/[[:space:]]+/\n/g' > .base + +# see also alterator-pkg (backend3/pkg-install); +# we only tar up what's up to it +metadata: metadata-.base + @mkdir -p $(METADIR); \ + tar -C $(PKGDIR) -cvf - \ + $(call rlist,$(MAIN_GROUPS) .base) \ + $(call rgroup,$(MAIN_GROUPS)) \ + > $(METADIR)/pkg-groups.tar diff --git a/features.in/repo/lib/build-genbasedir.mk b/features.in/repo/lib/50-genbasedir.mk similarity index 100% rename from features.in/repo/lib/build-genbasedir.mk rename to features.in/repo/lib/50-genbasedir.mk diff --git a/image.in/functions.mk b/image.in/functions.mk index 765c9b54..a0fb03a0 100644 --- a/image.in/functions.mk +++ b/image.in/functions.mk @@ -5,11 +5,13 @@ PKGDIR := $(GLOBAL_BUILDDIR)/pkg ARCH ?= $(shell arch | sed 's/i686/i586/') DATE ?= $(shell date +%Y%m%d) -# prefix pkglist name with its directory to form a path -list = $(1:%=$(PKGDIR)/lists/%) +# prefix pkglist name with its directory to form a path (relative/absolute) +rlist = $(1:%=lists/%) +list = $(addprefix $(PKGDIR)/,$(call rlist,$(1))) -# prefix/suffix group name to form a path -group = $(1:%=$(PKGDIR)/groups/%.directory) +# prefix/suffix group name to form a path (relative/absolute) +rgroup = $(1:%=groups/%.directory) +group = $(addprefix $(PKGDIR)/,$(call rgroup,$(1))) # map first argument (a function) onto second one (an argument list) map = $(foreach a,$(2),$(call $(1),$(a))) diff --git a/lib/distro.mk b/lib/distro.mk index f2e94872..92a46128 100644 --- a/lib/distro.mk +++ b/lib/distro.mk @@ -23,8 +23,7 @@ distro/.init: profile/bare # NB: the last flavour in KFLAVOURS gets to be the default one; # the kernel packages regexp evaluation has to take place at build stage -distro/.base: distro/.init - @$(call set,KFLAVOURS,std-def) +distro/.base: distro/.init use/kernel @$(call set,META_SYSTEM_ID,LINUX) @$(call set,META_VOL_ID,ALT Linux $(ARCH)) @$(call set,META_VOL_SET,ALT Linux) diff --git a/pkg.in/lists/Makefile b/pkg.in/lists/Makefile index 9f5071a3..34fa8d61 100644 --- a/pkg.in/lists/Makefile +++ b/pkg.in/lists/Makefile @@ -18,13 +18,6 @@ include $(BUILDDIR)/distcfg.mk SUFFIX := pkg/lists TARGET := $(BUILDDIR)/$(SUFFIX) -# Metadata/ needed only for installers (and not for e.g. syslinux.iso) -# FIXME: installable live needs it too, don't move to install2 feature -### see also .../features.in/build-distro/lib/build-distro.mk -ifneq (,$(findstring install2,$(FEATURES))) -DOTBASE := dot-base -endif - all: $(TARGET) $(GLOBAL_DEBUG) $(DOTBASE) copy-lists copy-groups @if type -t git >&/dev/null && cd $(TARGET); then \ if [ -n "`git status -s`" ]; then \ @@ -47,23 +40,6 @@ copy-groups: cp -at $(TARGET) -- $(THE_GROUPS) $(MAIN_GROUPS); \ fi -# args: name, suffix, command -define dump-THEM -if [ -n "$($(1)_$(2))" ]; then echo -e "\n## $(1)_$(2)"; $(3) $($(1)_$(2)); fi; -endef - -dump-PACKAGES = $(call dump-THEM,$(1),PACKAGES,echo) -dump-LISTS = $(call dump-THEM,$(1),LISTS,cat) - -# BASE_PACKAGES, BASE_LISTS and whatever else goes into base install -dot-base: - @# construct .base packagelist for alterator-pkg - @{ \ - echo "## generated by pkg.in/lists/Makefile"; \ - $(foreach p,SYSTEM COMMON THE BASE,$(call dump-PACKAGES,$(p))) \ - $(foreach l,THE BASE,$(call dump-LISTS,$(l))) \ - } | sed -re '/^[^[:space:]#]/ s/[[:space:]]+/\n/g' >$(TARGET)/.base - # do beforehand as foreach gets expanded before recipe execution $(TARGET): @mkdir -p $(TARGET)