aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorNicolas Lécureuil <neoclust@mageia.org>2015-11-28 14:14:24 +0100
committerNicolas Lécureuil <neoclust@mageia.org>2015-11-28 14:14:37 +0100
commit4521eb9e1425919f6e6a87011098c2a3490295c4 (patch)
treeb7018b596d494d57637ba47054f56bb01ab1d908 /MgaRepo
parent300b17538e211372f7e7a90f36ba062f92b6ac68 (diff)
downloadmgarepo-4521eb9e1425919f6e6a87011098c2a3490295c4.tar
mgarepo-4521eb9e1425919f6e6a87011098c2a3490295c4.tar.gz
mgarepo-4521eb9e1425919f6e6a87011098c2a3490295c4.tar.bz2
mgarepo-4521eb9e1425919f6e6a87011098c2a3490295c4.tar.xz
mgarepo-4521eb9e1425919f6e6a87011098c2a3490295c4.zip
Add support for backports checkout MGA#15251
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/commands/co.py2
-rw-r--r--MgaRepo/layout.py16
-rw-r--r--MgaRepo/rpmutil.py6
3 files changed, 16 insertions, 8 deletions
diff --git a/MgaRepo/commands/co.py b/MgaRepo/commands/co.py
index 24ce257..a6911cc 100644
--- a/MgaRepo/commands/co.py
+++ b/MgaRepo/commands/co.py
@@ -21,6 +21,7 @@ Options:
-r REV Revision to checkout
-s Only checkout the SPECS/ directory
-M Do not use the mirror (use the main repository)
+ -k the package backport branch
-h Show this message
Examples:
@@ -36,6 +37,7 @@ def parse_options():
parser.add_option("-r", dest="revision")
parser.add_option("--distribution", "-d", dest="distro", default=None)
parser.add_option("--branch", "-b", dest="branch", default=None)
+ parser.add_option("--backports", "-k", dest="backports", default=None)
parser.add_option("-s", "--spec", dest="spec", default=False,
action="store_true")
parser.add_option("-M", "--no-mirror", action="callback",
diff --git a/MgaRepo/layout.py b/MgaRepo/layout.py
index e1cc6f4..2cc670e 100644
--- a/MgaRepo/layout.py
+++ b/MgaRepo/layout.py
@@ -13,7 +13,9 @@ def layout_dirs():
devel_branch = os.path.normpath(devel_branch)
branches_dir = config.get("global", "branches-dir", "updates/")
branches_dir = os.path.normpath(branches_dir)
- return devel_branch, branches_dir
+ backports_dir = config.get("global", "backports-dir", "backports/")
+ backports_dir = os.path.normpath(backports_dir)
+ return devel_branch, branches_dir, backports_dir
def get_url_revision(url, retrieve=True):
"""Get the revision from a given URL
@@ -69,7 +71,7 @@ def split_url_revision(url):
newurl = urllib.parse.urlunparse(parsed)
return newurl, rev
-def checkout_url(pkgdirurl, branch=None, version=None, release=None,
+def checkout_url(pkgdirurl, branch=None, version=None, release=None, backports=None,
releases=False, pristine=False, append_path=None):
"""Get the URL of a branch of the package, defaults to current/
@@ -130,7 +132,7 @@ def repository_url(mirrored=False):
url = convert_default_parent(default_parent)
return url
-def package_url(name_or_url, version=None, release=None, distro=None,
+def package_url(name_or_url, version=None, release=None, distro=None, backports=None,
mirrored=True):
"""Returns a tuple with the absolute package URL and its name
@@ -139,6 +141,7 @@ def package_url(name_or_url, version=None, release=None, distro=None,
@version: the version to be fetched from releases/ (requires release)
@release: the release number to be fetched from releases/$version/
@distro: the name of the repository branch inside updates/
+ @backports: the name of the repository branch inside backports/
@mirrored: return an URL based on the mirror repository, if enabled
"""
from MgaRepo import mirror
@@ -150,11 +153,13 @@ def package_url(name_or_url, version=None, release=None, distro=None,
repository_url(), pkgdirurl)
else:
name = name_or_url
- devel_branch, branches_dir = layout_dirs()
+ devel_branch, branches_dir, backports_dir = layout_dirs()
if distro or "/" in name:
default_branch = branches_dir
if distro:
default_branch = os.path.join(default_branch, distro)
+ elif backports:
+ default_branch = os.path.join(backports_dir, backports)
else:
default_branch = devel_branch # cauldron
path = os.path.join(default_branch, name)
@@ -187,7 +192,7 @@ def distro_branch(pkgdirurl):
found = None
repo = repository_url()
if same_base(repo, pkgdirurl):
- devel_branch, branches_dir = layout_dirs()
+ devel_branch, branches_dir, backports_dir = layout_dirs()
repo_path = urllib.parse.urlparse(repo)[2]
devel_path = os.path.join(repo_path, devel_branch)
branches_path = os.path.join(repo_path, branches_dir)
@@ -203,5 +208,6 @@ def distro_branch(pkgdirurl):
found = comps[1]
elif len(comps) >= 2: # must be at least branch/pkgname
found = comps[branches_path.count("/")+1]
+
return found
diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py
index 321c47d..531c5fc 100644
--- a/MgaRepo/rpmutil.py
+++ b/MgaRepo/rpmutil.py
@@ -457,14 +457,14 @@ def check_changed(pkgdirurl, all=0, show=0, verbose=0):
"nocurrent": nocurrent,
"nopristine": nopristine}
-def checkout(pkgdirurl, path=None, revision=None, branch=None, distro=None,
+def checkout(pkgdirurl, path=None, revision=None, branch=None, distro=None, backports=None,
spec=False):
o_pkgdirurl = pkgdirurl
- pkgdirurl = layout.package_url(o_pkgdirurl, distro=distro)
+ pkgdirurl = layout.package_url(o_pkgdirurl, distro=distro, backports=backports)
append = None
if spec:
append = "SPECS"
- current = layout.checkout_url(pkgdirurl, branch=branch,
+ current = layout.checkout_url(pkgdirurl, branch=branch, backports=backports,
append_path=append)
if path is None:
path = layout.package_name(pkgdirurl)