summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2021-04-24 23:07:01 +0100
committerDiederik de Haas <didi.debian@cknow.org>2021-06-24 19:33:33 +0200
commit821aff4e192be913a9b0e18779bbd505de9f8296 (patch)
tree60b92c7eb0e277bf4c3e6f4fcdde60786729263f /Makefile
parent5aadb0116a468d8fef5155e93fcc219ad58c2e81 (diff)
Makefile: Automatically use fakemachine if not uid 0
fakemachine launches a virtual machine reusing the host system's /usr, and runs commands as root on that virtual machine. It's used by debos, but can also be used to wrap arbitrary commands, in particular vmdb2; it's enough to run the parts of vmdb2 that need to mount filesystems and run apt. This won't work if fakemachine isn't available (in particular on non-x86), but that seems better than just failing altogether. Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile8
1 files changed, 7 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 40b4bb4..0da3f06 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,12 @@ xzimages: $(addsuffix .img.xz,$(platforms))
images: $(addsuffix .img,$(platforms))
yaml: $(addsuffix .yaml,$(platforms))
+ifeq ($(shell id -u),0)
+as_root =
+else
+as_root = fakemachine -v $(CURDIR) -- env --chdir $(CURDIR)
+endif
+
target_platforms:
@echo $(platforms)
@@ -122,7 +128,7 @@ raspi_4_bullseye.yaml: raspi_base_bullseye.yaml
%.img: %.yaml
touch $(@:.img=.log)
- time nice vmdb2 --verbose --rootfs-tarball=$(subst .img,.tar.gz,$@) --output=$@ $(subst .img,.yaml,$@) --log $(subst .img,.log,$@)
+ time nice $(as_root) vmdb2 --verbose --rootfs-tarball=$(subst .img,.tar.gz,$@) --output=$@ $(subst .img,.yaml,$@) --log $(subst .img,.log,$@)
chmod 0644 $@ $(@,.img=.log)
_ck_root: