update script to update exsting checkout
This commit is contained in:
parent
f9410e4e86
commit
cf931f673f
16
Makefile
16
Makefile
|
@ -50,23 +50,21 @@ flake8:
|
|||
@echo 'tox -e flake8' is preferred to 'make flake8'
|
||||
$(PYTHON) -m flake8 $(CHECK_DIRS) --exclude gettext38.py,contextlib38.py
|
||||
|
||||
unit:
|
||||
unit: gitdeps
|
||||
python3 -m unittest discover
|
||||
|
||||
integration:
|
||||
integration: gitdeps
|
||||
echo "Running integration tests..."
|
||||
./scripts/runtests.sh
|
||||
|
||||
check: unit integration
|
||||
|
||||
curtin:
|
||||
./scripts/checkout-part.py curtin
|
||||
curtin: snapcraft.yaml
|
||||
./scripts/update-part.py curtin
|
||||
|
||||
probert:
|
||||
@if [ ! -d "$(PROBERTDIR)" ]; then \
|
||||
./scripts/checkout-part.py probert && \
|
||||
(cd probert && $(PYTHON) setup.py build_ext -i); \
|
||||
fi
|
||||
probert: snapcraft.yaml
|
||||
./scripts/update-part.py probert
|
||||
(cd probert && $(PYTHON) setup.py build_ext -i);
|
||||
|
||||
gitdeps: curtin probert
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
#!/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)
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/python3
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
part = sys.argv[1]
|
||||
|
||||
|
||||
def r(*args, **kw):
|
||||
print('running', args)
|
||||
subprocess.run(args, check=True, **kw)
|
||||
|
||||
|
||||
def o(*args, **kw):
|
||||
return subprocess.run(args, check=True, stdout=subprocess.PIPE).stdout
|
||||
|
||||
|
||||
with open("snapcraft.yaml") as f:
|
||||
config = yaml.safe_load(f)["parts"][part]
|
||||
|
||||
|
||||
c = "master"
|
||||
for k in "source-commit", "source-tag", "source-branch":
|
||||
if k in config:
|
||||
c = config[k]
|
||||
break
|
||||
|
||||
if not os.path.isdir(part):
|
||||
r('git', 'clone', config['source'], part)
|
||||
|
||||
expected = o('git', '-C', part, 'rev-parse', c)
|
||||
actual = o('git', '-C', part, 'rev-parse', 'HEAD')
|
||||
|
||||
if expected != actual:
|
||||
try:
|
||||
r('git', '-c', 'advice.detachedHead=false', '-C', part, 'checkout', c)
|
||||
except subprocess.CalledProcessError:
|
||||
r('git', '-C', part, 'fetch', config['source'])
|
||||
r('git', '-c', 'advice.detachedHead=false', '-C', part, 'checkout', c)
|
Loading…
Reference in New Issue