buildstream-plugins 2.3.0.dev1__tar.gz → 2.5.0.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/NEWS +23 -0
  2. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/PKG-INFO +2 -2
  3. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/project.conf +7 -1
  4. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/requirements/test-requirements.txt +1 -0
  5. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/setup.py +5 -1
  6. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/__init__.py +1 -1
  7. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/elements/make.py +0 -5
  8. buildstream-plugins-2.5.0.dev0/src/buildstream_plugins/sourcemirrors/gitlab_lfs_mirror.py +89 -0
  9. buildstream-plugins-2.5.0.dev0/src/buildstream_plugins/sourcemirrors/simple_mirror.py +59 -0
  10. buildstream-plugins-2.5.0.dev0/src/buildstream_plugins/sources/__init__.py +0 -0
  11. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/sources/bzr.py +50 -3
  12. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/sources/cargo.py +30 -1
  13. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/sources/docker.py +85 -10
  14. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/sources/git.py +133 -5
  15. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/sources/patch.py +31 -2
  16. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/sources/pip.py +48 -2
  17. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins.egg-info/PKG-INFO +2 -2
  18. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins.egg-info/SOURCES.txt +3 -14
  19. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins.egg-info/entry_points.txt +4 -0
  20. buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages/buildstream/data/projectconfig.yaml +0 -184
  21. buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages/buildstream/data/userconfig.yaml +0 -148
  22. buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages/buildstream/plugins/elements/compose.yaml +0 -45
  23. buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages/buildstream/plugins/elements/filter.yaml +0 -45
  24. buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages/buildstream/plugins/elements/import.yaml +0 -26
  25. buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages/buildstream/plugins/elements/manual.yaml +0 -34
  26. buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages/buildstream/plugins/elements/script.yaml +0 -45
  27. buildstream_plugins-2.3.0.dev1/.tox/release/lib/python3.11/site-packages/markdown_it/port.yaml +0 -48
  28. buildstream_plugins-2.3.0.dev1/src/buildstream_plugins/elements/autotools.yaml +0 -143
  29. buildstream_plugins-2.3.0.dev1/src/buildstream_plugins/elements/cmake.yaml +0 -80
  30. buildstream_plugins-2.3.0.dev1/src/buildstream_plugins/elements/make.yaml +0 -60
  31. buildstream_plugins-2.3.0.dev1/src/buildstream_plugins/elements/meson.yaml +0 -88
  32. buildstream_plugins-2.3.0.dev1/src/buildstream_plugins/elements/pip.yaml +0 -46
  33. buildstream_plugins-2.3.0.dev1/src/buildstream_plugins/elements/setuptools.yaml +0 -59
  34. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/.asf.yaml +0 -0
  35. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/COMMITTERS.rst +0 -0
  36. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/LICENSE +0 -0
  37. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/MANIFEST.in +0 -0
  38. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/NOTICE +0 -0
  39. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/README.rst +0 -0
  40. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/pyproject.toml +0 -0
  41. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/requirements/mypy-requirements.txt +0 -0
  42. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/requirements/plugin-requirements.txt +0 -0
  43. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/setup.cfg +0 -0
  44. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/elements/__init__.py +0 -0
  45. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/elements/autotools.py +0 -0
  46. {buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages → buildstream-plugins-2.5.0.dev0/src}/buildstream_plugins/elements/autotools.yaml +0 -0
  47. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/elements/cmake.py +0 -0
  48. {buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages → buildstream-plugins-2.5.0.dev0/src}/buildstream_plugins/elements/cmake.yaml +0 -0
  49. {buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages → buildstream-plugins-2.5.0.dev0/src}/buildstream_plugins/elements/make.yaml +0 -0
  50. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/elements/meson.py +0 -0
  51. {buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages → buildstream-plugins-2.5.0.dev0/src}/buildstream_plugins/elements/meson.yaml +0 -0
  52. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/elements/pip.py +0 -0
  53. {buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages → buildstream-plugins-2.5.0.dev0/src}/buildstream_plugins/elements/pip.yaml +0 -0
  54. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/elements/setuptools.py +0 -0
  55. {buildstream_plugins-2.3.0.dev1/.tox/lint/lib/python3.11/site-packages → buildstream-plugins-2.5.0.dev0/src}/buildstream_plugins/elements/setuptools.yaml +0 -0
  56. {buildstream_plugins-2.3.0.dev1/src/buildstream_plugins/sources → buildstream-plugins-2.5.0.dev0/src/buildstream_plugins/sourcemirrors}/__init__.py +0 -0
  57. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins/sources/_utils.py +0 -0
  58. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins.egg-info/dependency_links.txt +0 -0
  59. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins.egg-info/not-zip-safe +0 -0
  60. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins.egg-info/requires.txt +0 -0
  61. {buildstream_plugins-2.3.0.dev1 → buildstream-plugins-2.5.0.dev0}/src/buildstream_plugins.egg-info/top_level.txt +0 -0
