From 501395c36e80a915592b820a44e41ddd977413ca Mon Sep 17 00:00:00 2001 From: mustard Date: Mon, 20 Oct 2025 14:53:32 +0200 Subject: [PATCH] feat: add basic Makefile and .gitignore --- .gitignore | 1 + Makefile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e756d11 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.bundles/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f2a1bd2 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +SHELL = /bin/sh + +ifneq (,$(wildcard .bundle-env)) +include .bundle-env +endif + +ifeq (root,$(shell whoami)) +check-root = @true +else +check-root = $(error this target requires root) +endif + +ifeq (dom0,$(shell hostname)) +check-dom0 = @true +check-domu = $(error this target must be run in the guest qube) +else +check-dom0 = $(error this target must be run in dom0) +check-domu = @true +endif + +BUNDLEOUT := .bundles/dom0.bundle +BUNDLEIN := .bundles/domu.bundle + +clean-workdir = git init -q -b $* && git diff --quiet && git diff --cached --quiet || (echo 'dirty tree; check git status' && false) + +create-bundle = git show-ref --verify --quiet refs/remotes/${1}/$* \ + && git bundle create $(BUNDLEOUT) $(1)/$*..$* \ + || git bundle create $(BUNDLEOUT) $* +.PHONY: pull pull/% + +pull: pull/$(shell git branch --show-current) +pull%: + $(check-dom0) + $(clean-workdir) + + qvm-run -p $(GUEST) "cd $(GUEST_REPO) && $(call create-bundle,dom0)" $(BUNDLEIN) + + git remote add $(GUEST) $(BUNDLEIN) || true + + git pull $(GUEST) $*:$* + + qvm-run -p $(GUEST) "cd $(GUEST_REPO) && git update-ref refs/remotes/dom0/$* $*"