Will Salmon pushed to branch willsalmon/outOfSourecBuild at BuildStream / buildstream
Commits:
-
d827dfae
by Angelos Evripiotis at 2018-10-09T09:12:45Z
-
9590e8ae
by Angelos Evripiotis at 2018-10-09T09:12:45Z
-
6d02e269
by Angelos Evripiotis at 2018-10-09T09:12:45Z
-
3ed26a47
by Angelos Evripiotis at 2018-10-09T09:12:45Z
-
5b22d850
by Angelos Evripiotis at 2018-10-09T09:12:45Z
-
ac0776f8
by Tristan Van Berkom at 2018-10-09T09:36:33Z
-
885bd946
by Tristan Van Berkom at 2018-10-09T09:39:24Z
-
120d8c73
by Tristan Van Berkom at 2018-10-09T09:45:23Z
-
cda1354c
by Chandan Singh at 2018-10-10T00:17:51Z
-
dd472d95
by Chandan Singh at 2018-10-10T00:18:17Z
-
35ac26a7
by Chandan Singh at 2018-10-10T00:59:17Z
-
c6298bc0
by William Salmon at 2018-10-10T09:16:24Z
-
836727ba
by William Salmon at 2018-10-10T09:16:29Z
-
8f865d18
by William Salmon at 2018-10-10T09:16:36Z
-
be9208a1
by William Salmon at 2018-10-10T14:06:06Z
-
01e1d116
by William Salmon at 2018-10-10T14:17:24Z
-
4651e4b0
by William Salmon at 2018-10-10T14:17:25Z
24 changed files:
- CONTRIBUTING.rst
- NEWS
- buildstream/_versions.py
- buildstream/buildelement.py
- buildstream/data/projectconfig.yaml
- buildstream/plugins/elements/autotools.yaml
- buildstream/plugins/elements/cmake.yaml
- buildstream/plugins/elements/distutils.yaml
- buildstream/plugins/elements/meson.yaml
- buildstream/plugins/elements/pip.yaml
- buildstream/plugins/elements/qmake.yaml
- buildstream/sandbox/_sandboxbwrap.py
- buildstream/sandbox/_sandboxchroot.py
- buildstream/sandbox/sandbox.py
- buildstream/source.py
- + doc/source/additional_docker.rst
- doc/source/core_additional.rst
- tests/format/variables.py
- tests/integration/autotools.py
- tests/integration/cmake.py
- + tests/integration/project/elements/autotools/amhelloconfroot.bst
- + tests/integration/project/elements/cmake/cmakeconfroothello.bst
- + tests/integration/project/elements/workspace/workspace-commanddir.bst
- tests/integration/workspace.py
Changes:
... | ... | @@ -14,7 +14,7 @@ if no issue already exists. |
14 | 14 |
|
15 | 15 |
For policies on how to submit an issue and how to use our project labels,
|
16 | 16 |
we recommend that you read the `policies guide
|
17 |
-<https://gitlab.com/BuildStream/nosoftware/alignment/blob/master/BuildStream_policies.md>`_
|
|
17 |
+<https://gitlab.com/BuildStream/nosoftware/alignment/blob/master/BuildStream_policies.md>`_.
|
|
18 | 18 |
|
19 | 19 |
|
20 | 20 |
.. _contributing_fixing_bugs:
|
... | ... | @@ -270,6 +270,11 @@ comments and docstrings. |
270 | 270 |
*Since: 1.2*
|
271 | 271 |
"""
|
272 | 272 |
|
273 |
+.. note::
|
|
274 |
+ |
|
275 |
+ Python does not support docstrings on instance variables, but sphinx does
|
|
276 |
+ pick them up and includes them in the generated documentation.
|
|
277 |
+ |
|
273 | 278 |
**Internal instance variable**::
|
274 | 279 |
|
275 | 280 |
def __init__(self, context, element):
|
... | ... | @@ -404,7 +409,7 @@ on a Python class in BuildStream:: |
404 | 409 |
# Implementation of the "frobbish" abstract method
|
405 | 410 |
# defined by the parent Bar class.
|
406 | 411 |
#
|
407 |
- return True
|
|
412 |
+ return True
|
|
408 | 413 |
|
409 | 414 |
################################################
|
410 | 415 |
# Public Methods #
|
... | ... | @@ -445,7 +450,7 @@ on a Python class in BuildStream:: |
445 | 450 |
# Returns:
|
446 | 451 |
# (int): The count of this foo
|
447 | 452 |
#
|
448 |
- def set_count(self, count):
|
|
453 |
+ def get_count(self, count):
|
|
449 | 454 |
|
450 | 455 |
return self._count
|
451 | 456 |
|
... | ... | @@ -459,7 +464,7 @@ on a Python class in BuildStream:: |
459 | 464 |
# Even though these are private implementation
|
460 | 465 |
# details, they still MUST have API documenting
|
461 | 466 |
# comments on them.
|
462 |
-
|
|
467 |
+ |
|
463 | 468 |
# _do_frobbing()
|
464 | 469 |
#
|
465 | 470 |
# Does the actual frobbing
|
... | ... | @@ -494,10 +499,10 @@ reference on how the PEP-8 defines public and non-public. |
494 | 499 |
|
495 | 500 |
A private symbol must be denoted by a leading underscore.
|
496 | 501 |
|
497 |
-* When a class can have subclasses (for example, the ``Sandbox`` or ``Platform``
|
|
502 |
+* When a class can have subclasses, then private symbols should be denoted
|
|
503 |
+ by two leading underscores. For example, the ``Sandbox`` or ``Platform``
|
|
498 | 504 |
classes which have various implementations, or the ``Element`` and ``Source``
|
499 |
- classes which plugins derive from), then private symbols should be denoted
|
|
500 |
- by two leading underscores.
|
|
505 |
+ classes which plugins derive from.
|
|
501 | 506 |
|
502 | 507 |
The double leading underscore naming convention invokes Python's name
|
503 | 508 |
mangling algorithm which helps prevent namespace collisions in the case
|
... | ... | @@ -536,7 +541,7 @@ In order to disambiguate between: |
536 | 541 |
|
537 | 542 |
* Symbols which are publicly accessible details of the ``Element`` class, can
|
538 | 543 |
be accessed by BuildStream internals, but must remain hidden from the
|
539 |
- *"Public API Surface"*
|
|
544 |
+ *"Public API Surface"*.
|
|
540 | 545 |
|
541 | 546 |
* Symbols which are private to the ``Element`` class, and cannot be accessed
|
542 | 547 |
from outside of the ``Element`` class at all.
|
... | ... | @@ -586,7 +591,7 @@ is found at ``_artifactcache/artifactcache.py``. |
586 | 591 |
|
587 | 592 |
Imports
|
588 | 593 |
~~~~~~~
|
589 |
-Module imports inside BuildStream are done with relative ``.`` notation
|
|
594 |
+Module imports inside BuildStream are done with relative ``.`` notation:
|
|
590 | 595 |
|
591 | 596 |
**Good**::
|
592 | 597 |
|
... | ... | @@ -628,12 +633,12 @@ which exposes an instance variable is the only one in control of the value of th |
628 | 633 |
variable.
|
629 | 634 |
|
630 | 635 |
* If an instance variable is public and must be modified; then it must be
|
631 |
- modified using a :ref:`mutator <contributing_accessor_mutator>`
|
|
636 |
+ modified using a :ref:`mutator <contributing_accessor_mutator>`.
|
|
632 | 637 |
|
633 | 638 |
* Ideally for better encapsulation, all object state is declared as
|
634 | 639 |
:ref:`private instance variables <contributing_public_and_private>` and can
|
635 | 640 |
only be accessed by external classes via public :ref:`accessors and mutators
|
636 |
- <contributing_accessor_mutator>`
|
|
641 |
+ <contributing_accessor_mutator>`.
|
|
637 | 642 |
|
638 | 643 |
.. note::
|
639 | 644 |
|
... | ... | @@ -720,10 +725,10 @@ In BuildStream, we use the term *"Abstract Method"*, to refer to |
720 | 725 |
a method which **can** be overridden by a subclass, whereas it
|
721 | 726 |
is **illegal** to override any other method.
|
722 | 727 |
|
723 |
-* Abstract methods are allowed to have default implementations
|
|
728 |
+* Abstract methods are allowed to have default implementations.
|
|
724 | 729 |
|
725 | 730 |
* Subclasses are not allowed to redefine the calling signature
|
726 |
- of an abstract method, or redefine the API contract in any way
|
|
731 |
+ of an abstract method, or redefine the API contract in any way.
|
|
727 | 732 |
|
728 | 733 |
* Subclasses are not allowed to override any other methods.
|
729 | 734 |
|
... | ... | @@ -798,7 +803,7 @@ BstError parameters |
798 | 803 |
When raising ``BstError`` class exceptions, there are some common properties
|
799 | 804 |
which can be useful to know about:
|
800 | 805 |
|
801 |
-* **message:** The brief human readable error, will be formatted on one line in the frontend
|
|
806 |
+* **message:** The brief human readable error, will be formatted on one line in the frontend.
|
|
802 | 807 |
|
803 | 808 |
* **detail:** An optional detailed human readable message to accompany the **message** summary
|
804 | 809 |
of the error. This is often used to recommend the user some course of action, or to provide
|
... | ... | @@ -974,9 +979,9 @@ symbols to a minimum, this is important for both |
974 | 979 |
|
975 | 980 |
When anyone visits a file, there are two levels of comprehension:
|
976 | 981 |
|
977 |
-* What do I need to know in order to *use* this object
|
|
982 |
+* What do I need to know in order to *use* this object.
|
|
978 | 983 |
|
979 |
-* What do I need to know in order to *modify* this object
|
|
984 |
+* What do I need to know in order to *modify* this object.
|
|
980 | 985 |
|
981 | 986 |
For the former, we want the reader to understand with as little effort
|
982 | 987 |
as possible, what the public API contract is for a given object and consequently,
|
... | ... | @@ -1001,9 +1006,9 @@ well documented and minimal. |
1001 | 1006 |
|
1002 | 1007 |
When adding new API to a given object for a new purpose, consider whether
|
1003 | 1008 |
the new API is in any way redundant with other API (should this value now
|
1004 |
-go into the constructor, since we use it more than once ? could this
|
|
1009 |
+go into the constructor, since we use it more than once? could this
|
|
1005 | 1010 |
value be passed along with another function, and the other function renamed,
|
1006 |
-to better suit the new purposes of this module/object ?) and repurpose
|
|
1011 |
+to better suit the new purposes of this module/object?) and repurpose
|
|
1007 | 1012 |
the outward facing API of an object as a whole every time.
|
1008 | 1013 |
|
1009 | 1014 |
|
... | ... | @@ -1183,7 +1188,7 @@ The BuildStream documentation style is as follows: |
1183 | 1188 |
* Cross references should be of the form ``:role:`target```.
|
1184 | 1189 |
|
1185 | 1190 |
* Explicit anchors can be declared as ``.. _anchor_name:`` on a line by itself.
|
1186 |
-
|
|
1191 |
+ |
|
1187 | 1192 |
* To cross reference arbitrary locations with, for example, the anchor ``anchor_name``,
|
1188 | 1193 |
always provide some explicit text in the link instead of deriving the text from
|
1189 | 1194 |
the target, e.g.: ``:ref:`Link text <anchor_name>```.
|
... | ... | @@ -1266,23 +1271,23 @@ Documentation Examples |
1266 | 1271 |
The examples section of the documentation contains a series of standalone
|
1267 | 1272 |
examples, here are the criteria for an example addition.
|
1268 | 1273 |
|
1269 |
-* The example has a ``${name}``
|
|
1274 |
+* The example has a ``${name}``.
|
|
1270 | 1275 |
|
1271 |
-* The example has a project users can copy and use
|
|
1276 |
+* The example has a project users can copy and use.
|
|
1272 | 1277 |
|
1273 |
- * This project is added in the directory ``doc/examples/${name}``
|
|
1278 |
+ * This project is added in the directory ``doc/examples/${name}``.
|
|
1274 | 1279 |
|
1275 |
-* The example has a documentation component
|
|
1280 |
+* The example has a documentation component.
|
|
1276 | 1281 |
|
1277 | 1282 |
* This is added at ``doc/source/examples/${name}.rst``
|
1278 | 1283 |
* A reference to ``examples/${name}`` is added to the toctree in ``doc/source/examples.rst``
|
1279 | 1284 |
* This documentation discusses the project elements declared in the project and may
|
1280 |
- provide some BuildStream command examples
|
|
1281 |
- * This documentation links out to the reference manual at every opportunity
|
|
1285 |
+ provide some BuildStream command examples.
|
|
1286 |
+ * This documentation links out to the reference manual at every opportunity.
|
|
1282 | 1287 |
|
1283 |
-* The example has a CI test component
|
|
1288 |
+* The example has a CI test component.
|
|
1284 | 1289 |
|
1285 |
- * This is an integration test added at ``tests/examples/${name}``
|
|
1290 |
+ * This is an integration test added at ``tests/examples/${name}``.
|
|
1286 | 1291 |
* This test runs BuildStream in the ways described in the example
|
1287 | 1292 |
and assert that we get the results which we advertize to users in
|
1288 | 1293 |
the said examples.
|
... | ... | @@ -1309,17 +1314,17 @@ The ``.run`` file format is just another YAML dictionary which consists of a |
1309 | 1314 |
|
1310 | 1315 |
Each *command* is a dictionary, the members of which are listed here:
|
1311 | 1316 |
|
1312 |
-* ``directory``: The input file relative project directory
|
|
1317 |
+* ``directory``: The input file relative project directory.
|
|
1313 | 1318 |
|
1314 |
-* ``output``: The input file relative output html file to generate (optional)
|
|
1319 |
+* ``output``: The input file relative output html file to generate (optional).
|
|
1315 | 1320 |
|
1316 | 1321 |
* ``fake-output``: Don't really run the command, just pretend to and pretend
|
1317 | 1322 |
this was the output, an empty string will enable this too.
|
1318 | 1323 |
|
1319 |
-* ``command``: The command to run, without the leading ``bst``
|
|
1324 |
+* ``command``: The command to run, without the leading ``bst``.
|
|
1320 | 1325 |
|
1321 | 1326 |
* ``shell``: Specifying ``True`` indicates that ``command`` should be run as
|
1322 |
- a shell command from the project directory, instead of a bst command (optional)
|
|
1327 |
+ a shell command from the project directory, instead of a bst command (optional).
|
|
1323 | 1328 |
|
1324 | 1329 |
When adding a new ``.run`` file, one should normally also commit the new
|
1325 | 1330 |
resulting generated ``.html`` file(s) into the ``doc/source/sessions-stored/``
|
... | ... | @@ -1417,7 +1422,7 @@ a subdirectory beside your test in which to store data. |
1417 | 1422 |
When creating a test that needs data, use the datafiles extension
|
1418 | 1423 |
to decorate your test case (again, examples exist in the existing
|
1419 | 1424 |
tests for this), documentation on the datafiles extension can
|
1420 |
-be found here: https://pypi.python.org/pypi/pytest-datafiles
|
|
1425 |
+be found here: https://pypi.python.org/pypi/pytest-datafiles.
|
|
1421 | 1426 |
|
1422 | 1427 |
Tests that run a sandbox should be decorated with::
|
1423 | 1428 |
|
... | ... | @@ -24,6 +24,12 @@ buildstream 1.3.1 |
24 | 24 |
o Add new `pip` source plugin for downloading python packages using pip,
|
25 | 25 |
based on requirements files from previous sources.
|
26 | 26 |
|
27 |
+ o Generate Docker images from built artifacts using
|
|
28 |
+ `contrib/bst-docker-import` script.
|
|
29 |
+ |
|
30 |
+ o Added Documentation on how to create out of source builds. This includes the
|
|
31 |
+ new the `conf-root` variable to make the process easier. And there has been
|
|
32 |
+ a bug fix to workspaces so they can be build in workspaces too.
|
|
27 | 33 |
|
28 | 34 |
=================
|
29 | 35 |
buildstream 1.1.5
|
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 |
# This version is bumped whenever enhancements are made
|
24 | 24 |
# to the `project.conf` format or the core element format.
|
25 | 25 |
#
|
26 |
-BST_FORMAT_VERSION = 16
|
|
26 |
+BST_FORMAT_VERSION = 17
|
|
27 | 27 |
|
28 | 28 |
|
29 | 29 |
# The base BuildStream artifact version
|
... | ... | @@ -23,6 +23,48 @@ BuildElement - Abstract class for build elements |
23 | 23 |
The BuildElement class is a convenience element one can derive from for
|
24 | 24 |
implementing the most common case of element.
|
25 | 25 |
|
26 |
+Built-in functionality
|
|
27 |
+----------------------
|
|
28 |
+ |
|
29 |
+The BuildElement base class provides built in functionality that could be
|
|
30 |
+overridden by the individual plugins.
|
|
31 |
+ |
|
32 |
+This section will give a brief summary of how some of the common features work,
|
|
33 |
+some of them or the variables they use will be further detailed in the following
|
|
34 |
+sections.
|
|
35 |
+ |
|
36 |
+* Location for running commands
|
|
37 |
+ |
|
38 |
+ The ``command-subdir`` variable sets where the build commands will be executed,
|
|
39 |
+ if the directory does not exist it will be created, it is defined relative to
|
|
40 |
+ the buildroot.
|
|
41 |
+ |
|
42 |
+* Location for configuring the project
|
|
43 |
+ |
|
44 |
+ The ``conf-root`` is defined by default as ``.`` and is the location that
|
|
45 |
+ specific build element can use to look for build configuration files, currently
|
|
46 |
+ autotools, cmake, distutils, meson, pip and qmake use this.
|
|
47 |
+ |
|
48 |
+ The configuration commands are run in ``command-subdir`` and by default
|
|
49 |
+ ``conf-root`` is ``.`` so if ``conf-root`` is not set the configuration files
|
|
50 |
+ in ``command-subdir`` will be used.
|
|
51 |
+ |
|
52 |
+ By setting ``conf-root`` to ``"%{build-root}/Source/conf_location"`` and your
|
|
53 |
+ source elements ``directory`` variable to ``Source`` then the configuration
|
|
54 |
+ files in the directory ``conf_location`` with in your Source will be used.
|
|
55 |
+ However the location where your configuration command will be run will still
|
|
56 |
+ be wherever you set your ``command-subdir`` to be.
|
|
57 |
+ |
|
58 |
+.. note::
|
|
59 |
+ |
|
60 |
+ The ``conf-root`` variable is available since :ref:`format version 17 <project_format_version>`
|
|
61 |
+ |
|
62 |
+* Install Location
|
|
63 |
+ |
|
64 |
+ You should not change the ``install-root`` variable as it is a special
|
|
65 |
+ writeable location in the sandbox but it is useful when writing custom
|
|
66 |
+ install instructions as it may need to be supplied as the ``DESTDIR``, please
|
|
67 |
+ see the cmake build element for example.
|
|
26 | 68 |
|
27 | 69 |
Abstract method implementations
|
28 | 70 |
-------------------------------
|
... | ... | @@ -38,6 +38,9 @@ variables: |
38 | 38 |
# normally staged
|
39 | 39 |
build-root: /buildstream/%{project-name}/%{element-name}
|
40 | 40 |
|
41 |
+ # Indicates where the build system should look for configuration files
|
|
42 |
+ conf-root: .
|
|
43 |
+
|
|
41 | 44 |
# Indicates the build installation directory in the sandbox
|
42 | 45 |
install-root: /buildstream-install
|
43 | 46 |
|
... | ... | @@ -6,11 +6,11 @@ variables: |
6 | 6 |
export NOCONFIGURE=1;
|
7 | 7 |
|
8 | 8 |
if [ -x %{conf-cmd} ]; then true;
|
9 |
- elif [ -x autogen ]; then ./autogen;
|
|
10 |
- elif [ -x autogen.sh ]; then ./autogen.sh;
|
|
11 |
- elif [ -x bootstrap ]; then ./bootstrap;
|
|
12 |
- elif [ -x bootstrap.sh ]; then ./bootstrap.sh;
|
|
13 |
- else autoreconf -ivf;
|
|
9 |
+ elif [ -x %{conf-root}/autogen ]; then %{conf-root}/autogen;
|
|
10 |
+ elif [ -x %{conf-root}/autogen.sh ]; then %{conf-root}/autogen.sh;
|
|
11 |
+ elif [ -x %{conf-root}/bootstrap ]; then %{conf-root}/bootstrap;
|
|
12 |
+ elif [ -x %{conf-root}/bootstrap.sh ]; then %{conf-root}/bootstrap.sh;
|
|
13 |
+ else autoreconf -ivf %{conf-root};
|
|
14 | 14 |
fi
|
15 | 15 |
|
16 | 16 |
# Project-wide extra arguments to be passed to `configure`
|
... | ... | @@ -22,7 +22,8 @@ variables: |
22 | 22 |
# For backwards compatibility only, do not use.
|
23 | 23 |
conf-extra: ''
|
24 | 24 |
|
25 |
- conf-cmd: ./configure
|
|
25 |
+ conf-cmd: "%{conf-root}/configure"
|
|
26 |
+
|
|
26 | 27 |
conf-args: |
|
27 | 28 |
|
28 | 29 |
--prefix=%{prefix} \
|
... | ... | @@ -23,7 +23,7 @@ variables: |
23 | 23 |
|
24 | 24 |
cmake: |
|
25 | 25 |
|
26 |
- cmake -B%{build-dir} -H. -G"%{generator}" %{cmake-args}
|
|
26 |
+ cmake -B%{build-dir} -H"%{conf-root}" -G"%{generator}" %{cmake-args}
|
|
27 | 27 |
|
28 | 28 |
make: cmake --build %{build-dir} -- ${JOBS}
|
29 | 29 |
make-install: env DESTDIR="%{install-root}" cmake --build %{build-dir} --target install
|
... | ... | @@ -8,7 +8,7 @@ variables: |
8 | 8 |
|
9 | 9 |
python-build: |
|
10 | 10 |
|
11 |
- %{python} setup.py build
|
|
11 |
+ %{python} %{conf-root}/setup.py build
|
|
12 | 12 |
|
13 | 13 |
install-args: |
|
14 | 14 |
|
... | ... | @@ -17,7 +17,7 @@ variables: |
17 | 17 |
|
18 | 18 |
python-install: |
|
19 | 19 |
|
20 |
- %{python} setup.py install %{install-args}
|
|
20 |
+ %{python} %{conf-root}/setup.py install %{install-args}
|
|
21 | 21 |
|
22 | 22 |
|
23 | 23 |
config:
|
... | ... | @@ -28,7 +28,7 @@ variables: |
28 | 28 |
--mandir=%{mandir} \
|
29 | 29 |
--infodir=%{infodir} %{meson-extra} %{meson-global} %{meson-local}
|
30 | 30 |
|
31 |
- meson: meson %{build-dir} %{meson-args}
|
|
31 |
+ meson: meson %{conf-root} %{build-dir} %{meson-args}
|
|
32 | 32 |
|
33 | 33 |
ninja: |
|
34 | 34 |
ninja -j ${NINJAJOBS} -C %{build-dir}
|
... | ... | @@ -14,7 +14,7 @@ config: |
14 | 14 |
#
|
15 | 15 |
install-commands:
|
16 | 16 |
- |
|
17 |
- %{pip} install --no-deps --root=%{install-root} --prefix=%{prefix} .
|
|
17 |
+ %{pip} install --no-deps --root=%{install-root} --prefix=%{prefix} %{conf-root}
|
|
18 | 18 |
|
19 | 19 |
# Commands for stripping debugging information out of
|
20 | 20 |
# installed binaries
|
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 |
|
3 | 3 |
variables:
|
4 | 4 |
|
5 |
- qmake: qmake -makefile
|
|
5 |
+ qmake: qmake -makefile %{conf-root}
|
|
6 | 6 |
make: make
|
7 | 7 |
make-install: make -j1 INSTALL_ROOT="%{install-root}" install
|
8 | 8 |
|
... | ... | @@ -108,9 +108,6 @@ class SandboxBwrap(Sandbox): |
108 | 108 |
bwrap_command += ['--unshare-uts', '--hostname', 'buildstream']
|
109 | 109 |
bwrap_command += ['--unshare-ipc']
|
110 | 110 |
|
111 |
- if cwd is not None:
|
|
112 |
- bwrap_command += ['--chdir', cwd]
|
|
113 |
- |
|
114 | 111 |
# Give it a proc and tmpfs
|
115 | 112 |
bwrap_command += [
|
116 | 113 |
'--proc', '/proc',
|
... | ... | @@ -151,6 +148,10 @@ class SandboxBwrap(Sandbox): |
151 | 148 |
if flags & SandboxFlags.ROOT_READ_ONLY:
|
152 | 149 |
bwrap_command += ["--remount-ro", "/"]
|
153 | 150 |
|
151 |
+ if cwd is not None:
|
|
152 |
+ bwrap_command += ['--dir', cwd]
|
|
153 |
+ bwrap_command += ['--chdir', cwd]
|
|
154 |
+ |
|
154 | 155 |
# Set UID and GUI
|
155 | 156 |
if self.user_ns_available:
|
156 | 157 |
bwrap_command += ['--unshare-user']
|
... | ... | @@ -179,11 +180,6 @@ class SandboxBwrap(Sandbox): |
179 | 180 |
with ExitStack() as stack:
|
180 | 181 |
stack.enter_context(mount_map.mounted(self))
|
181 | 182 |
|
182 |
- # Ensure the cwd exists
|
|
183 |
- if cwd is not None:
|
|
184 |
- workdir = os.path.join(root_mount_source, cwd.lstrip(os.sep))
|
|
185 |
- os.makedirs(workdir, exist_ok=True)
|
|
186 |
- |
|
187 | 183 |
# If we're interactive, we want to inherit our stdin,
|
188 | 184 |
# otherwise redirect to /dev/null, ensuring process
|
189 | 185 |
# disconnected from terminal.
|
... | ... | @@ -100,9 +100,8 @@ class SandboxChroot(Sandbox): |
100 | 100 |
|
101 | 101 |
# Ensure the cwd exists
|
102 | 102 |
if cwd is not None:
|
103 |
- workdir = os.path.join(root_mount_source, cwd.lstrip(os.sep))
|
|
103 |
+ workdir = os.path.join(rootfs, cwd.lstrip(os.sep))
|
|
104 | 104 |
os.makedirs(workdir, exist_ok=True)
|
105 |
- |
|
106 | 105 |
status = self.chroot(rootfs, command, stdin, stdout,
|
107 | 106 |
stderr, cwd, env, flags)
|
108 | 107 |
|
... | ... | @@ -223,7 +223,9 @@ class Sandbox(): |
223 | 223 |
.. note::
|
224 | 224 |
|
225 | 225 |
The optional *cwd* argument will default to the value set with
|
226 |
- :func:`~buildstream.sandbox.Sandbox.set_work_directory`
|
|
226 |
+ :func:`~buildstream.sandbox.Sandbox.set_work_directory` and this
|
|
227 |
+ function must make sure the directory will be created if it does
|
|
228 |
+ not exist yet, even if a workspace is being used.
|
|
227 | 229 |
"""
|
228 | 230 |
raise ImplError("Sandbox of type '{}' does not implement run()"
|
229 | 231 |
.format(type(self).__name__))
|
... | ... | @@ -20,6 +20,19 @@ |
20 | 20 |
Source - Base source class
|
21 | 21 |
==========================
|
22 | 22 |
|
23 |
+Built-in functionality
|
|
24 |
+----------------------
|
|
25 |
+ |
|
26 |
+The Source base class provides built in functionality that could be overridden
|
|
27 |
+by the individual plugins.
|
|
28 |
+ |
|
29 |
+* Directory
|
|
30 |
+ |
|
31 |
+ The ``directory`` variable can be set for all sources of a type in project.conf
|
|
32 |
+ or per source within a element.
|
|
33 |
+ |
|
34 |
+ This sets the location with in the build root that the content of the source
|
|
35 |
+ will be loaded in to. If the location dose not exist it will be created.
|
|
23 | 36 |
|
24 | 37 |
.. _core_source_abstract_methods:
|
25 | 38 |
|
1 |
+ |
|
2 |
+.. _bst_and_docker:
|
|
3 |
+ |
|
4 |
+ |
|
5 |
+BuildStream and Docker
|
|
6 |
+======================
|
|
7 |
+ |
|
8 |
+BuildStream integrates with Docker in multiple ways. Here are some ways in
|
|
9 |
+which these integrations work.
|
|
10 |
+ |
|
11 |
+Run BuildStream inside Docker
|
|
12 |
+-----------------------------
|
|
13 |
+ |
|
14 |
+Refer to the :ref:`BuildStream inside Docker <docker>` documentation for
|
|
15 |
+instructions on how to run BuildStream as a Docker container.
|
|
16 |
+ |
|
17 |
+Generate Docker images
|
|
18 |
+----------------------
|
|
19 |
+ |
|
20 |
+The
|
|
21 |
+`bst-docker-import script <https://gitlab.com/BuildStream/buildstream/blob/master/contrib/bst-docker-import>`_
|
|
22 |
+can be used to generate a Docker image from built artifacts.
|
|
23 |
+ |
|
24 |
+You can download it and make it executable like this:
|
|
25 |
+ |
|
26 |
+.. code:: bash
|
|
27 |
+ |
|
28 |
+ mkdir -p ~/.local/bin
|
|
29 |
+ curl --get https://gitlab.com/BuildStream/buildstream/raw/master/contrib/bst-docker-import > ~/.local/bin/bst-docker-import
|
|
30 |
+ chmod +x ~/.local/bin/bst-docker-import
|
|
31 |
+ |
|
32 |
+Check if ``~/.local/bin`` appears in your PATH environment variable -- if it
|
|
33 |
+doesn't, you should
|
|
34 |
+`edit your ~/.profile so that it does <https://stackoverflow.com/questions/14637979/>`_.
|
|
35 |
+ |
|
36 |
+Once the script is available in your PATH and assuming you have Docker
|
|
37 |
+installed, you can start using the ``bst-docker-import`` script. Here is a
|
|
38 |
+minimal example to generate an image called ``bst-hello`` from an element
|
|
39 |
+called ``hello.bst`` assuming it is already built:
|
|
40 |
+ |
|
41 |
+.. code:: bash
|
|
42 |
+ |
|
43 |
+ bst-docker-import -t bst-hello hello.bst
|
|
44 |
+ |
|
45 |
+This script can also be used if you are running BuildStream inside Docker. In
|
|
46 |
+this case, you will need to supply the command that you are using to run
|
|
47 |
+BuildStream using the ``-c`` option. If you are using the
|
|
48 |
+`bst-here wrapper script <https://gitlab.com/BuildStream/buildstream/blob/master/contrib/bst-here>`_,
|
|
49 |
+you can achieve the same results as the above example like this:
|
|
50 |
+ |
|
51 |
+.. code:: bash
|
|
52 |
+ |
|
53 |
+ bst-docker-import -c bst-here -t bst-hello hello.bst
|
... | ... | @@ -8,3 +8,4 @@ Additional writings |
8 | 8 |
|
9 | 9 |
additional_cachekeys
|
10 | 10 |
additional_sandboxing
|
11 |
+ additional_docker
|
... | ... | @@ -19,10 +19,10 @@ DATA_DIR = os.path.join( |
19 | 19 |
@pytest.mark.parametrize("target,varname,expected", [
|
20 | 20 |
('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/buildstream-install\" install"),
|
21 | 21 |
('cmake.bst', 'cmake',
|
22 |
- "cmake -B_builddir -H. -G\"Unix Makefiles\" -DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
|
|
22 |
+ "cmake -B_builddir -H\".\" -G\"Unix Makefiles\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
|
|
23 | 23 |
"-DCMAKE_INSTALL_LIBDIR=lib "),
|
24 | 24 |
('distutils.bst', 'python-install',
|
25 |
- "python3 setup.py install --prefix \"/usr\" \\\n" +
|
|
25 |
+ "python3 ./setup.py install --prefix \"/usr\" \\\n" +
|
|
26 | 26 |
"--root \"/buildstream-install\""),
|
27 | 27 |
('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/buildstream-install/usr"),
|
28 | 28 |
('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/buildstream-install/usr\""),
|
... | ... | @@ -45,10 +45,10 @@ def test_defaults(cli, datafiles, tmpdir, target, varname, expected): |
45 | 45 |
@pytest.mark.parametrize("target,varname,expected", [
|
46 | 46 |
('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/custom/install/root\" install"),
|
47 | 47 |
('cmake.bst', 'cmake',
|
48 |
- "cmake -B_builddir -H. -G\"Ninja\" -DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
|
|
48 |
+ "cmake -B_builddir -H\".\" -G\"Ninja\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
|
|
49 | 49 |
"-DCMAKE_INSTALL_LIBDIR=lib "),
|
50 | 50 |
('distutils.bst', 'python-install',
|
51 |
- "python3 setup.py install --prefix \"/opt\" \\\n" +
|
|
51 |
+ "python3 ./setup.py install --prefix \"/opt\" \\\n" +
|
|
52 | 52 |
"--root \"/custom/install/root\""),
|
53 | 53 |
('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/custom/install/root/opt"),
|
54 | 54 |
('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/custom/install/root/opt\""),
|
... | ... | @@ -38,6 +38,30 @@ def test_autotools_build(cli, tmpdir, datafiles): |
38 | 38 |
'/usr/share/doc/amhello/README'])
|
39 | 39 |
|
40 | 40 |
|
41 |
+# Test that an autotools build 'works' - we use the autotools sample
|
|
42 |
+# amhello project for this.
|
|
43 |
+@pytest.mark.integration
|
|
44 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
45 |
+def test_autotools_confroot_build(cli, tmpdir, datafiles):
|
|
46 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
47 |
+ checkout = os.path.join(cli.directory, 'checkout')
|
|
48 |
+ element_name = 'autotools/amhelloconfroot.bst'
|
|
49 |
+ |
|
50 |
+ result = cli.run(project=project, args=['build', element_name])
|
|
51 |
+ assert result.exit_code == 0
|
|
52 |
+ |
|
53 |
+ result = cli.run(project=project, args=['checkout', element_name, checkout])
|
|
54 |
+ assert result.exit_code == 0
|
|
55 |
+ |
|
56 |
+ assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
|
|
57 |
+ '/usr/share', '/usr/lib/debug',
|
|
58 |
+ '/usr/lib/debug/usr', '/usr/lib/debug/usr/bin',
|
|
59 |
+ '/usr/lib/debug/usr/bin/hello',
|
|
60 |
+ '/usr/bin/hello', '/usr/share/doc',
|
|
61 |
+ '/usr/share/doc/amhello',
|
|
62 |
+ '/usr/share/doc/amhello/README'])
|
|
63 |
+ |
|
64 |
+ |
|
41 | 65 |
# Test running an executable built with autotools
|
42 | 66 |
@pytest.mark.datafiles(DATA_DIR)
|
43 | 67 |
def test_autotools_run(cli, tmpdir, datafiles):
|
... | ... | @@ -32,6 +32,24 @@ def test_cmake_build(cli, tmpdir, datafiles): |
32 | 32 |
'/usr/lib/debug/usr/bin/hello'])
|
33 | 33 |
|
34 | 34 |
|
35 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
36 |
+def test_cmake_confroot_build(cli, tmpdir, datafiles):
|
|
37 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
38 |
+ checkout = os.path.join(cli.directory, 'checkout')
|
|
39 |
+ element_name = 'cmake/cmakeconfroothello.bst'
|
|
40 |
+ |
|
41 |
+ result = cli.run(project=project, args=['build', element_name])
|
|
42 |
+ assert result.exit_code == 0
|
|
43 |
+ |
|
44 |
+ result = cli.run(project=project, args=['checkout', element_name, checkout])
|
|
45 |
+ assert result.exit_code == 0
|
|
46 |
+ |
|
47 |
+ assert_contains(checkout, ['/usr', '/usr/bin', '/usr/bin/hello',
|
|
48 |
+ '/usr/lib/debug', '/usr/lib/debug/usr',
|
|
49 |
+ '/usr/lib/debug/usr/bin',
|
|
50 |
+ '/usr/lib/debug/usr/bin/hello'])
|
|
51 |
+ |
|
52 |
+ |
|
35 | 53 |
@pytest.mark.datafiles(DATA_DIR)
|
36 | 54 |
def test_cmake_run(cli, tmpdir, datafiles):
|
37 | 55 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
1 |
+kind: autotools
|
|
2 |
+description: Autotools test
|
|
3 |
+ |
|
4 |
+depends:
|
|
5 |
+- base.bst
|
|
6 |
+ |
|
7 |
+sources:
|
|
8 |
+- kind: tar
|
|
9 |
+ url: project_dir:/files/amhello.tar.gz
|
|
10 |
+ ref: 9ba123fa4e660929e9a0aa99f0c487b7eee59c5e7594f3284d015640b90f5590
|
|
11 |
+ directory: SourceFile
|
|
12 |
+ |
|
13 |
+variables:
|
|
14 |
+ conf-root: "%{build-root}/SourceFile"
|
|
15 |
+ command-subdir: build
|
1 |
+kind: cmake
|
|
2 |
+description: Cmake test
|
|
3 |
+ |
|
4 |
+depends:
|
|
5 |
+ - base.bst
|
|
6 |
+ |
|
7 |
+sources:
|
|
8 |
+ - kind: tar
|
|
9 |
+ directory: Source
|
|
10 |
+ url: project_dir:/files/cmakehello.tar.gz
|
|
11 |
+ ref: 508266f40dbc5875293bd24c4e50a9eb6b88cbacab742033f7b92f8c087b64e5
|
|
12 |
+ |
|
13 |
+variables:
|
|
14 |
+ conf-root: "%{build-root}/Source"
|
|
15 |
+ command-subdir: build
|
1 |
+kind: manual
|
|
2 |
+description: Workspace mount test
|
|
3 |
+ |
|
4 |
+depends:
|
|
5 |
+ - filename: base.bst
|
|
6 |
+ type: build
|
|
7 |
+ |
|
8 |
+sources:
|
|
9 |
+ - kind: local
|
|
10 |
+ path: files/workspace-mount-src/
|
|
11 |
+ |
|
12 |
+variables:
|
|
13 |
+ command-subdir: build
|
|
14 |
+ |
|
15 |
+config:
|
|
16 |
+ build-commands:
|
|
17 |
+ - cc -c ../hello.c
|
... | ... | @@ -32,6 +32,23 @@ def test_workspace_mount(cli, tmpdir, datafiles): |
32 | 32 |
assert os.path.exists(os.path.join(cli.directory, 'workspace'))
|
33 | 33 |
|
34 | 34 |
|
35 |
+@pytest.mark.integration
|
|
36 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
37 |
+def test_workspace_commanddir(cli, tmpdir, datafiles):
|
|
38 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
39 |
+ workspace = os.path.join(cli.directory, 'workspace')
|
|
40 |
+ element_name = 'workspace/workspace-commanddir.bst'
|
|
41 |
+ |
|
42 |
+ res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
|
|
43 |
+ assert res.exit_code == 0
|
|
44 |
+ |
|
45 |
+ res = cli.run(project=project, args=['build', element_name])
|
|
46 |
+ assert res.exit_code == 0
|
|
47 |
+ |
|
48 |
+ assert os.path.exists(os.path.join(cli.directory, 'workspace'))
|
|
49 |
+ assert os.path.exists(os.path.join(cli.directory, 'workspace', 'build'))
|
|
50 |
+ |
|
51 |
+ |
|
35 | 52 |
@pytest.mark.integration
|
36 | 53 |
@pytest.mark.datafiles(DATA_DIR)
|
37 | 54 |
def test_workspace_updated_dependency(cli, tmpdir, datafiles):
|