lifted directories should be under share_dir and lib_dir
Otherwise passing --sharedir pointed to some other path will not use the correct providers.
This commit is contained in:
parent
1a6bc098d9
commit
1b84f90963
35
src/lifted/config.py
Normal file
35
src/lifted/config.py
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright (C) 2019 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from pylorax.sysutils import joinpaths
|
||||
|
||||
def configure(conf):
|
||||
"""Add lifted settings to the configuration
|
||||
|
||||
:param conf: configuration object
|
||||
:type conf: ComposerConfig
|
||||
:returns: None
|
||||
|
||||
This uses the composer.share_dir and composer.lib_dir as the base
|
||||
directories for the settings.
|
||||
"""
|
||||
share_dir = conf.get("composer", "share_dir")
|
||||
lib_dir = conf.get("composer", "lib_dir")
|
||||
|
||||
conf.add_section("upload")
|
||||
conf.set("upload", "providers_dir", joinpaths(share_dir, "/lifted/providers/"))
|
||||
conf.set("upload", "queue_dir", joinpaths(lib_dir, "/upload/queue/"))
|
||||
conf.set("upload", "settings_dir", joinpaths(lib_dir, "/upload/settings/"))
|
@ -38,6 +38,8 @@ def configure(conf_file="/etc/lorax/composer.conf", root_dir="/", test_config=Fa
|
||||
:type root_dir: str
|
||||
:param test_config: Set to True to skip reading conf_file
|
||||
:type test_config: bool
|
||||
:returns: Configuration
|
||||
:rtype: ComposerConfig
|
||||
"""
|
||||
conf = ComposerConfig()
|
||||
|
||||
@ -54,11 +56,6 @@ def configure(conf_file="/etc/lorax/composer.conf", root_dir="/", test_config=Fa
|
||||
conf.add_section("users")
|
||||
conf.set("users", "root", "1")
|
||||
|
||||
conf.add_section("upload")
|
||||
conf.set("upload", "providers_dir", os.path.realpath(joinpaths(root_dir, "/usr/share/lorax/lifted/providers/")))
|
||||
conf.set("upload", "queue_dir", os.path.realpath(joinpaths(root_dir, "/var/lib/lorax/upload/queue")))
|
||||
conf.set("upload", "settings_dir", os.path.realpath(joinpaths(root_dir, "/var/lib/lorax/upload/settings")))
|
||||
|
||||
# Enable all available repo files by default
|
||||
conf.add_section("repos")
|
||||
conf.set("repos", "use_system_repos", "1")
|
||||
|
@ -44,6 +44,7 @@ from pylorax.api.queue import start_queue_monitor
|
||||
from pylorax.api.recipes import open_or_create_repo, commit_recipe_directory
|
||||
from pylorax.api.server import server, GitLock
|
||||
|
||||
import lifted.config
|
||||
from lifted.queue import start_upload_monitor
|
||||
|
||||
VERSION = "{0}-{1}".format(os.path.basename(sys.argv[0]), vernum)
|
||||
@ -208,6 +209,9 @@ if __name__ == '__main__':
|
||||
if opts.no_system_repos:
|
||||
server.config["COMPOSER_CFG"].set("repos", "use_system_repos", "0")
|
||||
|
||||
# Setup the lifted configuration settings
|
||||
lifted.config.configure(server.config["COMPOSER_CFG"])
|
||||
|
||||
# Make sure the queue paths are setup correctly, exit on errors
|
||||
errors = make_queue_dirs(server.config["COMPOSER_CFG"], gid)
|
||||
if errors:
|
||||
|
@ -20,6 +20,7 @@ import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import lifted.config
|
||||
from pylorax import get_buildarch
|
||||
from pylorax.api.compose import add_customizations, get_extra_pkgs, compose_types
|
||||
from pylorax.api.compose import timezone_cmd, get_timezone_settings
|
||||
@ -804,6 +805,7 @@ class ExtraPkgsTest(unittest.TestCase):
|
||||
def setUpClass(self):
|
||||
self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
|
||||
self.config = configure(root_dir=self.tmp_dir, test_config=True)
|
||||
lifted.config.configure(self.config)
|
||||
make_dnf_dirs(self.config, os.getuid(), os.getgid())
|
||||
self.dbo = get_base_object(self.config)
|
||||
|
||||
|
@ -21,6 +21,7 @@ import unittest
|
||||
|
||||
import configparser
|
||||
|
||||
import lifted.config
|
||||
from pylorax.api.config import configure, make_dnf_dirs
|
||||
from pylorax.api.dnfbase import get_base_object
|
||||
|
||||
@ -42,6 +43,7 @@ use_system_repos = False
|
||||
|
||||
# will read the above configuration
|
||||
config = configure(conf_file=conf_file, root_dir=self.tmp_dir)
|
||||
lifted.config.configure(config)
|
||||
make_dnf_dirs(config, os.getuid(), os.getgid())
|
||||
|
||||
# will read composer config and store a dnf config file
|
||||
@ -76,6 +78,7 @@ class DnfbaseSystemReposTest(unittest.TestCase):
|
||||
|
||||
# will read the above configuration
|
||||
config = configure(root_dir=self.tmp_dir)
|
||||
lifted.config.configure(config)
|
||||
make_dnf_dirs(config, os.getuid(), os.getgid())
|
||||
|
||||
# will read composer config and store a dnf config file
|
||||
@ -105,6 +108,7 @@ class CreateDnfDirsTest(unittest.TestCase):
|
||||
|
||||
def test_creates_missing_dnf_root_directory(self):
|
||||
config = configure(test_config=True, root_dir=self.tmp_dir)
|
||||
lifted.config.configure(config)
|
||||
|
||||
# will create the above directory if missing
|
||||
make_dnf_dirs(config, os.getuid(), os.getgid())
|
||||
|
@ -22,6 +22,7 @@ import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import lifted.config
|
||||
from pylorax.sysutils import joinpaths
|
||||
from pylorax.api.config import configure, make_dnf_dirs
|
||||
from pylorax.api.projects import api_time, api_changelog, pkg_to_project, pkg_to_project_info, pkg_to_dep
|
||||
@ -49,6 +50,7 @@ class ProjectsTest(unittest.TestCase):
|
||||
def setUpClass(self):
|
||||
self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
|
||||
self.config = configure(root_dir=self.tmp_dir, test_config=True)
|
||||
lifted.config.configure(self.config)
|
||||
make_dnf_dirs(self.config, os.getuid(), os.getgid())
|
||||
self.dbo = get_base_object(self.config)
|
||||
os.environ["TZ"] = "UTC"
|
||||
@ -215,10 +217,12 @@ class ConfigureTest(unittest.TestCase):
|
||||
|
||||
def test_configure_reads_existing_file(self):
|
||||
config = configure(conf_file=self.conf_file)
|
||||
lifted.config.configure(config)
|
||||
self.assertEqual(config.get('composer', 'cache_dir'), '/tmp/cache-test')
|
||||
|
||||
def test_configure_reads_non_existing_file(self):
|
||||
config = configure(conf_file=self.conf_file + '.non-existing')
|
||||
lifted.config.configure(config)
|
||||
self.assertEqual(config.get('composer', 'cache_dir'), '/var/tmp/composer/cache')
|
||||
|
||||
def fakerepo_baseurl_v0():
|
||||
|
@ -20,6 +20,7 @@ import tempfile
|
||||
import unittest
|
||||
from uuid import uuid4
|
||||
|
||||
import lifted.config
|
||||
from pylorax.api.config import configure, make_queue_dirs
|
||||
from pylorax.api.queue import check_queues
|
||||
from pylorax.base import DataHolder
|
||||
@ -36,6 +37,7 @@ class QueueTestCase(unittest.TestCase):
|
||||
self.config["REPO_DIR"] = repo_dir
|
||||
|
||||
self.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
|
||||
lifted.config.configure(self.config["COMPOSER_CFG"])
|
||||
os.makedirs(joinpaths(self.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
|
||||
errors = make_queue_dirs(self.config["COMPOSER_CFG"], os.getgid())
|
||||
if errors:
|
||||
|
@ -29,6 +29,7 @@ import unittest
|
||||
|
||||
from flask import json
|
||||
from ..lib import create_git_repo
|
||||
import lifted.config
|
||||
from pylorax.api.config import configure, make_dnf_dirs, make_queue_dirs
|
||||
from pylorax.api.errors import * # pylint: disable=wildcard-import
|
||||
from pylorax.api.queue import start_queue_monitor
|
||||
@ -112,6 +113,7 @@ class ServerAPIV0TestCase(unittest.TestCase):
|
||||
server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=repo_dir)
|
||||
|
||||
server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
|
||||
lifted.config.configure(server.config["COMPOSER_CFG"])
|
||||
os.makedirs(joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
|
||||
errors = make_queue_dirs(server.config["COMPOSER_CFG"], os.getgid())
|
||||
if errors:
|
||||
@ -1758,6 +1760,7 @@ class ServerAPIV1TestCase(unittest.TestCase):
|
||||
server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=repo_dir)
|
||||
|
||||
server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
|
||||
lifted.config.configure(server.config["COMPOSER_CFG"])
|
||||
os.makedirs(joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
|
||||
errors = make_queue_dirs(server.config["COMPOSER_CFG"], os.getgid())
|
||||
if errors:
|
||||
@ -3517,6 +3520,7 @@ class RepoCacheAPIV0TestCase(unittest.TestCase):
|
||||
server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=repo_dir)
|
||||
|
||||
server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
|
||||
lifted.config.configure(server.config["COMPOSER_CFG"])
|
||||
os.makedirs(joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
|
||||
errors = make_queue_dirs(server.config["COMPOSER_CFG"], os.getgid())
|
||||
if errors:
|
||||
@ -3656,6 +3660,7 @@ class RepoCacheAPIV1TestCase(unittest.TestCase):
|
||||
server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=repo_dir)
|
||||
|
||||
server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
|
||||
lifted.config.configure(server.config["COMPOSER_CFG"])
|
||||
os.makedirs(joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
|
||||
errors = make_queue_dirs(server.config["COMPOSER_CFG"], os.getgid())
|
||||
if errors:
|
||||
@ -3797,6 +3802,7 @@ class GitRPMBlueprintTestCase(unittest.TestCase):
|
||||
server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=repo_dir)
|
||||
|
||||
server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
|
||||
lifted.config.configure(server.config["COMPOSER_CFG"])
|
||||
os.makedirs(joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
|
||||
errors = make_queue_dirs(server.config["COMPOSER_CFG"], os.getgid())
|
||||
if errors:
|
||||
|
Loading…
Reference in New Issue
Block a user