From 50ce450f2ae48287a69dbd896d84ab78f4b3a753 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Fri, 2 Jul 2021 13:48:45 +1200 Subject: [PATCH] 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. --- Makefile | 11 ++++++++--- scripts/checkout-part.py | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 scripts/checkout-part.py diff --git a/Makefile b/Makefile index adf0d5b1..c3984d00 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # NAME=subiquity PYTHONSRC=$(NAME) -PYTHONPATH=$(shell pwd):$(shell pwd)/probert +PYTHONPATH=$(shell pwd):$(shell pwd)/probert:$(shell pwd)/curtin PROBERTDIR=./probert PROBERT_REPO=https://github.com/canonical/probert 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 \ python3-yaml python3-coverage python3-dev pkg-config libnl-genl-3-dev \ 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 i18n: @@ -59,12 +59,17 @@ integration: check: unit integration +curtin: + ./scripts/checkout-part.py curtin + probert: @if [ ! -d "$(PROBERTDIR)" ]; then \ - git clone -q $(PROBERT_REPO) $(PROBERTDIR); \ + ./scripts/checkout-part.py probert && \ (cd probert && $(PYTHON) setup.py build_ext -i); \ fi +gitdeps: curtin probert + schema: probert @$(PYTHON) -m subiquity.cmd.schema > autoinstall-schema.json diff --git a/scripts/checkout-part.py b/scripts/checkout-part.py new file mode 100755 index 00000000..a257316b --- /dev/null +++ b/scripts/checkout-part.py @@ -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)