Files
bootrr/Makefile
Bjorn Andersson 04922d1bd7 Makefile: Override owner of files in cpio archive
In the typical scenario where the bootrr cpio archive is concatenated
onto some ramdisk, attributes of this cpio archive will overwrite those
previously extracted.

When used in combination with a ramdisk with systemd, this results in
many services failing to start, because the namespaced services does not
have permission to open e.g. /

Fix this my overriding the owner and group.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2024-04-21 20:38:32 -07:00

51 lines
956 B
Makefile

.PHONY: all
all:
all-install :=
DESTDIR ?= dest
CPIONAME ?= bootrr
HELPERS := $(wildcard helpers/*)
BOARDS := $(wildcard boards/*)
BINS := bin/bootrr bin/bootrr-generate-template
LIBEXEC_DIR ?= $(prefix)/libexec
BOOTRR_DIR = $(LIBEXEC_DIR)/bootrr
define add-scripts
$(DESTDIR)$1/$2: $2
@echo "INSTALL $$<"
@install -D -m 755 $$< $$@
all-install += $(DESTDIR)$1/$2
endef
$(foreach v,${BOARDS},$(eval $(call add-scripts,$(BOOTRR_DIR),$v)))
$(foreach v,${HELPERS},$(eval $(call add-scripts,$(BOOTRR_DIR),$v)))
$(foreach v,${BINS},$(eval $(call add-scripts,$(prefix),$v)))
bin/bootrr: bin/bootrr.in Makefile
@sed -e 's!@BOOTRR@!$(BOOTRR_DIR)!g' $< > $@.tmp
@mv $@.tmp $@
install: $(all-install)
CPIO := $(PWD)/$(CPIONAME).cpio
$(CPIO): $(all-install)
@cd $(DESTDIR) && find ./$(prefix) | cpio -o -H newc -R +0:+0 > $(CPIO)
%.cpio.gz: %.cpio
@gzip < $< > $@
cpio: $(CPIO)
cpio.gz: $(CPIO).gz
clean:
@rm -f $(CPIO) $(CPIO).gz bin/bootrr