server-ovz; KDEFAULT; syslinux features reworked

Renamed server-light.iso into server-ovz.iso to avoid brand dilution
and confusion (rider@'s server-light rather favours kvm, anyways).

Introduced KDEFAULT: a reliable default kernel chooser knob
since apt's regex ordering proved pretty unreliable.
Spelling things explicitly is better anyways.

SYSLINUX related features undergone pretty major rewrite
(that includes syslinux, hdt and memtest).

The problem to tackle was features.in/syslinux/generate.mk
assuming syslinux and pciids available in build *host* system;
this well might not be the case (or worse yet, those can be
just different).  So now we're a bit less elegant and a bit
more enterprise, stuffing things into chroot and working there.

Bunch of other fixes along the road, including ; to name a few:
- fixed memtest entry (overlooked while renaming SYSLINUX_ITEMS)
- new and shiny doc/CodingStyle
- gfxboot, stage1 target chain, hdt tweaks
- distro.mk rehashed
- README++
- TODO: dropped (integer overflow anyways)
  + actually moved off-tree to reduce commit spam
- s,\.config\.mk,distcfg.mk,g
- doc/profiles.mk.sample: sample ~/.mkimage/profiles.mk
- ...and assorted fixups/additions

Sorry for convoluted commit, this would have been pretty hard to
rework into some really readable shape (and you might be interested
in the original repo's history horrors then, anyways).
This commit is contained in:
Michael Shigorin 2011-05-31 02:05:33 +04:00
parent d93989a3ff
commit 3f012958dc
37 changed files with 462 additions and 173 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*~
build

View File

@ -2,7 +2,7 @@
# --- here
# 1. initialize new profile (BUILDDIR) as a copy of image.in/
# 2. configure distro
# 3. copy subprofiles, package lists/groups and script hooks
# 3. copy subprofiles, script hooks, and package lists/groups
# from metaprofile to new profile (as needed)
# --- in BUILDDIR
# 4. build subprofiles and subsequently image
@ -33,7 +33,7 @@ DATE = $(shell date +%Y%m%d)
export ARCH BUILDDIR DATE SHELL
# to be passed into .config.mk
# to be passed into distcfg.mk
IMAGEDIR ?= $(shell [ -d "$$HOME/out" -a -w "$$HOME/out" ] \
&& echo "$$HOME/out" \
|| echo "$(BUILDDIR)/out" )
@ -42,9 +42,13 @@ IMAGENAME ?= mkimage-profiles-$(ARCH).iso
$(DISTROS): %.iso: | profile/init distro/% boot/isolinux profile/populate iso
@# TODO: run automated tests (e.g. iso size)
@OUTNAME="$(@:.iso=)-$(DATE)-$(ARCH).iso"; \
OUTPATH="$(IMAGEDIR)/$$OUTNAME"; \
test -s "$(IMAGEDIR)/$(IMAGENAME)" && \
mv "$(IMAGEDIR)/"{$(IMAGENAME),$$OUTNAME} && \
echo "** image: $(IMAGEDIR)/$$OUTNAME" && \
mv "$(IMAGEDIR)/$(IMAGENAME)" "$$OUTPATH" && \
echo "** image: $$OUTPATH" && \
ln -sf "$$OUTNAME" "$(IMAGEDIR)/$@" && \
ln -sf "$@" "$(IMAGEDIR)/mkimage-profiles.iso"
### TODO: copy build.log as well for successful builds?
ln -sf "$@" "$(IMAGEDIR)/mkimage-profiles.iso"; \
if [ -n "$(DEBUG)" ]; then \
cp -a "$(BUILDLOG)" "$$OUTPATH.log"; \
cp -a "$(CONFIG)" "$$OUTPATH.cfg"; \
fi

9
README
View File

@ -1,8 +1,8 @@
see also http://www.altlinux.org/Mkimage/Profiles/next;
quickstart: make distclean server-light.iso
quickstart: make distclean server-base.iso
configurables: ~/.mkimage/metaconf.mk, see distro.mk
configurables: ~/.mkimage/profiles.mk, see libdistro.mk
Концепция:
- метапрофиль служит репозиторием всего возможно нужного для
@ -15,7 +15,8 @@ configurables: ~/.mkimage/metaconf.mk, see distro.mk
Особенности:
- метапрофиль может быть полностью read-only при сборке
- для сборки подыскивается предпочтительно tmpfs
- в профиль копируются только нужные объекты
- в профиль копируются только нужные объекты;
он автономен относительно метапрофиля
Стадии работы:
- инициализация дистрибутивного профиля
@ -36,7 +37,7 @@ configurables: ~/.mkimage/metaconf.mk, see distro.mk
(не путать с дистрибутивами), но законченными; могут жить
в distro.mk (или сделать use.mk?), либо же в индивидуальных
features.in/*/config.mk, если необходимо дополнить не только
.config.mk, а и дерево формируемого профиля
distcfg.mk, а и дерево формируемого профиля
- фичи: законченные кусочки функциональности, могут зависеть
друг от друга; сливаются с соответствующими субпрофилями
при сборке $(BUILDDIR), могут нести с собой копируемые в один

0
TODO
View File

View File

@ -6,7 +6,7 @@
clean:
@echo '** cleaning up'
@find -name '*~' -delete >&/dev/null
@if test -L build; then \
@if [ -L build -a -d build/ ]; then \
$(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG); \
fi
@ -14,9 +14,10 @@ clean:
# $(BUILDDIR)/ gets purged: make might have failed,
# and BUILDLOG can be specified by hand either
distclean: clean
@if test -L build; then \
@if [ -L build -a -d build/ ]; then \
$(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG); \
rm -rf build/.git; \
$(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG) && \
rm -r $(shell readlink build) && \
rm build; \
rm -r $(shell readlink build); \
fi
@rm -f build

View File

@ -3,79 +3,63 @@ ifdef BUILDDIR
# step 2: build up distribution's configuration
# NB: distro/ targets should be defined here,
# see toplevel Makefile's $(DISTRO) assignment
CONFIG = $(BUILDDIR)/.config.mk
# NB: distro/ targets should be defined in this file,
# see toplevel Makefile's $(DISTROS) assignment
CONFIG = $(BUILDDIR)/distcfg.mk
# source initial feature snippets
# collect use/% (source initial feature snippets)
-include features.in/*/config.mk
# put(), add(), set(), try(), tags(): see functions.mk
#
# package list names are considered relative to pkg/lists/
#
# put(), add(), set(), try(), tags():
# package list names are considered relative to pkg/lists/;
# tags can do boolean expressions: (tag1 && !(tag2 || tag3))
include functions.mk
# distro/.%, sub/.%, boot/%
include libdistro.mk
# bootloader test target; requires recent mkimage to build
distro/syslinux: distro/.init distro/.branding sub/stage1 \
use/syslinux use/syslinux/localboot.cfg \
use/syslinux/ui-gfxboot use/hdt use/memtest
# $(VAR) will be substituted before writing them to $(CONFIG);
# $$(VAR) will remain unsubstituted util $(CONFIG) is included
# and their value requested (so the variable referenced
# can change its value during configuration _before_
# it's actually used)
#
# tags can do boolean expressions: (tag1 && !(tag2 || tag3))
include functions.mk
# it's actually used); just peek inside $(CONFIG) ;-)
# request particular image subprofile inclusion
sub/%:
@$(call add,SUBPROFILES,$(@:sub/%=%))
# initalize config from scratch, put some sane defaults in
distro/.init:
@echo "** preparing distro configuration$${DEBUG:+: see $(CONFIG)}"
@$(call try,MKIMAGE_PREFIX,/usr/share/mkimage)
@$(call try,GLOBAL_VERBOSE,)
@$(call try,IMAGEDIR,$(IMAGEDIR))
@$(call try,IMAGENAME,$(IMAGENAME))
# 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 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)
distro/installer: distro/.base sub/install2 use/syslinux/install2.cfg
# something actually useful (as a network-only installer)
distro/installer: distro/.base use/installer
@$(call set,INSTALLER,server-light)
@$(call set,INSTALL2_PACKAGES,installer-distro-$$(INSTALLER)-stage2)
@$(call add,INSTALL2_PACKAGES,branding-$$(BRANDING)-alterator)
@$(call add,MAIN_PACKAGES,branding-$$(BRANDING)-release)
@$(call set,BASE_LISTS,base)
# BASE_LISTS, DISK_LISTS, MAIN_PACKAGES: see sub.in/main/
distro/server-base: distro/installer sub/main use/syslinux/ui-menu use/memtest
@$(call add,BASE_LISTS,server-base)
distro/server-light: distro/server-base use/hdt
@$(call set,BRANDING,sisyphus-server-light)
@$(call set,KFLAVOURS,ovz-el el-smp) # override default
# STAGE1_KFLAVOUR is the one for installer
# KDEFAULT is for the installed system
# both of these default to the last KFLAVOURS item if not set
distro/server-ovz: distro/server-base use/hdt
@$(call set,STAGE1_KFLAVOUR,std-def)
@$(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,DISK_LISTS,kernel-wifi)
@$(call add,BASE_LISTS,ovz-server)
@$(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)
distro/minicd: distro/server-base
@$(call set,KFLAVOURS,un-def) # we might need the most recent drivers (NB: std-ng lacks aufs2)
@$(call set,KFLAVOURS,un-def) # we might need the most recent drivers
@$(call add,MAIN_PACKAGES,etcnet-full)
# bootloader test target
distro/syslinux: distro/.base use/syslinux/ui-gfxboot use/hdt use/memtest
# pick up release manager's config (TODO: distro-specific include as well?)
distro/.metaconf:
@if [ -s $(HOME)/.mkimage/metaconf.mk ]; then \
$(call put,-include $(HOME)/.mkimage/metaconf.mk); \
fi
boot/%: distro/.init
@$(call set,BOOTLOADER,$*)
# if there are too many screens above, it might make sense to distro.d/
else
$(error BUILDDIR not defined)
endif

33
doc/CodingStyle Normal file
View File

@ -0,0 +1,33 @@
требования по оформлению кода
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* постарайтесь не вносить без обсуждения разнобой стилей,
если есть предметные пожелания по коррекции текущего --
пишите, обсудим;
* перед тем, как делать существенные переработки уже имеющегося
кода -- опять же опишите проблему, идею и предполагаемый результат,
порой могут выясниться непредвиденные последствия;
* документируйте на русском (README) или английском (README.en) языке
то, что написали или изменили.
рекомендации
~~~~~~~~~~~~
* трезво относитесь ко входным данным и не пренебрегайте кавычками:
название дистрибутива с пробелом или получение текста ошибки вместо
ожидаемого вывода команды могут привести к сложнодиагностируемым
ошибкам; вместе с тем в ряде случаев, где требуется пословная
обработка значений переменных или раскрытие шаблонов shell (*?[])
-- кавычки могут оказаться лишними;
* пользуйтесь if [ ... ]; then ...; fi вместо [ ... ] && ...:
это кажется более громоздким, но текст оказывается более читаемым
и в т.ч. расширяемым, поскольку между then/else/fi можно спокойно
добавлять строки; с && проще забыть { ... } или оставить ненулевой
код возврата при неудаче теста, когда он считается несущественным;
* предпочтительно применение $() вместо `` (особенно при вложенности);
* постарайтесь не вылазить за 80 колонок.

7
doc/profiles.mk.sample Normal file
View File

@ -0,0 +1,7 @@
### ~/.mkimage/profiles.mk
# ARCH is defined in/for metaprofile's toplevel Makefile, not here
APTCONF = ~/apt/apt.conf.$(ARCH)
# can be defined here but passing DEBUG=1 is preferred
#GLOBAL_VERBOSE = 1

View File

@ -8,7 +8,7 @@
#
# for a real-world example, see syslinux feature
include $(BUILDDIR)/.config.mk
include $(BUILDDIR)/distcfg.mk
ifndef 00EXAMPLE
$(warning this is an example, who might want to include it? :])

View File

@ -1,30 +1,44 @@
ifdef BUILDDIR
# step 3: copy the needed features to $(BUILDDIR)
# (only regarding the needed subprofiles)
-include $(BUILDDIR)/.config.mk
-include $(BUILDDIR)/distcfg.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)" ] || \
for dir in $(sort $(FEATURES)); do \
@if test -n "$(DEBUG)"; then echo "** requested: $(FEATURES)"; fi
@for dir in $(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; \
} ||:; \
if test -d $$dir/$$sub/; then \
if rsync -ab $$dir/$$sub/ $(BUILDDIR)/$$sub/; \
then \
type -t git >&/dev/null && \
pushd $(BUILDDIR)/$$sub/ && \
git add . && \
git commit -qam "$@/$$dir/$$sub" ||:; \
popd; \
fi; \
fi; \
done; \
[ -x $$dir/generate.sh ] && { cd $$dir && ./generate.sh; cd -; }; \
[ -s $$dir/generate.mk ] && $(MAKE) -C $$dir -f generate.mk; \
if test -x $$dir/generate.sh; then \
pushd $$dir && \
sh generate.sh; \
popd; \
fi; \
if test -s $$dir/generate.mk; then \
$(MAKE) -C $$dir -f generate.mk; \
fi; \
done
@find $(BUILDDIR) -name '*~' ||:
help:
@echo "** available features:"
@grep '^use/*' */config.mk | cut -f2 -d:
@grep -h '^use/' */config.mk
else
$(error BUILDDIR not defined)
endif

View File

@ -1,5 +1,10 @@
Добавление модуля hdt (Hardware Detection Tool COM32 module) к syslinux;
может быть востребовано для инсталяторов, live/rescue.
TODO: недоступно Memory->memtest; может иметь смысл класть сжатые gzip
Фича не только требует фичу syslinux (и соответствующий пакет,
а также pciids), но и тесно с ней интегрирована; в частности,
фрагмент конфигурационного файла располагается не "здесь",
а "там", поскольку сам hdt.c32 также вхоодит в пакет syslinux.
FIXME: недоступно Memory->memtest; может иметь смысл класть сжатые gzip
pci.ids и modules.pcimap.

View File

@ -1,4 +1,6 @@
use/hdt: use/syslinux
use/hdt: use/syslinux use/memtest
@$(call add,FEATURES,hdt)
@$(call add,STAGE1_PACKAGES,pciids)
@$(call add,SYSLINUX_MODULES,hdt)
@$(call add,SYSLINUX_FILES,/usr/share/misc/pci.ids)
### moved to scripts.d/02-hdt along with compression
# @$(call add,SYSLINUX_FILES,/usr/share/misc/pci.ids)

View File

@ -1,2 +1,9 @@
#!/bin/sh
gzip -9 "$WORKDIR"/syslinux/pci.ids ||:
# http://syslinux.zytor.com/wiki/index.php/Hdt_%28Hardware_Detection_Tool%29#pci_stuff
# NB: this script intentionally supports pci.ids provided by
# pciids package as that one is updated automatically
[ -z "$GLOBAL_VERBOSE" ] || echo "** compressing pci.ids"
mkdir -p "$WORKDIR/syslinux"
gzip -9 < /usr/share/misc/pci.ids > "$WORKDIR"/syslinux/pci.ids

