Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2022-03-05 19:33:05 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2022-03-07 18:08:25 +0300
commit417126bee6afcf6f5f3110d7fa8f7d5c5316c8fa (patch)
treefcc8a499cac3eed6e20730e460820d88d560a7d2 /calm/package.py
parent8a55677b7ddc5f268ffd8a0759ae970a0c099ca3 (diff)
Factor out navigating from pkg to srcpkg
Diffstat (limited to 'calm/package.py')
-rwxr-xr-xcalm/package.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/calm/package.py b/calm/package.py
index 71c58af..522689e 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -79,6 +79,22 @@ class Package(object):
def versions(self):
return self.tarfiles.keys()
+ def srcpackage(self, vr, suffix=True):
+ if self.kind == Kind.source:
+ spn = self.name
+ else:
+ # source tarfile is in the external-source package, if specified,
+ # otherwise it's in the sibling source package
+ hints = self.version_hints.get(vr, {})
+ spn = hints.get('external-source', self.name + '-src')
+
+ # strip '-src' suffix?
+ if not suffix:
+ if spn.endswith('-src'):
+ spn = spn[:-4]
+
+ return spn
+
# information we keep about a tar file
class Tar(object):
@@ -419,6 +435,7 @@ def read_one_package(packages, p, relpath, dirpath, files, remove, kind, strict)
actual_tars[ovr] = tars[vr]
packages[pn] = Package()
+ packages[pn].name = pn
packages[pn].version_hints = version_hints
packages[pn].override_hints = override_hints
packages[pn].tarfiles = actual_tars
@@ -755,12 +772,7 @@ def validate_packages(args, packages, valid_requires_extra=None):
sourceless = False
missing_source = True
- # source tarfile is in the external-source package, if specified,
- # otherwise it's in the sibling source package
- if 'external-source' in packages[p].version_hints[v]:
- es_p = packages[p].version_hints[v]['external-source']
- else:
- es_p = p + '-src'
+ es_p = packages[p].srcpackage(v)
# mark the source tarfile as being used by an install tarfile
if es_p in packages:
@@ -837,7 +849,7 @@ def validate_packages(args, packages, valid_requires_extra=None):
# ignore packages which have a different external-source:
# (e.g. where a different source package supersedes this one)
- es = packages[install_p].version_hints[packages[install_p].best_version].get('external-source', source_p)
+ es = packages[install_p].srcpackage(packages[install_p].best_version)
if es != source_p:
continue
@@ -902,7 +914,7 @@ def validate_package_maintainers(args, packages):
# validate that the source package has a maintainer
bv = packages[p].best_version
if bv:
- es = packages[p].version_hints[bv].get('external-source', p)
+ es = packages[p].srcpackage(bv)
if es in packages:
es_pn = packages[es].orig_name
if es_pn not in all_packages and p not in all_packages:
@@ -1084,12 +1096,9 @@ def write_setup_ini(args, packages, arch):
hints = po.version_hints.get(version, {})
# follow external-source
- if 'external-source' in hints:
- s = hints['external-source']
- else:
- s = sibling_src
- if s not in packages:
- s = None
+ s = po.srcpackage(version)
+ if s not in packages:
+ s = None
# external-source points to a source file in another package
if s: