Commit c2f70e5c authored by Michael Shigorin's avatar Michael Shigorin

kernel and BUILDDIR fixes

- image.in/functions.mk: rework kpackage() + it takes two arguments explicitly now: this adds some noise for "generic" invocations but is rather less messy with recently introduced STAGE1_KFLAVOUR (which in its turn is rather cleaner than messing with KFLAVOURS, especially since soemthing changed in presumably apt and we can't rely on kernel packages being installed in the order formed). - BUILDDIR/DEBUG related fixes + Makefile: BUILDDIR initialization moved to distro.mk - build.log += git info
parent 3f012958
......@@ -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" ] \
......
# 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
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
......@@ -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
......@@ -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)))$$
......@@ -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%-*}
......
# 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
......@@ -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
......
# 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
# 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); \
......
# 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
# 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
# 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
# step 3: copy the needed subprofiles to $(BUILDDIR)
ifndef BUILDDIR
$(error BUILDDIR not defined)
endif
include $(BUILDDIR)/distcfg.mk
all:
......
# 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
#!/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
# 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)"
# 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
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