View File

@ -0,0 +1,5 @@
use/installer: sub/install2 use/syslinux/install2.cfg
@$(call set,INSTALL2_PACKAGES,installer-distro-$$(INSTALLER)-stage2)
@$(call add,INSTALL2_PACKAGES,branding-$$(BRANDING)-alterator)
@$(call add,MAIN_PACKAGES,branding-$$(BRANDING)-release)
@$(call set,BASE_LISTS,base)

View File

@ -1,4 +1,4 @@
use/memtest:
@$(call add,FEATURES,memtest)
@$(call add,COMMON_PACKAGES,memtest86+)
@$(call add,SYSLINUX_ITEMS,memtest)
@$(call add,SYSLINUX_CFG,memtest)

View File

@ -1,6 +1,6 @@
Добавление поддержки syslinux; требуется для инсталяторов, live/rescue.
Цели:
Цели config.mk:
* use/syslinux/ui-% -- конфигурирование интерфейса (см. cfg.in/00*.cfg);
при использовании автоматически добавляют syslinux в FEATURES
@ -9,3 +9,13 @@
(копирование бинарников и включение кусочков конфигурации; экспериментальное)
* use/syslinux/%.cfg -- подключение кусочков конфигурации (используется)
Переменные generate.mk:
* BOOTLOADER -- isolinux (TODO: добавить поддержку syslinux для флэшек);
* SYSLINUX_UI -- модуль интерфейса (если не указан, то внутренний prompt);
* SYSLINUX_MODULES -- модули .com или .c32 (перечисляются без расширения);
* SYSLINUX_CFG -- дополнительные кусочки конфигурации (например, localboot).
Здесь производится первичная обработка конфигурационных данных,
окончательно проверяемых и используемых уже в инструментальном чруте.

