add a gitdeps target to Makefile that checks out probert and curtin

This uses a silly python script to get the exact version that the
snapcraft.yaml specifies.
This commit is contained in:
Michael Hudson-Doyle 2021-07-02 13:48:45 +12:00
parent 5b54579d24
commit 50ce450f2a
2 changed files with 35 additions and 3 deletions

View File

@ -3,7 +3,7 @@
# #
NAME=subiquity NAME=subiquity
PYTHONSRC=$(NAME) PYTHONSRC=$(NAME)
PYTHONPATH=$(shell pwd):$(shell pwd)/probert PYTHONPATH=$(shell pwd):$(shell pwd)/probert:$(shell pwd)/curtin
PROBERTDIR=./probert PROBERTDIR=./probert
PROBERT_REPO=https://github.com/canonical/probert PROBERT_REPO=https://github.com/canonical/probert
DRYRUN?=--dry-run --bootloader uefi --machine-config examples/simple.json DRYRUN?=--dry-run --bootloader uefi --machine-config examples/simple.json
@ -25,7 +25,7 @@ install_deps:
sudo apt-get install -y python3-urwid python3-pyudev python3-nose python3-flake8 \ sudo apt-get install -y python3-urwid python3-pyudev python3-nose python3-flake8 \
python3-yaml python3-coverage python3-dev pkg-config libnl-genl-3-dev \ python3-yaml python3-coverage python3-dev pkg-config libnl-genl-3-dev \
libnl-route-3-dev python3-attr python3-distutils-extra python3-requests \ libnl-route-3-dev python3-attr python3-distutils-extra python3-requests \
python3-requests-unixsocket python3-jsonschema python3-curtin python3-apport \ python3-requests-unixsocket python3-jsonschema python3-apport \
python3-bson xorriso isolinux python3-aiohttp probert cloud-init ssh-import-id python3-bson xorriso isolinux python3-aiohttp probert cloud-init ssh-import-id
i18n: i18n:
@ -59,12 +59,17 @@ integration:
check: unit integration check: unit integration
curtin:
./scripts/checkout-part.py curtin
probert: probert:
@if [ ! -d "$(PROBERTDIR)" ]; then \ @if [ ! -d "$(PROBERTDIR)" ]; then \
git clone -q $(PROBERT_REPO) $(PROBERTDIR); \ ./scripts/checkout-part.py probert && \
(cd probert && $(PYTHON) setup.py build_ext -i); \ (cd probert && $(PYTHON) setup.py build_ext -i); \
fi fi
gitdeps: curtin probert
schema: probert schema: probert
@$(PYTHON) -m subiquity.cmd.schema > autoinstall-schema.json @$(PYTHON) -m subiquity.cmd.schema > autoinstall-schema.json

27
scripts/checkout-part.py Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/python3
import subprocess
import sys
import yaml
part = sys.argv[1]
def r(*args):
print('running', args)
subprocess.run(args, check=True)
with open("snapcraft.yaml") as f:
config = yaml.safe_load(f)["parts"][part]
r('git', 'clone', config['source'], part)
c = None
for k in "source-commit", "source-tag", "source-branch":
if k in config:
c = config[k]
break
if c is not None:
r('git', '-c', 'advice.detachedHead=false', '-C', part, 'checkout', c)