1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import subprocess
import pytest
from buildstream.testing import Repo
from .. import site
class OSTree(Repo):
def __init__(self, directory, subdir):
if not site.HAVE_OSTREE_CLI or not site.HAVE_OSTREE:
pytest.skip("ostree cli is not available")
super(OSTree, self).__init__(directory, subdir)
self.ostree = site.OSTREE_CLI
def create(self, directory):
subprocess.call([self.ostree, 'init',
'--repo', self.repo,
'--mode', 'archive-z2'])
subprocess.call([self.ostree, 'commit',
'--repo', self.repo,
'--branch', 'master',
'--subject', 'Initial commit',
directory])
latest = self.latest_commit()
return latest
def source_config(self, ref=None):
config = {
'kind': 'ostree',
'url': 'file://' + self.repo,
'track': 'master'
}
if ref is not None:
config['ref'] = ref
return config
def latest_commit(self):
return subprocess.check_output([
self.ostree, 'rev-parse',
'--repo', self.repo,
'master'
], universal_newlines=True).strip()
|