View File

@ -1,3 +1,3 @@
label harddisk
menu label ^Boot from HDD (as usual)
menu label ^Boot from hard drive as usual
localboot 0x80

View File

@ -3,6 +3,6 @@ label linux
kernel alt0/vmlinuz
append initrd=alt0/full.cz changedisk vga=0x314 quiet=1 showopts automatic=method:cdrom
label noapic
menu label ^Install ALT Linux (failsafe)
menu label ^Failsafe install
kernel alt0/vmlinuz
append initrd=alt0/full.cz changedisk showopts nolapic noapic

View File

@ -1,5 +1,10 @@
# NB: data can be gzipped (without .gz suffix);
# paths must be relative to image root;
# http://tinyurl.com/hdt-args is wrong as of 2011-05-31
# FIXME: weird, gfxboot menu entry boots "nomenu" somehow
# while entering "hdt" from isolinux cli dumps menu
label hdt
menu label ^Hardware info
menu label ^Hardware information
com32 hdt.c32
append pciids=pci.ids
# NB: data can be gzipped (without .gz suffix)
append quiet
# append pciids=pci.ids memtest=memtest

View File

@ -1,56 +1,67 @@
include $(BUILDDIR)/.config.mk
ifdef BUILDDIR
# prepare data for syslinux installation;
# see also stage1/scripts.d/01-syslinux
include $(BUILDDIR)/distcfg.mk
ifndef BOOTLOADER
$(warning syslinux feature enabled but BOOTLOADER undefined)
endif
ifndef SYSLINUX_UI
$(warning no syslinux ui configured, default is plain text prompt)
SYSLINUX_UI := prompt
$(error syslinux feature enabled but BOOTLOADER undefined)
endif
# UI is backed by modules in modern syslinux
# (except for built-in text prompt)
ifdef SYSLINUX_UI
SYSLINUX_MODULES := $(SYSLINUX_MODULES) $(SYSLINUX_UI)
else
$(warning no syslinux ui configured, default is plain text prompt)
SYSLINUX_UI := prompt
endif
# 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
MODDIR := /usr/lib/syslinux
### have to operate BUILDDIR, not pretty...
DSTDIR := $(BUILDDIR)/stage1/files/syslinux/.in
# 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)
#
# config snippets are copied into generated profile where they can
# be also tested against syslinux modules (some can be unavailable);
# we can't do tests right now since that implies host syslinux being
# identical to build system one which might be not the case...
#
# have to piggyback parameters as we're running in host system yet,
# and files involved will appear inside instrumental chroot
#
# arguments get evaluated before recipe body execution thus prep
all: prep debug
@cat $(sort \
@echo $(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); \
}
$(foreach M,$(SYSLINUX_MODULES),$(call cfg,$(M)))) \
| xargs cp -pLt $(DSTDIR) --
@echo $(SYSLINUX_MODULES) > $(DSTDIR)/modules.list
@echo $(SYSLINUX_FILES) > $(DSTDIR)/files.list
@echo $(BOOTLOADER) > $(DSTDIR)/bootloader
# cat's argument gets evaluated before recipe body execution
prep:
@mkdir -p $(DSTDIR)
# for p in $...; do ls ??$p.cfg; done | sort
debug:
@echo "** BOOTLOADER: $(BOOTLOADER)"
@echo "** SYSLINUX_UI: $(SYSLINUX_UI)"
@echo "** SYSLINUX_CFG: $(SYSLINUX_CFG)"
@echo "** SYSLINUX_FILES: $(SYSLINUX_FILES)"
@echo "** SYSLINUX_MODULES: $(SYSLINUX_MODULES)"
@if test -n "$(DEBUG)"; then \
echo "** BOOTLOADER: $(BOOTLOADER)"; \
echo "** SYSLINUX_UI: $(SYSLINUX_UI)"; \
echo "** SYSLINUX_CFG: $(SYSLINUX_CFG)"; \
echo "** SYSLINUX_FILES: $(SYSLINUX_FILES)"; \
echo "** SYSLINUX_MODULES: $(SYSLINUX_MODULES)"; \
fi
endif

View File

@ -0,0 +1,36 @@
#!/bin/sh
# gather syslinux configuration from snippets;
# copy modules; see also ../../generate.mk
MODDIR="/usr/lib/syslinux"
mkdir -p "$WORKDIR/syslinux"
cd "$WORKDIR/syslinux"
# validate just in case (written by ../../generate.mk)
BOOTLOADER="$(cat .in/bootloader)"
case "$BOOTLOADER" in
isolinux|syslinux) ;;
*) echo "$0: error: weird BOOTLOADER: $BOOTLOADER" >&2; exit 1;;
esac
# copy extra files, if any
SYSLINUX_FILES="$(cat .in/files.list)"
if test -n "${SYSLINUX_FILES% }"; then
cp -a $SYSLINUX_FILES .
fi
# prune module-specific config snippets; skip built-in one
SYSLINUX_MODULES="$(cat .in/modules.list)"
if test -n "$SYSLINUX_MODULES"; then
for module in $SYSLINUX_MODULES; do
if test "$modules" == "prompt"; then continue; fi
cp -a $MODDIR/$module.c?? . || rm .in/[0-9][0-9]$module.cfg
done
fi
# number ordering sponsored by shell's pathname expansion
grep -hv '^#' .in/[0-9][0-9]*.cfg > "$BOOTLOADER.cfg"
# snippets are not going into the actual image
if test "$DEBUG" != 2; then rm -r .in/; fi

