From a9e161b40dc68ccb0106c8a557fa1f8770605291 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Sat, 18 Sep 2010 17:46:32 +0300 Subject: [PATCH] gfxboot brought to reasonable shape Also included: - reworked syslinux feature inclusion - syslinux: s/textprompt/prompt/ - README++ --- Makefile | 4 +- README | 1 + distro.mk | 49 ++++++++-------- features.in/Makefile | 13 +++-- features.in/hdt/config.mk | 7 +-- features.in/hdt/stage1/scripts.d/02-hdt | 2 + features.in/memtest/config.mk | 6 +- .../memtest/stage1/scripts.d/02-memtest | 4 +- features.in/syslinux/cfg.in/00gfxboot.cfg | 5 +- features.in/syslinux/cfg.in/00menu.cfg | 2 +- features.in/syslinux/cfg.in/00prompt.cfg | 2 +- .../cfg.in/{01timeout.cfg => 01defaults.cfg} | 0 features.in/syslinux/config.mk | 24 +++++--- features.in/syslinux/generate.mk | 58 ++++++++++++------- .../syslinux/stage1/scripts.d/02-gfxboot | 20 +++++++ functions.mk | 19 +++--- image.in/Makefile | 6 +- pkg.in/groups/Makefile | 6 +- profile.mk | 6 +- sub.in/Makefile | 1 + sub.in/stage1/Makefile | 2 +- 21 files changed, 147 insertions(+), 90 deletions(-) create mode 100755 features.in/hdt/stage1/scripts.d/02-hdt rename features.in/syslinux/cfg.in/{01timeout.cfg => 01defaults.cfg} (100%) create mode 100755 features.in/syslinux/stage1/scripts.d/02-gfxboot diff --git a/Makefile b/Makefile index 4f60f9e7..f1f06e0f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # 1. configure distro -# 2. configure subprofiles, prepare package lists +# 2. configure subprofiles, prepare package lists/groups and hooks # 3. build subprofiles # 4. build image @@ -9,7 +9,7 @@ include profile.mk include iso.mk # this could have come from environment; -# if not, can be symlinked if r/w, or made anew +# if not, can be symlinked if r/w, or made anew (NB: immediate assignment) ifndef BUILDDIR BUILDDIR := $(shell realpath build || bin/mktmpdir mkimage-profiles.build) endif diff --git a/README b/README index 953faef6..a1e140c1 100644 --- a/README +++ b/README @@ -33,5 +33,6 @@ make distclean server-light.iso или несколько субпрофилей каталоги/файлы и могут выполнять необходимые действия во время сборки после копирования (generate.sh, generate.mk). NB: добавляем в $(FEATURES) + (из того же config.mk, который будет включён в distro.mk) - списки пакетов: большая человеческая просьба по возможности избегать дублирования и подумать над pkg/lists/tagged... diff --git a/distro.mk b/distro.mk index d8edc6d6..be636759 100644 --- a/distro.mk +++ b/distro.mk @@ -19,41 +19,38 @@ include functions.mk # request particular image subprofile inclusion sub/%: - $(call add,SUBPROFILES,$(@:sub/%=%)) + @$(call add,SUBPROFILES,$(@:sub/%=%)) distro/init: @echo "** starting distro configuration build process" @:> $(CONFIG) -distro/base: distro/init sub/stage1 use/syslinux/localboot - $(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/base: distro/init sub/stage1 use/syslinux/localboot.cfg + @$(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)) -# bootloader test target -distro/syslinux: distro/base use/syslinux/ui/menu use/syslinux/localboot use/hdt use/memtest boot/isolinux - -distro/installer: distro/base sub/install2 use/syslinux/install2 +distro/installer: distro/base sub/install2 use/syslinux/install2.cfg @#$(call put,BRANDING=altlinux-sisyphus) ### - $(call set,BASE_LISTS,base kernel) - $(call set,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/syslinux/ui/menu use/memtest - $(call add,BASE_LISTS,server-base kernel-server) +distro/server-base: distro/installer sub/main use/syslinux/ui-menu use/memtest + @$(call add,BASE_LISTS,server-base kernel-server) distro/server-light: distro/server-base use/hdt - $(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)) - $(call add,GROUPS,dns-server http-server ftp-server kvm-server) - $(call add,GROUPS,ipmi mysql-server dhcp-server mail-server) - $(call add,GROUPS,monitoring diag-tools) + @$(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)) + @$(call add,GROUPS,dns-server http-server ftp-server kvm-server) + @$(call add,GROUPS,ipmi mysql-server dhcp-server mail-server) + @$(call add,GROUPS,monitoring diag-tools) -# FIXME: this belongs to bootsplash feature -#use/bootsplash: -# $(call add,COMMON_TAGS,bootsplash) +# bootloader test target +distro/syslinux: distro/base use/syslinux/ui-gfxboot \ + use/hdt use/memtest boot/isolinux -boot/%: - $(call set,BOOTLOADER,$*) +boot/%: distro/init + @$(call set,BOOTLOADER,$*) diff --git a/features.in/Makefile b/features.in/Makefile index 21d45123..9a1ecb80 100644 --- a/features.in/Makefile +++ b/features.in/Makefile @@ -1,24 +1,27 @@ -include $(BUILDDIR)/.config.mk - -SHELL += -x +-include $(BUILDDIR)/.config.mk # first rsync what's static, and make backups -- # these might signal of file clashes (or plain dirt); # then handle two more ways of implementing a feature all: @echo "** starting feature configuration" - @[ -z $(FEATURES) ] || \ + @[ -z "$(FEATURES)" ] || \ for dir in $(sort $(FEATURES)); do \ for sub in $(SUBPROFILES); do \ [ -d $$dir/$$sub/ ] && \ rsync -ab $$dir/$$sub/ $(BUILDDIR)/$$sub/ && { \ + type -t git >&/dev/null && \ cd $(BUILDDIR)/$$sub/ && \ git add . && \ git commit -qam "$@/$$dir/$$sub" ||:; \ cd - >&/dev/null; \ - }; \ + } ||:; \ done; \ [ -x $$dir/generate.sh ] && { cd $$dir && ./generate.sh; cd -; }; \ [ -s $$dir/generate.mk ] && $(MAKE) -C $$dir -f generate.mk; \ done @find $(BUILDDIR) -name '*~' ||: + +help: + @echo "** available features:" + @grep '^use/*' */config.mk | cut -f2 -d: diff --git a/features.in/hdt/config.mk b/features.in/hdt/config.mk index 3ef4cec9..e7a01a1d 100644 --- a/features.in/hdt/config.mk +++ b/features.in/hdt/config.mk @@ -1,8 +1,5 @@ # no "Memory" in hdt's menu, weird use/hdt: use/memtest - $(call add,SYSLINUX_ITEMS,hdt) - @# ITEMS iterator will happily omit a missing file, so... - $(call add,SYSLINUX_FILES,/usr/lib/syslinux/hdt.c32) - @# TODO: modules.pcimap (optional); maybe gzip - $(call add,SYSLINUX_FILES,/usr/share/pci.ids) + @$(call add,SYSLINUX_MODULES,hdt) + @$(call add,SYSLINUX_FILES,/usr/share/pci.ids) diff --git a/features.in/hdt/stage1/scripts.d/02-hdt b/features.in/hdt/stage1/scripts.d/02-hdt new file mode 100755 index 00000000..8aba7ec5 --- /dev/null +++ b/features.in/hdt/stage1/scripts.d/02-hdt @@ -0,0 +1,2 @@ +#!/bin/sh +gzip -9 "$WORKDIR"/syslinux/pci.ids ||: diff --git a/features.in/memtest/config.mk b/features.in/memtest/config.mk index 6453f63f..9e1938a5 100644 --- a/features.in/memtest/config.mk +++ b/features.in/memtest/config.mk @@ -1,4 +1,4 @@ use/memtest: - $(call add,FEATURES,memtest) - $(call add,COMMON_PACKAGES,memtest86+) - $(call add,SYSLINUX_ITEMS,memtest) + @$(call add,FEATURES,memtest) + @$(call add,COMMON_PACKAGES,memtest86+) + @$(call add,SYSLINUX_ITEMS,memtest) diff --git a/features.in/memtest/stage1/scripts.d/02-memtest b/features.in/memtest/stage1/scripts.d/02-memtest index 57c7f104..f63d97fd 100755 --- a/features.in/memtest/stage1/scripts.d/02-memtest +++ b/features.in/memtest/stage1/scripts.d/02-memtest @@ -1,7 +1,7 @@ -#!/bin/sh -x +#!/bin/sh mkdir -p "$WORKDIR"/syslinux MEMTEST="$(find /boot/ -name 'memtest*' -print -quit)" -# hdt recommends adding .bin +# hdt wiki recommends adding .bin [ -z "$MEMTEST" ] || cp -f "$MEMTEST" "$WORKDIR"/syslinux/memtest.bin diff --git a/features.in/syslinux/cfg.in/00gfxboot.cfg b/features.in/syslinux/cfg.in/00gfxboot.cfg index 5e5826b2..25f297bf 100644 --- a/features.in/syslinux/cfg.in/00gfxboot.cfg +++ b/features.in/syslinux/cfg.in/00gfxboot.cfg @@ -1,4 +1,3 @@ -ui gfxboot.com -menu title mkimage-profiles 2.0 ### +ui gfxboot bootlogo +menu title mkimage-profiles 2.0 prompt 0 -gfxboot bootlogo diff --git a/features.in/syslinux/cfg.in/00menu.cfg b/features.in/syslinux/cfg.in/00menu.cfg index bb58db88..702e7ee8 100644 --- a/features.in/syslinux/cfg.in/00menu.cfg +++ b/features.in/syslinux/cfg.in/00menu.cfg @@ -1,3 +1,3 @@ ui menu.c32 -menu title mkimage-profiles 2.0 ### +menu title mkimage-profiles 2.0 prompt 0 diff --git a/features.in/syslinux/cfg.in/00prompt.cfg b/features.in/syslinux/cfg.in/00prompt.cfg index cdda3b66..bea660b3 100644 --- a/features.in/syslinux/cfg.in/00prompt.cfg +++ b/features.in/syslinux/cfg.in/00prompt.cfg @@ -1,2 +1,2 @@ -say mkimage-profiles 2.0 ### +say mkimage-profiles 2.0 prompt 1 diff --git a/features.in/syslinux/cfg.in/01timeout.cfg b/features.in/syslinux/cfg.in/01defaults.cfg similarity index 100% rename from features.in/syslinux/cfg.in/01timeout.cfg rename to features.in/syslinux/cfg.in/01defaults.cfg diff --git a/features.in/syslinux/config.mk b/features.in/syslinux/config.mk index 8593a0c4..3f1afcc3 100644 --- a/features.in/syslinux/config.mk +++ b/features.in/syslinux/config.mk @@ -1,9 +1,17 @@ -# UI _does_ automatically enable the feature... -use/syslinux/ui/%: - $(call set,SYSLINUX_UI,$*) - $(call add,FEATURES,syslinux) - $(call add,SYSLINUX_ITEMS,$*) +# UI is overwritten and _does_ automatically enable the feature... +use/syslinux/ui-%: + @$(call add,FEATURES,syslinux) + @$(call set,SYSLINUX_UI,$*) + @$(call add,STAGE1_PACKAGES,syslinux) + if [ "$*" == gfxboot ]; then \ + $(call add,STAGE1_PACKAGES,gfxboot); \ + $(call add,STAGE1_PACKAGES,branding-$$(BRANDING)-bootloader); \ + fi -# ...and menu items don't -use/syslinux/%: - $(call add,SYSLINUX_ITEMS,$*) +# ...while plain modules... +use/syslinux/%.com use/syslinux/%.c32: + @$(call add,SYSLINUX_MODULES,$*) + +# ...and menu items don't autoenable it (but stack up themselves) +use/syslinux/%.cfg: + @$(call add,SYSLINUX_CFG,$*) diff --git a/features.in/syslinux/generate.mk b/features.in/syslinux/generate.mk index 27883a76..44c29963 100644 --- a/features.in/syslinux/generate.mk +++ b/features.in/syslinux/generate.mk @@ -4,35 +4,53 @@ ifndef BOOTLOADER $(warning syslinux feature enabled but BOOTLOADER undefined) endif -ifndef SYSLINUX -SYSLINUX = textprompt +ifndef SYSLINUX_UI +$(warning no syslinux ui module configured, falling back to plain text prompt) +SYSLINUX_UI := prompt endif -### FIXME: too much insight (ab)used +# UI is backed by modules in modern syslinux +# (except for built-in text prompt) +SYSLINUX_MODULES := $(SYSLINUX_MODULES) $(SYSLINUX_UI) + +# SUBPROFILES are considered SYSLINUX_CFG too; +# 01defaults.cfg is included indefinitely +SYSLINUX_CFG := $(SYSLINUX_CFG) $(SUBPROFILES) defaults + DSTDIR := $(BUILDDIR)/stage1/files/syslinux CONFIG := $(DSTDIR)/$(BOOTLOADER).cfg -PARTS := $(SYSLINUX_UI) $(SYSLINUX_ITEMS) $(SUBPROFILES) timeout MODDIR := /usr/lib/syslinux -# compile bootloader config from chosen parts -# NB: list position determined by file numbering (*.cfg) -config: debug copy - @cat $(sort $(foreach P,$(PARTS),$(wildcard cfg.in/??$(P).cfg))) /dev/null > $(CONFIG) +# we can do SYSLINUX_{CFG,MODULES,FILES} +# CFG have only cfg snippet +# FILES have only filenames (absolute or relative to /usr/lib/syslinux/) +# MODULES must have both cfg snippet and syslinux module filename +# (and get included iff cfg snippet AND module exist) +# syslinux modules come as .com and .c32 files +sysmod = $(wildcard $(addprefix $(MODDIR)/,$(addsuffix .c??,$(1)))) +cfg = $(wildcard cfg.in/??$(1).cfg) + +# NB: list position determined by file numbering (*.cfg sorting) +all: prep debug + cat $(sort \ + $(foreach C,$(SYSLINUX_CFG),$(call cfg,$(C))) \ + $(foreach M,$(SYSLINUX_MODULES), \ + $(shell cp -pLt $(DSTDIR) -- $(call sysmod,$(M)) && echo $(call cfg,$(M))))) \ + /dev/null > $(CONFIG) + [ -z "$(SYSLINUX_FILES)" ] || { \ + cd $(MODDIR); \ + cp -pLt $(DSTDIR) -- $(SYSLINUX_FILES); \ + } + +# cat's argument gets evaluated before recipe body execution prep: - @mkdir -p $(DSTDIR) + mkdir -p $(DSTDIR) -# copy over the needed syslinux modules (item.c32 or item.com) -# and SYSLINUX_FILES (list of absolute paths) -copy: prep - @$(foreach F, \ - $(SYSLINUX_FILES) $(wildcard $(addprefix $(MODDIR)/,$(addsuffix .c??,$(SYSLINUX_ITEMS)))), \ - $(shell cp -pLt $(DSTDIR) -- $(F))) - -# for p in $PARTS; do ls ??$p.cfg; done | sort +# for p in $...; do ls ??$p.cfg; done | sort debug: @echo "** BOOTLOADER: $(BOOTLOADER)" @echo "** SYSLINUX_UI: $(SYSLINUX_UI)" - @echo "** SYSLINUX_ITEMS: $(SYSLINUX_ITEMS)" - @echo "** PARTS: $(sort $(foreach P,$(PARTS),$(wildcard cfg.in/??$(P).cfg)))" - @echo "** MODULES: $(wildcard $(addprefix $(MODDIR)/,$(addsuffix .c??,$(SYSLINUX_ITEMS))))" + @echo "** SYSLINUX_CFG: $(SYSLINUX_CFG)" + @echo "** SYSLINUX_FILES: $(SYSLINUX_FILES)" + @echo "** SYSLINUX_MODULES: $(SYSLINUX_MODULES)" diff --git a/features.in/syslinux/stage1/scripts.d/02-gfxboot b/features.in/syslinux/stage1/scripts.d/02-gfxboot new file mode 100755 index 00000000..eab6833e --- /dev/null +++ b/features.in/syslinux/stage1/scripts.d/02-gfxboot @@ -0,0 +1,20 @@ +#!/bin/sh + +gfxboot_datadir=/usr/share/gfxboot +bootlogo="`ls $gfxboot_datadir/*/bootlogo | head -1`" ### + +if [ ! -f "$bootlogo" ]; then + echo "${0##*/} - SKIP: $bootlogo not found" + ls -alR $gfxboot_datadir + exit 0 +fi +cd "$WORKDIR" +mkdir -p syslinux +cd syslinux + +# unpack +cpio -iduV <"$bootlogo" + +# pack +printf 'init\nlanguages\n' | + cpio -oV >bootlogo diff --git a/functions.mk b/functions.mk index 79f9adf3..5f4569e5 100644 --- a/functions.mk +++ b/functions.mk @@ -1,33 +1,36 @@ # 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: +# e.g. features.in/syslinux/config.mk introduces conditionals + # this one adds whatever is given as an argument put = $(and $(1),$(put_body)) define put_body -$(log_body) -@printf '%s\n' '$(1)' >> "$(CONFIG)" +{ $(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)" +{ $(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)" +{ $(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)" +{ grep -q '^# $@$$' "$(CONFIG)" || printf '# %s\n' '$@' >> "$(CONFIG)"; } endef tags = $(shell echo "$(1)" | bin/tags2lists) diff --git a/image.in/Makefile b/image.in/Makefile index f04fdbb7..ca5ee7aa 100644 --- a/image.in/Makefile +++ b/image.in/Makefile @@ -23,8 +23,10 @@ prep: disk-info metadata disk-info: @mkdir -p files/.disk @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 + @type -t git >&/dev/null && ( \ + cd $(TOPDIR) && \ + git show-ref --head --dereference -s -- HEAD 2>/dev/null; \ + ) >files/.disk/commit # see also alterator-pkg (backend3/pkg-install) # FIXME: if we copy --as-needed, maybe just tar . ? diff --git a/pkg.in/groups/Makefile b/pkg.in/groups/Makefile index fc25ff63..12f08c67 100644 --- a/pkg.in/groups/Makefile +++ b/pkg.in/groups/Makefile @@ -4,8 +4,10 @@ include $(BUILDDIR)/.config.mk all: debug - @mkdir -p $(BUILDDIR)/pkg/groups \ - && cp -at $(BUILDDIR)/pkg/groups/ -- $(addsuffix .directory,$(GROUPS)) + @[ -n "$(GROUPS)" ] && { \ + mkdir -p $(BUILDDIR)/pkg/groups && \ + cp -at $(BUILDDIR)/pkg/groups/ -- $(addsuffix .directory,$(GROUPS)); \ + } ||: debug: @echo "** GROUPS: $(GROUPS)" diff --git a/profile.mk b/profile.mk index ad41f785..747604bb 100644 --- a/profile.mk +++ b/profile.mk @@ -3,7 +3,11 @@ profile/init: @rsync -qaH --delete image.in/ "$(BUILDDIR)"/ @touch "$(BUILDDIR)"/.config.mk @mkdir "$(BUILDDIR)"/.mki - cd $(BUILDDIR); git init -q; git add .; git commit -qam 'init' ### + @type -t git >&/dev/null && \ + cd $(BUILDDIR) && \ + git init -q && \ + git add . && \ + git commit -qam 'init' @rm -f build @[ -w . ] \ && ln -sf "$(BUILDDIR)" build \ diff --git a/sub.in/Makefile b/sub.in/Makefile index df12dc0b..7a2a59f7 100644 --- a/sub.in/Makefile +++ b/sub.in/Makefile @@ -3,6 +3,7 @@ include $(BUILDDIR)/.config.mk all: @for dir in $(SUBPROFILES); do \ rsync -a $$dir/ $(BUILDDIR)/$$dir/ && \ + type -t git >&/dev/null && \ cd $(BUILDDIR)/$$dir/ && \ git add . && \ git commit -qam "$@/$$dir"; \ diff --git a/sub.in/stage1/Makefile b/sub.in/stage1/Makefile index dde93dc8..13c2fd45 100644 --- a/sub.in/stage1/Makefile +++ b/sub.in/stage1/Makefile @@ -3,7 +3,7 @@ include ../functions.mk include $(MKIMAGE_PREFIX)/config.mk include $(GLOBAL_BUILDDIR)/.config.mk -CHROOT_PACKAGES = syslinux $(KERNEL_PACKAGES) $(COMMON_PACKAGES) +CHROOT_PACKAGES = $(KERNEL_PACKAGES) $(STAGE1_PACKAGES) $(COMMON_PACKAGES) MKI_PACK_RESULTS = data ###