2014-02-25 14:12:28 +01:00
|
|
|
import os
|
2014-02-12 13:15:49 +01:00
|
|
|
import os.path
|
2017-10-17 09:10:39 +02:00
|
|
|
import subprocess
|
2014-02-12 13:15:49 +01:00
|
|
|
import sys
|
2017-01-13 01:23:17 -06:00
|
|
|
import tempfile
|
2015-02-19 10:57:55 +01:00
|
|
|
import warnings
|
2017-01-13 01:23:17 -06:00
|
|
|
import yaml
|
2014-02-12 18:34:17 +01:00
|
|
|
|
2017-04-21 17:09:17 -05:00
|
|
|
import colorama
|
2017-04-26 21:38:58 -05:00
|
|
|
from colorama import Fore
|
2017-04-28 10:19:15 -05:00
|
|
|
from colorama import ansi
|
2017-04-21 17:09:17 -05:00
|
|
|
|
2015-02-10 17:22:00 +01:00
|
|
|
from osc import cmdln
|
2017-04-21 17:09:17 -05:00
|
|
|
from osc import conf
|
2017-05-01 22:03:23 -05:00
|
|
|
from osc import core
|
2015-02-10 17:22:00 +01:00
|
|
|
from osc import oscerr
|
2014-02-12 13:15:49 +01:00
|
|
|
|
2014-03-04 09:39:14 +01:00
|
|
|
from osclib.accept_command import AcceptCommand
|
2015-08-28 13:30:25 +02:00
|
|
|
from osclib.adi_command import AdiCommand
|
2014-08-07 12:39:41 +02:00
|
|
|
from osclib.check_command import CheckCommand
|
2017-06-14 23:51:14 -05:00
|
|
|
from osclib.check_duplicate_binaries_command import CheckDuplicateBinariesCommand
|
2014-03-04 09:39:14 +01:00
|
|
|
from osclib.cleanup_rings import CleanupRings
|
2015-02-17 17:51:27 +01:00
|
|
|
from osclib.conf import Config
|
2014-03-06 18:50:59 +01:00
|
|
|
from osclib.freeze_command import FreezeCommand
|
2017-01-10 01:27:40 -06:00
|
|
|
from osclib.ignore_command import IgnoreCommand
|
|
|
|
from osclib.unignore_command import UnignoreCommand
|
2014-08-07 12:39:41 +02:00
|
|
|
from osclib.list_command import ListCommand
|
2015-02-10 17:22:00 +01:00
|
|
|
from osclib.obslock import OBSLock
|
2014-08-07 12:39:41 +02:00
|
|
|
from osclib.select_command import SelectCommand
|
|
|
|
from osclib.stagingapi import StagingAPI
|
2017-01-09 21:49:50 -06:00
|
|
|
from osclib.cache import Cache
|
2014-08-07 12:39:41 +02:00
|
|
|
from osclib.unselect_command import UnselectCommand
|
2016-04-18 19:26:47 +08:00
|
|
|
from osclib.repair_command import RepairCommand
|
2017-03-08 16:03:27 -06:00
|
|
|
from osclib.rebuild_command import RebuildCommand
|
2017-01-13 01:23:17 -06:00
|
|
|
from osclib.request_splitter import RequestSplitter
|
2019-08-16 15:12:19 -05:00
|
|
|
from osclib.sentry import sentry_init
|
2017-04-19 17:11:46 -05:00
|
|
|
from osclib.supersede_command import SupersedeCommand
|
2017-03-16 14:43:28 +01:00
|
|
|
from osclib.prio_command import PrioCommand
|
2014-03-04 09:39:14 +01:00
|
|
|
|
2019-04-20 21:16:50 +02:00
|
|
|
try:
|
|
|
|
import __builtin__
|
|
|
|
input = getattr(__builtin__, 'raw_input')
|
|
|
|
except (ImportError, AttributeError):
|
|
|
|
pass
|
|
|
|
|
2014-03-11 09:38:27 +01:00
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
def _print_version(self):
|
2018-09-04 14:59:12 -05:00
|
|
|
from osclib.common import VERSION
|
|
|
|
print(VERSION)
|
2013-09-04 15:11:27 +02:00
|
|
|
quit(0)
|
|
|
|
|
2015-02-17 17:51:27 +01:00
|
|
|
def _full_project_name(self, project):
|
|
|
|
"""Deduce the full project name."""
|
2015-02-19 10:57:55 +01:00
|
|
|
if project.startswith(('openSUSE', 'SUSE')):
|
2015-02-17 17:51:27 +01:00
|
|
|
return project
|
|
|
|
|
|
|
|
if 'Factory' in project or 'openSUSE' in project:
|
|
|
|
return 'openSUSE:%s' % project
|
|
|
|
|
|
|
|
if 'SLE' in project:
|
|
|
|
return 'SUSE:%s' % project
|
|
|
|
|
|
|
|
# If we can't guess, raise a Warning
|
2015-02-26 15:19:29 +01:00
|
|
|
warnings.warn('%s project not recognized.' % project)
|
2015-02-17 17:51:27 +01:00
|
|
|
return project
|
|
|
|
|
2017-05-08 19:39:15 -05:00
|
|
|
def lock_needed(cmd, opts):
|
|
|
|
return not(
|
2019-12-04 15:09:12 +01:00
|
|
|
cmd in ('check', 'check_duplicate_binaries', 'check_local_links', 'frozenage', 'rebuild', 'unlock', 'setprio') or
|
2017-05-08 19:39:15 -05:00
|
|
|
(cmd == 'list' and not opts.supersede)
|
|
|
|
)
|
|
|
|
|
2017-05-10 09:34:36 -05:00
|
|
|
def clean_args(args):
|
|
|
|
out = []
|
|
|
|
for arg in args:
|
|
|
|
if arg == 'and':
|
|
|
|
continue
|
|
|
|
if ' ' not in arg:
|
|
|
|
arg = arg.rstrip(',')
|
|
|
|
if ',' in arg:
|
|
|
|
out.extend(arg.split(','))
|
|
|
|
continue
|
|
|
|
out.append(arg)
|
|
|
|
return out
|
|
|
|
|
2015-02-17 17:51:27 +01:00
|
|
|
|
2014-03-04 09:39:14 +01:00
|
|
|
@cmdln.option('--move', action='store_true',
|
2014-03-03 17:20:40 +01:00
|
|
|
help='force the selection to become a move')
|
2015-08-27 18:42:39 +08:00
|
|
|
@cmdln.option('--by-develproject', action='store_true',
|
2017-02-10 17:03:52 -06:00
|
|
|
help='split the requests by devel project')
|
2016-05-30 19:21:14 +08:00
|
|
|
@cmdln.option('--split', action='store_true',
|
2017-02-10 17:03:52 -06:00
|
|
|
help='split the requests into individual groups')
|
2015-10-01 19:09:15 +08:00
|
|
|
@cmdln.option('--supersede', action='store_true',
|
2017-02-10 17:03:52 -06:00
|
|
|
help='replace staged requests when superseded')
|
2018-10-18 17:14:17 -05:00
|
|
|
@cmdln.option('--filter-from', metavar='STAGING',
|
|
|
|
help='filter request list to only those from a specific staging')
|
2017-05-01 22:03:23 -05:00
|
|
|
@cmdln.option('-p', '--project', dest='project', metavar='PROJECT',
|
2017-02-10 17:03:52 -06:00
|
|
|
help='indicate the project on which to operate, default is openSUSE:Factory')
|
|
|
|
@cmdln.option('--force', action='store_true',
|
|
|
|
help='force action, overruling internal checks (CAUTION)')
|
2013-09-04 15:11:27 +02:00
|
|
|
@cmdln.option('-v', '--version', action='store_true',
|
2017-02-10 17:03:52 -06:00
|
|
|
help='print the plugin version')
|
2015-03-24 14:46:36 +01:00
|
|
|
@cmdln.option('--no-freeze', dest='no_freeze', action='store_true',
|
|
|
|
help='force the select command ignoring the time from the last freeze')
|
2017-03-02 15:28:13 -06:00
|
|
|
@cmdln.option('--cleanup', action='store_true', help='cleanup after completing operation')
|
2016-05-31 15:30:29 +02:00
|
|
|
@cmdln.option('--no-cleanup', dest='no_cleanup', action='store_true',
|
|
|
|
help='do not cleanup remaining packages in staging projects after accept')
|
2016-05-12 11:22:33 +02:00
|
|
|
@cmdln.option('--no-bootstrap', dest='bootstrap', action='store_false', default=True,
|
|
|
|
help='do not update bootstrap-copy when freezing')
|
2017-01-09 21:49:50 -06:00
|
|
|
@cmdln.option('--wipe-cache', dest='wipe_cache', action='store_true', default=False,
|
|
|
|
help='wipe GET request cache before executing')
|
2017-01-10 01:27:40 -06:00
|
|
|
@cmdln.option('-m', '--message', help='message used by ignore command')
|
2017-01-13 01:23:17 -06:00
|
|
|
@cmdln.option('--filter-by', action='append', help='xpath by which to filter requests')
|
|
|
|
@cmdln.option('--group-by', action='append', help='xpath by which to group requests')
|
|
|
|
@cmdln.option('-i', '--interactive', action='store_true', help='interactively modify selection proposal')
|
2017-02-09 23:55:35 -06:00
|
|
|
@cmdln.option('-n', '--non-interactive', action='store_true', help='do not ask anything, use default answers')
|
2017-02-17 21:51:11 -06:00
|
|
|
@cmdln.option('--merge', action='store_true', help='propose merge where applicable and store details to allow future merges')
|
|
|
|
@cmdln.option('--try-strategies', action='store_true', default=False, help='apply strategies and keep any with desireable outcome')
|
|
|
|
@cmdln.option('--strategy', help='apply a specific strategy')
|
2017-04-21 17:09:17 -05:00
|
|
|
@cmdln.option('--no-color', action='store_true', help='strip colors from output (or add staging.color = 0 to the .oscrc general section')
|
2018-08-17 22:23:09 -05:00
|
|
|
@cmdln.option('--save', action='store_true', help='save the result to the pseudometa package')
|
2013-09-04 15:11:27 +02:00
|
|
|
def do_staging(self, subcmd, opts, *args):
|
|
|
|
"""${cmd_name}: Commands to work with staging projects
|
|
|
|
|
2016-02-01 16:35:36 +01:00
|
|
|
${cmd_option_list}
|
|
|
|
|
2014-03-06 18:50:59 +01:00
|
|
|
"accept" will accept all requests in
|
2017-02-10 17:03:52 -06:00
|
|
|
$PROJECT:Staging:<LETTER> into $PROJECT
|
|
|
|
If openSUSE:* project, requests marked ready from adi stagings will also
|
|
|
|
be accepted.
|
2014-03-06 18:50:59 +01:00
|
|
|
|
2017-02-10 17:03:52 -06:00
|
|
|
"adi" will list already staged requests, stage new requests, and supersede
|
|
|
|
requests where applicable. New adi stagings will be created for new
|
|
|
|
packages based on the grouping options used. The default grouping is by
|
|
|
|
source project. When adi stagings are ready the request will be marked
|
|
|
|
ready, unstaged, and the adi staging deleted.
|
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
"check" will check if all packages are links without changes
|
|
|
|
|
2019-11-24 20:02:58 +01:00
|
|
|
"check_local_links" lists local links that don't match multispec package
|
|
|
|
|
2017-06-14 23:51:14 -05:00
|
|
|
"check_duplicate_binaries" list binaries provided by multiple packages
|
|
|
|
|
2014-03-06 18:50:59 +01:00
|
|
|
"cleanup_rings" will try to cleanup rings content and print
|
|
|
|
out problems
|
|
|
|
|
2017-02-10 17:03:52 -06:00
|
|
|
"freeze" will freeze the sources of the project's links while not
|
|
|
|
affecting the source packages
|
2014-02-10 10:19:37 +01:00
|
|
|
|
2016-02-03 13:04:30 +01:00
|
|
|
"frozenage" will show when the respective staging project was last frozen
|
|
|
|
|
2017-01-10 01:27:40 -06:00
|
|
|
"ignore" will ignore a request from "list" and "adi" commands until unignored
|
|
|
|
|
2017-03-02 15:28:13 -06:00
|
|
|
"unignore" will remove from requests from ignore list
|
|
|
|
If the --cleanup flag is included then all ignored requests that were
|
|
|
|
changed from state new or review more than 3 days ago will be removed.
|
2017-01-10 01:27:40 -06:00
|
|
|
|
2017-02-10 17:03:52 -06:00
|
|
|
"list" will list/supersede requests for ring packages or all if no rings.
|
|
|
|
|
2017-04-28 17:03:13 -05:00
|
|
|
"lock" acquire a hold on the project in order to execute multiple commands
|
|
|
|
and prevent others from interrupting. An example:
|
|
|
|
|
|
|
|
lock -m "checkin round"
|
|
|
|
|
|
|
|
list --supersede
|
|
|
|
adi
|
|
|
|
accept A B C D E
|
|
|
|
|
|
|
|
unlock
|
|
|
|
|
|
|
|
Each command will update the lock to keep it up-to-date.
|
|
|
|
|
2017-02-10 17:03:52 -06:00
|
|
|
"repair" will attempt to repair the state of a request that has been
|
|
|
|
corrupted.
|
2014-01-31 10:29:44 +01:00
|
|
|
|
2017-03-18 17:59:50 -05:00
|
|
|
Use the --cleanup flag to include all untracked requests.
|
|
|
|
|
2014-02-12 13:36:41 +01:00
|
|
|
"select" will add requests to the project
|
2017-01-13 01:23:17 -06:00
|
|
|
Stagings are expected to be either in short-hand or the full project
|
|
|
|
name. For example letter or named stagings can be specified simply as
|
|
|
|
A, B, Gcc6, etc, while adi stagings can be specified as adi:1, adi:2,
|
|
|
|
etc. Currently, adi stagings are not supported in proposal mode.
|
|
|
|
|
|
|
|
Requests may either be the target package or the request ID.
|
|
|
|
|
|
|
|
When using --filter-by or --group-by the xpath will be applied to the
|
2018-02-06 23:05:51 -06:00
|
|
|
request node as returned by OBS. Use the following on a current request
|
|
|
|
to see the XML structure.
|
|
|
|
|
|
|
|
osc api /request/1337
|
|
|
|
|
|
|
|
A number of additional values will supplement the normal request node.
|
2017-01-13 01:23:17 -06:00
|
|
|
|
2017-01-31 18:36:54 -06:00
|
|
|
- ./action/target/@devel_project: the devel project for the package
|
2018-02-06 23:04:49 -06:00
|
|
|
- ./action/target/@devel_project_super: super devel project if relevant
|
2017-01-13 01:23:17 -06:00
|
|
|
- ./action/target/@ring: the ring to which the package belongs
|
2018-02-06 23:04:49 -06:00
|
|
|
- ./@aged: either True or False based on splitter-request-age-threshold
|
|
|
|
- ./@ignored: either False or the provided message
|
2017-01-13 01:23:17 -06:00
|
|
|
|
|
|
|
Some useful examples:
|
|
|
|
|
|
|
|
--filter-by './action/target[starts-with(@package, "yast-")]'
|
2017-01-31 18:36:54 -06:00
|
|
|
--filter-by './action/target/[@devel_project="YaST:Head"]'
|
2017-01-13 01:23:17 -06:00
|
|
|
--filter-by './action/target[starts-with(@ring, "1")]'
|
|
|
|
--filter-by '@id!="1234567"'
|
2018-02-06 22:00:40 -06:00
|
|
|
--filter-by 'contains(description, "#Portus")'
|
2017-01-13 01:23:17 -06:00
|
|
|
|
2017-01-31 18:36:54 -06:00
|
|
|
--group-by='./action/target/@devel_project'
|
2017-01-13 01:23:17 -06:00
|
|
|
--group-by='./action/target/@ring'
|
|
|
|
|
|
|
|
Multiple filter-by or group-by options may be used at the same time.
|
|
|
|
|
|
|
|
Note that when using proposal mode, multiple stagings to consider may be
|
|
|
|
provided in addition to a list of requests by which to filter. A more
|
|
|
|
complex example:
|
|
|
|
|
2017-01-31 18:36:54 -06:00
|
|
|
select --group-by='./action/target/@devel_project' A B C 123 456 789
|
2017-01-13 01:23:17 -06:00
|
|
|
|
|
|
|
This will separate the requests 123, 456, 789 by devel project and only
|
|
|
|
consider stagings A, B, or C, if available, for placement.
|
|
|
|
|
|
|
|
No arguments is also a valid choice and will propose all non-ignored
|
|
|
|
requests into the first available staging. Note that bootstrapped
|
|
|
|
stagings are only used when either required or no other stagings are
|
|
|
|
available.
|
|
|
|
|
|
|
|
Another useful example is placing all open requests into a specific
|
|
|
|
letter staging with:
|
|
|
|
|
|
|
|
select A
|
|
|
|
|
2017-04-17 23:10:33 -05:00
|
|
|
Built in strategies may be specified as well. For example:
|
|
|
|
|
|
|
|
select --strategy devel
|
2018-02-06 23:03:37 -06:00
|
|
|
select --strategy quick
|
2017-04-17 23:10:33 -05:00
|
|
|
select --strategy special
|
|
|
|
select --strategy super
|
|
|
|
|
|
|
|
The default is none and custom is used with any filter-by or group-by
|
|
|
|
arguments are provided.
|
|
|
|
|
|
|
|
To merge applicable requests into an existing staging.
|
|
|
|
|
|
|
|
select --merge A
|
|
|
|
|
|
|
|
To automatically try all available strategies.
|
|
|
|
|
|
|
|
select --try-strategies
|
|
|
|
|
|
|
|
These concepts can be combined and interactive mode allows the proposal
|
|
|
|
to be modified before it is executed.
|
2014-03-06 18:50:59 +01:00
|
|
|
|
2018-10-18 17:14:43 -05:00
|
|
|
Moving requests can be accomplished using the --move flag. For example,
|
|
|
|
to move already staged pac1 and pac2 to staging B use the following.
|
|
|
|
|
|
|
|
select --move B pac1 pac2
|
|
|
|
|
|
|
|
The staging in which the requests are staged will automatically be
|
|
|
|
determined and the requests will be removed from that staging and placed
|
|
|
|
in the specified staging.
|
|
|
|
|
|
|
|
Related to this, the --filter-from option may be used in conjunction
|
|
|
|
with --move to only move requests already staged in a specific staging.
|
|
|
|
This can be useful if a staging master is responsible for a specific set
|
|
|
|
of packages and wants to move them into a different staging when they
|
|
|
|
were already placed in a mixed staging. For example, if one had a file
|
|
|
|
with a list of packages the following would move any of them found in
|
|
|
|
staging A to staging B.
|
|
|
|
|
|
|
|
select --move --filter-from A B $(< package.list)
|
|
|
|
|
2014-03-05 09:24:07 +01:00
|
|
|
"unselect" will remove from the project - pushing them back to the backlog
|
2017-03-10 01:01:28 -06:00
|
|
|
If a message is included the requests will be ignored first.
|
2014-02-10 10:20:16 +01:00
|
|
|
|
2017-03-18 17:45:53 -05:00
|
|
|
Use the --cleanup flag to include all obsolete requests.
|
|
|
|
|
2017-04-28 17:03:13 -05:00
|
|
|
"unlock" will remove the staging lock in case it gets stuck or a manual hold
|
|
|
|
If a command lock gets stuck while a hold is placed on a project the
|
|
|
|
unlock command will need to be run twice since there are two layers of
|
|
|
|
locks.
|
2017-03-08 00:06:01 -06:00
|
|
|
|
2017-03-08 16:03:27 -06:00
|
|
|
"rebuild" will rebuild broken packages in the given stagings or all
|
2017-03-10 22:17:54 -06:00
|
|
|
The rebuild command will only trigger builds for packages with less than
|
|
|
|
3 failures since the last success or if the build log indicates a stall.
|
|
|
|
|
|
|
|
If the force option is included the rebuild checks will be ignored and
|
|
|
|
all packages failing to build will be triggered.
|
2017-03-08 16:03:27 -06:00
|
|
|
|
2018-08-16 18:01:52 -05:00
|
|
|
"setprio" will set priority of requests withing stagings
|
|
|
|
If no stagings are specified all stagings will be used.
|
|
|
|
The default priority is important, but the possible values are:
|
|
|
|
"critical", "important", "moderate" or "low".
|
|
|
|
|
2017-04-19 17:11:46 -05:00
|
|
|
"supersede" will supersede requests were applicable.
|
|
|
|
A request list can be used to limit what is superseded.
|
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
Usage:
|
2017-02-10 17:03:52 -06:00
|
|
|
osc staging accept [--force] [--no-cleanup] [LETTER...]
|
2017-03-14 00:32:33 -05:00
|
|
|
osc staging adi [--move] [--by-develproject] [--split] [REQUEST...]
|
2019-10-07 15:39:39 +02:00
|
|
|
osc staging check [STAGING...]
|
2017-06-14 23:51:14 -05:00
|
|
|
osc staging check_duplicate_binaries
|
2019-11-24 20:02:58 +01:00
|
|
|
osc staging check_local_links
|
2014-03-06 18:50:59 +01:00
|
|
|
osc staging cleanup_rings
|
2017-09-01 13:41:29 +02:00
|
|
|
osc staging freeze [--no-bootstrap] STAGING...
|
2017-03-09 16:11:26 -06:00
|
|
|
osc staging frozenage [STAGING...]
|
2017-01-10 01:27:40 -06:00
|
|
|
osc staging ignore [-m MESSAGE] REQUEST...
|
2017-03-14 00:32:33 -05:00
|
|
|
osc staging unignore [--cleanup] [REQUEST...|all]
|
2017-04-19 17:11:46 -05:00
|
|
|
osc staging list [--supersede]
|
2017-04-28 17:03:13 -05:00
|
|
|
osc staging lock [-m MESSAGE]
|
2018-10-18 17:14:17 -05:00
|
|
|
osc staging select [--no-freeze] [--move [--filter-from STAGING]]
|
2017-03-14 00:32:33 -05:00
|
|
|
STAGING REQUEST...
|
2017-02-17 21:51:11 -06:00
|
|
|
osc staging select [--no-freeze] [--interactive|--non-interactive]
|
|
|
|
[--filter-by...] [--group-by...]
|
|
|
|
[--merge] [--try-strategies] [--strategy]
|
|
|
|
[STAGING...] [REQUEST...]
|
2017-03-18 17:45:53 -05:00
|
|
|
osc staging unselect [--cleanup] [-m MESSAGE] [REQUEST...]
|
2017-03-08 00:06:01 -06:00
|
|
|
osc staging unlock
|
2017-03-10 22:17:54 -06:00
|
|
|
osc staging rebuild [--force] [STAGING...]
|
2017-03-18 17:59:50 -05:00
|
|
|
osc staging repair [--cleanup] [REQUEST...]
|
2018-08-16 18:01:25 -05:00
|
|
|
osc staging setprio [STAGING...] [priority]
|
2017-04-19 17:18:25 -05:00
|
|
|
osc staging supersede [REQUEST...]
|
2013-09-04 15:11:27 +02:00
|
|
|
"""
|
|
|
|
if opts.version:
|
|
|
|
self._print_version()
|
|
|
|
|
|
|
|
# verify the argument counts match the commands
|
2014-02-10 19:59:45 +01:00
|
|
|
if len(args) == 0:
|
|
|
|
raise oscerr.WrongArgs('No command given, see "osc help staging"!')
|
2013-09-04 15:11:27 +02:00
|
|
|
cmd = args[0]
|
2017-04-29 00:00:48 -05:00
|
|
|
if cmd in (
|
|
|
|
'accept',
|
|
|
|
'adi',
|
|
|
|
'check',
|
2017-10-11 17:39:42 -05:00
|
|
|
'config',
|
2017-04-29 00:00:48 -05:00
|
|
|
'frozenage',
|
|
|
|
'unignore',
|
|
|
|
'select',
|
|
|
|
'unselect',
|
|
|
|
'rebuild',
|
|
|
|
'repair',
|
|
|
|
'supersede',
|
|
|
|
):
|
2017-02-10 17:04:59 -06:00
|
|
|
min_args, max_args = 0, None
|
2017-04-29 00:00:48 -05:00
|
|
|
elif cmd in (
|
|
|
|
'freeze',
|
2019-12-04 15:09:12 +01:00
|
|
|
'setprio',
|
2017-04-29 00:00:48 -05:00
|
|
|
'ignore',
|
|
|
|
):
|
2017-01-10 01:27:40 -06:00
|
|
|
min_args, max_args = 1, None
|
2017-04-29 00:00:48 -05:00
|
|
|
elif cmd in (
|
2017-06-14 23:51:14 -05:00
|
|
|
'check_duplicate_binaries',
|
2019-11-24 20:02:58 +01:00
|
|
|
'check_local_links',
|
2017-04-29 00:00:48 -05:00
|
|
|
'cleanup_rings',
|
|
|
|
'list',
|
|
|
|
'lock',
|
|
|
|
'unlock',
|
|
|
|
):
|
2017-04-28 17:03:13 -05:00
|
|
|
min_args, max_args = 0, 0
|
2013-09-04 15:11:27 +02:00
|
|
|
else:
|
2014-03-03 17:20:40 +01:00
|
|
|
raise oscerr.WrongArgs('Unknown command: %s' % cmd)
|
2017-05-10 09:34:36 -05:00
|
|
|
args = clean_args(args)
|
2013-09-04 15:11:27 +02:00
|
|
|
if len(args) - 1 < min_args:
|
|
|
|
raise oscerr.WrongArgs('Too few arguments.')
|
2014-03-28 11:46:14 +01:00
|
|
|
if max_args is not None and len(args) - 1 > max_args:
|
2013-09-04 15:11:27 +02:00
|
|
|
raise oscerr.WrongArgs('Too many arguments.')
|
|
|
|
|
2017-05-01 22:03:23 -05:00
|
|
|
# Allow for determining project from osc store.
|
|
|
|
if not opts.project:
|
|
|
|
if core.is_project_dir('.'):
|
|
|
|
opts.project = core.store_read_project('.')
|
|
|
|
else:
|
|
|
|
opts.project = 'Factory'
|
|
|
|
|
2018-09-04 15:04:04 -05:00
|
|
|
# Cache the remote config fetch.
|
|
|
|
Cache.init()
|
|
|
|
|
2015-02-17 17:51:27 +01:00
|
|
|
# Init the OBS access and configuration
|
|
|
|
opts.project = self._full_project_name(opts.project)
|
2014-01-31 10:29:44 +01:00
|
|
|
opts.apiurl = self.get_api_url()
|
|
|
|
opts.verbose = False
|
2018-08-16 21:46:05 -05:00
|
|
|
Config(opts.apiurl, opts.project)
|
2017-04-28 10:19:15 -05:00
|
|
|
|
2017-04-21 17:09:17 -05:00
|
|
|
colorama.init(autoreset=True,
|
|
|
|
strip=(opts.no_color or not bool(int(conf.config.get('staging.color', True)))))
|
2017-04-28 10:19:15 -05:00
|
|
|
# Allow colors to be changed.
|
|
|
|
for name in dir(Fore):
|
|
|
|
if not name.startswith('_'):
|
|
|
|
# .oscrc requires keys to be lower-case.
|
|
|
|
value = conf.config.get('staging.color.' + name.lower())
|
|
|
|
if value:
|
|
|
|
setattr(Fore, name, ansi.code_to_chars(value))
|
2015-02-10 17:22:00 +01:00
|
|
|
|
2019-08-16 15:12:19 -05:00
|
|
|
sentry_init(opts.apiurl, {'osc_plugin': subcmd})
|
|
|
|
|
2017-01-09 21:49:50 -06:00
|
|
|
if opts.wipe_cache:
|
|
|
|
Cache.delete_all()
|
|
|
|
|
2018-06-11 19:35:45 +02:00
|
|
|
api = StagingAPI(opts.apiurl, opts.project)
|
2017-05-08 19:39:15 -05:00
|
|
|
needed = lock_needed(cmd, opts)
|
|
|
|
with OBSLock(opts.apiurl, opts.project, reason=cmd, needed=needed) as lock:
|
2015-02-10 17:22:00 +01:00
|
|
|
|
|
|
|
# call the respective command and parse args by need
|
|
|
|
if cmd == 'check':
|
2017-04-28 23:55:47 -05:00
|
|
|
if len(args) == 1:
|
2019-10-07 15:39:39 +02:00
|
|
|
CheckCommand(api).perform(None)
|
2017-04-28 23:55:47 -05:00
|
|
|
else:
|
|
|
|
for prj in args[1:]:
|
2019-10-07 15:39:39 +02:00
|
|
|
CheckCommand(api).perform(prj)
|
2017-04-28 23:55:47 -05:00
|
|
|
print()
|
2017-06-14 23:51:14 -05:00
|
|
|
elif cmd == 'check_duplicate_binaries':
|
|
|
|
CheckDuplicateBinariesCommand(api).perform(opts.save)
|
2019-11-24 20:02:58 +01:00
|
|
|
elif cmd == 'check_local_links':
|
|
|
|
AcceptCommand(api).check_local_links()
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'freeze':
|
|
|
|
for prj in args[1:]:
|
2017-08-22 20:46:00 +08:00
|
|
|
prj = api.prj_from_short(prj)
|
2017-04-26 21:43:27 -05:00
|
|
|
print(Fore.YELLOW + prj)
|
|
|
|
FreezeCommand(api).perform(prj, copy_bootstrap=opts.bootstrap)
|
2016-02-03 13:04:30 +01:00
|
|
|
elif cmd == 'frozenage':
|
2017-03-09 16:11:26 -06:00
|
|
|
projects = api.get_staging_projects_short() if len(args) == 1 else args[1:]
|
|
|
|
for prj in projects:
|
2017-04-26 21:38:58 -05:00
|
|
|
prj = api.prj_from_letter(prj)
|
|
|
|
print('{} last frozen {}{:.1f} days ago'.format(
|
|
|
|
Fore.YELLOW + prj + Fore.RESET,
|
|
|
|
Fore.GREEN if api.prj_frozen_enough(prj) else Fore.RED,
|
|
|
|
api.days_since_last_freeze(prj)))
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'accept':
|
2019-10-17 15:05:44 +02:00
|
|
|
cmd = AcceptCommand(api)
|
2019-11-22 13:21:06 +01:00
|
|
|
cmd.accept_all(args[1:], opts.force, not opts.no_cleanup)
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'unselect':
|
2019-11-19 18:17:26 +01:00
|
|
|
UnselectCommand(api).perform(args[1:], opts.cleanup, opts.message)
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'select':
|
2017-01-13 01:23:17 -06:00
|
|
|
# Include list of all stagings in short-hand and by full name.
|
|
|
|
existing_stagings = api.get_staging_projects_short(None)
|
2018-07-05 20:43:07 +02:00
|
|
|
existing_stagings += api.get_staging_projects()
|
2017-01-13 01:23:17 -06:00
|
|
|
stagings = []
|
|
|
|
requests = []
|
|
|
|
for arg in args[1:]:
|
|
|
|
# Since requests may be given by either request ID or package
|
|
|
|
# name and stagings may include multi-letter special stagings
|
|
|
|
# there is no easy way to distinguish between stagings and
|
|
|
|
# requests in arguments. Therefore, check if argument is in the
|
|
|
|
# list of short-hand and full project name stagings, otherwise
|
|
|
|
# consider it a request. This also allows for special stagings
|
|
|
|
# with the same name as package, but the staging will be assumed
|
|
|
|
# first time around. The current practice seems to be to start a
|
|
|
|
# special staging with a capital letter which makes them unique.
|
|
|
|
# lastly adi stagings are consistently prefix with adi: which
|
|
|
|
# also makes it consistent to distinguish them from request IDs.
|
|
|
|
if arg in existing_stagings and arg not in stagings:
|
|
|
|
stagings.append(api.extract_staging_short(arg))
|
|
|
|
elif arg not in requests:
|
|
|
|
requests.append(arg)
|
|
|
|
|
|
|
|
if len(stagings) != 1 or len(requests) == 0 or opts.filter_by or opts.group_by:
|
2018-10-18 17:14:17 -05:00
|
|
|
if opts.move or opts.filter_from:
|
|
|
|
print('--move and --filter-from must be used with explicit staging and request list')
|
2017-01-13 01:23:17 -06:00
|
|
|
return
|
|
|
|
|
2019-11-21 13:42:19 +01:00
|
|
|
open_requests = api.get_open_requests({'withhistory': 1})
|
2017-02-17 20:33:53 -06:00
|
|
|
if len(open_requests) == 0:
|
|
|
|
print('No open requests to consider')
|
|
|
|
return
|
|
|
|
|
|
|
|
splitter = RequestSplitter(api, open_requests, in_ring=True)
|
2017-02-17 21:12:47 -06:00
|
|
|
|
|
|
|
considerable = splitter.stagings_load(stagings)
|
|
|
|
if considerable == 0:
|
|
|
|
print('No considerable stagings on which to act')
|
2017-01-13 01:23:17 -06:00
|
|
|
return
|
2017-02-17 21:12:47 -06:00
|
|
|
|
2017-02-17 21:51:11 -06:00
|
|
|
if opts.merge:
|
|
|
|
splitter.merge()
|
|
|
|
if opts.try_strategies:
|
|
|
|
splitter.strategies_try()
|
2017-01-13 01:23:17 -06:00
|
|
|
if len(requests) > 0:
|
2017-02-17 21:51:11 -06:00
|
|
|
splitter.strategy_do('requests', requests=requests)
|
|
|
|
if opts.strategy:
|
|
|
|
splitter.strategy_do(opts.strategy)
|
|
|
|
elif opts.filter_by or opts.group_by:
|
|
|
|
kwargs = {}
|
|
|
|
if opts.filter_by:
|
|
|
|
kwargs['filters'] = opts.filter_by
|
|
|
|
if opts.group_by:
|
|
|
|
kwargs['groups'] = opts.group_by
|
|
|
|
splitter.strategy_do('custom', **kwargs)
|
|
|
|
else:
|
|
|
|
if opts.merge:
|
|
|
|
# Merge any none strategies before final none strategy.
|
|
|
|
splitter.merge(strategy_none=True)
|
|
|
|
splitter.strategy_do('none')
|
2017-02-18 00:03:55 -06:00
|
|
|
splitter.strategy_do_non_bootstrapped('none')
|
2017-02-17 21:51:11 -06:00
|
|
|
|
2017-01-13 01:23:17 -06:00
|
|
|
proposal = splitter.proposal
|
|
|
|
if len(proposal) == 0:
|
|
|
|
print('Empty proposal')
|
|
|
|
return
|
|
|
|
|
|
|
|
if opts.interactive:
|
2019-10-08 14:47:18 -05:00
|
|
|
with tempfile.NamedTemporaryFile(mode='w', suffix='.yml') as temp:
|
2017-01-13 01:23:17 -06:00
|
|
|
temp.write(yaml.safe_dump(splitter.proposal, default_flow_style=False) + '\n\n')
|
2017-10-16 16:20:08 -05:00
|
|
|
|
|
|
|
if len(splitter.requests):
|
|
|
|
temp.write('# remaining requests:\n')
|
|
|
|
for request in splitter.requests:
|
|
|
|
temp.write('# {}: {}\n'.format(
|
|
|
|
request.get('id'), request.find('action/target').get('package')))
|
|
|
|
temp.write('\n')
|
|
|
|
|
2017-01-13 01:23:17 -06:00
|
|
|
temp.write('# move requests between stagings or comment/remove them\n')
|
|
|
|
temp.write('# change the target staging for a group\n')
|
2017-04-17 23:08:55 -05:00
|
|
|
temp.write('# remove the group, requests, staging, or strategy to skip\n')
|
2017-01-13 01:23:17 -06:00
|
|
|
temp.write('# stagings\n')
|
2017-02-17 21:51:11 -06:00
|
|
|
if opts.merge:
|
2017-10-16 16:20:55 -05:00
|
|
|
temp.write('# - mergeable: {}\n'
|
2017-02-17 21:51:11 -06:00
|
|
|
.format(', '.join(sorted(splitter.stagings_mergeable +
|
|
|
|
splitter.stagings_mergeable_none))))
|
2017-01-13 01:23:17 -06:00
|
|
|
temp.write('# - considered: {}\n'
|
2017-02-17 21:51:11 -06:00
|
|
|
.format(', '.join(sorted(splitter.stagings_considerable))))
|
2017-02-08 16:45:39 -06:00
|
|
|
temp.write('# - remaining: {}\n'
|
2017-02-17 21:51:11 -06:00
|
|
|
.format(', '.join(sorted(splitter.stagings_available))))
|
2017-01-13 01:23:17 -06:00
|
|
|
temp.flush()
|
|
|
|
|
|
|
|
editor = os.getenv('EDITOR')
|
|
|
|
if not editor:
|
|
|
|
editor = 'xdg-open'
|
2017-11-22 09:13:06 -06:00
|
|
|
return_code = subprocess.call(editor.split(' ') + [temp.name])
|
2017-01-13 01:23:17 -06:00
|
|
|
|
|
|
|
proposal = yaml.safe_load(open(temp.name).read())
|
|
|
|
|
2017-02-17 20:37:50 -06:00
|
|
|
# Filter invalidated groups from proposal.
|
2017-02-17 21:51:11 -06:00
|
|
|
keys = ['group', 'requests', 'staging', 'strategy']
|
2017-02-17 20:37:50 -06:00
|
|
|
for group, info in sorted(proposal.items()):
|
|
|
|
for key in keys:
|
|
|
|
if not info.get(key):
|
|
|
|
del proposal[group]
|
|
|
|
break
|
|
|
|
|
2017-01-13 01:23:17 -06:00
|
|
|
print(yaml.safe_dump(proposal, default_flow_style=False))
|
|
|
|
|
|
|
|
print('Accept proposal? [y/n] (y): ', end='')
|
2017-02-09 23:55:35 -06:00
|
|
|
if opts.non_interactive:
|
|
|
|
print('y')
|
|
|
|
else:
|
2019-04-20 21:16:50 +02:00
|
|
|
response = input().lower()
|
2017-02-09 23:55:35 -06:00
|
|
|
if response != '' and response != 'y':
|
|
|
|
print('Quit')
|
|
|
|
return
|
2017-01-13 01:23:17 -06:00
|
|
|
|
2017-02-17 20:40:05 -06:00
|
|
|
for group, info in sorted(proposal.items()):
|
|
|
|
print('Staging {} in {}'.format(group, info['staging']))
|
2017-01-13 01:23:17 -06:00
|
|
|
|
|
|
|
# SelectCommand expects strings.
|
2017-02-17 20:40:05 -06:00
|
|
|
request_ids = map(str, info['requests'].keys())
|
|
|
|
target_project = api.prj_from_short(info['staging'])
|
2017-01-13 01:23:17 -06:00
|
|
|
|
2019-11-19 18:07:22 +01:00
|
|
|
# TODO: Find better place for splitter info
|
|
|
|
# if 'merge' not in info:
|
|
|
|
# Assume that the original splitter_info is desireable
|
|
|
|
# and that this staging is simply manual followup.
|
|
|
|
# api.set_splitter_info_in_prj_pseudometa(target_project, info['group'], info['strategy'])
|
2017-01-13 01:23:17 -06:00
|
|
|
|
|
|
|
SelectCommand(api, target_project) \
|
2017-03-14 00:46:00 -05:00
|
|
|
.perform(request_ids, no_freeze=opts.no_freeze)
|
2015-02-10 17:22:00 +01:00
|
|
|
else:
|
2017-01-13 01:23:17 -06:00
|
|
|
target_project = api.prj_from_short(stagings[0])
|
2019-06-03 16:54:30 +02:00
|
|
|
filter_from = api.prj_from_short(opts.filter_from) if opts.filter_from else None
|
|
|
|
SelectCommand(api, target_project) \
|
|
|
|
.perform(requests, opts.move,
|
|
|
|
filter_from, opts.no_freeze)
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'cleanup_rings':
|
|
|
|
CleanupRings(api).perform()
|
2017-01-10 01:27:40 -06:00
|
|
|
elif cmd == 'ignore':
|
|
|
|
IgnoreCommand(api).perform(args[1:], opts.message)
|
|
|
|
elif cmd == 'unignore':
|
2017-03-02 15:28:13 -06:00
|
|
|
UnignoreCommand(api).perform(args[1:], opts.cleanup)
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'list':
|
2017-04-19 17:11:46 -05:00
|
|
|
ListCommand(api).perform(supersede=opts.supersede)
|
2017-04-28 17:03:13 -05:00
|
|
|
elif cmd == 'lock':
|
|
|
|
lock.hold(opts.message)
|
2015-07-16 15:09:26 +02:00
|
|
|
elif cmd == 'adi':
|
2016-05-30 19:21:14 +08:00
|
|
|
AdiCommand(api).perform(args[1:], move=opts.move, by_dp=opts.by_develproject, split=opts.split)
|
2017-03-08 16:03:27 -06:00
|
|
|
elif cmd == 'rebuild':
|
2017-03-10 22:17:54 -06:00
|
|
|
RebuildCommand(api).perform(args[1:], opts.force)
|
2016-04-18 19:26:47 +08:00
|
|
|
elif cmd == 'repair':
|
2017-03-18 17:59:50 -05:00
|
|
|
RepairCommand(api).perform(args[1:], opts.cleanup)
|
2017-03-16 14:43:28 +01:00
|
|
|
elif cmd == 'setprio':
|
2018-08-16 18:01:25 -05:00
|
|
|
stagings = []
|
|
|
|
priority = None
|
|
|
|
|
|
|
|
priorities = ['critical', 'important', 'moderate', 'low']
|
|
|
|
for arg in args[1:]:
|
|
|
|
if arg in priorities:
|
|
|
|
priority = arg
|
|
|
|
else:
|
|
|
|
stagings.append(arg)
|
|
|
|
|
|
|
|
PrioCommand(api).perform(stagings, priority)
|
2017-04-19 17:11:46 -05:00
|
|
|
elif cmd == 'supersede':
|
|
|
|
SupersedeCommand(api).perform(args[1:])
|
2017-05-08 19:39:15 -05:00
|
|
|
elif cmd == 'unlock':
|
|
|
|
lock.release(force=True)
|