View File

@ -4,7 +4,7 @@ gfxboot_datadir=/usr/share/gfxboot
bootlogo="`ls $gfxboot_datadir/*/bootlogo | head -1`" ###
if [ ! -f "$bootlogo" ]; then
echo "${0##*/} - SKIP: $bootlogo not found"
echo "${0##*/} - SKIP: $bootlogo not found" >&2
ls -alR $gfxboot_datadir
exit 0
fi

View File

@ -4,7 +4,7 @@
include functions.mk
include $(GLOBAL_BUILDDIR)/functions.mk
include $(GLOBAL_BUILDDIR)/.config.mk
include $(GLOBAL_BUILDDIR)/distcfg.mk
include $(MKIMAGE_PREFIX)/config.mk
SUBDIRS = $(SUBPROFILES)
@ -19,7 +19,8 @@ BOOT_TYPE = isolinux
# outdir shouldn't be wiped clean before use
CLEANUP_OUTDIR =
ifeq "$(wildcard $(APTCONF))" ""
APTCONF := $(wildcard $(APTCONF))
ifeq "$(APTCONF)" ""
GLOBAL_HSH_APT_CONFIG = /etc/apt/apt.conf
else
GLOBAL_HSH_APT_CONFIG = $(APTCONF)
@ -29,6 +30,28 @@ 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)" ""
metadata:
@echo "** skipping metadata target, no kernel installed"
else
# see also alterator-pkg (backend3/pkg-install)
# FIXME: if we copy --as-needed, maybe just tar . ?
# TODO: initfs seems conditionally needed as well
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 "branding-$(BRANDING)-release" >> $(call list,.base)
@tar -cvf files/Metadata/pkg-groups.tar \
-C $(PKGDIR) \
$$(echo $(call list,.base) \
$(call list,$(GROUPS)) \
$(call group,$(GROUPS)) \
| sed 's,$(PKGDIR)/*,,g')
endif
# FIXME: scripts.d/?
prep: debug dot-disk metadata $(IMAGEDIR)
@ -54,14 +77,3 @@ dot-disk:
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 . ?
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 "branding-$(BRANDING)-release" >> $(call list,.base)
@tar -cvf files/Metadata/pkg-groups.tar \
-C $(PKGDIR) \
$$(echo $(call list,.base) $(call list,$(GROUPS)) $(call group,$(GROUPS)) | sed 's,$(PKGDIR)/*,,g')

33
libdistro.mk Normal file
View File

@ -0,0 +1,33 @@
# low-level part of distro.mk
# request particular image subprofile inclusion
sub/%:
@$(call add,SUBPROFILES,$(@:sub/%=%))
boot/%: distro/.init
@$(call set,BOOTLOADER,$*)
# initalize config from scratch, put some sane defaults in
distro/.init:
@echo "** preparing distro configuration$${DEBUG:+: see $(CONFIG)}"
@$(call try,MKIMAGE_PREFIX,/usr/share/mkimage)
@$(call try,GLOBAL_VERBOSE,)
@$(call try,IMAGEDIR,$(IMAGEDIR))
@$(call try,IMAGENAME,$(IMAGENAME))
distro/.branding: distro/.init
@$(call try,BRANDING,altlinux-sisyphus)
@$(call set,IMAGE_INIT_LIST,+branding-$$(BRANDING)-release)
# 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/.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
distro/.rc:
@if [ -s $(HOME)/.mkimage/profiles.mk ]; then \
$(call put,-include $(HOME)/.mkimage/profiles.mk); \
fi