@@ -1,3 +1,26 @@
1
+ =========================
2
+ buildstream-plugins 2.5.0
3
+ =========================
4
+
5
+ o Drop support for python 3.8 and add support for python 3.13 (#84)
6
+
7
+ o Implement Source.collect_source_info() or SourceFetcher.get_source_info() on
8
+ all source plugins (#87)
9
+
10
+ =========================
11
+ buildstream-plugins 2.4.0
12
+ =========================
13
+
14
+ o docker: Support storing ref in project.refs (#66)
15
+
16
+ o simple_mirror: Added SourceMirror plugin supporting enhanced URL formatting (#80)
17
+
18
+ o gitlab_lfs_mirror: Added SourceMirror intended for use with GitLab LFS repos (#80)
19
+
20
+ o Enhanced testing and CI enhancements (#78)
21
+
22
+ o Resurrecting CI (#81)
23
+
1
24
  =========================
2
25
  buildstream-plugins 2.3.0
3
26
  =========================
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: buildstream-plugins
3
- Version: 2.3.0.dev1
3
+ Version: 2.5.0.dev0
4
4
  Summary: A collection of plugins for BuildStream.
5
5
  Home-page: https://buildstream.build
6
6
  Author: The Apache Software Foundation
@@ -15,11 +15,11 @@ Classifier: Intended Audience :: Developers
15
15
  Classifier: License :: OSI Approved :: Apache Software License
16
16
  Classifier: Operating System :: POSIX
17
17
  Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.8
19
18
  Classifier: Programming Language :: Python :: 3.9
20
19
  Classifier: Programming Language :: Python :: 3.10
21
20
  Classifier: Programming Language :: Python :: 3.11
22
21
  Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
23
  Classifier: Topic :: Software Development :: Build Tools
24
24
  Description-Content-Type: text/x-rst; charset=UTF-8
25
25
  License-File: LICENSE
@@ -17,7 +17,7 @@
17
17
  # that plugins can be loaded via junctions.
18
18
  #
19
19
  name: buildstream-plugins
20
- min-version: 2.0
20
+ min-version: 2.5
21
21
 
22
22
  plugins:
23
23
  - origin: local
@@ -39,3 +39,9 @@ plugins:
39
39
  - git
40
40
  - patch
41
41
  - pip
42
+
43
+ - origin: local
44
+ path: src/buildstream_plugins/sourcemirrors
45
+ source-mirrors:
46
+ - gitlab_lfs_mirror
47
+ - simple_mirror
@@ -8,4 +8,5 @@ pylint
8
8
  pycodestyle
9
9
  pyftpdlib
10
10
  responses
11
+ setuptools
11
12
  wheel
@@ -53,11 +53,11 @@ setup(
53
53
  "License :: OSI Approved :: Apache Software License",
54
54
  "Operating System :: POSIX",
55
55
  "Programming Language :: Python :: 3",
56
- "Programming Language :: Python :: 3.8",
57
56
  "Programming Language :: Python :: 3.9",
58
57
  "Programming Language :: Python :: 3.10",
59
58
  "Programming Language :: Python :: 3.11",
60
59
  "Programming Language :: Python :: 3.12",
60
+ "Programming Language :: Python :: 3.13",
61
61
  "Topic :: Software Development :: Build Tools",
62
62
  ],
63
63
  description="A collection of plugins for BuildStream.",
@@ -92,6 +92,10 @@ setup(
92
92
  "pip = buildstream_plugins.sources.pip",
93
93
  "zip = buildstream_plugins.sources.zip",
94
94
  ],
95
+ "buildstream.plugins.sourcemirrors": [
96
+ "gitlab_lfs_mirror = buildstream_plugins.sourcemirrors.gitlab_lfs_mirror",
97
+ "simple_mirror = buildstream_plugins.sourcemirrors.simple_mirror",
98
+ ],
95
99
  },
96
100
  extras_require={
97
101
  "cargo": ['tomli; python_version < "3.11"'],
@@ -15,4 +15,4 @@
15
15
  #
16
16
  # Remember to adjust this version number before tagging releases
17
17
  #
18
- __version__ = "2.3.0.dev1"
18
+ __version__ = "2.5.0.dev0"
@@ -26,11 +26,6 @@ This is a `BuildElement
26
26
  <https://docs.buildstream.build/master/buildstream.scriptelement.html#module-buildstream.scriptelement>`_
27
27
  implementation for using GNU make based build.
28
28
 
29
- .. note::
30
-
31
- The ``make`` element is available since `format version 9
32
- <https://docs.buildstream.build/master/format_project.html#project-format-version>`_
33
-
34
29
  Here is the default configuration for the ``make`` element in full:
35
30
 
36
31
  .. literalinclude:: ../../../src/buildstream_plugins/elements/make.yaml
@@ -0,0 +1,89 @@
1
+ #
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ """
15
+ gitlab_lfs_mirror - plugin for accessing files stored in git-lfs on GitLab
16
+ ==========================================================================
17
+
18
+ .. note::
19
+
20
+ The ``gitlab_lfs_mirror`` plugin is available *Since 2.4.0*
21
+
22
+ If you store files in a git-lfs repository on gitlab.com, you can access
23
+ them using a URL like
24
+
25
+ https://gitlab.com/path/to/repo/-/raw/master/path/to/file
26
+
27
+ which you can then use as a mirror for buildstream. However this only works for
28
+ public repositories. For internal (on self-hosted GitLab instances) and private
29
+ repositories, the above doesn't work since buildstream cannot authenticate with
30
+ the GitLab web UI.
31
+
32
+ This plugin solves this by going through the GitLab REST API. You need an
33
+ access token that access the Repository Files API (i.e. with read_api or
34
+ read_repository scope). As of this writing, the GitLab CI/CD job token doesn't
35
+ allow access to this API endpoint, so you need a dedicated access token.
36
+
37
+ **Usage:**
38
+
39
+ .. code:: yaml
40
+
41
+ - name: my-mirror
42
+ kind: gitlab_lfs_mirror
43
+ config:
44
+ url: https://gitlab.example.com/
45
+ project: mirrors/{alias}
46
+ ref: main # optional, defaults to master
47
+ aliases:
48
+ - my-alias
49
+ - another-alias
50
+ """
51
+
52
+ from posixpath import join
53
+ from urllib.parse import quote
54
+
55
+ from buildstream import SourceMirror
56
+
57
+
58
+ class GitlabLFSMirror(SourceMirror):
59
+ BST_MIN_VERSION = "2.2"
60
+
61
+ def configure(self, node):
62
+ node.validate_keys(["aliases", "url", "project", "ref"])
63
+ self.set_supported_aliases(node.get_str_list("aliases"))
64
+
65
+ self.url = node.get_str("url")
66
+ self.project = node.get_str("project")
67
+ self.ref = node.get_str("ref", "master")
68
+
69
+ def translate_url(self, *, alias, alias_url, source_url, extra_data):
70
+ project_id = quote(self.project.format(alias=alias), safe="")
71
+ filename = quote(source_url, safe="")
72
+
73
+ translated_url = join(
74
+ self.url,
75
+ "api/v4/projects",
76
+ project_id,
77
+ "repository/files",
78
+ filename,
79
+ f"raw?ref={self.ref}&lfs=true",
80
+ )
81
+
82
+ if extra_data is not None:
83
+ extra_data["http-auth"] = "bearer"
84
+
85
+ return translated_url
86
+
87
+
88
+ def setup():
89
+ return GitlabLFSMirror
@@ -0,0 +1,59 @@
1
+ #
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ """
15
+ simple_mirror - plugin for simplifying mirror definitions
16
+ =========================================================
17
+
18
+ .. note::
19
+
20
+ The ``simple_mirror`` plugin is available *Since 2.4.0*
21
+
22
+ **Usage:**
23
+
24
+ .. code:: yaml
25
+
26
+ - name: my-mirror
27
+ kind: simple_mirror
28
+ config:
29
+ url: https://example.com/mirrors/{alias}/
30
+ aliases:
31
+ - my-alias
32
+ - another-alias
33
+
34
+ This plugin simplifies defining mirrors for projects where the mirrors follow
35
+ a predictable URL format that only varies with the alias name.
36
+ """
37
+
38
+ from posixpath import join
39
+ from buildstream import SourceMirror
40
+
41
+
42
+ class SimpleMirror(SourceMirror):
43
+ BST_MIN_VERSION = "2.2"
44
+
45
+ def configure(self, node):
46
+ node.validate_keys(["url", "aliases"])
47
+ self.set_supported_aliases(node.get_str_list("aliases"))
48
+
49
+ self.url = node.get_str("url")
50
+
51
+ def translate_url(self, *, alias, alias_url, source_url, extra_data):
52
+ base_url = self.url.format(alias=alias)
53
+ translated_url = join(base_url, source_url)
54
+
55
+ return translated_url
56
+
57
+
58
+ def setup():
59
+ return SimpleMirror
@@ -53,9 +53,31 @@ bzr - stage files from a bazaar repository
53
53
  # revision number to the one on the tip of the branch specified in 'track'.
54
54
  ref: 6622
55
55
 
56
+ # Specify the version to be reported as the *guess_version* when reporting
57
+ # SourceInfo
58
+ #
59
+ # Since 2.5
60
+ #
61
+ version: 1.2
62
+
56
63
  See `built-in functionality doumentation
57
64
  <https://docs.buildstream.build/master/buildstream.source.html#core-source-builtins>`_ for
58
65
  details on common configuration options for sources.
66
+
67
+
68
+ Reporting `SourceInfo <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceInfo>`_
69
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70
+ The bzr source reports the URL of the bzr repository as the *url*.
71
+
72
+ Further, the bzr source reports the `SourceInfoMedium.BZR
73
+ <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceInfoMedium.BZR>`_
74
+ *medium* and the` `SourceVersionType.COMMIT
75
+ <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceVersionType.COMMIT>`_
76
+ *version_type*, for which it reports the bzr revision number as the *version*.
77
+
78
+ Since the bzr source does not have a way to know what the release version
79
+ corresponds to the revision number, the bzr source exposes the ``version`` configuration
80
+ attribute to allow explicit specification of the *guess_version*.
59
81
  """
60
82
 
61
83
  import os
@@ -66,26 +88,44 @@ from contextlib import contextmanager
66
88
  from buildstream import Source, SourceError
67
89
  from buildstream import utils
68
90
 
91
+ #
92
+ # Soft import of buildstream symbols only available in newer versions
93
+ #
94
+ # The BST_MIN_VERSION will provide a better user experience.
95
+ #
96
+ try:
97
+ from buildstream import SourceInfoMedium, SourceVersionType
98
+ except ImportError:
99
+ pass
100
+
69
101
 
70
102
  class BzrSource(Source):
71
103
  # pylint: disable=attribute-defined-outside-init
72
104
 
73
- BST_MIN_VERSION = "2.0"
105
+ BST_MIN_VERSION = "2.5"
74
106
 
75
107
  def configure(self, node):
76
- node.validate_keys(["url", "track", "ref", *Source.COMMON_CONFIG_KEYS])
108
+ node.validate_keys(["url", "track", "ref", "version", *Source.COMMON_CONFIG_KEYS])
77
109
 
78
110
  self.original_url = node.get_str("url")
79
111
  self.tracking = node.get_str("track")
80
112
  self.ref = node.get_str("ref", None)
81
113
  self.url = self.translate_url(self.original_url)
114
+ self.version = node.get_str("version", None)
82
115
 
83
116
  def preflight(self):
84
117
  # Check if bzr is installed, get the binary at the same time.
85
118
  self.host_bzr = utils.get_host_tool("bzr")
86
119
 
87
120
  def get_unique_key(self):
88
- return [self.original_url, self.tracking, self.ref]
121
+ unique_key = [self.original_url, self.tracking, self.ref]
122
+
123
+ # Backwards compatible method of supporting configuration
124
+ # attributes which affect SourceInfo generation.
125
+ if self.version is not None:
126
+ unique_key.append(self.version)
127
+
128
+ return unique_key
89
129
 
90
130
  def is_cached(self):
91
131
  with self._locked():
@@ -167,6 +207,13 @@ class BzrSource(Source):
167
207
  fail="Failed to switch workspace's parent branch to {}".format(url),
168
208
  )
169
209
 
210
+ def collect_source_info(self):
211
+ return [
212
+ self.create_source_info(
213
+ self.url, SourceInfoMedium.BAZAAR, SourceVersionType.COMMIT, self.ref, version_guess=self.version
214
+ )
215
+ ]
216
+
170
217
  # _locked()
171
218
  #
172
219
  # This context manager ensures exclusive access to the
@@ -61,6 +61,19 @@ Set the `ref` field to an empty list like so: `ref: []`, and then run
61
61
  See `built-in functionality doumentation
62
62
  <https://docs.buildstream.build/master/buildstream.source.html#core-source-builtins>`_ for
63
63
  details on common configuration options for sources.
64
+
65
+
66
+ Reporting `SourceInfo <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceInfo>`_
67
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68
+ The cargo source reports the URL of the archive crates as the *url* for each crate.
69
+
70
+ Further, the cargo source reports the `SourceInfoMedium.REMOTE_FILE
71
+ <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceInfoMedium.REMOTE_FILE>`_
72
+ *medium* and the `SourceVersionType.SHA256
73
+ <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceVersionType.SHA256>`_
74
+ *version_type*, for which it reports the checksum of the archive as the *version*.
75
+
76
+ The versions extracted from the Cargo.lock at tracking time are used to report the *guess_version*.
64
77
  """
65
78
 
66
79
  import json
@@ -79,6 +92,16 @@ from buildstream import utils
79
92
 
80
93
  from ._utils import download_file
81
94
 
95
+ #
96
+ # Soft import of buildstream symbols only available in newer versions
97
+ #
98
+ # The BST_MIN_VERSION will provide a better user experience.
99
+ #
100
+ try:
101
+ from buildstream import SourceInfoMedium, SourceVersionType
102
+ except:
103
+ pass
104
+
82
105
 
83
106
  # This automatically goes into .cargo/config
84
107
  #
@@ -133,6 +156,12 @@ class Crate(SourceFetcher):
133
156
  "File downloaded from {} has sha256sum '{}', not '{}'!".format(crate_url, sha256, self.sha)
134
157
  )
135
158
 
159
+ def get_source_info(self):
160
+ url, _ = self._get_url()
161
+ return self.cargo.create_source_info(
162
+ url, SourceInfoMedium.REMOTE_FILE, SourceVersionType.SHA256, self.sha, version_guess=self.version
163
+ )
164
+
136
165
  ########################################################
137
166
  # Helper APIs for the Cargo Source to use #
138
167
  ########################################################
@@ -334,7 +363,7 @@ class Crate(SourceFetcher):
334
363
 
335
364
 
336
365
  class CargoSource(Source):
337
- BST_MIN_VERSION = "2.0"
366
+ BST_MIN_VERSION = "2.5"
338
367
 
339
368
  # We need the Cargo.lock file to construct our ref at track time
340
369
  BST_REQUIRES_PREVIOUS_SOURCES_TRACK = True
@@ -57,6 +57,13 @@ docker - stage files from Docker images
57
57
  #
58
58
  # **Since**: 2.0.1
59
59
 
60
+ # Specify the version to be reported as the *guess_version* when reporting
61
+ # SourceInfo
62
+ #
63
+ # Since: 2.5
64
+ #
65
+ version: 1.2
66
+
60
67
  Note that Docker images may contain device nodes. BuildStream elements cannot
61
68
  contain device nodes so those will be dropped. Any regular files in the /dev
62
69
  directory will also be dropped.
@@ -64,6 +71,32 @@ directory will also be dropped.
64
71
  See `built-in functionality doumentation
65
72
  <https://docs.buildstream.build/master/buildstream.source.html#core-source-builtins>`_ for
66
73
  details on common configuration options for sources.
74
+
75
+
76
+ Reporting `SourceInfo <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceInfo>`_
77
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
+ The docker source reports the URL of the docker registry as the *url*.
79
+
80
+ Further, the docker source reports the `SourceInfoMedium.OCI_IMAGE
81
+ <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceInfoMedium.OCI_IMAGE>`_
82
+ *medium* and the `SourceVersionType.OCI_DIGEST
83
+ <https://docs.buildstream.build/master/buildstream.source.html#buildstream.source.SourceVersionType.OCI_DIGEST>`_
84
+ *version_type*, for which it reports the content digest of the docker image as the *version*.
85
+
86
+ Additionally, the docker source reports the docker image name through
87
+ the ``image-name`` key of the *extra_data*.
88
+
89
+ As such, after removing the scheme from the URL (i.e. remove ``https://``) the same docker
90
+ image can be obtained by calling:
91
+
92
+ .. code:: bash
93
+
94
+ docker pull <url-without-scheme>/<image-name>@<version>
95
+
96
+ Since the docker source does not have any way to guess what tag is associated
97
+ to the digest, or what release version that would mean; the docker source exposes
98
+ the ``version`` configuration attribute to allow explicit specification of the
99
+ *guess_version*.
67
100
  """
68
101
 
69
102
  import hashlib
@@ -84,6 +117,16 @@ from buildstream.utils import (
84
117
  move_atomic,
85
118
  )
86
119
 
120
+ #
121
+ # Soft import of buildstream symbols only available in newer versions
122
+ #
123
+ # The BST_MIN_VERSION will provide a better user experience.
124
+ #
125
+ try:
126
+ from buildstream import SourceInfoMedium, SourceVersionType
127
+ except ImportError:
128
+ pass
129
+
87
130
  _DOCKER_HUB_URL = "https://registry.hub.docker.com"
88
131
 
89
132
 
@@ -342,7 +385,7 @@ class ReadableTarInfo(tarfile.TarInfo):
342
385
  class DockerSource(Source):
343
386
  # pylint: disable=too-many-instance-attributes
344
387
 
345
- BST_MIN_VERSION = "2.0"
388
+ BST_MIN_VERSION = "2.5"
346
389
 
347
390
  # Docker identifies images by a content digest calculated from the image's
348
391
  # manifest. This corresponds well with the concept of a 'ref' in
@@ -365,7 +408,8 @@ class DockerSource(Source):
365
408
  # url is deprecated, but accept it as a valid key so that we can raise
366
409
  # a nicer warning.
367
410
  node.validate_keys(
368
- Source.COMMON_CONFIG_KEYS + ["architecture", "registry-url", "image", "os", "ref", "track", "url"]
411
+ Source.COMMON_CONFIG_KEYS
412
+ + ["architecture", "registry-url", "image", "os", "ref", "track", "url", "version"]
369
413
  )
370
414
 
371
415
  if "url" in node and ("image" in node or "registry-url" in node):
@@ -387,30 +431,39 @@ class DockerSource(Source):
387
431
  self.original_registry_url = node.get_str("registry-url", _DOCKER_HUB_URL)
388
432
  self.registry_url = self.translate_url(self.original_registry_url)
389
433
 
390
- if "ref" in node:
391
- self.digest = self._ref_to_digest(node.get_str("ref"))
392
- else:
393
- self.digest = None
394
434
  self.tag = node.get_str("track", "") or None
395
435
 
396
436
  self.architecture = node.get_str("architecture", "") or default_architecture()
397
437
  self.os = node.get_str("os", "") or default_os()
438
+ self.version = node.get_str("version", None)
398
439
 
399
- if not (self.digest or self.tag):
400
- raise SourceError("{}: Must specify either 'ref' or 'track' parameters".format(self))
440
+ self.digest = None
441
+ self.load_ref(node)
401
442
 
402
443
  self.client = DockerRegistryV2Client(self.registry_url)
403
444
 
404
445
  self.manifest = None
405
446
 
447
+ def load_ref(self, node):
448
+ ref = node.get_str("ref", None)
449
+ if ref is not None:
450
+ self.digest = self._ref_to_digest(ref)
451
+
406
452
  def preflight(self):
407
453
  return
408
454
 
409
455
  def get_unique_key(self):
410
456
  if self.url is not None:
411
- return [self.url, self.digest]
457
+ unique_key = [self.url, self.digest]
412
458
  else:
413
- return [self.original_registry_url, self.image, self.digest]
459
+ unique_key = [self.original_registry_url, self.image, self.digest]
460
+
461
+ # Backwards compatible method of supporting configuration
462
+ # attributes which affect SourceInfo generation.
463
+ if self.version is not None:
464
+ unique_key.append(self.version)
465
+
466
+ return unique_key
414
467
 
415
468
  def get_ref(self):
416
469
  return None if self.digest is None else self._digest_to_ref(self.digest)
@@ -582,6 +635,28 @@ class DockerSource(Source):
582
635
  except (OSError, SourceError, tarfile.TarError) as e:
583
636
  raise SourceError("{}: Error staging source: {}".format(self, e)) from e
584
637
 
638
+ def collect_source_info(self):
639
+
640
+ # If the image was configured with "url" only rather
641
+ # than "registry-url" and "image", then self.image
642
+ # at this point will have a leading forward slash "/".
643
+ #
644
+ # Lets just normalize that problem here, as changing
645
+ # the self.image itself can break cache keys.
646
+ #
647
+ image_name = self.image.lstrip("/")
648
+
649
+ return [
650
+ self.create_source_info(
651
+ self.registry_url,
652
+ SourceInfoMedium.OCI_IMAGE,
653
+ SourceVersionType.OCI_DIGEST,
654
+ self.digest,
655
+ version_guess=self.version,
656
+ extra_data={"image-name": image_name},
657
+ )
658
+ ]
659
+
585
660
  @staticmethod
586
661
  def _get_extract_and_remove_files(layer_tar_path):
587
662
  """Return the set of files to remove and extract for a given layer