2025-10-20 22:23:13 +02:00
|
|
|
SHELL = /bin/bash
|
2025-10-28 00:18:20 +01:00
|
|
|
.POSIX_SHELL
|
2025-10-20 14:53:32 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2025-10-20 17:09:44 +02:00
|
|
|
BUNDLEIN := .bundles/qubes-mgmt-salt
|
2025-10-20 14:53:32 +02:00
|
|
|
|
2025-10-24 18:59:11 +02:00
|
|
|
|
|
|
|
|
ifeq (apply, $(firstword $(MAKECMDGOALS)))
|
|
|
|
|
# use the rest as arguments for "run"
|
|
|
|
|
APPLY_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
|
|
|
|
# ...and turn them into do-nothing targets
|
|
|
|
|
$(eval $(APPLY_ARGS):;@:)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-20 14:53:32 +02:00
|
|
|
clean-workdir = git init -q -b $* && git diff --quiet && git diff --cached --quiet || (echo 'dirty tree; check git status' && false)
|
|
|
|
|
|
2025-10-20 17:09:44 +02:00
|
|
|
.PHONY: guard-domu
|
|
|
|
|
guard-domu:
|
|
|
|
|
@ if [ "`hostname`" != "`qubesdb-read /name`" ]; then \
|
|
|
|
|
echo "This task must be run in a guest domain"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-20 17:18:12 +02:00
|
|
|
.PHONY: create-bundle
|
2025-10-20 17:09:44 +02:00
|
|
|
create-bundle: guard-domu
|
|
|
|
|
mkdir -p .bundles
|
|
|
|
|
git bundle create - --all > .bundles/qubes-mgmt-salt
|
2025-10-20 14:53:32 +02:00
|
|
|
|
2025-10-20 23:42:41 +02:00
|
|
|
# cures common weird states (thanks xyhhx for the tip)
|
|
|
|
|
# also try `sudo rm -rf /var/cache/salt /srv/salt/_tops/*`
|
|
|
|
|
.PHONY: cure
|
|
|
|
|
cure:
|
|
|
|
|
sudo rm -rf /var/cache/salt
|
2025-10-20 23:44:17 +02:00
|
|
|
sudo rm -rf /srv/salt/_tops/user
|
2025-10-20 23:42:41 +02:00
|
|
|
qubesctl saltutil.clear_cache
|
|
|
|
|
qubesctl saltutil.sync_all
|
|
|
|
|
|
2025-10-20 15:08:03 +02:00
|
|
|
.PHONY: pull pull/%
|
2025-10-20 14:53:32 +02:00
|
|
|
pull: pull/$(shell git branch --show-current)
|
2025-10-20 15:23:06 +02:00
|
|
|
pull/%:
|
2025-10-20 15:53:33 +02:00
|
|
|
echo "check dom0"
|
2025-10-20 14:53:32 +02:00
|
|
|
$(check-dom0)
|
2025-10-20 15:53:33 +02:00
|
|
|
echo "clean workdir"
|
2025-10-20 14:53:32 +02:00
|
|
|
$(clean-workdir)
|
2025-10-20 22:23:13 +02:00
|
|
|
|
2025-10-20 15:53:33 +02:00
|
|
|
echo "creating bundle"
|
2025-10-20 17:19:24 +02:00
|
|
|
qvm-run -p $(GUEST) "cd $(GUEST_REPO) && make create-bundle" </dev/null
|
2025-10-20 14:53:32 +02:00
|
|
|
|
2025-10-20 17:20:34 +02:00
|
|
|
qvm-run -p $(GUEST) "cat $(GUEST_REPO)/.bundles/qubes-mgmt-salt" </dev/null >$(BUNDLEIN)
|
2025-10-20 14:53:32 +02:00
|
|
|
|
|
|
|
|
git remote add $(GUEST) $(BUNDLEIN) || true
|
2025-10-20 22:23:13 +02:00
|
|
|
|
2025-10-20 14:53:32 +02:00
|
|
|
git pull $(GUEST) $*:$*
|
2025-10-20 22:23:13 +02:00
|
|
|
|
2025-10-20 14:53:32 +02:00
|
|
|
qvm-run -p $(GUEST) "cd $(GUEST_REPO) && git update-ref refs/remotes/dom0/$* $*" </dev/null
|
|
|
|
|
|
|
|
|
|
@echo "updated branch $* from $(GUEST)"
|
2025-10-20 15:44:13 +02:00
|
|
|
|
2025-10-20 22:23:13 +02:00
|
|
|
install:
|
|
|
|
|
install -D -oroot -groot -m0644 conf/z_user.conf /etc/salt/minion.d/z_user.conf
|
|
|
|
|
install -D -oroot -groot -m0644 conf/overrides.conf /usr/local/etc/salt/minion.d/overrides.conf
|
2025-10-20 22:46:50 +02:00
|
|
|
mkdir -p /srv/user
|
2025-10-20 22:55:22 +02:00
|
|
|
ln -s $(CURDIR)/salt /srv/user/salt
|
2025-10-20 22:46:50 +02:00
|
|
|
|
2025-10-24 18:59:11 +02:00
|
|
|
.PHONY: apply
|
2025-10-20 22:46:50 +02:00
|
|
|
apply:
|
2025-10-20 23:00:53 +02:00
|
|
|
install -D -oroot -groot -m0644 conf/z_user.conf /etc/salt/minion.d/z_user.conf
|
|
|
|
|
install -D -oroot -groot -m0644 conf/overrides.conf /usr/local/etc/salt/minion.d/overrides.conf
|
2025-10-21 00:46:27 +02:00
|
|
|
|
2025-10-25 00:06:02 +02:00
|
|
|
qubesctl top.enable topd
|
2025-10-24 18:59:11 +02:00
|
|
|
qubesctl top.enable $(APPLY_ARGS)
|
2025-10-28 00:18:20 +01:00
|
|
|
qubesctl --show-output --force-color --skip-dom0 --targets templates state.apply $(APPLY_ARGS)
|
2025-10-24 18:59:11 +02:00
|
|
|
qubesctl top.disable $(APPLY_ARGS)
|