View File

@ -1,13 +1,22 @@
# step 3: copy package groups referenced in distro configuration
# (and only those!) over to $(BUILDDIR)
include $(BUILDDIR)/.config.mk
include $(BUILDDIR)/distcfg.mk
SUFFIX := pkg/groups
TARGET := $(BUILDDIR)/$(SUFFIX)
all: debug
@[ -n "$(GROUPS)" ] && { \
mkdir -p $(BUILDDIR)/pkg/groups && \
cp -at $(BUILDDIR)/pkg/groups/ -- $(addsuffix .directory,$(GROUPS)); \
} ||:
@if [ -n "$(GROUPS)" ]; then \
mkdir -p $(TARGET) && \
cp -at $(TARGET) -- $(addsuffix .directory,$(GROUPS)); \
type -t git >&/dev/null && \
cd $(TARGET) && \
git add . && \
git commit -qam "$(SUFFIX)"; \
cd - >&/dev/null; \
fi
debug:
ifdef GLOBAL_VERBOSE
@echo "** GROUPS: $(GROUPS)"
endif

View File

@ -1,29 +1,34 @@
# step 3: copy package lists referenced in distro configuration
# (and only those!) over to $(BUILDDIR)
include $(BUILDDIR)/.config.mk
TARGET := $(BUILDDIR)/pkg/lists/
include $(BUILDDIR)/distcfg.mk
SUFFIX := pkg/lists
TARGET := $(BUILDDIR)/$(SUFFIX)
# env | sort -u | grep _LISTS | xargs cp
all: prep debug
all: $(TARGET) debug
@$(foreach V, \
$(filter %_LISTS,$(sort $(.VARIABLES))), \
$(if $(filter environment% file,$(origin $V)),\
$(shell cp --parents -at $(TARGET) \
-- $(value $V))))
@cp -a .base $(GROUPS) $(TARGET)
@type -t git >&/dev/null && \
cd $(TARGET) && \
git add . && \
git commit -qam "$(SUFFIX)"; \
cd - >&/dev/null; \
# moving this into 'all' spoils execution order (clobbers results)
prep:
@mkdir -p $(BUILDDIR)/pkg/lists
# do beforehand as foreach gets expanded before recipe execution
$(TARGET):
@mkdir -p $(TARGET)
# dump *_LISTS variables' values
# TODO: consider GLOBAL_VERBOSE? (currently not coming with .config.mk)
# (for cp -v then, too)
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

View File

@ -1,4 +1,4 @@
kvm
qemu
#qemu
libvirt
mkve

7
pkg.in/lists/ovz-server Normal file
View File

@ -0,0 +1,7 @@
vzctl
vzdump
#vzautolimit
#vzfree
#vzvalidate
htop
yabeda

View File

@ -1,11 +1,11 @@
# this makefile is designed to be included in toplevel one
ifdef BUILDDIR
# step 1: initialize the off-tree mkimage profile
# step 1: initialize the off-tree mkimage profile (BUILDDIR)
profile/init: distclean
@echo -n "** initializing BUILDDIR: "
@rsync -qaH --delete image.in/ "$(BUILDDIR)"/
@:> "$(BUILDDIR)"/.config.mk
@:> "$(BUILDDIR)"/distcfg.mk
@:> "$(BUILDLOG)"
@mkdir "$(BUILDDIR)"/.mki # mkimage toplevel marker
@type -t git >&/dev/null && \
@ -13,16 +13,16 @@ profile/init: distclean
git init -q && \
git add . && \
git commit -qam 'init'
@rm -f build
@if [ -w . ]; then \
ln -sf "$(BUILDDIR)" build && \
echo "build/"; \
else \
echo "$(BUILDDIR)/"; \
fi
@rm -f build && \
if [ -w . ]; then \
ln -sf "$(BUILDDIR)" build && \
echo "build/"; \
else \
echo "$(BUILDDIR)/"; \
fi
# this is done after step 2, see toplevel Makefile
profile/populate: profile/init distro/.metaconf
# step 3 entry point: copy the needed parts into BUILDDIR
profile/populate: profile/init distro/.rc
@for dir in sub.in features.in pkg.in; do \
$(MAKE) -C $$dir $(LOG); \
done

View File

