summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <jjardon@gnome.org>2019-05-12 12:44:34 -0700
committerJavier Jardón <jjardon@gnome.org>2019-05-14 01:18:40 -0500
commitb415a50152bc823cfca3dac190ed1a821700517b (patch)
treed299af648edabb68293af3274930d2d1a45d5cbc
parentcc871d37500cc78d16112cf31bf32685c3b7e9aa (diff)
downloadbuildstream-jjardon/ostree_removal.tar.gz
Remove OSTree plugin; It lives now in the bst-plugins-experimental repojjardon/ostree_removal
-rw-r--r--CONTRIBUTING.rst4
-rw-r--r--NEWS3
-rw-r--r--buildstream/_ostree.py276
-rw-r--r--buildstream/plugins/sources/ostree.py205
-rw-r--r--doc/examples/flatpak-autotools/project.conf5
-rw-r--r--doc/source/core_plugins.rst1
-rw-r--r--tests/cachekey/cachekey.py3
-rw-r--r--tests/cachekey/project/sources/ostree1.bst6
-rw-r--r--tests/cachekey/project/target.bst1
-rw-r--r--tests/cachekey/project/target.expected2
-rwxr-xr-xtests/conftest.py2
-rw-r--r--tests/sources/ostree.py60
-rw-r--r--tests/testutils/repo/ostree.py48
-rw-r--r--tests/testutils/site.py2
14 files changed, 13 insertions, 605 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index c0dffe8c9..fdc500435 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -1484,12 +1484,12 @@ for installing them for some common distributions are listed below.
For Fedora-based systems::
- dnf install gcc pkg-config python3-devel cairo-gobject-devel glib2-devel gobject-introspection-devel
+ dnf install gcc python3-devel
For Debian-based systems::
- apt install gcc pkg-config python3-dev libcairo2-dev libgirepository1.0-dev
+ apt install gcc python3-dev
Running tests
diff --git a/NEWS b/NEWS
index 75e6f1f9f..239fcf35e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@
buildstream 1.3.1
=================
+ o BREAKING CHANGE: ostree plugin has been removed. It now leaves in the
+ bst-plugins-experimental repo
+
o BREAKING CHANGE: YAML New World Order. The parsing and loading of .bst files
and node handling has been completely rewritten and is now faster. This now
requires that plugin authors must use the Plugin API to access or modify node
diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py
deleted file mode 100644
index ab652d77c..000000000
--- a/buildstream/_ostree.py
+++ /dev/null
@@ -1,276 +0,0 @@
-#
-# Copyright (C) 2017 Codethink Limited
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-#
-# Authors:
-# Jürg Billeter <juerg.billeter@codethink.co.uk>
-# Andrew Leeming <andrew.leeming@codethink.co.uk>
-# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
-#
-# Code based on Jürg's artifact cache and Andrew's ostree plugin
-#
-
-# Disable pylint warnings that are not appicable to this module
-# pylint: disable=bad-exception-context,catching-non-exception
-
-import os
-
-import gi
-from gi.repository.GLib import Variant, VariantDict
-
-from ._exceptions import BstError, ErrorDomain
-
-# pylint: disable=wrong-import-position,wrong-import-order
-gi.require_version('OSTree', '1.0')
-from gi.repository import GLib, Gio, OSTree # noqa
-
-
-# For users of this file, they must expect (except) it.
-class OSTreeError(BstError):
- def __init__(self, message, reason=None):
- super().__init__(message, domain=ErrorDomain.UTIL, reason=reason)
-
-
-# ensure()
-#
-# Args:
-# path (str): The file path to where the desired repo should be
-# compress (bool): use compression or not when creating
-#
-# Returns: an OSTree.Repo
-def ensure(path, compress):
-
- # create also succeeds on existing repository
- repo = OSTree.Repo.new(Gio.File.new_for_path(path))
- mode = OSTree.RepoMode.ARCHIVE_Z2 if compress \
- else OSTree.RepoMode.BARE_USER
-
- repo.create(mode)
-
- # Disble OSTree's built in minimum-disk-space check.
- config = repo.copy_config()
- config.set_string('core', 'min-free-space-percent', '0')
- repo.write_config(config)
- repo.reload_config()
-
- return repo
-
-
-# checkout()
-#
-# Checkout the content at 'commit' from 'repo' in
-# the specified 'path'
-#
-# Args:
-# repo (OSTree.Repo): The repo
-# path (str): The checkout path
-# commit_ (str): The commit checksum to checkout
-# user (boot): Whether to checkout in user mode
-#
-def checkout(repo, path, commit_, user=False):
-
- # Check out a full copy of an OSTree at a given ref to some directory.
- #
- # Note: OSTree does not like updating directories inline/sync, therefore
- # make sure you checkout to a clean directory or add additional code to support
- # union mode or (if it exists) file replacement/update.
- #
- # Returns True on success
- #
- # cli exmaple:
- # ostree --repo=repo checkout --user-mode runtime/org.freedesktop.Sdk/x86_64/1.4 foo
- os.makedirs(os.path.dirname(path), exist_ok=True)
-
- options = OSTree.RepoCheckoutAtOptions()
-
- # For repos which contain root owned files, we need
- # to checkout with OSTree.RepoCheckoutMode.USER
- #
- # This will reassign uid/gid and also munge the
- # permission bits a bit.
- if user:
- options.mode = OSTree.RepoCheckoutMode.USER
-
- # Using AT_FDCWD value from fcntl.h
- #
- # This will be ignored if the passed path is an absolute path,
- # if path is a relative path then it will be appended to the
- # current working directory.
- AT_FDCWD = -100
- try:
- repo.checkout_at(options, AT_FDCWD, path, commit_)
- except GLib.GError as e:
- raise OSTreeError("Failed to checkout commit '{}': {}".format(commit_, e.message)) from e
-
-
-# exists():
-#
-# Checks wether a given commit or symbolic ref exists and
-# is locally cached in the specified repo.
-#
-# Args:
-# repo (OSTree.Repo): The repo
-# ref (str): A commit checksum or symbolic ref
-#
-# Returns:
-# (bool): Whether 'ref' is valid in 'repo'
-#
-def exists(repo, ref):
-
- # Get the commit checksum, this will:
- #
- # o Return a commit checksum if ref is a symbolic branch
- # o Return the same commit checksum if ref is a valid commit checksum
- # o Return None if the ostree repo doesnt know this ref.
- #
- ref = checksum(repo, ref)
- if ref is None:
- return False
-
- # If we do have a ref which the ostree knows about, this does
- # not mean we necessarily have the object locally (we may just
- # have some metadata about it, this can happen).
- #
- # Use has_object() only with a resolved valid commit checksum
- # to check if we actually have the object locally.
- _, has_object = repo.has_object(OSTree.ObjectType.COMMIT, ref, None)
- return has_object
-
-
-# checksum():
-#
-# Returns the commit checksum for a given symbolic ref,
-# which might be a branch or tag. If it is a branch,
-# the latest commit checksum for the given branch is returned.
-#
-# Args:
-# repo (OSTree.Repo): The repo
-# ref (str): The symbolic ref
-#
-# Returns:
-# (str): The commit checksum, or None if ref does not exist.
-#
-def checksum(repo, ref):
-
- _, checksum_ = repo.resolve_rev(ref, True)
- return checksum_
-
-
-# fetch()
-#
-# Fetch new objects from a remote, if configured
-#
-# Args:
-# repo (OSTree.Repo): The repo
-# remote (str): An optional remote name, defaults to 'origin'
-# ref (str): An optional ref to fetch, will reduce the amount of objects fetched
-# progress (callable): An optional progress callback
-#
-# Note that a commit checksum or a branch reference are both
-# valid options for the 'ref' parameter. Using the ref parameter
-# can save a lot of bandwidth but mirroring the full repo is
-# still possible.
-#
-def fetch(repo, remote="origin", ref=None, progress=None):
- # Fetch metadata of the repo from a remote
- #
- # cli example:
- # ostree --repo=repo pull --mirror freedesktop:runtime/org.freedesktop.Sdk/x86_64/1.4
- def progress_callback(info):
- status = async_progress.get_status()
- outstanding_fetches = async_progress.get_uint('outstanding-fetches')
- bytes_transferred = async_progress.get_uint64('bytes-transferred')
- fetched = async_progress.get_uint('fetched')
- requested = async_progress.get_uint('requested')
-
- if status:
- progress(0.0, status)
- elif outstanding_fetches > 0:
- formatted_bytes = GLib.format_size_full(bytes_transferred, 0)
- if requested == 0:
- percent = 0.0
- else:
- percent = (fetched * 1.0 / requested) * 100
-
- progress(percent,
- "Receiving objects: {:d}% ({:d}/{:d}) {}".format(int(percent), fetched,
- requested, formatted_bytes))
- else:
- progress(100.0, "Writing Objects")
-
- async_progress = None
- if progress is not None:
- async_progress = OSTree.AsyncProgress.new()
- async_progress.connect('changed', progress_callback)
-
- # FIXME: This hangs the process and ignores keyboard interrupt,
- # fix this using the Gio.Cancellable
- refs = None
- if ref is not None:
- refs = [ref]
-
- try:
- repo.pull(remote,
- refs,
- OSTree.RepoPullFlags.MIRROR,
- async_progress,
- None) # Gio.Cancellable
- except GLib.GError as e:
- if ref is not None:
- raise OSTreeError("Failed to fetch ref '{}' from '{}': {}".format(ref, remote, e.message)) from e
- else:
- raise OSTreeError("Failed to fetch from '{}': {}".format(remote, e.message)) from e
-
-
-# configure_remote():
-#
-# Ensures a remote is setup to a given url.
-#
-# Args:
-# repo (OSTree.Repo): The repo
-# remote (str): The name of the remote
-# url (str): The url of the remote ostree repo
-# key_url (str): The optional url of a GPG key (should be a local file)
-#
-def configure_remote(repo, remote, url, key_url=None):
- # Add a remote OSTree repo. If no key is given, we disable gpg checking.
- #
- # cli exmaple:
- # wget https://sdk.gnome.org/keys/gnome-sdk.gpg
- # ostree --repo=repo --gpg-import=gnome-sdk.gpg remote add freedesktop https://sdk.gnome.org/repo
- options = None # or GLib.Variant of type a{sv}
- if key_url is None:
- vd = VariantDict.new()
- vd.insert_value('gpg-verify', Variant.new_boolean(False))
- options = vd.end()
-
- try:
- repo.remote_change(None, # Optional OSTree.Sysroot
- OSTree.RepoRemoteChange.ADD_IF_NOT_EXISTS,
- remote, # Remote name
- url, # Remote url
- options, # Remote options
- None) # Optional Gio.Cancellable
- except GLib.GError as e:
- raise OSTreeError("Failed to configure remote '{}': {}".format(remote, e.message)) from e
-
- # Remote needs to exist before adding key
- if key_url is not None:
- try:
- gfile = Gio.File.new_for_uri(key_url)
- stream = gfile.read()
- repo.remote_gpg_import(remote, stream, None, 0, None)
- except GLib.GError as e:
- raise OSTreeError("Failed to add gpg key from url '{}': {}".format(key_url, e.message)) from e
diff --git a/buildstream/plugins/sources/ostree.py b/buildstream/plugins/sources/ostree.py
deleted file mode 100644
index 23115090f..000000000
--- a/buildstream/plugins/sources/ostree.py
+++ /dev/null
@@ -1,205 +0,0 @@
-#
-# Copyright (C) 2018 Codethink Limited
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-#
-# Authors:
-# Andrew Leeming <andrew.leeming@codethink.co.uk>
-# Tiago Gomes <tiago.gomes@codethink.co.uk>
-
-"""
-ostree - stage files from an OSTree repository
-==============================================
-
-**Usage:**
-
-.. code:: yaml
-
- # Specify the ostree source kind
- kind: ostree
-
- # Specify the repository url, using an alias defined
- # in your project configuration is recommended.
- url: upstream:runtime
-
- # Optionally specify a symbolic tracking branch or tag, this
- # will be used to update the 'ref' when refreshing the pipeline.
- track: runtime/x86_64/stable
-
- # Specify the commit checksum, this must be specified in order
- # to checkout sources and build, but can be automatically
- # updated if the 'track' attribute was specified.
- ref: d63cbb6fdc0bbdadc4a1b92284826a6d63a7ebcd
-
- # For signed ostree repositories, specify a local project relative
- # path to the public verifying GPG key for this remote.
- gpg-key: keys/runtime.gpg
-
-See :ref:`built-in functionality doumentation <core_source_builtins>` for
-details on common configuration options for sources.
-"""
-
-import os
-import shutil
-
-from buildstream import Source, SourceError, Consistency
-from buildstream import _ostree
-from buildstream import utils
-from buildstream._ostree import OSTreeError
-
-
-class OSTreeSource(Source):
- # pylint: disable=attribute-defined-outside-init
-
- def configure(self, node):
-
- self.node_validate(node, ['url', 'ref', 'track', 'gpg-key', *Source.COMMON_CONFIG_KEYS])
-
- self.original_url = self.node_get_member(node, str, 'url')
- self.url = self.translate_url(self.original_url)
- self.ref = self.node_get_member(node, str, 'ref', None)
- self.tracking = self.node_get_member(node, str, 'track', None)
- self.mirror = os.path.join(self.get_mirror_directory(),
- utils.url_directory_name(self.original_url))
-
- # At this point we now know if the source has a ref and/or a track.
- # If it is missing both then we will be unable to track or build.
- if self.ref is None and self.tracking is None:
- raise SourceError("{}: OSTree sources require a ref and/or track".format(self),
- reason="missing-track-and-ref")
-
- # (optional) Not all repos are signed. But if they are, get the gpg key
- self.gpg_key_path = None
- if self.node_get_member(node, str, 'gpg-key', None):
- self.gpg_key = self.node_get_project_path(node, 'gpg-key',
- check_is_file=True)
- self.gpg_key_path = os.path.join(self.get_project_directory(), self.gpg_key)
-
- # Our OSTree repo handle
- self.repo = None
-
- def preflight(self):
- pass
-
- def get_unique_key(self):
- return [self.original_url, self.ref]
-
- def load_ref(self, node):
- self.ref = self.node_get_member(node, str, 'ref', None)
-
- def get_ref(self):
- return self.ref
-
- def set_ref(self, ref, node):
- node['ref'] = self.ref = ref
-
- def track(self):
- # If self.tracking is not specified it's not an error, just silently return
- if not self.tracking:
- return None
-
- self.ensure()
- remote_name = self.ensure_remote(self.url)
- with self.timed_activity("Fetching tracking ref '{}' from origin: {}"
- .format(self.tracking, self.url)):
- try:
- _ostree.fetch(self.repo, remote=remote_name, ref=self.tracking, progress=self.progress)
- except OSTreeError as e:
- raise SourceError("{}: Failed to fetch tracking ref '{}' from origin {}\n\n{}"
- .format(self, self.tracking, self.url, e)) from e
-
- return _ostree.checksum(self.repo, self.tracking)
-
- def fetch(self):
- self.ensure()
- remote_name = self.ensure_remote(self.url)
- if not _ostree.exists(self.repo, self.ref):
- with self.timed_activity("Fetching remote ref: {} from origin: {}"
- .format(self.ref, self.url)):
- try:
- _ostree.fetch(self.repo, remote=remote_name, ref=self.ref, progress=self.progress)
- except OSTreeError as e:
- raise SourceError("{}: Failed to fetch ref '{}' from origin: {}\n\n{}"
- .format(self, self.ref, self.url, e)) from e
-
- def stage(self, directory):
- self.ensure()
-
- # Checkout self.ref into the specified directory
- with self.tempdir() as tmpdir:
- checkoutdir = os.path.join(tmpdir, 'checkout')
-
- with self.timed_activity("Staging ref: {} from origin: {}"
- .format(self.ref, self.url)):
- try:
- _ostree.checkout(self.repo, checkoutdir, self.ref, user=True)
- except OSTreeError as e:
- raise SourceError("{}: Failed to checkout ref '{}' from origin: {}\n\n{}"
- .format(self, self.ref, self.url, e)) from e
-
- # The target directory is guaranteed to exist, here we must move the
- # content of out checkout into the existing target directory.
- #
- # We may not be able to create the target directory as its parent
- # may be readonly, and the directory itself is often a mount point.
- #
- try:
- for entry in os.listdir(checkoutdir):
- source_path = os.path.join(checkoutdir, entry)
- shutil.move(source_path, directory)
- except (shutil.Error, OSError) as e:
- raise SourceError("{}: Failed to move ostree checkout {} from '{}' to '{}'\n\n{}"
- .format(self, self.url, tmpdir, directory, e)) from e
-
- def get_consistency(self):
- if self.ref is None:
- return Consistency.INCONSISTENT
-
- self.ensure()
- if _ostree.exists(self.repo, self.ref):
- return Consistency.CACHED
- return Consistency.RESOLVED
-
- #
- # Local helpers
- #
- def ensure(self):
- if not self.repo:
- self.status("Creating local mirror for {}".format(self.url))
-
- self.repo = _ostree.ensure(self.mirror, True)
-
- def ensure_remote(self, url):
- if self.original_url == self.url:
- remote_name = 'origin'
- else:
- remote_name = utils.url_directory_name(url)
-
- gpg_key = None
- if self.gpg_key_path:
- gpg_key = 'file://' + self.gpg_key_path
-
- try:
- _ostree.configure_remote(self.repo, remote_name, url, key_url=gpg_key)
- except OSTreeError as e:
- raise SourceError("{}: Failed to configure origin {}\n\n{}".format(self, self.url, e)) from e
- return remote_name
-
- def progress(self, percent, message):
- self.status(message)
-
-
-# Plugin entry point
-def setup():
- return OSTreeSource
diff --git a/doc/examples/flatpak-autotools/project.conf b/doc/examples/flatpak-autotools/project.conf
index 401dc561a..73197b9ec 100644
--- a/doc/examples/flatpak-autotools/project.conf
+++ b/doc/examples/flatpak-autotools/project.conf
@@ -13,3 +13,8 @@ options:
- x86-64
- x86-32
+plugins:
+ - origin: pip
+ package-name: bst-plugins-experimental
+ sources:
+ ostree: 0
diff --git a/doc/source/core_plugins.rst b/doc/source/core_plugins.rst
index 38ed56e29..b2defe489 100644
--- a/doc/source/core_plugins.rst
+++ b/doc/source/core_plugins.rst
@@ -55,7 +55,6 @@ Sources
sources/zip
sources/git
sources/bzr
- sources/ostree
sources/patch
sources/deb
sources/pip
diff --git a/tests/cachekey/cachekey.py b/tests/cachekey/cachekey.py
index 671bbb3a1..2e8c29805 100644
--- a/tests/cachekey/cachekey.py
+++ b/tests/cachekey/cachekey.py
@@ -47,7 +47,7 @@ import pytest
from buildstream.testing.runcli import cli # pylint: disable=unused-import
from buildstream.plugin import CoreWarnings
from buildstream import _yaml
-from tests.testutils.site import HAVE_BZR, HAVE_GIT, HAVE_OSTREE, IS_LINUX, MACHINE_ARCH
+from tests.testutils.site import HAVE_BZR, HAVE_GIT, IS_LINUX, MACHINE_ARCH
##############################################
@@ -155,7 +155,6 @@ DATA_DIR = os.path.join(
@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
@pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available")
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
-@pytest.mark.skipif(HAVE_OSTREE is False, reason="ostree is not available")
@pytest.mark.datafiles(DATA_DIR)
def test_cache_key(datafiles, cli):
project = str(datafiles)
diff --git a/tests/cachekey/project/sources/ostree1.bst b/tests/cachekey/project/sources/ostree1.bst
deleted file mode 100644
index 766fdecb0..000000000
--- a/tests/cachekey/project/sources/ostree1.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: import
-sources:
-- kind: ostree
- url: https://example.com/repo
- ref: ccc885b96749f9d1774c7fa0c3262a9a3694e2d2643d1f8d420f5d23adf5db48
- track: testing/x86_64
diff --git a/tests/cachekey/project/target.bst b/tests/cachekey/project/target.bst
index 8c5c12723..cabf3f7bf 100644
--- a/tests/cachekey/project/target.bst
+++ b/tests/cachekey/project/target.bst
@@ -10,7 +10,6 @@ depends:
- sources/git3.bst
- sources/local1.bst
- sources/local2.bst
-- sources/ostree1.bst
- sources/patch1.bst
- sources/patch2.bst
- sources/patch3.bst
diff --git a/tests/cachekey/project/target.expected b/tests/cachekey/project/target.expected
index c6214eb23..a56b64970 100644
--- a/tests/cachekey/project/target.expected
+++ b/tests/cachekey/project/target.expected
@@ -1 +1 @@
-faf895b1292cdcba9724c337c70442aedc350bf053b9df937da2515a8cb69e5a \ No newline at end of file
+6099e17150d3ab573569bfcdcdf19358ddbe0f2b597de5931a545559dd4ebc34
diff --git a/tests/conftest.py b/tests/conftest.py
index 31b86e301..138ae0745 100755
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -29,7 +29,6 @@ from buildstream.testing.integration import integration_cache # pylint: disable
from tests.testutils.repo.git import Git
from tests.testutils.repo.bzr import Bzr
-from tests.testutils.repo.ostree import OSTree
from tests.testutils.repo.tar import Tar
from tests.testutils.repo.zip import Zip
@@ -124,7 +123,6 @@ def ensure_platform_cache_is_clean():
#################################################
register_repo_kind('git', Git)
register_repo_kind('bzr', Bzr)
-register_repo_kind('ostree', OSTree)
register_repo_kind('tar', Tar)
register_repo_kind('zip', Zip)
diff --git a/tests/sources/ostree.py b/tests/sources/ostree.py
deleted file mode 100644
index aefad68fa..000000000
--- a/tests/sources/ostree.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright (C) 2018 Bloomberg Finance LP
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-#
-# Authors: William Salmon <will.salmon@codethink.co.uk>
-#
-
-# Pylint doesn't play well with fixtures and dependency injection from pytest
-# pylint: disable=redefined-outer-name
-
-import os
-import pytest
-
-from buildstream._exceptions import ErrorDomain
-from buildstream import _yaml
-from buildstream.testing import cli # pylint: disable=unused-import
-from buildstream.testing import create_repo
-
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'ostree',
-)
-
-
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
-def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles):
- project = str(datafiles)
-
- # Create the repo from 'repofiles' subdir
- repo = create_repo('ostree', str(tmpdir))
- repo.create(os.path.join(project, 'repofiles'))
-
- # Write out our test target
- ostreesource = repo.source_config(ref=None)
- ostreesource.pop('track')
- element = {
- 'kind': 'import',
- 'sources': [
- ostreesource
- ]
- }
-
- _yaml.dump(element, os.path.join(project, 'target.bst'))
-
- # Track will encounter an inconsistent submodule without any ref
- result = cli.run(project=project, args=['show', 'target.bst'])
- result.assert_main_error(ErrorDomain.SOURCE, "missing-track-and-ref")
- result.assert_task_error(None, None)
diff --git a/tests/testutils/repo/ostree.py b/tests/testutils/repo/ostree.py
deleted file mode 100644
index c43f39ef2..000000000
--- a/tests/testutils/repo/ostree.py
+++ /dev/null
@@ -1,48 +0,0 @@
-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()
diff --git a/tests/testutils/site.py b/tests/testutils/site.py
index 17c84cd8d..ef315efd6 100644
--- a/tests/testutils/site.py
+++ b/tests/testutils/site.py
@@ -32,7 +32,7 @@ except ProgramNotFoundError:
HAVE_OSTREE_CLI = False
try:
- from buildstream import _ostree # pylint: disable=unused-import
+ from bst_plugins_experimental.sources import _ostree # pylint: disable=unused-import
HAVE_OSTREE = True
except (ImportError, ValueError):
HAVE_OSTREE = False