2016-03-21 09:58:36 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
import json
|
2018-08-10 07:54:30 +00:00
|
|
|
import os
|
2016-03-21 09:58:36 +00:00
|
|
|
|
2018-08-10 07:54:30 +00:00
|
|
|
import mock
|
2019-10-04 12:45:03 +00:00
|
|
|
import six
|
2018-08-10 07:54:30 +00:00
|
|
|
import yaml
|
|
|
|
|
2016-03-21 09:58:36 +00:00
|
|
|
from tests import helpers
|
2016-04-05 07:13:01 +00:00
|
|
|
from pungi import ostree
|
2016-03-21 09:58:36 +00:00
|
|
|
|
|
|
|
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
class OstreeTreeScriptTest(helpers.PungiTestCase):
|
2018-09-13 14:14:57 +00:00
|
|
|
def setUp(self):
|
|
|
|
super(OstreeTreeScriptTest, self).setUp()
|
|
|
|
self.repo = os.path.join(self.topdir, "atomic")
|
|
|
|
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
def _make_dummy_config_dir(self, path):
|
2020-01-22 10:02:22 +00:00
|
|
|
helpers.touch(
|
|
|
|
os.path.join(path, "fedora-atomic-docker-host.json"),
|
|
|
|
json.dumps(
|
|
|
|
{
|
|
|
|
"ref": "fedora-atomic/25/x86_64",
|
|
|
|
"repos": ["fedora-rawhide", "fedora-24", "fedora-23"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
os.path.join(path, "fedora-atomic-docker-host.yaml"),
|
|
|
|
yaml.dump(
|
|
|
|
{
|
|
|
|
"ref": "fedora-atomic/25/x86_64",
|
|
|
|
"repos": ["fedora-rawhide", "fedora-24", "fedora-23"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
os.path.join(path, "fedora-rawhide.repo"),
|
|
|
|
"[fedora-rawhide]\nmirrorlist=mirror-mirror-on-the-wall",
|
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
os.path.join(path, "fedora-24.repo"),
|
|
|
|
"[fedora-24]\nmetalink=who-is-the-fairest-of-them-all",
|
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
os.path.join(path, "fedora-23.repo"),
|
|
|
|
"[fedora-23]\nbaseurl=why-not-zoidberg?",
|
|
|
|
)
|
2016-03-21 09:58:36 +00:00
|
|
|
|
2018-09-13 14:14:57 +00:00
|
|
|
def assertCorrectCall(self, mock_run, extra_calls=[], extra_args=[]):
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-09-13 14:14:57 +00:00
|
|
|
mock_run.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
[
|
|
|
|
"rpm-ostree",
|
|
|
|
"compose",
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
2020-01-22 10:02:22 +00:00
|
|
|
"--write-commitid-to=%s"
|
|
|
|
% (self.topdir + "/logs/Atomic/commitid.log"),
|
|
|
|
"--touch-if-changed=%s.stamp"
|
|
|
|
% (self.topdir + "/logs/Atomic/commitid.log"),
|
|
|
|
]
|
|
|
|
+ extra_args
|
|
|
|
+ [self.topdir + "/fedora-atomic-docker-host.json"],
|
2018-09-13 14:14:57 +00:00
|
|
|
logfile=self.topdir + "/logs/Atomic/create-ostree-repo.log",
|
|
|
|
show_cmd=True,
|
|
|
|
stdout=True,
|
2019-10-02 12:44:26 +00:00
|
|
|
universal_newlines=True,
|
2018-09-13 14:14:57 +00:00
|
|
|
)
|
2020-01-22 10:02:22 +00:00
|
|
|
]
|
|
|
|
+ extra_calls,
|
2018-09-13 14:14:57 +00:00
|
|
|
)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-04-07 12:33:37 +00:00
|
|
|
def test_full_run(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json" % self.topdir,
|
|
|
|
]
|
|
|
|
)
|
2016-04-05 06:40:54 +00:00
|
|
|
|
2018-09-13 14:14:57 +00:00
|
|
|
self.assertCorrectCall(run)
|
2016-03-21 09:58:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-05-09 13:59:02 +00:00
|
|
|
def test_run_on_existing_empty_dir(self, run):
|
2018-09-13 14:14:57 +00:00
|
|
|
os.mkdir(self.repo)
|
2016-05-09 13:59:02 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json" % self.topdir,
|
|
|
|
]
|
|
|
|
)
|
2016-05-09 13:59:02 +00:00
|
|
|
|
2018-09-13 14:14:57 +00:00
|
|
|
self.assertCorrectCall(run)
|
2016-05-09 13:59:02 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-05-09 13:59:02 +00:00
|
|
|
def test_run_on_initialized_repo(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
helpers.touch(os.path.join(self.repo, "initialized"))
|
2016-05-09 13:59:02 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json" % self.topdir,
|
|
|
|
]
|
|
|
|
)
|
2016-05-09 13:59:02 +00:00
|
|
|
|
2018-09-13 14:14:57 +00:00
|
|
|
self.assertCorrectCall(run)
|
2016-05-09 13:59:02 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-11-03 12:59:00 +00:00
|
|
|
def test_update_summary(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json" % self.topdir,
|
|
|
|
"--update-summary",
|
|
|
|
]
|
|
|
|
)
|
2016-11-03 12:59:00 +00:00
|
|
|
|
2018-09-13 14:14:57 +00:00
|
|
|
self.assertCorrectCall(
|
|
|
|
run,
|
|
|
|
extra_calls=[
|
|
|
|
mock.call(
|
|
|
|
["ostree", "summary", "-u", "--repo=%s" % self.repo],
|
|
|
|
logfile=self.topdir + "/logs/Atomic/ostree-summary.log",
|
|
|
|
show_cmd=True,
|
|
|
|
stdout=True,
|
2019-10-02 12:44:26 +00:00
|
|
|
universal_newlines=True,
|
2018-09-13 14:14:57 +00:00
|
|
|
)
|
2020-01-22 10:02:22 +00:00
|
|
|
],
|
2018-09-13 14:14:57 +00:00
|
|
|
)
|
2016-11-03 12:59:00 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-11-04 08:07:26 +00:00
|
|
|
def test_versioning_metadata(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json" % self.topdir,
|
|
|
|
"--version=24",
|
|
|
|
]
|
|
|
|
)
|
2016-11-04 08:07:26 +00:00
|
|
|
|
2018-09-13 14:14:57 +00:00
|
|
|
self.assertCorrectCall(run, extra_args=["--add-metadata-string=version=24"])
|
2016-03-21 09:58:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2017-12-04 14:15:20 +00:00
|
|
|
def test_ostree_ref(self, run):
|
|
|
|
self._make_dummy_config_dir(self.topdir)
|
2020-01-22 10:02:22 +00:00
|
|
|
treefile = os.path.join(self.topdir, "fedora-atomic-docker-host.json")
|
2017-12-04 14:15:20 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with open(treefile, "r") as f:
|
2017-12-04 14:15:20 +00:00
|
|
|
treefile_content = json.load(f)
|
2020-01-22 10:02:22 +00:00
|
|
|
original_repos = treefile_content["repos"]
|
|
|
|
original_ref = treefile_content["ref"]
|
|
|
|
replacing_ref = original_ref + "-changed"
|
|
|
|
|
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s" % treefile,
|
|
|
|
"--ostree-ref=%s" % replacing_ref,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
with open(treefile, "r") as f:
|
2017-12-04 14:15:20 +00:00
|
|
|
treefile_content = json.load(f)
|
2020-01-22 10:02:22 +00:00
|
|
|
new_repos = treefile_content["repos"]
|
|
|
|
new_ref = treefile_content["ref"]
|
2017-12-04 14:15:20 +00:00
|
|
|
|
|
|
|
# ref value in treefile should be overrided with new ref
|
|
|
|
self.assertEqual(replacing_ref, new_ref)
|
|
|
|
# repos should stay unchanged
|
|
|
|
self.assertEqual(original_repos, new_repos)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2018-08-10 07:54:30 +00:00
|
|
|
def test_run_with_yaml_file(self, run):
|
|
|
|
self._make_dummy_config_dir(self.topdir)
|
2020-01-22 10:02:22 +00:00
|
|
|
treefile = os.path.join(self.topdir, "fedora-atomic-docker-host.yaml")
|
2018-08-10 07:54:30 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with open(treefile, "r") as f:
|
2018-08-10 07:54:30 +00:00
|
|
|
# Read initial content from YAML file
|
2018-11-13 20:11:02 +00:00
|
|
|
treefile_content = yaml.safe_load(f)
|
2020-01-22 10:02:22 +00:00
|
|
|
original_repos = treefile_content["repos"]
|
|
|
|
original_ref = treefile_content["ref"]
|
|
|
|
replacing_ref = original_ref + "-changed"
|
|
|
|
|
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s" % treefile,
|
|
|
|
"--ostree-ref=%s" % replacing_ref,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
with open(treefile.replace(".yaml", ".json"), "r") as f:
|
2018-08-10 07:54:30 +00:00
|
|
|
# There is now a tweaked JSON file
|
|
|
|
treefile_content = json.load(f)
|
2020-01-22 10:02:22 +00:00
|
|
|
new_repos = treefile_content["repos"]
|
|
|
|
new_ref = treefile_content["ref"]
|
2018-08-10 07:54:30 +00:00
|
|
|
|
|
|
|
# ref value in treefile should be overrided with new ref
|
|
|
|
self.assertEqual(replacing_ref, new_ref)
|
|
|
|
# repos should stay unchanged
|
|
|
|
self.assertEqual(original_repos, new_repos)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2018-01-11 14:08:07 +00:00
|
|
|
def test_force_new_commit(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
helpers.touch(os.path.join(self.repo, "initialized"))
|
2018-01-11 14:08:07 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json" % self.topdir,
|
|
|
|
"--force-new-commit",
|
|
|
|
]
|
|
|
|
)
|
2018-01-11 14:08:07 +00:00
|
|
|
|
2018-09-13 14:14:57 +00:00
|
|
|
self.assertCorrectCall(run, extra_args=["--force-nocache"])
|
2018-01-11 14:08:07 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2018-01-12 11:55:04 +00:00
|
|
|
def test_extra_config_with_extra_repos(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
configdir = os.path.join(self.topdir, "config")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
self._make_dummy_config_dir(configdir)
|
2020-01-22 10:02:22 +00:00
|
|
|
treefile = os.path.join(configdir, "fedora-atomic-docker-host.json")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_config_file = os.path.join(self.topdir, "extra_config.json")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
extra_config = {
|
2017-02-22 02:48:05 +00:00
|
|
|
"repo": [
|
2020-01-22 10:02:22 +00:00
|
|
|
{"name": "server", "baseurl": "http://www.example.com/Server/repo"},
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
{
|
|
|
|
"name": "optional",
|
|
|
|
"baseurl": "http://example.com/repo/x86_64/optional",
|
|
|
|
"exclude": "systemd-container",
|
2020-01-22 10:02:22 +00:00
|
|
|
"gpgcheck": False,
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
{"name": "extra", "baseurl": "http://example.com/repo/x86_64/extra"},
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
helpers.touch(extra_config_file, json.dumps(extra_config))
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s" % treefile,
|
|
|
|
"--extra-config=%s" % extra_config_file,
|
|
|
|
]
|
|
|
|
)
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
|
2018-01-12 11:55:04 +00:00
|
|
|
pungi_repo = os.path.join(configdir, "pungi.repo")
|
|
|
|
self.assertTrue(os.path.isfile(pungi_repo))
|
2020-01-22 10:02:22 +00:00
|
|
|
with open(pungi_repo, "r") as f:
|
2018-01-12 11:55:04 +00:00
|
|
|
content = f.read().strip()
|
|
|
|
result_template = (
|
|
|
|
"[repo-0]",
|
|
|
|
"name=repo-0",
|
|
|
|
"baseurl=http://example.com/repo/x86_64/extra",
|
|
|
|
"gpgcheck=0",
|
|
|
|
"[repo-1]",
|
|
|
|
"name=repo-1",
|
|
|
|
"baseurl=http://example.com/repo/x86_64/optional",
|
|
|
|
"exclude=systemd-container",
|
|
|
|
"gpgcheck=0",
|
|
|
|
"[repo-2]",
|
|
|
|
"name=repo-2",
|
|
|
|
"baseurl=http://www.example.com/Server/repo",
|
|
|
|
"gpgcheck=0",
|
|
|
|
)
|
2020-01-22 10:02:22 +00:00
|
|
|
result = "\n".join(result_template).strip()
|
2018-01-12 11:55:04 +00:00
|
|
|
self.assertEqual(content, result)
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
treeconf = json.load(open(treefile, "r"))
|
|
|
|
repos = treeconf["repos"]
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
self.assertEqual(len(repos), 3)
|
2018-01-12 11:55:04 +00:00
|
|
|
for name in ("repo-0", "repo-1", "repo-2"):
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
self.assertIn(name, repos)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2018-01-12 11:55:04 +00:00
|
|
|
def test_extra_config_with_keep_original_sources(self, run):
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
configdir = os.path.join(self.topdir, "config")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
self._make_dummy_config_dir(configdir)
|
2020-01-22 10:02:22 +00:00
|
|
|
treefile = os.path.join(configdir, "fedora-atomic-docker-host.json")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_config_file = os.path.join(self.topdir, "extra_config.json")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
extra_config = {
|
2017-02-22 02:48:05 +00:00
|
|
|
"repo": [
|
2020-01-22 10:02:22 +00:00
|
|
|
{"name": "server", "baseurl": "http://www.example.com/Server/repo"},
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
{
|
|
|
|
"name": "optional",
|
|
|
|
"baseurl": "http://example.com/repo/x86_64/optional",
|
|
|
|
"exclude": "systemd-container",
|
2020-01-22 10:02:22 +00:00
|
|
|
"gpgcheck": False,
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
{"name": "extra", "baseurl": "http://example.com/repo/x86_64/extra"},
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
],
|
2020-01-22 10:02:22 +00:00
|
|
|
"keep_original_sources": True,
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
}
|
|
|
|
helpers.touch(extra_config_file, json.dumps(extra_config))
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ostree.main(
|
|
|
|
[
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s" % os.path.join(self.topdir, "logs", "Atomic"),
|
|
|
|
"--treefile=%s" % treefile,
|
|
|
|
"--extra-config=%s" % extra_config_file,
|
|
|
|
]
|
|
|
|
)
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
treeconf = json.load(open(treefile, "r"))
|
|
|
|
repos = treeconf["repos"]
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
self.assertEqual(len(repos), 6)
|
2020-01-22 10:02:22 +00:00
|
|
|
for name in [
|
|
|
|
"fedora-rawhide",
|
|
|
|
"fedora-24",
|
|
|
|
"fedora-23",
|
|
|
|
"repo-0",
|
|
|
|
"repo-1",
|
|
|
|
"repo-2",
|
|
|
|
]:
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
self.assertIn(name, repos)
|
|
|
|
|
2016-12-04 18:02:51 +00:00
|
|
|
|
|
|
|
class OstreeInstallerScriptTest(helpers.PungiTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(OstreeInstallerScriptTest, self).setUp()
|
|
|
|
self.product = "dummyproduct"
|
|
|
|
self.version = "1.0"
|
|
|
|
self.release = "20160101.t.0"
|
2020-01-22 10:02:22 +00:00
|
|
|
self.output = os.path.join(self.topdir, "output")
|
|
|
|
self.logdir = os.path.join(self.topdir, "logs")
|
|
|
|
self.volid = "%s-%s" % (self.product, self.version)
|
|
|
|
self.variant = "dummy"
|
2016-12-04 18:02:51 +00:00
|
|
|
self.rootfs_size = None
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-12-04 18:02:51 +00:00
|
|
|
def test_run_with_args(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
args = [
|
|
|
|
"installer",
|
|
|
|
"--product=%s" % self.product,
|
|
|
|
"--version=%s" % self.version,
|
|
|
|
"--release=%s" % self.release,
|
|
|
|
"--output=%s" % self.output,
|
|
|
|
"--variant=%s" % self.variant,
|
|
|
|
"--rootfs-size=%s" % self.rootfs_size,
|
|
|
|
"--nomacboot",
|
|
|
|
"--isfinal",
|
|
|
|
]
|
|
|
|
args.append("--source=%s" % "http://www.example.com/dummy/repo")
|
|
|
|
args.append("--installpkgs=dummy-foo")
|
|
|
|
args.append("--installpkgs=dummy-bar")
|
|
|
|
args.append("--add-template=/path/to/lorax.tmpl")
|
|
|
|
args.append("--add-template-var=ostree_osname=dummy")
|
|
|
|
args.append("--add-arch-template=/path/to/lorax-embed.tmpl")
|
|
|
|
args.append("--add-arch-template-var=ostree_repo=http://www.example.com/ostree")
|
2016-12-04 18:02:51 +00:00
|
|
|
ostree.main(args)
|
|
|
|
self.maxDiff = None
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
|
|
|
run.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
[
|
|
|
|
"lorax",
|
|
|
|
"--product=dummyproduct",
|
|
|
|
"--version=1.0",
|
|
|
|
"--release=20160101.t.0",
|
|
|
|
"--source=http://www.example.com/dummy/repo",
|
|
|
|
"--variant=dummy",
|
|
|
|
"--nomacboot",
|
|
|
|
"--isfinal",
|
|
|
|
"--installpkgs=dummy-foo",
|
|
|
|
"--installpkgs=dummy-bar",
|
|
|
|
"--add-template=/path/to/lorax.tmpl",
|
|
|
|
"--add-arch-template=/path/to/lorax-embed.tmpl",
|
|
|
|
"--add-template-var=ostree_osname=dummy",
|
2020-02-06 07:09:32 +00:00
|
|
|
"--add-arch-template-var=ostree_repo=http://www.example.com/ostree", # noqa: E501
|
2019-10-04 12:45:03 +00:00
|
|
|
"--rootfs-size=None",
|
|
|
|
self.output,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2016-12-04 18:02:51 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-12-04 18:02:51 +00:00
|
|
|
def test_run_with_extra_config_file(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_config_file = os.path.join(self.topdir, "extra_config.json")
|
|
|
|
helpers.touch(
|
|
|
|
extra_config_file,
|
|
|
|
json.dumps(
|
|
|
|
{
|
|
|
|
"repo": "http://www.example.com/another/repo",
|
|
|
|
"installpkgs": ["dummy-foo", "dummy-bar"],
|
|
|
|
"add_template": ["/path/to/lorax.tmpl"],
|
|
|
|
"add_template_var": [
|
|
|
|
"ostree_osname=dummy-atomic",
|
|
|
|
"ostree_ref=dummy/x86_64/docker",
|
|
|
|
],
|
|
|
|
"add_arch_template": ["/path/to/lorax-embed.tmpl"],
|
|
|
|
"add_arch_template_var": [
|
|
|
|
"ostree_osname=dummy-atomic",
|
|
|
|
"ostree_repo=http://www.example.com/ostree",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
args = [
|
|
|
|
"installer",
|
|
|
|
"--product=%s" % self.product,
|
|
|
|
"--version=%s" % self.version,
|
|
|
|
"--release=%s" % self.release,
|
|
|
|
"--output=%s" % self.output,
|
|
|
|
"--variant=%s" % self.variant,
|
|
|
|
"--rootfs-size=%s" % self.rootfs_size,
|
|
|
|
"--nomacboot",
|
|
|
|
"--isfinal",
|
|
|
|
]
|
|
|
|
args.append("--source=%s" % "http://www.example.com/dummy/repo")
|
|
|
|
args.append("--extra-config=%s" % extra_config_file)
|
2016-12-04 18:02:51 +00:00
|
|
|
ostree.main(args)
|
|
|
|
self.maxDiff = None
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
|
|
|
run.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
[
|
|
|
|
"lorax",
|
|
|
|
"--product=dummyproduct",
|
|
|
|
"--version=1.0",
|
|
|
|
"--release=20160101.t.0",
|
|
|
|
"--source=http://www.example.com/dummy/repo",
|
|
|
|
"--variant=dummy",
|
|
|
|
"--nomacboot",
|
|
|
|
"--isfinal",
|
|
|
|
"--installpkgs=dummy-foo",
|
|
|
|
"--installpkgs=dummy-bar",
|
|
|
|
"--add-template=/path/to/lorax.tmpl",
|
|
|
|
"--add-arch-template=/path/to/lorax-embed.tmpl",
|
|
|
|
"--add-template-var=ostree_osname=dummy-atomic",
|
|
|
|
"--add-template-var=ostree_ref=dummy/x86_64/docker",
|
|
|
|
"--add-arch-template-var=ostree_osname=dummy-atomic",
|
2020-02-06 07:09:32 +00:00
|
|
|
"--add-arch-template-var=ostree_repo=http://www.example.com/ostree", # noqa: E501
|
2019-10-04 12:45:03 +00:00
|
|
|
"--rootfs-size=None",
|
|
|
|
self.output,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|