alpine.mk: build iso from binary packages in system repository

This is so you can build the iso image without having the aports tree.
This commit is contained in:
Natanael Copa 2009-06-02 11:13:35 +00:00
parent ac8aa51f4c
commit 261787abcd

View File

@ -7,25 +7,19 @@ ALPINE_RELEASE ?= $(BUILD_DATE)
ALPINE_NAME ?= alpine-test ALPINE_NAME ?= alpine-test
ALPINE_ARCH := i386 ALPINE_ARCH := i386
DESTDIR ?= $(shell pwd)/isotmp DESTDIR ?= $(shell pwd)/isotmp
APORTS_DIR ?= $(HOME)/aports
REPOS ?= core extra REPOS ?= core extra
SUDO = sudo SUDO = sudo
# this might need to change...
APKDIRS ?= $(REPOS_DIR)/*/
ISO ?= $(ALPINE_NAME)-$(ALPINE_RELEASE)-$(ALPINE_ARCH).iso ISO ?= $(ALPINE_NAME)-$(ALPINE_RELEASE)-$(ALPINE_ARCH).iso
ISO_LINK ?= $(ALPINE_NAME).iso ISO_LINK ?= $(ALPINE_NAME).iso
ISO_DIR := $(DESTDIR)/isofs ISO_DIR := $(DESTDIR)/isofs
REPOS_DIR ?= $(HOME)/packages ISO_PKGDIR := $(ISO_DIR)/apks
# limitations for find_apk: find_apk_ver = $(shell apk search $(1) | sort | uniq)
# can not be a subpackage find_apk_file = $(addsuffix .apk,$(call find_apk_ver,$(1)))
find_aport = $(firstword $(wildcard $(APORTS_DIR)/*/$(1))) find_apk = $(addprefix $(ISO_PKGDIR)/,$(call find_apk_file,$(1)))
find_repo = $(subst $(APORTS_DIR),$(REPOS_DIR),$(dir $(call find_aport,$(1))))
find_apk = $(shell . $(call find_aport,$(1))/APKBUILD ;\
echo $(call find_repo,$(1))/$(1)-$$pkgver-r$$pkgrel.apk)
KERNEL_FLAVOR ?= grsec KERNEL_FLAVOR ?= grsec
KERNEL_PKGNAME ?= linux-$(KERNEL_FLAVOR) KERNEL_PKGNAME ?= linux-$(KERNEL_FLAVOR)
@ -49,19 +43,11 @@ SYSLINUX_APK := $(call find_apk,syslinux)
STRACE_APK := $(call find_apk,strace) STRACE_APK := $(call find_apk,strace)
ACCT_APK := $(call find_apk,acct) ACCT_APK := $(call find_apk,acct)
APORTS_DIR ?= $(HOME)/aports APKS_FILTER ?= | grep -v -- '-dev$$' | grep -v 'sources'
REPOS ?= core extra
APKS_FILTER := | grep -v -- '-dev$$' | grep -v 'sources'
APKBUILDS := $(addsuffix /*/APKBUILD,$(addprefix $(APORTS_DIR)/,$(REPOS)))
APKS := $(shell for i in $(APKBUILDS); do cd $${i%/*}; \
. $$i; \
for j in $$pkgname $$subpackages; do \
echo $${j%:*}; \
done; \
done $(APKS_FILTER) | sort | uniq)
#test: APKS ?= '*'
# echo $(APKS) APK_FILES := $(call find_apk,$(APKS))
APK_REPO ?= --repo /var/cache/abuild/apks
all: isofs all: isofs
@ -85,7 +71,6 @@ endif
@echo "ALPINE_NAME: $(ALPINE_NAME)" @echo "ALPINE_NAME: $(ALPINE_NAME)"
@echo "ALPINE_RELEASE: $(ALPINE_RELEASE)" @echo "ALPINE_RELEASE: $(ALPINE_RELEASE)"
@echo "KERNEL_FLAVOR: $(KERNEL_FLAVOR)" @echo "KERNEL_FLAVOR: $(KERNEL_FLAVOR)"
@echo "APORTS_DIR: $(APORTS_DIR)"
@echo "KERNEL: $(KERNEL)" @echo "KERNEL: $(KERNEL)"
@echo @echo
@ -94,18 +79,12 @@ clean:
$(INITFS) $(INITFS_DIRSTAMP) $(INITFS_DIR) \ $(INITFS) $(INITFS_DIRSTAMP) $(INITFS_DIR) \
$(ISO_DIR) $(REPOS_DIRSTAMP) $(ISO_REPOS_DIRSTAMP) $(ISO_DIR) $(REPOS_DIRSTAMP) $(ISO_REPOS_DIRSTAMP)
#
# Repos
#
repos: $(REPOS_DIRSTAMP)
REPOS_DIRSTAMP := $(DESTDIR)/stamp.repos $(APK_FILES):
$(REPOS_DIRSTAMP): $(SOURCE_APKBUILDS) @mkdir -p "$(dir $@)";\
@echo "==> repositories: $(REPOS)" p="$(notdir $(basename $@))";\
@buildrepo -p -a $(APORTS_DIR) -d $(REPOS_DIR) $(REPOS) apk fetch $(APK_REPO) -R -v -o "$(dir $@)" $${p%-[0-9]*}
@mkdir -p $(dir $@) && touch $@ # apk fetch --repo /var/cache/abuild/apks -v -R -o $(ISO_PKGDIR) \
%.apk: $(REPOS_DIRSTAMP)
# #
# Modloop # Modloop
@ -138,7 +117,6 @@ $(MODLOOP): $(MODLOOP_DIRSTAMP)
INITFS := $(ISO_DIR)/boot/$(KERNEL_NAME).gz INITFS := $(ISO_DIR)/boot/$(KERNEL_NAME).gz
#INITFS_DIRSTAMP := $(DESTDIR)/stamp.initfs
INITFS_DIR := $(DESTDIR)/initfs INITFS_DIR := $(DESTDIR)/initfs
INITFS_FEATURES := ata base bootchart cdrom cramfs ext3 ide floppy raid scsi usb INITFS_FEATURES := ata base bootchart cdrom cramfs ext3 ide floppy raid scsi usb
@ -159,7 +137,7 @@ vstemplate: $(VSTEMPLATE)
$(VSTEMPLATE): $(VSTEMPLATE):
@$(SUDO) rm -rf "$(VSTEMPLATE_DIR)" @$(SUDO) rm -rf "$(VSTEMPLATE_DIR)"
@$(SUDO) mkdir -p "$(VSTEMPLATE_DIR)" @$(SUDO) mkdir -p "$(VSTEMPLATE_DIR)"
@$(SUDO) apk add --initdb --root $(VSTEMPLATE_DIR) alpine-baselayout @$(SUDO) apk add --initdb --root $(VSTEMPLATE_DIR) alpine-baselayout openrc busybox
@cd $(VSTEMPLATE_DIR) && $(SUDO) tar -jcf $@ * @cd $(VSTEMPLATE_DIR) && $(SUDO) tar -jcf $@ *
# #
@ -174,8 +152,10 @@ SYSLINUX_CFG := $(ISO_DIR)/syslinux.cfg
$(ISOLINUX_BIN): $(SYSLINUX_APK) $(ISOLINUX_BIN): $(SYSLINUX_APK)
@echo "==> iso: install isolinux" @echo "==> iso: install isolinux"
@mkdir -p $(dir $(ISOLINUX_BIN)) @mkdir -p $(dir $(ISOLINUX_BIN))
@tar -O -zxf $(SYSLINUX_APK) usr/share/syslinux/isolinux.bin > $@ @for i in $(SYSLINUX_APK); do \
# @cp /usr/share/syslinux/isolinux.bin $(ISOLINUX_BIN) [ -f "$$i" ] || continue ;\
tar -O -zxf "$$i" usr/share/syslinux/isolinux.bin > $@ && exit 0;\
done ; exit 1
$(ISOLINUX_CFG): $(ISOLINUX_CFG):
@echo "==> iso: configure isolinux" @echo "==> iso: configure isolinux"
@ -197,33 +177,17 @@ $(SYSLINUX_CFG):
@echo " append initrd=/boot/$(KERNEL_NAME).gz alpine_dev=sda1:vfat modules=sd-mod,usb-storage quiet" >>$@ @echo " append initrd=/boot/$(KERNEL_NAME).gz alpine_dev=sda1:vfat modules=sd-mod,usb-storage quiet" >>$@
ISO_KERNEL := $(ISO_DIR)/boot/$(KERNEL_NAME) ISO_KERNEL := $(ISO_DIR)/boot/$(KERNEL_NAME)
ISO_PKGDIR := $(ISO_DIR)/apks
ISO_REPOS := $(addprefix $(ISO_PKGDIR)/,$(REPOS)) ISO_REPOS := $(addprefix $(ISO_PKGDIR)/,$(REPOS))
ISO_APKINDEX := $(addsuffix /APK_INDEX.gz,$(ISO_REPOS)) ISO_APKINDEX := $(addsuffix /APK_INDEX.gz,$(ISO_REPOS))
ISO_REPOS_DIRSTAMP := $(DESTDIR)/stamp.isorepos ISO_REPOS_DIRSTAMP := $(DESTDIR)/stamp.isorepos
ISOFS_DIRSTAMP := $(DESTDIR)/stamp.isofs ISOFS_DIRSTAMP := $(DESTDIR)/stamp.isofs
#$(ISO_REPOS_DIRSTAMP): $(addsuffix /APK_INDEX.gz,$(addprefix $(REPOS_DIR)/,$(REPOS)))
$(ISO_REPOS_DIRSTAMP): $(ISO_PKGDIR)/APK_INDEX.gz $(ISO_REPOS_DIRSTAMP): $(ISO_PKGDIR)/APK_INDEX.gz
@touch $@ @touch $@
$(ISO_PKGDIR)/APK_INDEX.gz: $(ISO_PKGDIR)/APK_INDEX.gz: $(APK_FILES)
@echo "==> iso: prepare repositories $(REPOS)" @echo "==> iso: generating repository index"
# @rm -rf $(ISO_PKGDIR) @apk index $(APK_FILES) | gzip > $@
# @mkdir -p $(ISO_REPOS)
# @for r in $(REPOS); do \
# for a in $(REPOS_DIR)/$$r/*; do \
# ln -f "$$a" $(ISO_PKGDIR)/$$r/$${a##*/} 2>/dev/null \
# || cp -r "$$a" $(ISO_PKGDIR)/$$r/$${a##*/} ;\
# done;\
# done
mkdir -p $(ISO_PKGDIR)
apk fetch --repo /var/cache/abuild/apks -v -R -o $(ISO_PKGDIR) \
$(APKS)
apk index $(ISO_PKGDIR)/* | gzip > $@
#$(ISO_APKINDEX): $(ISO_REPOS)
# @apk index $(dir $@)/*.apk | gzip -9 > $@
$(ISO_KERNEL): $(KERNEL_APK) $(ISO_KERNEL): $(KERNEL_APK)
@echo "==> iso: install kernel $(KERNEL)" @echo "==> iso: install kernel $(KERNEL)"