allowing the use of a default appliance

An appliance with the name "default" can be created,
and its configuration is used as the basis for all
other appliances.
This commit is contained in:
Jörg Deckert 2021-02-07 18:31:01 +01:00
parent aabef6e83d
commit 38424c532b
1 changed files with 24 additions and 7 deletions

View File

@ -50,18 +50,23 @@ USEPKG = --usepkg --binpkg-respect-use=y
RSYNC_MIRROR = rsync://rsync.gtlib.gatech.edu/gentoo/
KERNEL_PKG = gentoo-sources
WORLD = appliances/$(APPLIANCE)/world
WORLD_DEFAULT = appliances/default/world
EXTRA_WORLD =
# /etc/portage targets
base_etc_portage := $(wildcard configs/portage/*)
etc_portage := $(patsubst configs/portage/%,$(CHROOT)/etc/portage/%,$(base_etc_portage))
default_package_files := $(wildcard appliances/default/package.*)
appliance_package_files := $(wildcard appliances/$(APPLIANCE)/package.*)
portage_package_files = $(patsubst appliances/$(APPLIANCE)/package.%,$(CHROOT)/etc/portage/package.%/01$(APPLIANCE),$(appliance_package_files))
portage_default_package_files = $(patsubst appliances/default/package.%,$(CHROOT)/etc/portage/package.%/01default,$(default_package_files))
portage_package_files = $(patsubst appliances/$(APPLIANCE)/package.%,$(CHROOT)/etc/portage/package.%/02$(APPLIANCE),$(appliance_package_files))
default_make_conf = $(wildcard appliances/default/make.conf)
appliance_make_conf = $(wildcard appliances/$(APPLIANCE)/make.conf)
portage_make_conf_local = $(CHROOT)/etc/portage/make.conf.local
appliance_profile := default/linux/amd64/17.1/systemd
# Allow appliance to override variables
-include appliances/default/default.cfg
-include appliances/$(APPLIANCE)/$(APPLIANCE).cfg
# Allow user to override variables
@ -131,7 +136,7 @@ else
$(M4) -DDRIVE=vda $< > $@
endif
$(PREPROOT): $(STAGE3) $(PORTAGE_DIR) $(foreach repo,$(REPO_NAMES),$(REPO_DIR)/$(repo)) $(CHROOT)/etc/fstab $(etc_portage) $(portage_package_files)
$(PREPROOT): $(STAGE3) $(PORTAGE_DIR) $(foreach repo,$(REPO_NAMES),$(REPO_DIR)/$(repo)) $(CHROOT)/etc/fstab $(etc_portage) $(portage_default_package_files) $(portage_package_files)
mkdir -p $(VA_PKGDIR) $(DISTDIR)
@print Creating swap file: `basename $(SWAP_FILE)`
dd if=/dev/zero of=$(SWAP_FILE) bs=1M count=$(SWAP_SIZE)
@ -178,8 +183,11 @@ $(CHROOT)/etc/portage/repos.conf: $(foreach repo,$(REPO_NAMES),$(REPO_DIR)/$(rep
)
touch $@
$(CHROOT)/etc/portage/package.%/01default: appliances/default/package.% $(STAGE3)
mkdir -p `dirname $@`
cp $< $@
$(CHROOT)/etc/portage/package.%/01$(APPLIANCE): appliances/$(APPLIANCE)/package.% $(STAGE3)
$(CHROOT)/etc/portage/package.%/02$(APPLIANCE): appliances/$(APPLIANCE)/package.% $(STAGE3)
mkdir -p `dirname $@`
cp $< $@
@ -187,8 +195,8 @@ $(CHROOT)/etc/portage/package.%/01$(APPLIANCE): appliances/$(APPLIANCE)/package.
$(CHROOT)/etc/portage/make.conf: configs/make.conf.$(VA_ARCH)
COPY configs/make.conf.$(VA_ARCH) /etc/portage/make.conf
$(portage_make_conf_local): $(appliance_make_conf)
COPY $< /etc/portage/make.conf.local || touch $@
$(portage_make_conf_local): $(default_make_conf) $(appliance_make_conf)
cat $< >> $(CHROOT)/etc/portage/make.conf.local || touch $@
$(CHROOT)/var/tmp/profile: $(STAGE3)
RUN eselect profile set $(appliance_profile)
@ -197,7 +205,7 @@ $(CHROOT)/var/tmp/profile: $(STAGE3)
$(CHROOT)/etc/locale.gen: configs/locale.gen
COPY configs/locale.gen /etc/locale.gen
$(COMPILE_OPTIONS): $(STAGE3) $(PORTAGE_DIR) $(CHROOT)/etc/portage/make.conf configs/locale.gen $(portage_package_files) $(portage_make_conf_local) $(CHROOT)/var/tmp/profile $(CHROOT)/etc/locale.gen $(CHROOT)/etc/portage/repos.conf
$(COMPILE_OPTIONS): $(STAGE3) $(PORTAGE_DIR) $(CHROOT)/etc/portage/make.conf configs/locale.gen $(portage_default_package_files) $(portage_package_files) $(portage_make_conf_local) $(CHROOT)/var/tmp/profile $(CHROOT)/etc/locale.gen $(CHROOT)/etc/portage/repos.conf
RUN locale-gen
touch $(COMPILE_OPTIONS)
@ -254,9 +262,15 @@ software: $(SOFTWARE)
$(SOFTWARE): $(SYSTOOLS) configs/eth.network configs/issue $(COMPILE_OPTIONS) $(WORLD)
@print Building $(APPLIANCE)-specific software
if test -f appliances/default/Makefile; \
then $(MAKE) -C appliances/default preinstall; \
fi
$(MAKE) -C appliances/$(APPLIANCE) preinstall
COPY $(WORLD) /var/lib/portage/world
if test -f $(WORLD_DEFAULT); \
then COPY $(WORLD_DEFAULT) /var/lib/portage/world; \
fi
cat $(WORLD) >> $(CHROOT)/var/lib/portage/world
RUN $(EMERGE) $(USEPKG) --update --newuse --deep @system
@print Running @preserved-rebuild
@ -275,6 +289,9 @@ endif
ifeq ($(DASH),YES)
RUN $(EMERGE) --depclean app-shells/bash
endif
if test -f appliances/default/Makefile; \
then $(MAKE) -C appliances/default postinstall; \
fi
$(MAKE) -C appliances/$(APPLIANCE) postinstall
ifneq ($(PKGLIST),0)
echo \# > $(LST_FILE)