@ -1,6 +1,6 @@
# step 3: copy the needed subprofiles to $(BUILDDIR)
include $(BUILDDIR)/.config.mk
include $(BUILDDIR)/distcfg.mk
all:
@for dir in $(SUBPROFILES); do \
@ -14,7 +14,8 @@ all:
clean:
@for dir in $(SUBPROFILES); do \
[ -n "$$dir" ] && \
rm -rf $(BUILDDIR)/$$dir && \
mkdir -p $(BUILDDIR)/$$dir ||:; \
if [ -n "$$dir" ]; then \
rm -rf $(BUILDDIR)/$$dir && \
mkdir -p $(BUILDDIR)/$$dir; \
fi; \
done

View File

@ -2,10 +2,11 @@
default: all
include $(GLOBAL_BUILDDIR)/.config.mk
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)
IMAGE_PACKAGES = $(COMMON_PACKAGES) \
$(INSTALL2_PACKAGES) \
@ -15,4 +16,11 @@ MKI_PACK_RESULTS = squash:altinst
include $(MKIMAGE_PREFIX)/targets.mk
all: build-image run-image-scripts pack-image
# 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

View File

@ -0,0 +1,25 @@
#!/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

View File

@ -2,7 +2,7 @@
default: all
include $(GLOBAL_BUILDDIR)/.config.mk
include $(GLOBAL_BUILDDIR)/distcfg.mk
include $(GLOBAL_BUILDDIR)/functions.mk
include $(MKIMAGE_PREFIX)/config.mk

View File

@ -1,14 +1,13 @@
# step 4: build stage1 subprofile (installer bootstrap)
include $(GLOBAL_BUILDDIR)/.config.mk
include $(GLOBAL_BUILDDIR)/distcfg.mk
include $(GLOBAL_BUILDDIR)/functions.mk
include $(MKIMAGE_PREFIX)/config.mk
CHROOT_PACKAGES_REGEXP = $(call kpackages)
CHROOT_PACKAGES = $(STAGE1_PACKAGES) $(COMMON_PACKAGES)
ifdef BOOTLOADER
MKI_PACK_RESULTS = data
###
# FIXME: un-hardwire description
PROPAGATOR_VERSION = mkimage-profiles 2.0
PROPAGATOR_MAR_MODULES = ./modules
PROPAGATOR_INITFS = ./initfs
@ -16,4 +15,41 @@ COPY_TREE = ./files
include $(MKIMAGE_PREFIX)/targets.mk
all: build-propagator copy-tree copy-isolinux run-scripts pack-image
CHROOT_PACKAGES = $(STAGE1_PACKAGES) $(COMMON_PACKAGES)
ifeq "$(KFLAVOURS)" ""
# propagator needed iff stage1 kernel installed (not for e.g. syslinux.iso)
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)
endif
# scripts prepare bootloader configuration, too
all: prepare-workdir copy-tree run-scripts $(BUILD_PROPAGATOR) \
copy-$(BOOTLOADER) pack-image
debug:
@if test -n "$(GLOBAL_VERBOSE)"; then \
echo "** STAGE1_PACKAGES: $(STAGE1_PACKAGES)"; \
echo "** CHROOT_PACKAGES: $(CHROOT_PACKAGES)"; \
echo "** CHROOT_PACKAGES_REGEXP: $(CHROOT_PACKAGES_REGEXP)"; \
echo "** BOOTLOADER: $(BOOTLOADER)"; \
fi
else
$(error BOOTLOADER undefined)
endif

View File

@ -41,6 +41,7 @@ atl1e.ko
atl2.ko
atp870u.ko
atp.ko
aufs.ko
axnet_cs.ko
b44.ko
bnx2.ko

0
sub.in/stage1/scripts.d/01-initfs Normal file → Executable file
View File

View File

@ -0,0 +1,25 @@
#!/bin/sh
# symlink default kernel iff requested but not yet done
STAGE1_KFLAVOUR="$INFO_STAGE1_KFLAVOUR"
if [ -n "$GLOBAL_VERBOSE" ]; then
echo "** STAGE1_KFLAVOUR: $STAGE1_KFLAVOUR"
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 "$STAGE1_KFLAVOUR" ]; then
VMLINUZ="$(cd /boot; echo vmlinuz-*-$STAGE1_KFLAVOUR-*)"
if [ -n "$VMLINUZ" ]; then
ln -sf "$VMLINUZ" "$VMLINK"
echo "** overriding $VMLINK with $VMLINUZ"
fi
fi