use additional overlays/repositories

This commit is contained in:
Jörg Deckert 2021-02-05 20:45:54 +01:00
parent 5cc933830b
commit f7c9fa17ca
2 changed files with 33 additions and 5 deletions

View File

@ -3,7 +3,9 @@ VABUILDER_OUTPUT := $(CURDIR)
CHROOT := $(VABUILDER_OUTPUT)/build/$(APPLIANCE) CHROOT := $(VABUILDER_OUTPUT)/build/$(APPLIANCE)
VA_PKGDIR = $(VABUILDER_OUTPUT)/packages VA_PKGDIR = $(VABUILDER_OUTPUT)/packages
DISTDIR = $(CURDIR)/distfiles DISTDIR = $(CURDIR)/distfiles
PORTAGE_DIR = $(CURDIR)/portage REPO_DIR = $(CURDIR)/repos
REPO_NAMES =
PORTAGE_DIR = $(REPO_DIR)/gentoo
HOSTNAME = $(APPLIANCE) HOSTNAME = $(APPLIANCE)
IMAGES = $(VABUILDER_OUTPUT)/images IMAGES = $(VABUILDER_OUTPUT)/images
RAW_IMAGE = $(IMAGES)/$(APPLIANCE).img RAW_IMAGE = $(IMAGES)/$(APPLIANCE).img
@ -73,13 +75,14 @@ endif
PATH := $(CURDIR)/scripts:$(PATH) PATH := $(CURDIR)/scripts:$(PATH)
export PATH CHROOT container PORTAGE_DIR VA_PKGDIR DISTDIR VA_ARCH export PATH CHROOT container PORTAGE_DIR REPO_DIR REPO_NAMES VA_PKGDIR DISTDIR VA_ARCH
inroot := systemd-nspawn --quiet \ inroot := systemd-nspawn --quiet \
--directory=$(CHROOT) \ --directory=$(CHROOT) \
--machine=$(container) \ --machine=$(container) \
--capability=CAP_NET_ADMIN \ --capability=CAP_NET_ADMIN \
--bind=$(PORTAGE_DIR):/var/db/repos/gentoo \ --bind=$(PORTAGE_DIR):/var/db/repos/gentoo \
$(foreach repo,$(REPO_NAMES),--bind=$(REPO_DIR)/$(repo):/var/db/repos/$(repo) ) \
--bind=$(VA_PKGDIR):/var/cache/binpkgs \ --bind=$(VA_PKGDIR):/var/cache/binpkgs \
--bind=$(DISTDIR):/var/cache/distfiles --bind=$(DISTDIR):/var/cache/distfiles
@ -128,7 +131,7 @@ else
$(M4) -DDRIVE=vda $< > $@ $(M4) -DDRIVE=vda $< > $@
endif endif
$(PREPROOT): $(STAGE3) $(PORTAGE_DIR) $(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_package_files)
mkdir -p $(VA_PKGDIR) $(DISTDIR) mkdir -p $(VA_PKGDIR) $(DISTDIR)
@print Creating swap file: `basename $(SWAP_FILE)` @print Creating swap file: `basename $(SWAP_FILE)`
dd if=/dev/zero of=$(SWAP_FILE) bs=1M count=$(SWAP_SIZE) dd if=/dev/zero of=$(SWAP_FILE) bs=1M count=$(SWAP_SIZE)
@ -157,6 +160,25 @@ endif
rm -f $(CHROOT)/etc/localtime rm -f $(CHROOT)/etc/localtime
touch $(STAGE3) touch $(STAGE3)
sync_repos: $(foreach repo,$(REPO_NAMES),$(REPO_DIR)/$(repo))
@print Updating the repositories
$(foreach repo,$(REPO_NAMES),git -C $(REPO_DIR)/$(repo) pull;touch $(REPO_DIR)/$(repo);)
$(foreach repo,$(REPO_NAMES),$(REPO_DIR)/$(repo)):
@print Grabbing a repository
git clone --depth=1 $(REPO_URI_$(subst $(REPO_DIR)/,,$@)) $@
$(CHROOT)/etc/portage/repos.conf: $(foreach repo,$(REPO_NAMES),$(REPO_DIR)/$(repo))
$(foreach repo,$(REPO_NAMES),\
echo "[$(repo)]" >>$@;\
echo "location = /var/db/repos/$(repo)" >>$@;\
echo "auto-sync = no" >>$@;\
echo "" >>$@;\
)
touch $@
$(CHROOT)/etc/portage/package.%/01$(APPLIANCE): appliances/$(APPLIANCE)/package.% $(STAGE3) $(CHROOT)/etc/portage/package.%/01$(APPLIANCE): appliances/$(APPLIANCE)/package.% $(STAGE3)
mkdir -p `dirname $@` mkdir -p `dirname $@`
cp $< $@ cp $< $@
@ -175,7 +197,7 @@ $(CHROOT)/var/tmp/profile: $(STAGE3)
$(CHROOT)/etc/locale.gen: configs/locale.gen $(CHROOT)/etc/locale.gen: configs/locale.gen
COPY configs/locale.gen /etc/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 $(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
RUN locale-gen RUN locale-gen
touch $(COMPILE_OPTIONS) touch $(COMPILE_OPTIONS)

View File

@ -7,6 +7,12 @@ import sys
def main(): def main():
environ = os.environ environ = os.environ
repobind = []
repodir = environ['REPO_DIR']
repos = str.split(environ['REPO_NAMES'])
for repo in repos:
repobind.append(f"--bind={repodir}/{repo}:/var/db/repos/{repo}")
command = [ command = [
"systemd-nspawn", "systemd-nspawn",
"--quiet", "--quiet",
@ -16,7 +22,7 @@ def main():
f"--bind={environ['PORTAGE_DIR']}:/var/db/repos/gentoo", f"--bind={environ['PORTAGE_DIR']}:/var/db/repos/gentoo",
f"--bind={environ['VA_PKGDIR']}:/var/cache/binpkgs", f"--bind={environ['VA_PKGDIR']}:/var/cache/binpkgs",
f"--bind={environ['DISTDIR']}:/var/cache/distfiles", f"--bind={environ['DISTDIR']}:/var/cache/distfiles",
] + sys.argv[1:] ] + repobind + sys.argv[1:]
if os.environ.get("VA_ARCH") == "linux32": if os.environ.get("VA_ARCH") == "linux32":
command = ["linux32"] + command command = ["linux32"] + command