-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds the possibility to enable repositories from the Ubuntu Cloud Archive. The Ubuntu Cloud Archive is a repository that enables users to install backported and patched versions of Openstack on Ubuntu LTS releases.
- Loading branch information
Showing
15 changed files
with
678 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright 2020-2023 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# 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/>. | ||
|
||
"""Ubuntu Cloud Archive helpers.""" | ||
|
||
|
||
import pathlib | ||
import subprocess | ||
|
||
from . import errors | ||
from .package_repository import RELEASE_MAP, UCA_KEYRING_PACKAGE, UCA_KEYRING_PATH | ||
|
||
|
||
def install_uca_keyring() -> bool: | ||
"""Install UCA keyring if missing.""" | ||
try: | ||
subprocess.run( | ||
["dpkg", "--status", UCA_KEYRING_PACKAGE], | ||
check=True, | ||
capture_output=True, | ||
) | ||
return False | ||
except subprocess.CalledProcessError as e: | ||
if b"not installed" not in e.stderr: | ||
raise e | ||
subprocess.run(["apt", "install", "--yes", UCA_KEYRING_PACKAGE], check=True) | ||
return True | ||
|
||
|
||
def get_uca_keyring_path() -> pathlib.Path: | ||
"""Return UCA keyring path.""" | ||
return pathlib.Path(UCA_KEYRING_PATH) | ||
|
||
|
||
def check_release_compatibility(cloud: str, codename: str) -> None: | ||
"""Raise an exception if the release is incompatible with codename.""" | ||
series = RELEASE_MAP.get(cloud) | ||
if not series or series != codename: | ||
raise errors.AptUCAInstallError(cloud, f"not a valid release for {codename!r}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.