[Notes] [Git][BuildStream/buildstream][tpollard/494] 17 commits: Merge branch 'chandan/bst-and-docker' into 'master'



Title: GitLab

Tom Pollard pushed to branch tpollard/494 at BuildStream / buildstream

Commits:

29 changed files:

Changes:

  • CONTRIBUTING.rst
    ... ... @@ -1147,7 +1147,7 @@ To actually regenerate the code::
    1147 1147
     Documenting
    
    1148 1148
     -----------
    
    1149 1149
     BuildStream starts out as a documented project from day one and uses
    
    1150
    -sphinx to document itself.
    
    1150
    +`sphinx <www.sphinx-doc.org>`_ to document itself.
    
    1151 1151
     
    
    1152 1152
     This section discusses formatting policies for editing files in the
    
    1153 1153
     ``doc/source`` directory, and describes the details of how the docs are
    
    ... ... @@ -1194,10 +1194,8 @@ The BuildStream documentation style is as follows:
    1194 1194
         the target, e.g.: ``:ref:`Link text <anchor_name>```.
    
    1195 1195
         Note that the "_" prefix is not used when referring to the target.
    
    1196 1196
     
    
    1197
    -Useful links:
    
    1198
    -
    
    1199
    -For further information, please see the `Sphinx Documentation
    
    1200
    -<http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_.
    
    1197
    +For further information about using the reStructuredText with sphinx, please see the
    
    1198
    +`Sphinx Documentation <http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_.
    
    1201 1199
     
    
    1202 1200
     
    
    1203 1201
     Building Docs
    
    ... ... @@ -1266,10 +1264,101 @@ the ``man/`` subdirectory, which will be automatically included
    1266 1264
     in the buildstream distribution.
    
    1267 1265
     
    
    1268 1266
     
    
    1269
    -Documentation Examples
    
    1270
    -~~~~~~~~~~~~~~~~~~~~~~
    
    1271
    -The examples section of the documentation contains a series of standalone
    
    1272
    -examples, here are the criteria for an example addition.
    
    1267
    +User guide
    
    1268
    +~~~~~~~~~~
    
    1269
    +The :ref:`user guide <using>` is comprised of free form documentation
    
    1270
    +in manually written ``.rst`` files and is split up into a few sections,
    
    1271
    +of main interest are the :ref:`tutorial <tutorial>` and the
    
    1272
    +:ref:`examples <examples>`.
    
    1273
    +
    
    1274
    +The distinction of the two categories of user guides is important to
    
    1275
    +understand too.
    
    1276
    +
    
    1277
    +* **Tutorial**
    
    1278
    +
    
    1279
    +  The tutorial is structured as a series of exercises which start with
    
    1280
    +  the most basic concepts and build upon the previous chapters in order
    
    1281
    +  to arrive at a basic understanding of how to create BuildStream projects.
    
    1282
    +
    
    1283
    +  This series of examples should be easy enough to complete in a matter
    
    1284
    +  of a few hours for a new user, and should provide just enough insight to
    
    1285
    +  get the user started in creating their own projects.
    
    1286
    +
    
    1287
    +  Going through the tutorial step by step should also result in the user
    
    1288
    +  becoming proficient enough with the reference manual to get by on their own.
    
    1289
    +
    
    1290
    +* **Examples**
    
    1291
    +
    
    1292
    +  These exist to demonstrate how to accomplish more advanced tasks which
    
    1293
    +  are not always obvious and discoverable.
    
    1294
    +
    
    1295
    +  Alternatively, these also demonstrate elegant and recommended ways of
    
    1296
    +  accomplishing some tasks which could be done in various ways.
    
    1297
    +
    
    1298
    +
    
    1299
    +Guidelines
    
    1300
    +''''''''''
    
    1301
    +Here are some general guidelines for adding new free form documentation
    
    1302
    +to the user guide.
    
    1303
    +
    
    1304
    +* **Focus on a single subject**
    
    1305
    +
    
    1306
    +  It is important to stay focused on a single subject and avoid getting
    
    1307
    +  into tangential material when creating a new entry, so that the articles
    
    1308
    +  remain concise and the user is not distracted by unrelated subject material.
    
    1309
    +
    
    1310
    +  A single tutorial chapter or example should not introduce any additional
    
    1311
    +  subject material than the material being added for the given example.
    
    1312
    +
    
    1313
    +* **Reuse existing sample project elements**
    
    1314
    +
    
    1315
    +  To help avoid distracting from the topic at hand, it is always preferable to
    
    1316
    +  reuse the same project sample material from other examples and only deviate
    
    1317
    +  slightly to demonstrate the new material, than to create completely new projects.
    
    1318
    +
    
    1319
    +  This helps us remain focused on a single topic at a time, and reduces the amount
    
    1320
    +  of unrelated material the reader needs to learn in order to digest the new
    
    1321
    +  example.
    
    1322
    +
    
    1323
    +* **Don't be redundant**
    
    1324
    +
    
    1325
    +  When something has already been explained in the tutorial or in another example,
    
    1326
    +  it is best to simply refer to the other user guide entry in a new example.
    
    1327
    +
    
    1328
    +  Always prefer to link to the tutorial if an explanation exists in the tutorial,
    
    1329
    +  rather than linking to another example, where possible.
    
    1330
    +
    
    1331
    +* **Link into the reference manual at every opportunity**
    
    1332
    +
    
    1333
    +  The format and plugin API is 100% documented at all times. Whenever discussing
    
    1334
    +  anything about the format or plugin API, always do so while providing a link
    
    1335
    +  into the more terse reference material.
    
    1336
    +
    
    1337
    +  We don't want users to have to search for the material themselves, and we also
    
    1338
    +  want the user to become proficient at navigating the reference material over
    
    1339
    +  time.
    
    1340
    +
    
    1341
    +* **Use concise terminology**
    
    1342
    +
    
    1343
    +  As developers, we tend to come up with code names for features we develop, and
    
    1344
    +  then end up documenting a new feature in an example.
    
    1345
    +
    
    1346
    +  Never use a code name or shorthand to refer to a feature in the user guide, instead
    
    1347
    +  always use fully qualified sentences outlining very explicitly what we are doing
    
    1348
    +  in the example, or what the example is for in the case of a title.
    
    1349
    +
    
    1350
    +  We need to be considerate that the audience of our user guide is probably a
    
    1351
    +  proficient developer or integrator, but has no idea what we might have decided
    
    1352
    +  to name a given activity.
    
    1353
    +
    
    1354
    +
    
    1355
    +Structure of an example
    
    1356
    +'''''''''''''''''''''''
    
    1357
    +The :ref:`tutorial <tutorial>` and the :ref:`examples <examples>` sections
    
    1358
    +of the documentation contain a series of sample projects, each chapter in
    
    1359
    +the tutoral, or standalone example uses a sample project.
    
    1360
    +
    
    1361
    +Here is the the structure for adding new examples and tutorial chapters.
    
    1273 1362
     
    
    1274 1363
     * The example has a ``${name}``.
    
    1275 1364
     
    
    ... ... @@ -1280,11 +1369,17 @@ examples, here are the criteria for an example addition.
    1280 1369
     * The example has a documentation component.
    
    1281 1370
     
    
    1282 1371
       * This is added at ``doc/source/examples/${name}.rst``
    
    1283
    -  * A reference to ``examples/${name}`` is added to the toctree in ``doc/source/examples.rst``
    
    1372
    +  * An entry for ``examples/${name}`` is added to the toctree in ``doc/source/using_examples.rst``
    
    1284 1373
       * This documentation discusses the project elements declared in the project and may
    
    1285 1374
         provide some BuildStream command examples.
    
    1286 1375
       * This documentation links out to the reference manual at every opportunity.
    
    1287 1376
     
    
    1377
    +  .. note::
    
    1378
    +
    
    1379
    +     In the case of a tutorial chapter, the ``.rst`` file is added in at
    
    1380
    +     ``doc/source/tutorial/${name}.rst`` and an entry for ``tutorial/${name}``
    
    1381
    +     is added to ``doc/source/using_tutorial.rst``.
    
    1382
    +
    
    1288 1383
     * The example has a CI test component.
    
    1289 1384
     
    
    1290 1385
       * This is an integration test added at ``tests/examples/${name}``.
    

  • README.rst
    ... ... @@ -19,7 +19,8 @@ About
    19 19
     
    
    20 20
     What is BuildStream?
    
    21 21
     ====================
    
    22
    -BuildStream is a Free Software tool for building/integrating software stacks.
    
    22
    +`BuildStream <https://buildstream.build>`_ is a Free Software tool for 
    
    23
    +building/integrating software stacks.
    
    23 24
     It takes inspiration, lessons and use-cases from various projects including
    
    24 25
     OBS, Reproducible Builds, Yocto, Baserock, Buildroot, Aboriginal, GNOME Continuous,
    
    25 26
     JHBuild, Flatpak Builder and Android repo.
    

  • buildstream/__init__.py
    ... ... @@ -28,9 +28,9 @@ if "_BST_COMPLETION" not in os.environ:
    28 28
     
    
    29 29
         from .utils import UtilError, ProgramNotFoundError
    
    30 30
         from .sandbox import Sandbox, SandboxFlags
    
    31
    +    from .types import Scope, Consistency
    
    31 32
         from .plugin import Plugin
    
    32
    -    from .source import Source, SourceError, Consistency, SourceFetcher
    
    33
    +    from .source import Source, SourceError, SourceFetcher
    
    33 34
         from .element import Element, ElementError
    
    34
    -    from .element_enums import Scope
    
    35 35
         from .buildelement import BuildElement
    
    36 36
         from .scriptelement import ScriptElement

  • buildstream/_artifactcache/artifactcache.py
    ... ... @@ -21,7 +21,7 @@ import os
    21 21
     import string
    
    22 22
     from collections import Mapping, namedtuple
    
    23 23
     
    
    24
    -from ..element_enums import _KeyStrength
    
    24
    +from ..types import _KeyStrength
    
    25 25
     from .._exceptions import ArtifactError, ImplError, LoadError, LoadErrorReason
    
    26 26
     from .._message import Message, MessageType
    
    27 27
     from .. import utils
    
    ... ... @@ -426,6 +426,22 @@ class ArtifactCache():
    426 426
             raise ImplError("Cache '{kind}' does not implement contains()"
    
    427 427
                             .format(kind=type(self).__name__))
    
    428 428
     
    
    429
    +    # contains_subdir_artifact():
    
    430
    +    #
    
    431
    +    # Check whether an artifact element contains a digest for a subdir
    
    432
    +    # which is populated in the cache, i.e non dangling.
    
    433
    +    #
    
    434
    +    # Args:
    
    435
    +    #     element (Element): The Element to check
    
    436
    +    #     key (str): The cache key to use
    
    437
    +    #     subdir (str): The subdir to check
    
    438
    +    #
    
    439
    +    # Returns: True if the subdir exists & is populated in the cache, False otherwise
    
    440
    +    #
    
    441
    +    def contains_subdir_artifact(self, element, key, subdir):
    
    442
    +        raise ImplError("Cache '{kind}' does not implement contains_subdir_artifact()"
    
    443
    +                        .format(kind=type(self).__name__))
    
    444
    +
    
    429 445
         # list_artifacts():
    
    430 446
         #
    
    431 447
         # List artifacts in this cache in LRU order.
    
    ... ... @@ -551,11 +567,12 @@ class ArtifactCache():
    551 567
         #     element (Element): The Element whose artifact is to be fetched
    
    552 568
         #     key (str): The cache key to use
    
    553 569
         #     progress (callable): The progress callback, if any
    
    570
    +    #     subdir (str): The optional specific subdir to pull
    
    554 571
         #
    
    555 572
         # Returns:
    
    556 573
         #   (bool): True if pull was successful, False if artifact was not available
    
    557 574
         #
    
    558
    -    def pull(self, element, key, *, progress=None):
    
    575
    +    def pull(self, element, key, *, progress=None, subdir=None, excluded_subdirs=None):
    
    559 576
             raise ImplError("Cache '{kind}' does not implement pull()"
    
    560 577
                             .format(kind=type(self).__name__))
    
    561 578
     
    

  • buildstream/_artifactcache/cascache.py
    ... ... @@ -92,6 +92,16 @@ class CASCache(ArtifactCache):
    92 92
             # This assumes that the repository doesn't have any dangling pointers
    
    93 93
             return os.path.exists(refpath)
    
    94 94
     
    
    95
    +    def contains_subdir_artifact(self, element, key, subdir):
    
    96
    +        tree = self.resolve_ref(self.get_artifact_fullname(element, key))
    
    97
    +
    
    98
    +        # This assumes that the subdir digest is present in the element tree
    
    99
    +        subdirdigest = self._get_subdir(tree, subdir)
    
    100
    +        objpath = self.objpath(subdirdigest)
    
    101
    +
    
    102
    +        # True if subdir content is cached or if empty as expected
    
    103
    +        return os.path.exists(objpath)
    
    104
    +
    
    95 105
         def extract(self, element, key):
    
    96 106
             ref = self.get_artifact_fullname(element, key)
    
    97 107
     
    
    ... ... @@ -228,7 +238,7 @@ class CASCache(ArtifactCache):
    228 238
                 remotes_for_project = self._remotes[element._get_project()]
    
    229 239
                 return any(remote.spec.push for remote in remotes_for_project)
    
    230 240
     
    
    231
    -    def pull(self, element, key, *, progress=None):
    
    241
    +    def pull(self, element, key, *, progress=None, subdir=None, excluded_subdirs=None):
    
    232 242
             ref = self.get_artifact_fullname(element, key)
    
    233 243
     
    
    234 244
             project = element._get_project()
    
    ... ... @@ -247,8 +257,14 @@ class CASCache(ArtifactCache):
    247 257
                     tree.hash = response.digest.hash
    
    248 258
                     tree.size_bytes = response.digest.size_bytes
    
    249 259
     
    
    250
    -                self._fetch_directory(remote, tree)
    
    260
    +                # Check if the element artifact is present, if so just fetch subdir
    
    261
    +                if subdir and os.path.exists(self.objpath(tree)):
    
    262
    +                    self._fetch_subdir(remote, tree, subdir)
    
    263
    +                else:
    
    264
    +                    # Fetch artifact, excluded_subdirs determined in pullqueue
    
    265
    +                    self._fetch_directory(remote, tree, excluded_subdirs=excluded_subdirs)
    
    251 266
     
    
    267
    +                # tree is the remote value, so is the same without or without dangling ref locally
    
    252 268
                     self.set_ref(ref, tree)
    
    253 269
     
    
    254 270
                     element.info("Pulled artifact {} <- {}".format(display_key, remote.spec.url))
    
    ... ... @@ -365,7 +381,10 @@ class CASCache(ArtifactCache):
    365 381
             Raises: ArtifactError if no push remotes are configured.
    
    366 382
             """
    
    367 383
     
    
    368
    -        push_remotes = [r for r in self._remotes[project] if r.spec.push]
    
    384
    +        if self._has_push_remotes:
    
    385
    +            push_remotes = [r for r in self._remotes[project] if r.spec.push]
    
    386
    +        else:
    
    387
    +            push_remotes = []
    
    369 388
     
    
    370 389
             if not push_remotes:
    
    371 390
                 raise ArtifactError("CASCache: push_directory was called, but no remote artifact " +
    
    ... ... @@ -668,8 +687,10 @@ class CASCache(ArtifactCache):
    668 687
                              stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
    
    669 688
     
    
    670 689
             for dirnode in directory.directories:
    
    671
    -            fullpath = os.path.join(dest, dirnode.name)
    
    672
    -            self._checkout(fullpath, dirnode.digest)
    
    690
    +            # Don't try to checkout a dangling ref
    
    691
    +            if os.path.exists(self.objpath(dirnode.digest)):
    
    692
    +                fullpath = os.path.join(dest, dirnode.name)
    
    693
    +                self._checkout(fullpath, dirnode.digest)
    
    673 694
     
    
    674 695
             for symlinknode in directory.symlinks:
    
    675 696
                 # symlink
    
    ... ... @@ -948,10 +969,12 @@ class CASCache(ArtifactCache):
    948 969
         #     remote (Remote): The remote to use.
    
    949 970
         #     dir_digest (Digest): Digest object for the directory to fetch.
    
    950 971
         #
    
    951
    -    def _fetch_directory(self, remote, dir_digest):
    
    972
    +    def _fetch_directory(self, remote, dir_digest, *, excluded_subdirs=None):
    
    952 973
             fetch_queue = [dir_digest]
    
    953 974
             fetch_next_queue = []
    
    954 975
             batch = _CASBatchRead(remote)
    
    976
    +        if not excluded_subdirs:
    
    977
    +            excluded_subdirs = []
    
    955 978
     
    
    956 979
             while len(fetch_queue) + len(fetch_next_queue) > 0:
    
    957 980
                 if len(fetch_queue) == 0:
    
    ... ... @@ -966,8 +989,9 @@ class CASCache(ArtifactCache):
    966 989
                     directory.ParseFromString(f.read())
    
    967 990
     
    
    968 991
                 for dirnode in directory.directories:
    
    969
    -                batch = self._fetch_directory_node(remote, dirnode.digest, batch,
    
    970
    -                                                   fetch_queue, fetch_next_queue, recursive=True)
    
    992
    +                if dirnode.name not in excluded_subdirs:
    
    993
    +                    batch = self._fetch_directory_node(remote, dirnode.digest, batch,
    
    994
    +                                                       fetch_queue, fetch_next_queue, recursive=True)
    
    971 995
     
    
    972 996
                 for filenode in directory.files:
    
    973 997
                     batch = self._fetch_directory_node(remote, filenode.digest, batch,
    
    ... ... @@ -976,6 +1000,10 @@ class CASCache(ArtifactCache):
    976 1000
             # Fetch final batch
    
    977 1001
             self._fetch_directory_batch(remote, batch, fetch_queue, fetch_next_queue)
    
    978 1002
     
    
    1003
    +    def _fetch_subdir(self, remote, tree, subdir):
    
    1004
    +        subdirdigest = self._get_subdir(tree, subdir)
    
    1005
    +        self._fetch_directory(remote, subdirdigest)
    
    1006
    +
    
    979 1007
         def _fetch_tree(self, remote, digest):
    
    980 1008
             # download but do not store the Tree object
    
    981 1009
             with tempfile.NamedTemporaryFile(dir=self.tmpdir) as out:
    

  • buildstream/_context.py
    ... ... @@ -110,6 +110,9 @@ class Context():
    110 110
             # Make sure the XDG vars are set in the environment before loading anything
    
    111 111
             self._init_xdg()
    
    112 112
     
    
    113
    +        # Whether or not to attempt to pull buildtrees globally
    
    114
    +        self.pullbuildtrees = False
    
    115
    +
    
    113 116
             # Private variables
    
    114 117
             self._cache_key = None
    
    115 118
             self._message_handler = None
    
    ... ... @@ -160,7 +163,7 @@ class Context():
    160 163
             _yaml.node_validate(defaults, [
    
    161 164
                 'sourcedir', 'builddir', 'artifactdir', 'logdir',
    
    162 165
                 'scheduler', 'artifacts', 'logging', 'projects',
    
    163
    -            'cache'
    
    166
    +            'cache', 'pullbuildtrees'
    
    164 167
             ])
    
    165 168
     
    
    166 169
             for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir']:
    
    ... ... @@ -185,6 +188,9 @@ class Context():
    185 188
             # Load artifact share configuration
    
    186 189
             self.artifact_cache_specs = ArtifactCache.specs_from_config_node(defaults)
    
    187 190
     
    
    191
    +        # Load pull buildtrees configuration
    
    192
    +        self.pullbuildtrees = _yaml.node_get(defaults, bool, 'pullbuildtrees', default_value='False')
    
    193
    +
    
    188 194
             # Load logging config
    
    189 195
             logging = _yaml.node_get(defaults, Mapping, 'logging')
    
    190 196
             _yaml.node_validate(logging, [
    

  • buildstream/_frontend/cli.py
    ... ... @@ -305,10 +305,12 @@ def init(app, project_name, format_version, element_path, force):
    305 305
                   help="Allow tracking to cross junction boundaries")
    
    306 306
     @click.option('--track-save', default=False, is_flag=True,
    
    307 307
                   help="Deprecated: This is ignored")
    
    308
    +@click.option('--pull-buildtrees', default=False, is_flag=True,
    
    309
    +              help="Pull buildtrees from a remote cache server")
    
    308 310
     @click.argument('elements', nargs=-1,
    
    309 311
                     type=click.Path(readable=False))
    
    310 312
     @click.pass_obj
    
    311
    -def build(app, elements, all_, track_, track_save, track_all, track_except, track_cross_junctions):
    
    313
    +def build(app, elements, all_, track_, track_save, track_all, track_except, track_cross_junctions, pull_buildtrees):
    
    312 314
         """Build elements in a pipeline"""
    
    313 315
     
    
    314 316
         if (track_except or track_cross_junctions) and not (track_ or track_all):
    
    ... ... @@ -327,7 +329,8 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac
    327 329
                              track_targets=track_,
    
    328 330
                              track_except=track_except,
    
    329 331
                              track_cross_junctions=track_cross_junctions,
    
    330
    -                         build_all=all_)
    
    332
    +                         build_all=all_,
    
    333
    +                         pull_buildtrees=pull_buildtrees)
    
    331 334
     
    
    332 335
     
    
    333 336
     ##################################################################
    
    ... ... @@ -429,10 +432,12 @@ def track(app, elements, deps, except_, cross_junctions):
    429 432
                   help='The dependency artifacts to pull (default: none)')
    
    430 433
     @click.option('--remote', '-r',
    
    431 434
                   help="The URL of the remote cache (defaults to the first configured cache)")
    
    435
    +@click.option('--pull-buildtrees', default=False, is_flag=True,
    
    436
    +              help="Pull buildtrees from a remote cache server")
    
    432 437
     @click.argument('elements', nargs=-1,
    
    433 438
                     type=click.Path(readable=False))
    
    434 439
     @click.pass_obj
    
    435
    -def pull(app, elements, deps, remote):
    
    440
    +def pull(app, elements, deps, remote, pull_buildtrees):
    
    436 441
         """Pull a built artifact from the configured remote artifact cache.
    
    437 442
     
    
    438 443
         By default the artifact will be pulled one of the configured caches
    
    ... ... @@ -446,7 +451,7 @@ def pull(app, elements, deps, remote):
    446 451
             all:   All dependencies
    
    447 452
         """
    
    448 453
         with app.initialized(session_name="Pull"):
    
    449
    -        app.stream.pull(elements, selection=deps, remote=remote)
    
    454
    +        app.stream.pull(elements, selection=deps, remote=remote, pull_buildtrees=pull_buildtrees)
    
    450 455
     
    
    451 456
     
    
    452 457
     ##################################################################
    

  • buildstream/_scheduler/queues/pullqueue.py
    ... ... @@ -32,9 +32,20 @@ class PullQueue(Queue):
    32 32
         complete_name = "Pulled"
    
    33 33
         resources = [ResourceType.DOWNLOAD, ResourceType.CACHE]
    
    34 34
     
    
    35
    +    def __init__(self, scheduler, buildtrees=False):
    
    36
    +        super().__init__(scheduler)
    
    37
    +
    
    38
    +        # Current default exclusions on pull
    
    39
    +        self._excluded_subdirs = ["buildtree"]
    
    40
    +        self._subdir = None
    
    41
    +        # If buildtrees are to be pulled, remove the value from exclusion list
    
    42
    +        if buildtrees:
    
    43
    +            self._subdir = "buildtree"
    
    44
    +            self._excluded_subdirs.remove(self._subdir)
    
    45
    +
    
    35 46
         def process(self, element):
    
    36 47
             # returns whether an artifact was downloaded or not
    
    37
    -        if not element._pull():
    
    48
    +        if not element._pull(subdir=self._subdir, excluded_subdirs=self._excluded_subdirs):
    
    38 49
                 raise SkipJob(self.action_name)
    
    39 50
     
    
    40 51
         def status(self, element):
    
    ... ... @@ -49,7 +60,7 @@ class PullQueue(Queue):
    49 60
             if not element._can_query_cache():
    
    50 61
                 return QueueStatus.WAIT
    
    51 62
     
    
    52
    -        if element._pull_pending():
    
    63
    +        if element._pull_pending(subdir=self._subdir):
    
    53 64
                 return QueueStatus.READY
    
    54 65
             else:
    
    55 66
                 return QueueStatus.SKIP
    

  • buildstream/_stream.py
    ... ... @@ -160,12 +160,14 @@ class Stream():
    160 160
         #    track_cross_junctions (bool): Whether tracking should cross junction boundaries
    
    161 161
         #    build_all (bool): Whether to build all elements, or only those
    
    162 162
         #                      which are required to build the target.
    
    163
    +    #    pull_buildtrees (bool): Whether to pull buildtrees from a remote cache server
    
    163 164
         #
    
    164 165
         def build(self, targets, *,
    
    165 166
                   track_targets=None,
    
    166 167
                   track_except=None,
    
    167 168
                   track_cross_junctions=False,
    
    168
    -              build_all=False):
    
    169
    +              build_all=False,
    
    170
    +              pull_buildtrees=False):
    
    169 171
     
    
    170 172
             if build_all:
    
    171 173
                 selection = PipelineSelection.ALL
    
    ... ... @@ -195,7 +197,10 @@ class Stream():
    195 197
                 self._add_queue(track_queue, track=True)
    
    196 198
     
    
    197 199
             if self._artifacts.has_fetch_remotes():
    
    198
    -            self._add_queue(PullQueue(self._scheduler))
    
    200
    +            # Query if pullbuildtrees has been set globally in user config
    
    201
    +            if self._context.pullbuildtrees:
    
    202
    +                pull_buildtrees = True
    
    203
    +            self._add_queue(PullQueue(self._scheduler, buildtrees=pull_buildtrees))
    
    199 204
     
    
    200 205
             self._add_queue(FetchQueue(self._scheduler, skip_cached=True))
    
    201 206
             self._add_queue(BuildQueue(self._scheduler))
    
    ... ... @@ -295,7 +300,8 @@ class Stream():
    295 300
         #
    
    296 301
         def pull(self, targets, *,
    
    297 302
                  selection=PipelineSelection.NONE,
    
    298
    -             remote=None):
    
    303
    +             remote=None,
    
    304
    +             pull_buildtrees=False):
    
    299 305
     
    
    300 306
             use_config = True
    
    301 307
             if remote:
    
    ... ... @@ -310,8 +316,12 @@ class Stream():
    310 316
             if not self._artifacts.has_fetch_remotes():
    
    311 317
                 raise StreamError("No artifact caches available for pulling artifacts")
    
    312 318
     
    
    319
    +        # Query if pullbuildtrees has been set globally in user config
    
    320
    +        if self._context.pullbuildtrees:
    
    321
    +            pull_buildtrees = True
    
    322
    +
    
    313 323
             self._pipeline.assert_consistent(elements)
    
    314
    -        self._add_queue(PullQueue(self._scheduler))
    
    324
    +        self._add_queue(PullQueue(self._scheduler, buildtrees=pull_buildtrees))
    
    315 325
             self._enqueue_plan(elements)
    
    316 326
             self._run()
    
    317 327
     
    

  • buildstream/element.py
    ... ... @@ -86,7 +86,7 @@ from ._variables import Variables
    86 86
     from ._versions import BST_CORE_ARTIFACT_VERSION
    
    87 87
     from ._exceptions import BstError, LoadError, LoadErrorReason, ImplError, ErrorDomain
    
    88 88
     from .utils import UtilError
    
    89
    -from . import Plugin, Consistency
    
    89
    +from . import Plugin, Consistency, Scope
    
    90 90
     from . import SandboxFlags
    
    91 91
     from . import utils
    
    92 92
     from . import _cachekey
    
    ... ... @@ -96,11 +96,11 @@ from ._platform import Platform
    96 96
     from .plugin import CoreWarnings
    
    97 97
     from .sandbox._config import SandboxConfig
    
    98 98
     from .sandbox._sandboxremote import SandboxRemote
    
    99
    +from .types import _KeyStrength
    
    99 100
     
    
    100 101
     from .storage.directory import Directory
    
    101 102
     from .storage._filebaseddirectory import FileBasedDirectory
    
    102 103
     from .storage.directory import VirtualDirectoryError
    
    103
    -from .element_enums import _KeyStrength, Scope
    
    104 104
     
    
    105 105
     
    
    106 106
     class ElementError(BstError):
    
    ... ... @@ -1692,18 +1692,26 @@ class Element(Plugin):
    1692 1692
     
    
    1693 1693
         # _pull_pending()
    
    1694 1694
         #
    
    1695
    -    # Check whether the artifact will be pulled.
    
    1695
    +    # Check whether the artifact will be pulled. If the pull operation is to
    
    1696
    +    # include a specific subdir of the element artifact (from cli or user conf)
    
    1697
    +    # then the local cache is queried for the subdirs existence.
    
    1698
    +    #
    
    1699
    +    # Args:
    
    1700
    +    #    subdir (str): Whether the pull has been invoked with a specific subdir set
    
    1696 1701
         #
    
    1697 1702
         # Returns:
    
    1698 1703
         #   (bool): Whether a pull operation is pending
    
    1699 1704
         #
    
    1700
    -    def _pull_pending(self):
    
    1705
    +    def _pull_pending(self, subdir=None):
    
    1701 1706
             if self._get_workspace():
    
    1702 1707
                 # Workspace builds are never pushed to artifact servers
    
    1703 1708
                 return False
    
    1704 1709
     
    
    1705
    -        if self.__strong_cached:
    
    1706
    -            # Artifact already in local cache
    
    1710
    +        if self.__strong_cached and subdir:
    
    1711
    +            # If we've specified a subdir, check if the subdir is cached locally
    
    1712
    +            if self.__artifacts.contains_subdir_artifact(self, self.__strict_cache_key, subdir):
    
    1713
    +                return False
    
    1714
    +        elif self.__strong_cached:
    
    1707 1715
                 return False
    
    1708 1716
     
    
    1709 1717
             # Pull is pending if artifact remote server available
    
    ... ... @@ -1725,11 +1733,10 @@ class Element(Plugin):
    1725 1733
     
    
    1726 1734
             self._update_state()
    
    1727 1735
     
    
    1728
    -    def _pull_strong(self, *, progress=None):
    
    1736
    +    def _pull_strong(self, *, progress=None, subdir=None, excluded_subdirs=None):
    
    1729 1737
             weak_key = self._get_cache_key(strength=_KeyStrength.WEAK)
    
    1730
    -
    
    1731 1738
             key = self.__strict_cache_key
    
    1732
    -        if not self.__artifacts.pull(self, key, progress=progress):
    
    1739
    +        if not self.__artifacts.pull(self, key, progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs):
    
    1733 1740
                 return False
    
    1734 1741
     
    
    1735 1742
             # update weak ref by pointing it to this newly fetched artifact
    
    ... ... @@ -1737,10 +1744,10 @@ class Element(Plugin):
    1737 1744
     
    
    1738 1745
             return True
    
    1739 1746
     
    
    1740
    -    def _pull_weak(self, *, progress=None):
    
    1747
    +    def _pull_weak(self, *, progress=None, subdir=None, excluded_subdirs=None):
    
    1741 1748
             weak_key = self._get_cache_key(strength=_KeyStrength.WEAK)
    
    1742
    -
    
    1743
    -        if not self.__artifacts.pull(self, weak_key, progress=progress):
    
    1749
    +        if not self.__artifacts.pull(self, weak_key, progress=progress, subdir=subdir,
    
    1750
    +                                     excluded_subdirs=excluded_subdirs):
    
    1744 1751
                 return False
    
    1745 1752
     
    
    1746 1753
             # extract strong cache key from this newly fetched artifact
    
    ... ... @@ -1758,17 +1765,17 @@ class Element(Plugin):
    1758 1765
         #
    
    1759 1766
         # Returns: True if the artifact has been downloaded, False otherwise
    
    1760 1767
         #
    
    1761
    -    def _pull(self):
    
    1768
    +    def _pull(self, subdir=None, excluded_subdirs=None):
    
    1762 1769
             context = self._get_context()
    
    1763 1770
     
    
    1764 1771
             def progress(percent, message):
    
    1765 1772
                 self.status(message)
    
    1766 1773
     
    
    1767 1774
             # Attempt to pull artifact without knowing whether it's available
    
    1768
    -        pulled = self._pull_strong(progress=progress)
    
    1775
    +        pulled = self._pull_strong(progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs)
    
    1769 1776
     
    
    1770 1777
             if not pulled and not self._cached() and not context.get_strict():
    
    1771
    -            pulled = self._pull_weak(progress=progress)
    
    1778
    +            pulled = self._pull_weak(progress=progress, subdir=subdir, excluded_subdirs=excluded_subdirs)
    
    1772 1779
     
    
    1773 1780
             if not pulled:
    
    1774 1781
                 return False
    
    ... ... @@ -1791,10 +1798,21 @@ class Element(Plugin):
    1791 1798
             if not self._cached():
    
    1792 1799
                 return True
    
    1793 1800
     
    
    1794
    -        # Do not push tained artifact
    
    1801
    +        # Do not push tainted artifact
    
    1795 1802
             if self.__get_tainted():
    
    1796 1803
                 return True
    
    1797 1804
     
    
    1805
    +        # Do not push elements that have a dangling buildtree artifact unless element type is
    
    1806
    +        # expected to have an empty buildtree directory
    
    1807
    +        if not self.__artifacts.contains_subdir_artifact(self, self.__strict_cache_key, 'buildtree'):
    
    1808
    +            return True
    
    1809
    +
    
    1810
    +        # strict_cache_key can't be relied on to be available when running in non strict mode
    
    1811
    +        context = self._get_context()
    
    1812
    +        if not context.get_strict():
    
    1813
    +            if not self.__artifacts.contains_subdir_artifact(self, self.__weak_cache_key, 'buildtree'):
    
    1814
    +                return True
    
    1815
    +
    
    1798 1816
             return False
    
    1799 1817
     
    
    1800 1818
         # _push():
    

  • buildstream/source.py
    ... ... @@ -145,35 +145,12 @@ import os
    145 145
     from collections import Mapping
    
    146 146
     from contextlib import contextmanager
    
    147 147
     
    
    148
    -from . import Plugin
    
    148
    +from . import Plugin, Consistency
    
    149 149
     from . import _yaml, utils
    
    150 150
     from ._exceptions import BstError, ImplError, ErrorDomain
    
    151 151
     from ._projectrefs import ProjectRefStorage
    
    152 152
     
    
    153 153
     
    
    154
    -class Consistency():
    
    155
    -    INCONSISTENT = 0
    
    156
    -    """Inconsistent
    
    157
    -
    
    158
    -    Inconsistent sources have no explicit reference set. They cannot
    
    159
    -    produce a cache key, be fetched or staged. They can only be tracked.
    
    160
    -    """
    
    161
    -
    
    162
    -    RESOLVED = 1
    
    163
    -    """Resolved
    
    164
    -
    
    165
    -    Resolved sources have a reference and can produce a cache key and
    
    166
    -    be fetched, however they cannot be staged.
    
    167
    -    """
    
    168
    -
    
    169
    -    CACHED = 2
    
    170
    -    """Cached
    
    171
    -
    
    172
    -    Cached sources have a reference which is present in the local
    
    173
    -    source cache. Only cached sources can be staged.
    
    174
    -    """
    
    175
    -
    
    176
    -
    
    177 154
     class SourceError(BstError):
    
    178 155
         """This exception should be raised by :class:`.Source` implementations
    
    179 156
         to report errors to the user.
    

  • buildstream/element_enums.pybuildstream/types.py
    ... ... @@ -19,31 +19,19 @@
    19 19
     #        Jim MacArthur <jim macarthur codethink co uk>
    
    20 20
     
    
    21 21
     """
    
    22
    -Element - Globally visible enumerations
    
    23
    -=======================================
    
    22
    +Foundation types
    
    23
    +================
    
    24 24
     
    
    25 25
     """
    
    26 26
     
    
    27 27
     from enum import Enum
    
    28 28
     
    
    29 29
     
    
    30
    -# _KeyStrength():
    
    31
    -#
    
    32
    -# Strength of cache key
    
    33
    -#
    
    34
    -class _KeyStrength(Enum):
    
    35
    -
    
    36
    -    # Includes strong cache keys of all build dependencies and their
    
    37
    -    # runtime dependencies.
    
    38
    -    STRONG = 1
    
    39
    -
    
    40
    -    # Includes names of direct build dependencies but does not include
    
    41
    -    # cache keys of dependencies.
    
    42
    -    WEAK = 2
    
    43
    -
    
    44
    -
    
    45 30
     class Scope(Enum):
    
    46
    -    """Types of scope for a given element"""
    
    31
    +    """Defines the scope of dependencies to include for a given element
    
    32
    +    when iterating over the dependency graph in APIs like
    
    33
    +    :func:`Element.dependencies() <buildstream.element.Element.dependencies>`
    
    34
    +    """
    
    47 35
     
    
    48 36
         ALL = 1
    
    49 37
         """All elements which the given element depends on, following
    
    ... ... @@ -59,3 +47,44 @@ class Scope(Enum):
    59 47
         """All elements required for running the element. Including the element
    
    60 48
         itself.
    
    61 49
         """
    
    50
    +
    
    51
    +
    
    52
    +class Consistency():
    
    53
    +    """Defines the various consistency states of a :class:`.Source`.
    
    54
    +    """
    
    55
    +
    
    56
    +    INCONSISTENT = 0
    
    57
    +    """Inconsistent
    
    58
    +
    
    59
    +    Inconsistent sources have no explicit reference set. They cannot
    
    60
    +    produce a cache key, be fetched or staged. They can only be tracked.
    
    61
    +    """
    
    62
    +
    
    63
    +    RESOLVED = 1
    
    64
    +    """Resolved
    
    65
    +
    
    66
    +    Resolved sources have a reference and can produce a cache key and
    
    67
    +    be fetched, however they cannot be staged.
    
    68
    +    """
    
    69
    +
    
    70
    +    CACHED = 2
    
    71
    +    """Cached
    
    72
    +
    
    73
    +    Cached sources have a reference which is present in the local
    
    74
    +    source cache. Only cached sources can be staged.
    
    75
    +    """
    
    76
    +
    
    77
    +
    
    78
    +# _KeyStrength():
    
    79
    +#
    
    80
    +# Strength of cache key
    
    81
    +#
    
    82
    +class _KeyStrength(Enum):
    
    83
    +
    
    84
    +    # Includes strong cache keys of all build dependencies and their
    
    85
    +    # runtime dependencies.
    
    86
    +    STRONG = 1
    
    87
    +
    
    88
    +    # Includes names of direct build dependencies but does not include
    
    89
    +    # cache keys of dependencies.
    
    90
    +    WEAK = 2

  • doc/source/additional_docker.rst
    ... ... @@ -4,19 +4,18 @@
    4 4
     
    
    5 5
     BuildStream and Docker
    
    6 6
     ======================
    
    7
    -
    
    8 7
     BuildStream integrates with Docker in multiple ways. Here are some ways in
    
    9 8
     which these integrations work.
    
    10 9
     
    
    10
    +
    
    11 11
     Run BuildStream inside Docker
    
    12 12
     -----------------------------
    
    13
    +Refer to the `BuildStream inside Docker <https://buildstream.build/docker_install.html>`_
    
    14
    +documentation for instructions on how to run BuildStream as a Docker container.
    
    13 15
     
    
    14
    -Refer to the :ref:`BuildStream inside Docker <docker>` documentation for
    
    15
    -instructions on how to run BuildStream as a Docker container.
    
    16 16
     
    
    17 17
     Generate Docker images
    
    18 18
     ----------------------
    
    19
    -
    
    20 19
     The
    
    21 20
     `bst-docker-import script <https://gitlab.com/BuildStream/buildstream/blob/master/contrib/bst-docker-import>`_
    
    22 21
     can be used to generate a Docker image from built artifacts.
    

  • doc/source/core_framework.rst
    ... ... @@ -12,6 +12,7 @@ useful for working on BuildStream itself.
    12 12
     .. toctree::
    
    13 13
        :maxdepth: 1
    
    14 14
     
    
    15
    +   buildstream.types
    
    15 16
        buildstream.plugin
    
    16 17
        buildstream.source
    
    17 18
        buildstream.element
    

  • doc/source/index.rst
    ... ... @@ -13,20 +13,13 @@ They begin with a basic introduction to BuildStream, background
    13 13
     information on basic concepts, and a guide to the BuildStream command line interface.
    
    14 14
     Later sections provide detailed information on BuildStream internals.
    
    15 15
     
    
    16
    -
    
    17 16
     .. toctree::
    
    18 17
        :maxdepth: 1
    
    19 18
     
    
    20 19
        main_about
    
    21
    -   main_install
    
    22 20
        main_using
    
    23 21
        main_core
    
    24 22
        CONTRIBUTING
    
    25 23
     
    
    26
    -
    
    27
    -Resources
    
    28
    ----------
    
    29
    -* GitLab repository: https://gitlab.com/BuildStream/buildstream
    
    30
    -* Bug Tracking: https://gitlab.com/BuildStream/buildstream/issues
    
    31
    -* Mailing list: https://mail.gnome.org/mailman/listinfo/buildstream-list
    
    32
    -* IRC Channel: irc://irc.gnome.org/#buildstream
    24
    +For any other information, including `how to install BuildStream <https://buildstream.build/install.html>`_,
    
    25
    +refer to `the BuildStream website <https://buildstream.build>`_.

  • doc/source/install_docker.rst deleted
    1
    -
    
    2
    -
    
    3
    -.. _docker:
    
    4
    -
    
    5
    -BuildStream inside Docker
    
    6
    --------------------------
    
    7
    -If your system cannot provide the base system requirements for BuildStream, then it is possible to run buildstream within a Docker image.
    
    8
    -
    
    9
    -The BuildStream project provides
    
    10
    -`Docker images <https://hub.docker.com/r/buildstream/buildstream-fedora>`_
    
    11
    -containing BuildStream and its dependencies.
    
    12
    -This gives you an easy way to get started using BuildStream on any Unix-like
    
    13
    -platform where Docker is available, including Mac OS X.
    
    14
    -
    
    15
    -We recommend using the
    
    16
    -`bst-here wrapper script <https://gitlab.com/BuildStream/buildstream/blob/master/contrib/bst-here>`_
    
    17
    -which automates the necessary container setup. You can download it and make
    
    18
    -it executable like this:
    
    19
    -
    
    20
    -.. code:: bash
    
    21
    -
    
    22
    -  mkdir -p ~/.local/bin
    
    23
    -  curl --get https://gitlab.com/BuildStream/buildstream/raw/master/contrib/bst-here > ~/.local/bin/bst-here
    
    24
    -  chmod +x ~/.local/bin/bst-here
    
    25
    -
    
    26
    -Check if ``~/.local/bin`` appears in your PATH environment variable -- if it
    
    27
    -doesn't, you should
    
    28
    -`edit your ~/.profile so that it does <https://stackoverflow.com/questions/14637979/>`_.
    
    29
    -
    
    30
    -Once the script is available in your PATH, you can run ``bst-here`` to open a
    
    31
    -shell session inside a new container based off the latest version of the
    
    32
    -buildstream-fedora Docker image. The current working directory will be mounted
    
    33
    -inside the container at ``/src``.
    
    34
    -
    
    35
    -You can also run individual BuildStream commands as ``bst-here COMMAND``. For
    
    36
    -example: ``bst-here show systems/my-system.bst``. Note that BuildStream won't
    
    37
    -be able to integrate with Bash tab-completion if you invoke it in this way.
    
    38
    -
    
    39
    -Two Docker volumes are set up by the ``bst-here`` script:
    
    40
    -
    
    41
    - * ``buildstream-cache --`` mounted at ``~/.cache/buildstream``
    
    42
    - * ``buildstream-config --`` mounted at ``~/.config/``
    
    43
    -
    
    44
    -These are necessary so that your BuildStream cache and configuration files
    
    45
    -persist between invocations of ``bst-here``.

  • doc/source/install_linux_distro.rst deleted
    1
    -
    
    2
    -
    
    3
    -.. _install_linux_distro:
    
    4
    -
    
    5
    -Installing from distro packages
    
    6
    -===============================
    
    7
    -BuildStream is available on some linux distributions, here are
    
    8
    -some install instructions for the linux distributions which
    
    9
    -have packaged BuildStream.
    
    10
    -
    
    11
    -
    
    12
    -Arch Linux
    
    13
    -----------
    
    14
    -Packages for Arch exist in `AUR <https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages>`_.
    
    15
    -Two different package versions are available:
    
    16
    -
    
    17
    -* Latest release: `buildstream <https://aur.archlinux.org/packages/buildstream>`_
    
    18
    -* Latest development snapshot: `buildstream-git <https://aur.archlinux.org/packages/buildstream-git>`_
    
    19
    -
    
    20
    -
    
    21
    -Fedora
    
    22
    -------
    
    23
    -BuildStream is not yet in the official Fedora repositories, but you can
    
    24
    -install it from a Copr::
    
    25
    -
    
    26
    -  sudo dnf copr enable bochecha/buildstream
    
    27
    -  sudo dnf install buildstream
    
    28
    -
    
    29
    -Optionally, install the ``buildstream-docs`` package to have the BuildStream
    
    30
    -documentation in Devhelp or GNOME Builder.

  • doc/source/install_source.rst deleted
    1
    -
    
    2
    -
    
    3
    -Installing from source
    
    4
    -======================
    
    5
    -Until BuildStream is available in :ref:`your distro <install_linux_distro>`, you will
    
    6
    -need to install it yourself from source.
    
    7
    -
    
    8
    -
    
    9
    -Installing dependencies
    
    10
    ------------------------
    
    11
    -Before installing BuildStream from source, it is necessary to first install
    
    12
    -the system dependencies. Below are some linux distribution specific instructions
    
    13
    -for installing these dependencies.
    
    14
    -
    
    15
    -BuildStream requires the following base system requirements:
    
    16
    -
    
    17
    -* python3 >= 3.5
    
    18
    -* bubblewrap >= 0.1.2
    
    19
    -* fuse2
    
    20
    -
    
    21
    -BuildStream also depends on the host tools for the :mod:`Source <buildstream.source>` plugins.
    
    22
    -Refer to the respective :ref:`source plugin <plugins_sources>` documentation for host tool
    
    23
    -requirements of specific plugins.
    
    24
    -
    
    25
    -The default plugins with extra host dependencies are:
    
    26
    -
    
    27
    -* bzr
    
    28
    -* deb
    
    29
    -* git
    
    30
    -* ostree
    
    31
    -* patch
    
    32
    -* pip
    
    33
    -* tar
    
    34
    -
    
    35
    -If you intend to push built artifacts to a remote artifact server,
    
    36
    -which requires special permissions, you will also need:
    
    37
    -
    
    38
    -* ssh
    
    39
    -
    
    40
    -
    
    41
    -Arch Linux
    
    42
    -~~~~~~~~~~
    
    43
    -Install the dependencies with::
    
    44
    -
    
    45
    -  sudo pacman -S \
    
    46
    -      python fuse2 bubblewrap \
    
    47
    -      python-pip
    
    48
    -
    
    49
    -For the default plugins::
    
    50
    -
    
    51
    -  sudo pacman -S \
    
    52
    -      bzr git lzip ostree patch python-gobject
    
    53
    -
    
    54
    -
    
    55
    -The package *python-arpy* is required by the deb source plugin. This is not
    
    56
    -obtainable via `pacman`, you must get *python-arpy* from AUR:
    
    57
    -https://aur.archlinux.org/packages/python-arpy/
    
    58
    -
    
    59
    -To install::
    
    60
    -
    
    61
    -  wget https://aur.archlinux.org/cgit/aur.git/snapshot/python-arpy.tar.gz
    
    62
    -  tar -xvf python-arpy.tar.gz
    
    63
    -  cd python-arpy
    
    64
    -  makepkg -si
    
    65
    -
    
    66
    -
    
    67
    -Debian
    
    68
    -~~~~~~
    
    69
    -Install the dependencies with::
    
    70
    -
    
    71
    -  sudo apt-get install \
    
    72
    -      python3 fuse bubblewrap \
    
    73
    -      python3-pip python3-dev
    
    74
    -
    
    75
    -For the default plugins:
    
    76
    -
    
    77
    -
    
    78
    -Stretch
    
    79
    -+++++++
    
    80
    -With stretch, you first need to ensure that you have the backports repository
    
    81
    -setup as described `here <https://backports.debian.org/Instructions/>`_
    
    82
    -
    
    83
    -By adding the following line to your sources.list::
    
    84
    -
    
    85
    -  deb http://deb.debian.org/debian stretch-backports main
    
    86
    -
    
    87
    -And then running::
    
    88
    -
    
    89
    -  sudo apt update
    
    90
    -
    
    91
    -At this point you should be able to get the system requirements for the default plugins with::
    
    92
    -
    
    93
    -  sudo apt install \
    
    94
    -      bzr git lzip patch python3-arpy python3-gi
    
    95
    -  sudo apt install -t stretch-backports \
    
    96
    -      gir1.2-ostree-1.0 ostree
    
    97
    -
    
    98
    -
    
    99
    -Buster or Sid
    
    100
    -+++++++++++++
    
    101
    -For debian unstable or testing, only the following line should be enough
    
    102
    -to get the system requirements for the default plugins installed::
    
    103
    -
    
    104
    -  sudo apt-get install \
    
    105
    -      lzip gir1.2-ostree-1.0 git bzr ostree patch python3-arpy python3-gi
    
    106
    -
    
    107
    -
    
    108
    -Fedora
    
    109
    -~~~~~~
    
    110
    -For recent fedora systems, the following line should get you the system
    
    111
    -requirements you need::
    
    112
    -
    
    113
    -  dnf install -y \
    
    114
    -      python3 fuse bubblewrap \
    
    115
    -      python3-pip python3-devel
    
    116
    -
    
    117
    -For the default plugins::
    
    118
    -
    
    119
    -  dnf install -y \
    
    120
    -      bzr git lzip patch ostree python3-gobject
    
    121
    -  pip3 install --user arpy
    
    122
    -
    
    123
    -
    
    124
    -Ubuntu
    
    125
    -~~~~~~
    
    126
    -
    
    127
    -
    
    128
    -Ubuntu 18.04 LTS or later
    
    129
    -+++++++++++++++++++++++++
    
    130
    -Install the dependencies with::
    
    131
    -
    
    132
    -  sudo apt install \
    
    133
    -      python3 fuse bubblewrap \
    
    134
    -      python3-pip python3-dev
    
    135
    -
    
    136
    -For the default plugins::
    
    137
    -
    
    138
    -  sudo apt install \
    
    139
    -      bzr gir1.2-ostree-1.0 git lzip ostree patch python3-arpy python3-gi
    
    140
    -
    
    141
    -
    
    142
    -Ubuntu 16.04 LTS
    
    143
    -++++++++++++++++
    
    144
    -On Ubuntu 16.04, neither `bubblewrap <https://github.com/projectatomic/bubblewrap/>`_
    
    145
    -or `ostree <https://github.com/ostreedev/ostree>`_ are available in the official repositories.
    
    146
    -You will need to install them in whichever way you see fit. Refer the the upstream documentation
    
    147
    -for advice on this.
    
    148
    -
    
    149
    -
    
    150
    -Installing
    
    151
    -----------
    
    152
    -Once you have the base system dependencies, you can install the BuildStream
    
    153
    -python package as a regular user.
    
    154
    -
    
    155
    -
    
    156
    -Installing from PyPI (recommended)
    
    157
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    158
    -Since we only ever publish :ref:`release versions <install_semantic_versioning>` on
    
    159
    -PyPI, it is currently recommended to use this installation path. This will
    
    160
    -ensure that you always have the latest recommended version of BuildStream that
    
    161
    -we recommend.
    
    162
    -
    
    163
    -To install from PyPI, you will additionally require:
    
    164
    -
    
    165
    -* pip for python3 (only required for setup)
    
    166
    -* Python 3 development libraries and headers
    
    167
    -
    
    168
    -Simply run the following command::
    
    169
    -
    
    170
    -  pip3 install --user BuildStream
    
    171
    -
    
    172
    -This will install latest stable version of BuildStream and its pure python
    
    173
    -dependencies into your user's homedir in ``~/.local``.
    
    174
    -
    
    175
    -Keep following the instructions below to ensure that the ``bst``
    
    176
    -command is in your ``PATH`` and to enable bash completions for it.
    
    177
    -
    
    178
    -.. note::
    
    179
    -
    
    180
    -  If you want a specific version of BuildStream, you can install it using
    
    181
    -  ``pip install --user BuildStream==<version-number>``
    
    182
    -
    
    183
    -
    
    184
    -Upgrading from PyPI
    
    185
    -+++++++++++++++++++
    
    186
    -Once you have already installed BuildStream from PyPI, you can later update
    
    187
    -to the latest recommended version like so::
    
    188
    -
    
    189
    -  pip install --user --upgrade BuildStream
    
    190
    -
    
    191
    -
    
    192
    -.. _install_git_checkout:
    
    193
    -
    
    194
    -Installing from a git checkout
    
    195
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    196
    -To install directly from the `git repository <https://gitlab.com/BuildStream/buildstream.git>`_
    
    197
    -using python's ``pip`` package manager, you will additionally require:
    
    198
    -
    
    199
    -* pip for python3 (only required for setup)
    
    200
    -* Python 3 development libraries and headers
    
    201
    -* git (to checkout BuildStream)
    
    202
    -
    
    203
    -Before installing, please check the existing tags in the git repository
    
    204
    -and determine which version you want to install, and whether you want
    
    205
    -to install an official release version (recommended), or a development snapshot
    
    206
    -to help us out testing the bleeding edge of development. Follow the
    
    207
    -:ref:`semantic versioning guide <install_semantic_versioning>` to determine
    
    208
    -which tag you intend to install.
    
    209
    -
    
    210
    -Run the following commands::
    
    211
    -
    
    212
    -  git clone https://gitlab.com/BuildStream/buildstream.git
    
    213
    -  cd buildstream
    
    214
    -  git checkout <desired release tag>
    
    215
    -  pip3 install --user -e .
    
    216
    -
    
    217
    -This will install buildstream's pure python dependencies into
    
    218
    -your user's homedir in ``~/.local`` and will run BuildStream directly
    
    219
    -from the git checkout directory.
    
    220
    -
    
    221
    -Keep following the instructions below to ensure that the ``bst``
    
    222
    -command is in your ``PATH`` and to enable bash completions for it.
    
    223
    -
    
    224
    -.. note::
    
    225
    -
    
    226
    -   We recommend the ``-e`` option because you can upgrade your
    
    227
    -   installation by simply updating the checked out git repository.
    
    228
    -
    
    229
    -   If you want a full installation that is not linked to your
    
    230
    -   git checkout, just omit the ``-e`` option from the above commands.
    
    231
    -
    
    232
    -
    
    233
    -Upgrading from a git checkout
    
    234
    -+++++++++++++++++++++++++++++
    
    235
    -If you installed BuildStream from a local git checkout using ``-e`` option, all
    
    236
    -you need to do to upgrade BuildStream is to update your local git checkout::
    
    237
    -
    
    238
    -  cd /path/to/buildstream
    
    239
    -  git pull --rebase
    
    240
    -
    
    241
    -If you did not specify the ``-e`` option at install time or the dependancies
    
    242
    -have changed, you will need to cleanly reinstall BuildStream::
    
    243
    -
    
    244
    -  pip3 uninstall buildstream
    
    245
    -  cd /path/to/buildstream
    
    246
    -  git pull --rebase
    
    247
    -  pip3 install --user .
    
    248
    -
    
    249
    -.. note::
    
    250
    -
    
    251
    -   If BuildStream has added any dependencies since the last upgrade,
    
    252
    -   you will need to uninstall and reinstall to ensure those dependencies
    
    253
    -   are met, regardless of whether you have used the ``-e`` option at
    
    254
    -   install time.
    
    255
    -
    
    256
    -
    
    257
    -Post install setup
    
    258
    -------------------
    
    259
    -After having installed from source using any of the above methods, some
    
    260
    -setup will be required to use BuildStream.
    
    261
    -
    
    262
    -
    
    263
    -Adjust PATH
    
    264
    -~~~~~~~~~~~
    
    265
    -Since BuildStream is now installed under your local user's install directories,
    
    266
    -you need to ensure that ``PATH`` is adjusted.
    
    267
    -
    
    268
    -A regular way to do this is to add the following line to the end of your ``~/.bashrc``::
    
    269
    -
    
    270
    -  export PATH="${PATH}:${HOME}/.local/bin"
    
    271
    -
    
    272
    -.. note::
    
    273
    -
    
    274
    -   You will have to restart your terminal in order for these changes to take effect.
    
    275
    -
    
    276
    -
    
    277
    -Bash completions
    
    278
    -~~~~~~~~~~~~~~~~
    
    279
    -Bash completions are supported by sourcing the ``buildstream/data/bst``
    
    280
    -script found in the BuildStream repository. On many systems this script
    
    281
    -can be installed into a completions directory but when installing BuildStream
    
    282
    -without a package manager this is not an option.
    
    283
    -
    
    284
    -To enable completions for an installation of BuildStream you
    
    285
    -installed yourself from git, just append the script verbatim
    
    286
    -to your ``~/.bash_completion``:
    
    287
    -
    
    288
    -.. literalinclude:: ../../buildstream/data/bst
    
    289
    -   :language: yaml

  • doc/source/install_versions.rst deleted
    1
    -
    
    2
    -
    
    3
    -.. _install_semantic_versioning:
    
    4
    -
    
    5
    -Semantic Versioning
    
    6
    -===================
    
    7
    -BuildStream follows the Semantic Versioning Convention `(SemVer) <https://semver.org/>`_,
    
    8
    -and uses even minor point numbers to denote releases intended for users while
    
    9
    -odd minor point numbers represent development snapshops.
    
    10
    -
    
    11
    -For example, for a given version number ``X.Y.Z``
    
    12
    - * The ``X.<even number>.*`` versions are releases intended for users.
    
    13
    - * The ``X.<odd number>.*`` versions are development spanshots intended for testing.
    
    14
    -
    
    15
    -If you are :ref:`installing from git <install_git_checkout>`, please look for the latest
    
    16
    -tag to ensure you're getting the latest release.
    
    17
    -
    
    18
    -* Latest release:
    
    19
    -
    
    20
    -  .. include:: release-badge.rst
    
    21
    -
    
    22
    -* Latest development snapshot:
    
    23
    -
    
    24
    -  .. include:: snapshot-badge.rst

  • doc/source/main_install.rst deleted
    1
    -
    
    2
    -
    
    3
    -.. _install:
    
    4
    -
    
    5
    -Install
    
    6
    -=======
    
    7
    -
    
    8
    -.. include:: release-badge.rst
    
    9
    -
    
    10
    -.. include:: snapshot-badge.rst
    
    11
    -
    
    12
    -This section provides instructions for installing BuildStream and its
    
    13
    -companion artifact server on various platforms, along with any installation
    
    14
    -related materials.
    
    15
    -
    
    16
    -.. note::
    
    17
    -
    
    18
    -   BuildStream is currently only supported natively on Linux. Users of Unix-like
    
    19
    -   systems where Docker is available can still use BuildStream by following the
    
    20
    -   :ref:`Docker install guide <docker>`
    
    21
    -
    
    22
    -.. toctree::
    
    23
    -   :maxdepth: 1
    
    24
    -
    
    25
    -   install_source
    
    26
    -   install_linux_distro
    
    27
    -   install_docker
    
    28
    -   install_artifacts
    
    29
    -   install_versions

  • doc/source/main_using.rst
    1 1
     
    
    2 2
     
    
    3
    +.. _using:
    
    4
    +
    
    3 5
     Using
    
    4 6
     =====
    
    5 7
     This section includes user facing documentation including tutorials,
    
    ... ... @@ -15,3 +17,4 @@ guides and information on user preferences and configuration.
    15 17
        using_examples
    
    16 18
        using_config
    
    17 19
        using_commands
    
    20
    +   using_configuring_artifact_server

  • doc/source/release-badge.rst deleted
    1
    -
    
    2
    -.. Use this file to include the badge in the documentation, but not in
    
    3
    -   the README.rst or gitlab rendered materials, that doesnt work.
    
    4
    -
    
    5
    -   This is partly a workaround for a sphinx issue, we will be able
    
    6
    -   to avoid the raw html once this is implemented in sphinx:
    
    7
    -
    
    8
    -       https://github.com/sphinx-doc/sphinx/issues/2240
    
    9
    -
    
    10
    -   Using the <object> tag instead of the <img> tag which sphinx generates
    
    11
    -   allows the svg to be "interactive", for us this basically means that
    
    12
    -   the link we encode in the badge svg is used, rather than static urls
    
    13
    -   which need to be used around the <img> tag.
    
    14
    -
    
    15
    -   WARNING: The custom CSS on the style tag will need to change if we
    
    16
    -            change the theme, so that the <object> tag behaves similar
    
    17
    -	    to how the <img> tag is themed by the style sheets.
    
    18
    -
    
    19
    -.. raw:: html
    
    20
    -
    
    21
    -   <a class="reference external image-reference">
    
    22
    -     <object style="margin-bottom:24px;vertical-align:middle"
    
    23
    -             data=""
    
    24
    -	     type="image/svg+xml"/>
    
    25
    -     </object>
    
    26
    -   </a>

  • doc/source/snapshot-badge.rst deleted
    1
    -
    
    2
    -.. Use this file to include the badge in the documentation, but not in
    
    3
    -   the README.rst or gitlab rendered materials, that doesnt work.
    
    4
    -
    
    5
    -   This is partly a workaround for a sphinx issue, we will be able
    
    6
    -   to avoid the raw html once this is implemented in sphinx:
    
    7
    -
    
    8
    -       https://github.com/sphinx-doc/sphinx/issues/2240
    
    9
    -
    
    10
    -   Using the <object> tag instead of the <img> tag which sphinx generates
    
    11
    -   allows the svg to be "interactive", for us this basically means that
    
    12
    -   the link we encode in the badge svg is used, rather than static urls
    
    13
    -   which need to be used around the <img> tag.
    
    14
    -
    
    15
    -   WARNING: The custom CSS on the style tag will need to change if we
    
    16
    -            change the theme, so that the <object> tag behaves similar
    
    17
    -	    to how the <img> tag is themed by the style sheets.
    
    18
    -
    
    19
    -.. raw:: html
    
    20
    -
    
    21
    -   <a class="reference external image-reference">
    
    22
    -     <object style="margin-bottom:24px;vertical-align:middle"
    
    23
    -             data=""
    
    24
    -	     type="image/svg+xml"/>
    
    25
    -     </object>
    
    26
    -   </a>

  • doc/source/install_artifacts.rstdoc/source/using_configuring_artifact_server.rst
    ... ... @@ -2,8 +2,8 @@
    2 2
     
    
    3 3
     .. _artifacts:
    
    4 4
     
    
    5
    -Installing an artifact server
    
    6
    -=============================
    
    5
    +Configuring Artifact Server
    
    6
    +===========================
    
    7 7
     BuildStream caches the results of builds in a local artifact cache, and will
    
    8 8
     avoid building an element if there is a suitable build already present in the
    
    9 9
     local artifact cache.
    
    ... ... @@ -72,7 +72,7 @@ Installing the server
    72 72
     ~~~~~~~~~~~~~~~~~~~~~
    
    73 73
     You will also need to install BuildStream on the artifact server in order
    
    74 74
     to receive uploaded artifacts over ssh. Follow the instructions for installing
    
    75
    -BuildStream :ref:`here <install>`
    
    75
    +BuildStream `here <https://buildstream.build/install.html>`_.
    
    76 76
     
    
    77 77
     When installing BuildStream on the artifact server, it must be installed
    
    78 78
     in a system wide location, with ``pip3 install .`` in the BuildStream
    

  • doc/source/using_examples.rst
    1 1
     
    
    2
    +
    
    3
    +.. _examples:
    
    4
    +
    
    2 5
     Examples
    
    3 6
     ========
    
    4 7
     This page contains documentation for real examples of BuildStream projects,
    

  • doc/source/using_tutorial.rst
    1 1
     
    
    2
    +
    
    3
    +.. _tutorial:
    
    4
    +
    
    2 5
     Tutorial
    
    3 6
     ========
    
    4 7
     This is a step by step walkthrough meant help the user quickly get
    

  • tests/completions/completions.py
    ... ... @@ -103,7 +103,7 @@ def test_commands(cli, cmd, word_idx, expected):
    103 103
         ('bst --no-colors build -', 3, ['--all ', '--track ', '--track-all ',
    
    104 104
                                         '--track-except ',
    
    105 105
                                         '--track-cross-junctions ', '-J ',
    
    106
    -                                    '--track-save ']),
    
    106
    +                                    '--track-save ', '--pull-buildtrees ']),
    
    107 107
     
    
    108 108
         # Test the behavior of completing after an option that has a
    
    109 109
         # parameter that cannot be completed, vs an option that has
    

  • tests/integration/pullbuildtrees.py
    1
    +import os
    
    2
    +import shutil
    
    3
    +import pytest
    
    4
    +
    
    5
    +from tests.testutils import cli_integration as cli, create_artifact_share
    
    6
    +from tests.testutils.integration import assert_contains
    
    7
    +
    
    8
    +
    
    9
    +DATA_DIR = os.path.join(
    
    10
    +    os.path.dirname(os.path.realpath(__file__)),
    
    11
    +    "project"
    
    12
    +)
    
    13
    +
    
    14
    +
    
    15
    +# Remove artifact cache & set cli.config value of pullbuildtrees
    
    16
    +# to false, which is the default user context
    
    17
    +def default_state(cli, integration_cache, share):
    
    18
    +    shutil.rmtree(os.path.join(integration_cache, 'artifacts'))
    
    19
    +    cli.configure({'pullbuildtrees': False, 'artifacts': {'url': share.repo, 'push': False}})
    
    20
    +
    
    21
    +
    
    22
    +# A test to capture the integration of the pullbuildtrees
    
    23
    +# behaviour, which by default is to not include the buildtree
    
    24
    +# directory of an element
    
    25
    +@pytest.mark.integration
    
    26
    +@pytest.mark.datafiles(DATA_DIR)
    
    27
    +def test_pullbuildtrees(cli, tmpdir, datafiles, integration_cache):
    
    28
    +
    
    29
    +    # Ensure artifact cache is purged, as we can't have dangling refs/objects
    
    30
    +    shutil.rmtree(os.path.join(integration_cache, 'artifacts'))
    
    31
    +
    
    32
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    33
    +    element_name = 'autotools/amhello.bst'
    
    34
    +
    
    35
    +    # Create artifact shares for pull & push testing
    
    36
    +    with create_artifact_share(os.path.join(str(tmpdir), 'share1')) as share1,\
    
    37
    +        create_artifact_share(os.path.join(str(tmpdir), 'share2')) as share2:
    
    38
    +        cli.configure({
    
    39
    +            'artifacts': {'url': share1.repo, 'push': True},
    
    40
    +        })
    
    41
    +
    
    42
    +        # Build autotools element, checked pushed, delete local
    
    43
    +        result = cli.run(project=project, args=['build', element_name])
    
    44
    +        assert result.exit_code == 0
    
    45
    +        assert cli.get_element_state(project, element_name) == 'cached'
    
    46
    +        assert share1.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    47
    +        default_state(cli, integration_cache, share1)
    
    48
    +
    
    49
    +        # Pull artifact with default config, assert that pulling again
    
    50
    +        # doesn't create a pull job, then assert with buildtrees user
    
    51
    +        # config set creates a pull job.
    
    52
    +        result = cli.run(project=project, args=['pull', element_name])
    
    53
    +        assert element_name in result.get_pulled_elements()
    
    54
    +        result = cli.run(project=project, args=['pull', element_name])
    
    55
    +        assert element_name not in result.get_pulled_elements()
    
    56
    +        cli.configure({'pullbuildtrees': True})
    
    57
    +        result = cli.run(project=project, args=['pull', element_name])
    
    58
    +        assert element_name in result.get_pulled_elements()
    
    59
    +        default_state(cli, integration_cache, share1)
    
    60
    +
    
    61
    +        # Pull artifact with default config, then assert that pulling
    
    62
    +        # with buildtrees cli flag set creates a pull job.
    
    63
    +        result = cli.run(project=project, args=['pull', element_name])
    
    64
    +        assert element_name in result.get_pulled_elements()
    
    65
    +        result = cli.run(project=project, args=['pull', '--pull-buildtrees', element_name])
    
    66
    +        assert element_name in result.get_pulled_elements()
    
    67
    +        default_state(cli, integration_cache, share1)
    
    68
    +
    
    69
    +        # Pull artifact with pullbuildtrees set in user config, then assert
    
    70
    +        # that pulling with the same user config doesn't creates a pull job,
    
    71
    +        # or when buildtrees cli flag is set.
    
    72
    +        cli.configure({'pullbuildtrees': True})
    
    73
    +        result = cli.run(project=project, args=['pull', element_name])
    
    74
    +        assert element_name in result.get_pulled_elements()
    
    75
    +        result = cli.run(project=project, args=['pull', element_name])
    
    76
    +        assert element_name not in result.get_pulled_elements()
    
    77
    +        result = cli.run(project=project, args=['pull', '--pull-buildtrees', element_name])
    
    78
    +        assert element_name not in result.get_pulled_elements()
    
    79
    +        default_state(cli, integration_cache, share1)
    
    80
    +
    
    81
    +        # Pull artifact with default config and buildtrees cli flag set, then assert
    
    82
    +        # that pulling with pullbuildtrees set in user config doesn't create a pull
    
    83
    +        # job.
    
    84
    +        result = cli.run(project=project, args=['pull', '--pull-buildtrees', element_name])
    
    85
    +        assert element_name in result.get_pulled_elements()
    
    86
    +        cli.configure({'pullbuildtrees': True})
    
    87
    +        result = cli.run(project=project, args=['pull', element_name])
    
    88
    +        assert element_name not in result.get_pulled_elements()
    
    89
    +        default_state(cli, integration_cache, share1)
    
    90
    +
    
    91
    +        # Assert that a partial build element (not containing a populated buildtree dir)
    
    92
    +        # can't be pushed to an artifact share, then assert that a complete build element
    
    93
    +        # can be. This will attempt a partial pull from share1 and then a partial push
    
    94
    +        # to share2
    
    95
    +        result = cli.run(project=project, args=['pull', element_name])
    
    96
    +        assert element_name in result.get_pulled_elements()
    
    97
    +        cli.configure({'artifacts': {'url': share2.repo, 'push': True}})
    
    98
    +        result = cli.run(project=project, args=['push', element_name])
    
    99
    +        assert element_name not in result.get_pushed_elements()
    
    100
    +        assert not share2.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    101
    +
    
    102
    +        # Assert that after pulling the missing buildtree the element artifact can be
    
    103
    +        # successfully pushed to the remote. This will attempt to pull the buildtree
    
    104
    +        # from share1 and then a 'complete' push to share2
    
    105
    +        cli.configure({'artifacts': {'url': share1.repo, 'push': False}})
    
    106
    +        result = cli.run(project=project, args=['pull', '--pull-buildtrees', element_name])
    
    107
    +        assert element_name in result.get_pulled_elements()
    
    108
    +        cli.configure({'artifacts': {'url': share2.repo, 'push': True}})
    
    109
    +        result = cli.run(project=project, args=['push', element_name])
    
    110
    +        assert element_name in result.get_pushed_elements()
    
    111
    +        assert share2.has_artifact('test', element_name, cli.get_element_key(project, element_name))

  • tests/testutils/artifactshare.py
    ... ... @@ -128,7 +128,7 @@ class ArtifactShare():
    128 128
     
    
    129 129
             valid_chars = string.digits + string.ascii_letters + '-._'
    
    130 130
             element_name = ''.join([
    
    131
    -            x if x in valid_chars else '_'
    
    131
    +            x if x in valid_chars else '-'
    
    132 132
                 for x in element_name
    
    133 133
             ])
    
    134 134
             artifact_key = '{0}/{1}/{2}'.format(project_name, element_name, cache_key)
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]