distro.mk: functionalization
- set(), add(), log() + special thanks to rider@ for log format feedback - simple debug facility - builds, installs and runs... again
This commit is contained in:
parent
c91a2a0994
commit
9a8f8ef7cd
9
Makefile
9
Makefile
@ -15,9 +15,14 @@ BUILDDIR := $(shell realpath build || bin/mktmpdir mkimage-profiles.build)
|
||||
endif
|
||||
export BUILDDIR
|
||||
|
||||
ifdef DEBUG
|
||||
GLOBAL_VERBOSE ?= 1
|
||||
SHELL += -x
|
||||
endif
|
||||
|
||||
# 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))
|
||||
CONFIGS := $(shell sed -n 's,^distro/\([^:]\+\):.*$$,\1,p' distro.mk)
|
||||
DISTROS := $(addsuffix .iso,$(CONFIGS))
|
||||
|
||||
all:
|
||||
@echo '** available distribution targets:'
|
||||
|
1
clean.mk
1
clean.mk
@ -6,6 +6,7 @@ clean:
|
||||
|
||||
distclean: clean
|
||||
@[ -d build/ ] && \
|
||||
rm -rf build/.git; \
|
||||
make -C build/ $@ GLOBAL_BUILDDIR=$(shell readlink build) && \
|
||||
rm -r $(shell readlink build) && \
|
||||
rm build \
|
||||
|
45
distro.mk
45
distro.mk
@ -4,14 +4,8 @@ CONFIG = $(BUILDDIR)/.config.mk
|
||||
# source initial feature snippets
|
||||
-include features.in/*/config.mk
|
||||
|
||||
# NB: don"t use ANY quotes ('/") for put() arguments!
|
||||
# shell will get confused by ' or args get spammed with "
|
||||
put = $(and $(1),$(put_body))
|
||||
define put_body
|
||||
@printf '%s\n' '$(1)#=- $@' >> "$(CONFIG)"
|
||||
endef
|
||||
|
||||
tags = $(shell echo "$(1)" | bin/tags2lists)
|
||||
# put(), add(), set(), tags()
|
||||
include functions.mk
|
||||
|
||||
# request particular image subprofile inclusion
|
||||
sub/%:
|
||||
@ -27,31 +21,32 @@ sub/%:
|
||||
#
|
||||
# tags do boolean expressions: (tag1 && !(tag2 || tag3))
|
||||
|
||||
init:
|
||||
distro/init:
|
||||
@echo "** starting distro configuration build process"
|
||||
:> $(CONFIG)
|
||||
$(call put,KFLAVOUR=std-def) ###
|
||||
$(call put,IMAGE_INIT_LIST=+branding-$$(BRANDING)-release)
|
||||
$(call put,BRANDING=altlinux-desktop) ###
|
||||
@#$(call put,STAGE1_PACKAGES=kernel-image-$$(KFLAVOUR))
|
||||
$(call put,KERNEL_PACKAGES=kernel-image-$$(KFLAVOUR))
|
||||
@:> $(CONFIG)
|
||||
|
||||
distro/syslinux: init
|
||||
distro/base: distro/init sub/stage1
|
||||
$(call set,KFLAVOUR,std-def) ###
|
||||
$(call set,IMAGE_INIT_LIST,+branding-$$(BRANDING)-release)
|
||||
$(call set,BRANDING,altlinux-desktop) ###
|
||||
$(call set,KERNEL_PACKAGES,kernel-image-$$(KFLAVOUR))
|
||||
|
||||
distro/syslinux: distro/base
|
||||
|
||||
# NB: our */* are phony targets really, just for namespace
|
||||
distro/installer: init sub/install2
|
||||
distro/installer: distro/base sub/install2
|
||||
@#$(call put,BRANDING=altlinux-sisyphus) ###
|
||||
$(call put,BASE_LISTS=base kernel)
|
||||
$(call put,INSTALL2_PACKAGES=installer-distro-server-light-stage2) ###
|
||||
$(call set,BASE_LISTS,base kernel)
|
||||
$(call set,INSTALL2_PACKAGES,installer-distro-server-light-stage2) ###
|
||||
|
||||
distro/server-base: distro/installer sub/main use/memtest86
|
||||
$(call put,BASE_LISTS+=server-base kernel-server)
|
||||
$(call add,BASE_LISTS,server-base kernel-server)
|
||||
|
||||
distro/server-light: distro/server-base use/bootsplash
|
||||
$(call put,KFLAVOUR=ovz-smp) # override default
|
||||
$(call put,BRANDING=sisyphus-server-light)
|
||||
$(call put,DISK_LISTS+=kernel-wifi)
|
||||
$(call put,BASE_LISTS+=$(call tags,base server))
|
||||
$(call set,KFLAVOUR,ovz-smp) # override default
|
||||
$(call set,BRANDING,sisyphus-server-light)
|
||||
$(call add,DISK_LISTS,kernel-wifi)
|
||||
$(call add,BASE_LISTS,$(call tags,base server))
|
||||
|
||||
use/bootsplash:
|
||||
$(call put,COMMON_TAGS+=bootsplash)
|
||||
$(call add,COMMON_TAGS,bootsplash)
|
||||
|
33
functions.mk
Normal file
33
functions.mk
Normal file
@ -0,0 +1,33 @@
|
||||
# NB: don"t use ANY quotes ('/") for put()/add()/set() arguments!
|
||||
# shell will get confused by ' or args get spammed with "
|
||||
|
||||
# this one adds whatever is given as an argument
|
||||
put = $(and $(1),$(put_body))
|
||||
define put_body
|
||||
$(log_body)
|
||||
@printf '%s\n' '$(1)' >> "$(CONFIG)"
|
||||
endef
|
||||
|
||||
# these two take two args
|
||||
# add() just appends an additive rule...
|
||||
add = $(and $(1),$(2),$(add_body))
|
||||
define add_body
|
||||
$(log_body)
|
||||
@printf '%s += %s\n' '$(1)' '$(2)' >> "$(CONFIG)"
|
||||
endef
|
||||
|
||||
# ...set() comments out any previous definition
|
||||
# and then appends an assigning rule
|
||||
set = $(and $(1),$(2),$(set_body))
|
||||
define set_body
|
||||
$(log_body)
|
||||
@subst 's|^$(1)[ ]*+*=.*$$|#& # overridden by $@|' "$(CONFIG)"
|
||||
@printf '%s = %s\n' '$(1)' '$(2)' >> "$(CONFIG)"
|
||||
endef
|
||||
|
||||
# is there a way to set a global make var from a recipe?..
|
||||
define log_body
|
||||
@grep -q '^# $@$$' "$(CONFIG)" || printf '# %s\n' '$@' >> "$(CONFIG)"
|
||||
endef
|
||||
|
||||
tags = $(shell echo "$(1)" | bin/tags2lists)
|
@ -22,7 +22,7 @@ prep: disk-info metadata
|
||||
|
||||
disk-info:
|
||||
mkdir -p files/.disk
|
||||
echo "$(PROPAGATOR_VERSION)" >files/.disk/info ### +$(ARCH)
|
||||
echo "FIXME" >files/.disk/info ### +$(ARCH)
|
||||
(cd $(TOPDIR); git show-ref --head --dereference -s -- HEAD 2>/dev/null) >files/.disk/commit
|
||||
[ -s files/.disk/commit ] || rm files/.disk/commit
|
||||
|
||||
|
@ -5,7 +5,7 @@ timeout 200
|
||||
# f1 help.txt
|
||||
# f2 version.txt
|
||||
# ...
|
||||
default rescue
|
||||
default linux
|
||||
|
||||
label harddisk
|
||||
menu label Continue as usual
|
||||
|
4
iso.mk
4
iso.mk
@ -1,6 +1,6 @@
|
||||
iso:
|
||||
@echo "** starting image build process"
|
||||
@### setup GLOBAL_BOOT_TYPE, etc
|
||||
@#echo (cd $(BUILDDIR)/; autoconf; ./configure --with-aptconf=$(HOME)/apt/apt.conf) ###
|
||||
@echo $(MAKE) -C $(BUILDDIR)/ GLOBAL_BUILDDIR=$(BUILDDIR)
|
||||
(cd $(BUILDDIR)/; autoconf; ./configure --with-aptconf=$(HOME)/apt/apt.conf) ###
|
||||
$(MAKE) -C $(BUILDDIR)/ GLOBAL_BUILDDIR=$(BUILDDIR)
|
||||
@# check iso size
|
||||
|
@ -1,5 +1,5 @@
|
||||
include globals.mk
|
||||
include functions.mk
|
||||
include ../globals.mk
|
||||
include ../functions.mk
|
||||
include $(MKIMAGE_PREFIX)/config.mk
|
||||
include $(GLOBAL_BUILDDIR)/.config.mk
|
||||
|
||||
|
1
sub.in/stage1/initfs
Normal file
1
sub.in/stage1/initfs
Normal file
@ -0,0 +1 @@
|
||||
file /.VERSION @TMPDIR@/.VERSION 0644 0 0
|
Loading…
Reference in New Issue
Block a user