Reuse function of accept to check local links
This commit is contained in:
parent
886dc106eb
commit
2bfc87088d
@ -66,7 +66,7 @@ def _full_project_name(self, project):
|
||||
|
||||
def lock_needed(cmd, opts):
|
||||
return not(
|
||||
cmd in ('check', 'check_duplicate_binaries', 'frozenage', 'rebuild', 'unlock') or
|
||||
cmd in ('check', 'check_duplicate_binaries', 'check_local_links', 'frozenage', 'rebuild', 'unlock') or
|
||||
(cmd == 'list' and not opts.supersede)
|
||||
)
|
||||
|
||||
@ -137,6 +137,8 @@ def do_staging(self, subcmd, opts, *args):
|
||||
|
||||
"check" will check if all packages are links without changes
|
||||
|
||||
"check_local_links" lists local links that don't match multispec package
|
||||
|
||||
"check_duplicate_binaries" list binaries provided by multiple packages
|
||||
|
||||
"cleanup_rings" will try to cleanup rings content and print
|
||||
@ -297,6 +299,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
osc staging adi [--move] [--by-develproject] [--split] [REQUEST...]
|
||||
osc staging check [STAGING...]
|
||||
osc staging check_duplicate_binaries
|
||||
osc staging check_local_links
|
||||
osc staging cleanup_rings
|
||||
osc staging freeze [--no-bootstrap] STAGING...
|
||||
osc staging frozenage [STAGING...]
|
||||
@ -346,6 +349,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
min_args, max_args = 1, None
|
||||
elif cmd in (
|
||||
'check_duplicate_binaries',
|
||||
'check_local_links',
|
||||
'cleanup_rings',
|
||||
'list',
|
||||
'lock',
|
||||
@ -405,6 +409,8 @@ def do_staging(self, subcmd, opts, *args):
|
||||
print()
|
||||
elif cmd == 'check_duplicate_binaries':
|
||||
CheckDuplicateBinariesCommand(api).perform(opts.save)
|
||||
elif cmd == 'check_local_links':
|
||||
AcceptCommand(api).check_local_links()
|
||||
elif cmd == 'freeze':
|
||||
for prj in args[1:]:
|
||||
prj = api.prj_from_short(prj)
|
||||
|
@ -8,7 +8,7 @@ from xml.etree import cElementTree as ET
|
||||
|
||||
from osc.core import change_request_state, show_package_meta, wipebinaries
|
||||
from osc.core import http_GET, http_PUT, http_DELETE, http_POST
|
||||
from osc.core import delete_package, search
|
||||
from osc.core import delete_package, search, meta_get_packagelist
|
||||
from osc.core import Request
|
||||
from osc.util.helper import decode_it
|
||||
from osclib.core import attribute_value_save
|
||||
@ -146,7 +146,11 @@ class AcceptCommand(object):
|
||||
|
||||
return
|
||||
|
||||
def fix_linking_packages(self, package):
|
||||
def check_local_links(self):
|
||||
for package in meta_get_packagelist(self.api.apiurl, self.api.project):
|
||||
self.fix_linking_packages(package, True)
|
||||
|
||||
def fix_linking_packages(self, package, dry=False):
|
||||
project = self.api.project
|
||||
file_list = self.api.get_filelist_for_package(package, project)
|
||||
# ignore
|
||||
@ -164,6 +168,8 @@ class AcceptCommand(object):
|
||||
# Deleting all the packages that no longer have a .spec file
|
||||
for link in local_links - needed_links:
|
||||
print(f"Deleting package {project}/{link}")
|
||||
if dry:
|
||||
continue
|
||||
try:
|
||||
delete_package(self.api.apiurl, project, link, msg=f"No longer linking to {package}")
|
||||
except HTTPError as err:
|
||||
@ -182,6 +188,8 @@ class AcceptCommand(object):
|
||||
# There is more than one .spec file in the package; link package containers as needed
|
||||
meta = ET.fromstring(source_file_load(self.api.apiurl, project, package, '_meta'))
|
||||
print(f"Creating new link {link}->{package}")
|
||||
if dry:
|
||||
continue
|
||||
|
||||
meta.attrib['name'] = link
|
||||
bcnt = meta.find('bcntsynctag')
|
||||
|
Loading…
x
Reference in New Issue
Block a user