diff --git a/.gitignore b/.gitignore index bdc5af0409bb506232f5fa7f1b4e87d2bf3fda5b..ea9e267e7f098238efa893a33af9dadb487963c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ +.*.swp build diff --git a/Makefile b/Makefile index f2ed74b31feb5c47064eb14ff31269da3eb72130..02dcd828e335924b801906aa49f29387989f5ed2 100644 --- a/Makefile +++ b/Makefile @@ -11,17 +11,10 @@ all help: @echo '** available distribution targets:' @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) -ifndef BUILDDIR -PREFIX := mkimage-profiles.build -BUILDDIR := $(shell [ -s build ] && realpath build || bin/mktmpdir $(PREFIX)) -endif - # most of the actual work done elsewhere include clean.mk -include distro.mk include profile.mk +include distro.mk include log.mk include iso.mk @@ -31,7 +24,7 @@ DISTROS := $(addsuffix .iso,$(CONFIGS)) ARCH ?= $(shell arch | sed 's/i686/i586/') DATE = $(shell date +%Y%m%d) -export ARCH BUILDDIR DATE SHELL +export ARCH DATE # to be passed into distcfg.mk IMAGEDIR ?= $(shell [ -d "$$HOME/out" -a -w "$$HOME/out" ] \ diff --git a/distro.mk b/distro.mk index 5d50529554f1e575c678cd4de48f5e89c5ee5de9..3765b8d10547f8d7442079e0bc9ae64aee2d3b7b 100644 --- a/distro.mk +++ b/distro.mk @@ -1,5 +1,7 @@ # this makefile is designed to be included in toplevel one -ifdef BUILDDIR +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif # step 2: build up distribution's configuration @@ -47,7 +49,9 @@ distro/server-ovz: distro/server-base use/hdt @$(call set,KFLAVOURS,std-def ovz-el) @$(call set,KDEFAULT,ovz-el) @$(call set,STAGE1_KMODULES_REGEXP,drm.*) - @$(call add,KMODULES,igb ipset kvm ndiswrapper pf_ring rtl8192 xtables-addons) + @$(call add,KMODULES,bcmwl e1000e igb ndiswrapper rtl8168 rtl8192) + @$(call add,KMODULES,ipset ipt-netflow opendpi pf_ring xtables-addons) + @$(call add,KMODULES,drbd83 kvm) @$(call add,DISK_LISTS,kernel-wifi) @$(call add,BASE_LISTS,ovz-server) @$(call add,BASE_LISTS,$(call tags,base server)) @@ -56,10 +60,7 @@ distro/server-ovz: distro/server-base use/hdt @$(call add,GROUPS,monitoring diag-tools) distro/minicd: distro/server-base - @$(call set,KFLAVOURS,un-def) # we might need the most recent drivers + @$(call set,KFLAVOURS,pure-emerald) # we might need the most recent drivers @$(call add,MAIN_PACKAGES,etcnet-full) # if there are too many screens above, it might make sense to distro.d/ -else -$(error BUILDDIR not defined) -endif diff --git a/features.in/Makefile b/features.in/Makefile index 3ade3027e44841e61d9a34d94357c8a2cab49b79..c677e45a43c70cccbcb2f7549a5d038b707ede45 100644 --- a/features.in/Makefile +++ b/features.in/Makefile @@ -1,8 +1,10 @@ -ifdef BUILDDIR - # step 3: copy the needed features to $(BUILDDIR) # (only regarding the needed subprofiles) +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif + -include $(BUILDDIR)/distcfg.mk # first rsync what's static, and make backups -- @@ -11,7 +13,7 @@ ifdef BUILDDIR all: @echo "** starting feature configuration" - @if test -n "$(DEBUG)"; then echo "** requested: $(FEATURES)"; fi + @if test -n "$(GLOBAL_DEBUG)"; then echo "** requested: $(FEATURES)"; fi @for dir in $(FEATURES); do \ for sub in $(SUBPROFILES); do \ if test -d $$dir/$$sub/; then \ @@ -38,7 +40,3 @@ all: help: @echo "** available features:" @grep -h '^use/' */config.mk - -else -$(error BUILDDIR not defined) -endif diff --git a/image.in/Makefile b/image.in/Makefile index 3ae725da391e28353d7943eda7c4c164b5be887f..3be96a38346654d72bca17e17b7eb77c24f99b82 100644 --- a/image.in/Makefile +++ b/image.in/Makefile @@ -2,6 +2,10 @@ # # NB: this metaprofile directory forms the initial BUILDDIR/ +ifndef GLOBAL_BUILDDIR +$(error GLOBAL_BUILDDIR not defined) +endif + include functions.mk include $(GLOBAL_BUILDDIR)/functions.mk include $(GLOBAL_BUILDDIR)/distcfg.mk @@ -31,9 +35,9 @@ include $(MKIMAGE_PREFIX)/targets.mk all: prep copy-subdirs copy-tree run-scripts pack-image # Metadata/ needed only for installer (and not for e.g. syslinux.iso) -ifeq "$(KFLAVOURS)" "" +ifeq "$(STAGE1_KFLAVOUR)$(KFLAVOURS)" "" metadata: - @echo "** skipping metadata target, no kernel installed" + @echo "** skipping metadata target, no stage1 kernel installed" else # see also alterator-pkg (backend3/pkg-install) # FIXME: if we copy --as-needed, maybe just tar . ? @@ -41,8 +45,8 @@ else metadata: @mkdir -p files/Metadata @rm -f files/Metadata/pkg-groups.tar - @echo -e "\n# auto-added in image.in/Makefile\n$(call kpackages)" \ - >> $(call list,.base) + @echo -e "\n# auto-added in image.in/Makefile" >> $(call list,.base) + @echo "$(call kpackages,$(KMODULES),$(KFLAVOURS))" >> $(call list,.base) @echo "branding-$(BRANDING)-release" >> $(call list,.base) @tar -cvf files/Metadata/pkg-groups.tar \ -C $(PKGDIR) \ @@ -53,7 +57,7 @@ metadata: endif # FIXME: scripts.d/? -prep: debug dot-disk metadata $(IMAGEDIR) +prep: $(GLOBAL_DEBUG) dot-disk metadata $(IMAGEDIR) $(IMAGEDIR): mkdir -p "$(IMAGEDIR)" @@ -62,11 +66,9 @@ $(IMAGEDIR): pack-image: OUTDIR = $(IMAGEDIR) debug: -ifdef DEBUG - @echo "TOPDIR=$(TOPDIR)" - @echo "ARCH=$(ARCH)" - @echo "GLOBAL_HSH_APT_CONFIG=$(GLOBAL_HSH_APT_CONFIG)" -endif + echo "TOPDIR=$(TOPDIR)" + echo "ARCH=$(ARCH)" + echo "GLOBAL_HSH_APT_CONFIG=$(GLOBAL_HSH_APT_CONFIG)" dot-disk: @mkdir -p files/.disk @@ -75,5 +77,5 @@ dot-disk: @echo "$(DATE)" >files/.disk/date @type -t git >&/dev/null && ( \ cd $(TOPDIR) && \ - git show-ref --head --dereference -s -- HEAD 2>/dev/null; \ + git show-ref --head -d -s -- HEAD 2>/dev/null; \ ) >files/.disk/commit diff --git a/image.in/functions.mk b/image.in/functions.mk index 37e0edb9332b953f7ed7fb7e4fe1f3176527b607..20fddb0f1c764401ee2ffd817e141b5203476176 100644 --- a/image.in/functions.mk +++ b/image.in/functions.mk @@ -12,6 +12,6 @@ map = $(foreach a,$(2),$(call $(1),$(a))) # kernel package list generation; see also #24669 NULL := SPACE := $(NULL) # the officially documented way of getting a space -# NB: sort() shouldn't be applied here as kernel image order matters list2re = $(subst $(SPACE),|,$(strip $(1))) -kpackages = ^kernel-(image|modules-($(call list2re,$(KMODULES))))-($(call list2re,$(KFLAVOURS)))$$ +# args: KMODULES, KFLAVOURS +kpackages = ^kernel-(image|modules-($(call list2re,$(1))))-($(call list2re,$(2)))$$ diff --git a/image.in/scripts.d/01-genbasedir b/image.in/scripts.d/01-genbasedir index 61390769e48bb56f17b8dc1ef04a958719bc62e8..71dbe321f850d340535c3c63f31f8ed7bdf6f9df 100755 --- a/image.in/scripts.d/01-genbasedir +++ b/image.in/scripts.d/01-genbasedir @@ -11,6 +11,7 @@ verbose started [ -d "$WORKDIR/ALTLinux" ] || exit 0 cd "$WORKDIR/ALTLinux" +# FIXME: m-p-d legacy set -- contrib-main addon-main ltsp-main for pair; do slave=${pair%-*} diff --git a/iso.mk b/iso.mk index f406fe8f2ace487905d106f0ccd2c88c2c507d39..ebaec04253913f6eb9217e7178eb7f81b405ec9f 100644 --- a/iso.mk +++ b/iso.mk @@ -1,5 +1,7 @@ # this makefile is designed to be included in toplevel one -ifdef BUILDDIR +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif # step 4 is kicked off here but actually done by image.in/Makefile # @@ -28,5 +30,3 @@ iso: fi; \ tail -100 "$(BUILDLOG)" | grep "^E:"; \ fi - -endif diff --git a/libdistro.mk b/libdistro.mk index 50abbc5e8b01e76296d614ec4dab2a65640f6183..49039a136d3c9e489350f2026453f4f7a0243ebf 100644 --- a/libdistro.mk +++ b/libdistro.mk @@ -23,7 +23,6 @@ distro/.branding: distro/.init # the kernel packages regexp evaluation has to take place at build stage distro/.base: distro/.branding sub/stage1 use/syslinux use/syslinux/localboot.cfg @$(call set,IMAGE_INIT_LIST,+branding-$$(BRANDING)-release) - @$(call set,BRANDING,altlinux-sisyphus) @$(call set,KFLAVOURS,std-def) # pick up release manager's config diff --git a/log.mk b/log.mk index ec4f93aee96026fba6fd1a82e4d563ee63a697f2..4a937bcfa4a05bd83f8f7805371ae6a86335a06d 100644 --- a/log.mk +++ b/log.mk @@ -1,5 +1,7 @@ # this makefile is designed to be included in toplevel one -ifdef BUILDDIR +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif # simple logging switch inspired by netch@'s advice: # you can add plain $(LOG) to a rule recipe line to moderate it @@ -16,8 +18,8 @@ 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 -export BUILDLOG DEBUG GLOBAL_VERBOSE LOG MAKE SHELL - -endif +export BUILDLOG DEBUG GLOBAL_DEBUG GLOBAL_VERBOSE LOG MAKE SHELL diff --git a/pkg.in/Makefile b/pkg.in/Makefile index 0525d480ca88dbb0830ce750ab92d809f5fd678d..9efe75ccd670ca3b33dea29173f9a94b34836571 100644 --- a/pkg.in/Makefile +++ b/pkg.in/Makefile @@ -1,6 +1,10 @@ # step 3: copy package lists and groups referenced in distro configuration # (and only those!) over to $(BUILDDIR) +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif + all: for dir in lists groups; do \ $(MAKE) -C $$dir BUILDDIR=$(BUILDDIR); \ diff --git a/pkg.in/groups/Makefile b/pkg.in/groups/Makefile index 0ca0f00d12727cd18acf602ad9d071cb893e2a04..1faae0945c77081eeffd7d1e9ba142606bcdc257 100644 --- a/pkg.in/groups/Makefile +++ b/pkg.in/groups/Makefile @@ -1,11 +1,15 @@ # step 3: copy package groups referenced in distro configuration # (and only those!) over to $(BUILDDIR) +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif + include $(BUILDDIR)/distcfg.mk SUFFIX := pkg/groups TARGET := $(BUILDDIR)/$(SUFFIX) -all: debug +all: $(GLOBAL_DEBUG) @if [ -n "$(GROUPS)" ]; then \ mkdir -p $(TARGET) && \ cp -at $(TARGET) -- $(addsuffix .directory,$(GROUPS)); \ @@ -17,6 +21,4 @@ all: debug fi debug: -ifdef GLOBAL_VERBOSE @echo "** GROUPS: $(GROUPS)" -endif diff --git a/pkg.in/lists/Makefile b/pkg.in/lists/Makefile index c8f1e2e2d2fae65c3a9455ac43b5c49881a64f25..c3334267dd71b816a423191546343615c57db602 100644 --- a/pkg.in/lists/Makefile +++ b/pkg.in/lists/Makefile @@ -1,12 +1,16 @@ # step 3: copy package lists referenced in distro configuration # (and only those!) over to $(BUILDDIR) +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif + include $(BUILDDIR)/distcfg.mk SUFFIX := pkg/lists TARGET := $(BUILDDIR)/$(SUFFIX) # env | sort -u | grep _LISTS | xargs cp -all: $(TARGET) debug +all: $(TARGET) $(GLOBAL_DEBUG) @$(foreach V, \ $(filter %_LISTS,$(sort $(.VARIABLES))), \ $(if $(filter environment% file,$(origin $V)),\ @@ -24,11 +28,9 @@ $(TARGET): @mkdir -p $(TARGET) debug: -ifdef GLOBAL_VERBOSE @$(foreach V, \ $(filter %_LISTS,$(sort $(.VARIABLES))), \ $(if $(filter environment% file,$(origin $V)),\ $(warning $V=$(value $V)))) @echo "** LISTS: -- see above" @echo "** GROUPS: $(GROUPS)" -endif diff --git a/profile.mk b/profile.mk index 7c6e5b28fce0a0b8137d24f0eeaed2b3e3386136..20dd04af494b043946b32d947467c3fef6ad79f9 100644 --- a/profile.mk +++ b/profile.mk @@ -1,12 +1,29 @@ # this makefile is designed to be included in toplevel one -ifdef BUILDDIR + +# this could have come from environment; +# if not, can be symlinked if r/w, or made anew +# NB: immediate assignment +ifndef BUILDDIR +BUILDDIR := $(shell [ -s build ] \ + && realpath build \ + || bin/mktmpdir mkimage-profiles.build) +endif + +# even smart caching only hurts when every build goes from scratch +NO_CACHE ?= 1 + +export BUILDDIR NO_CACHE # step 1: initialize the off-tree mkimage profile (BUILDDIR) profile/init: distclean @echo -n "** initializing BUILDDIR: " @rsync -qaH --delete image.in/ "$(BUILDDIR)"/ @:> "$(BUILDDIR)"/distcfg.mk - @:> "$(BUILDLOG)" + @{ \ + git show-ref --head -d -s -- HEAD && \ + git status -s && \ + echo; \ + } 2>/dev/null >> "$(BUILDLOG)" @mkdir "$(BUILDDIR)"/.mki # mkimage toplevel marker @type -t git >&/dev/null && \ cd $(BUILDDIR) && \ @@ -26,5 +43,3 @@ profile/populate: profile/init distro/.rc @for dir in sub.in features.in pkg.in; do \ $(MAKE) -C $$dir $(LOG); \ done - -endif diff --git a/sub.in/Makefile b/sub.in/Makefile index cc544c89eddcedaa3ea827588fb6027823c5527d..bf9e4df9f837074e5341352b03f9b70fa9b411d4 100644 --- a/sub.in/Makefile +++ b/sub.in/Makefile @@ -1,5 +1,9 @@ # step 3: copy the needed subprofiles to $(BUILDDIR) +ifndef BUILDDIR +$(error BUILDDIR not defined) +endif + include $(BUILDDIR)/distcfg.mk all: diff --git a/sub.in/install2/Makefile b/sub.in/install2/Makefile index f6bc4f517a7de3f223d645a61a1a01c155871091..70671c13d7bd2494627eb6e36c7d8a694706c0a9 100644 --- a/sub.in/install2/Makefile +++ b/sub.in/install2/Makefile @@ -1,13 +1,18 @@ # step 4: build install2 subprofile (installer "live" part) +ifndef GLOBAL_BUILDDIR +$(error GLOBAL_BUILDDIR not defined) +endif + default: all include $(GLOBAL_BUILDDIR)/distcfg.mk include $(GLOBAL_BUILDDIR)/functions.mk include $(MKIMAGE_PREFIX)/config.mk -# kernel-modules only (but these require corresponding kernel-image) -IMAGE_PACKAGES_REGEXP = $(call kpackages) +# need kernel modules only (which require corresponding kernel-image); +# these go into work chroot; NB: no vmlinuz there +IMAGE_PACKAGES_REGEXP = $(call kpackages,$(KMODULES),$(KFLAVOURS)) IMAGE_PACKAGES = $(COMMON_PACKAGES) \ $(INSTALL2_PACKAGES) \ ./packages @@ -16,11 +21,4 @@ MKI_PACK_RESULTS = squash:altinst include $(MKIMAGE_PREFIX)/targets.mk -# pass it to script hooks -ifneq "$(KDEFAULT)" "" -INFO_KDEFAULT := $(KDEFAULT) -else -INFO_KDEFAULT := $(lastword $(KFLAVOURS)) -endif - -all: build-image run-image-scripts run-scripts pack-image +all: build-image run-image-scripts pack-image diff --git a/sub.in/install2/scripts.d/22-kdefault b/sub.in/install2/scripts.d/22-kdefault deleted file mode 100755 index adf4f95699443407d92d163175f4fbabba374920..0000000000000000000000000000000000000000 --- a/sub.in/install2/scripts.d/22-kdefault +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# symlink default kernel iff requested but not yet done - -KDEFAULT="$INFO_KDEFAULT" -if [ -n "$GLOBAL_VERBOSE" ]; then - echo "** KDEFAULT: $KDEFAULT" -fi - -# kernel-image in instrumental chroot -VMLINK=/boot/vmlinuz - -# better bail out early rather than make a silly symlink -shopt -s failglob - -if [ -L "$VMLINK" ]; then - echo "** $VMLINK -> $(readlink "$VMLINK")" -fi - -if [ -n "$KDEFAULT" ]; then - VMLINUZ="$(cd /boot; echo vmlinuz-*-$KDEFAULT-*)" - if [ -n "$VMLINUZ" ]; then - ln -sf "$VMLINUZ" "$VMLINK" - echo "** overriding $VMLINK with $VMLINUZ" - fi -fi diff --git a/sub.in/main/Makefile b/sub.in/main/Makefile index abf2b2222de2d4591f12c0374dfd23ef895bd6c9..e512713a9a13efc107430b09fbe9877aa5abfc3b 100644 --- a/sub.in/main/Makefile +++ b/sub.in/main/Makefile @@ -1,5 +1,9 @@ # step 4: build main subprofile (requisite + optional packages for media) +ifndef GLOBAL_BUILDDIR +$(error GLOBAL_BUILDDIR not defined) +endif + default: all include $(GLOBAL_BUILDDIR)/distcfg.mk @@ -8,7 +12,7 @@ include $(MKIMAGE_PREFIX)/config.mk CHROOT_PACKAGES = apt-utils rsync -IMAGE_PACKAGES_REGEXP = $(call kpackages) +IMAGE_PACKAGES_REGEXP = $(call kpackages,$(KMODULES),$(KFLAVOURS)) IMAGE_PACKAGES = $(call map,list,.base $(BASE_LISTS) $(DISK_LISTS) $(GROUPS)) \ $(COMMON_PACKAGES) \ $(MAIN_PACKAGES) @@ -18,7 +22,7 @@ MKI_PACK_RESULTS = data include $(MKIMAGE_PREFIX)/targets.mk -all: debug copy-packages pack-image +all: $(GLOBAL_DEBUG) copy-packages pack-image debug: @echo "IMAGE_PACKAGES: $(IMAGE_PACKAGES)" diff --git a/sub.in/stage1/Makefile b/sub.in/stage1/Makefile index 6ea067f90e6deebd3d48d6459ebf5acc658c78b8..50f2041c47d67629ba0e0f115859df7ea3abc863 100644 --- a/sub.in/stage1/Makefile +++ b/sub.in/stage1/Makefile @@ -1,10 +1,16 @@ # step 4: build stage1 subprofile (installer bootstrap) +ifndef GLOBAL_BUILDDIR +$(error GLOBAL_BUILDDIR not defined) +endif + include $(GLOBAL_BUILDDIR)/distcfg.mk include $(GLOBAL_BUILDDIR)/functions.mk include $(MKIMAGE_PREFIX)/config.mk -ifdef BOOTLOADER +ifndef BOOTLOADER +$(error BOOTLOADER not defined) +endif MKI_PACK_RESULTS = data # FIXME: un-hardwire description @@ -17,29 +23,23 @@ include $(MKIMAGE_PREFIX)/targets.mk CHROOT_PACKAGES = $(STAGE1_PACKAGES) $(COMMON_PACKAGES) -ifeq "$(KFLAVOURS)" "" +# here we try and come up with the installer kernel/modules, if any; +# only a single kernel might be needed (STAGE1_KFLAVOUR sets explicitly); +# kernel image copied from instrumental chroot into .work/syslinux/alt0/ + +STAGE1_KFLAVOUR ?= $(lastword $(KFLAVOURS)) + # propagator needed iff stage1 kernel installed (not for e.g. syslinux.iso) +ifeq "$(STAGE1_KFLAVOUR)" "" build-propagator: @echo "** skipping build-propagator target, no kernel installed" else -# kernel image copied from instrumental chroot into .work/syslinux/alt0/ -# NB: installer only needs a single kernel, no use for multiple ones -ifneq "$(STAGE1_KFLAVOUR)" "" -KFLAVOURS := $(STAGE1_KFLAVOUR) -else -KFLAVOURS := $(lastword $(KFLAVOURS)) -endif -ifneq "$(STAGE1_KMODULES_REGEXP)" "" -KMODULES := $(STAGE1_KMODULES_REGEXP) -endif -# set up kernel related part, pass to hooks -CHROOT_PACKAGES_REGEXP := $(call kpackages) -BUILD_PROPAGATOR = build-propagator -INFO_STAGE1_KFLAVOUR := $(KFLAVOURS) +CHROOT_PACKAGES_REGEXP := $(call kpackages,$(STAGE1_KMODULES_REGEXP),$(STAGE1_KFLAVOUR)) +INFO_STAGE1_KFLAVOUR := $(STAGE1_KFLAVOUR) endif # scripts prepare bootloader configuration, too -all: prepare-workdir copy-tree run-scripts $(BUILD_PROPAGATOR) \ +all: debug prepare-workdir copy-tree run-scripts build-propagator \ copy-$(BOOTLOADER) pack-image debug: @@ -49,7 +49,3 @@ debug: echo "** CHROOT_PACKAGES_REGEXP: $(CHROOT_PACKAGES_REGEXP)"; \ echo "** BOOTLOADER: $(BOOTLOADER)"; \ fi - -else -$(error BOOTLOADER undefined) -endif