2015-02-17 17:51:27 +01:00
|
|
|
# Copyright (C) 2015 SUSE Linux Products GmbH
|
2013-09-04 15:11:27 +02:00
|
|
|
#
|
2015-02-17 17:51:27 +01:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# 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, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2013-09-04 15:11:27 +02:00
|
|
|
|
2017-01-13 01:23:17 -06:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2014-02-25 14:12:28 +01:00
|
|
|
import os
|
2014-02-12 13:15:49 +01:00
|
|
|
import os.path
|
|
|
|
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
|
2017-10-11 17:39:42 -05:00
|
|
|
from osclib.config_command import ConfigCommand
|
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
|
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
|
|
|
|
2014-03-03 17:20:40 +01:00
|
|
|
OSC_STAGING_VERSION = '0.0.1'
|
|
|
|
|
2014-03-11 09:38:27 +01:00
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
def _print_version(self):
|
|
|
|
""" Print version information about this extension. """
|
2017-04-29 00:05:00 -05:00
|
|
|
print(OSC_STAGING_VERSION)
|
2013-09-04 15:11:27 +02:00
|
|
|
quit(0)
|
|
|
|
|
2014-03-11 09:38:27 +01:00
|
|
|
|
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(
|
2017-06-14 23:51:14 -05:00
|
|
|
cmd in ('acheck', 'check', 'check_duplicate_binaries', 'frozenage', 'rebuild', 'unlock') 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')
|
2014-02-25 14:12:28 +01:00
|
|
|
@cmdln.option('-f', '--from', dest='from_', metavar='FROMPROJECT',
|
2017-02-10 17:03:52 -06:00
|
|
|
help='specify a source project when moving a request')
|
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')
|
2014-07-17 13:55:45 +02:00
|
|
|
@cmdln.option('--add', dest='add', metavar='PACKAGE',
|
|
|
|
help='mark additional packages to be checked by repo checker')
|
2017-02-10 17:03:52 -06:00
|
|
|
@cmdln.option('--force', action='store_true',
|
|
|
|
help='force action, overruling internal checks (CAUTION)')
|
2014-07-08 15:02:12 +02:00
|
|
|
@cmdln.option('-o', '--old', action='store_true',
|
|
|
|
help='use the old check algorithm')
|
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')
|
2017-06-14 23:51:14 -05:00
|
|
|
@cmdln.option('--save', action='store_true', help='save the result to the dashboard container')
|
2017-10-11 17:39:42 -05:00
|
|
|
@cmdln.option('--append', action='store_true', help='append to existing value')
|
|
|
|
@cmdln.option('--clear', action='store_true', help='clear value')
|
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
|
|
|
"acheck" will check if it is safe to accept new staging projects
|
|
|
|
As $PROJECT is syncing the right package versions between
|
|
|
|
/standard, /totest and /snapshot, it is important that the projects
|
2015-12-22 22:39:49 +01:00
|
|
|
are clean prior to a checkin round.
|
|
|
|
|
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
|
|
|
|
|
2017-06-14 23:51:14 -05:00
|
|
|
"check_duplicate_binaries" list binaries provided by multiple packages
|
|
|
|
|
2017-10-11 17:39:42 -05:00
|
|
|
"config" will modify or view staging specific configuration
|
|
|
|
|
|
|
|
Target project level configuration that applies to all stagings can be
|
|
|
|
found in the $PROJECT:Staging/dashboard container in file "config". Both
|
|
|
|
configuration locations follow the .oscrc format (space separated list).
|
|
|
|
|
|
|
|
config
|
|
|
|
Print all staging configuration.
|
|
|
|
config key
|
|
|
|
Print the value of key for stagings.
|
|
|
|
conf key value...
|
|
|
|
Set the value of key for stagings.
|
|
|
|
config --clear
|
|
|
|
Clear all staging configuration.
|
|
|
|
config --clear key
|
|
|
|
Clear (unset) a single key from staging configuration
|
|
|
|
config --append key value...
|
|
|
|
Append value to existing value or set if no existing value.
|
|
|
|
|
|
|
|
All of the above may be restricted to a set of stagings.
|
|
|
|
|
|
|
|
The staging configuration is automatically cleared anytime staging
|
|
|
|
psuedometa is cleared (accept, or unstage all requests).
|
|
|
|
|
|
|
|
The keys that may be set in staging configuration are:
|
|
|
|
|
|
|
|
- repo_checker-binary-whitelist[-arch]: appended to target project list
|
|
|
|
|
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
|
|
|
|
request node as returned by OBS. Several values will supplement the
|
|
|
|
normal request node.
|
|
|
|
|
2017-01-31 18:36:54 -06:00
|
|
|
- ./action/target/@devel_project: the devel project for the package
|
2017-01-13 01:23:17 -06:00
|
|
|
- ./action/target/@ring: the ring to which the package belongs
|
|
|
|
- ./@ignored: either false or the provided message
|
|
|
|
|
|
|
|
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"'
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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...]
|
|
|
|
osc staging acheck
|
2017-03-14 00:32:33 -05:00
|
|
|
osc staging adi [--move] [--by-develproject] [--split] [REQUEST...]
|
2017-04-28 23:55:47 -05:00
|
|
|
osc staging check [--old] [STAGING...]
|
2017-06-14 23:51:14 -05:00
|
|
|
osc staging check_duplicate_binaries
|
2017-10-11 17:39:42 -05:00
|
|
|
osc staging config [--append] [--clear] [STAGING...] [key] [value]
|
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]
|
2017-03-14 00:32:33 -05:00
|
|
|
osc staging select [--no-freeze] [--move [--from STAGING]]
|
|
|
|
[--add PACKAGE]
|
|
|
|
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...]
|
2017-03-16 14:43:28 +01:00
|
|
|
osc staging setprio [STAGING...]
|
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',
|
|
|
|
'setprio',
|
|
|
|
'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',
|
|
|
|
'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 (
|
|
|
|
'acheck',
|
2017-06-14 23:51:14 -05:00
|
|
|
'check_duplicate_binaries',
|
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'
|
|
|
|
|
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
|
2017-04-28 22:12:32 -05:00
|
|
|
config = Config(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
|
|
|
|
2017-01-09 21:49:50 -06:00
|
|
|
if opts.wipe_cache:
|
|
|
|
Cache.delete_all()
|
|
|
|
|
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
|
|
|
api = StagingAPI(opts.apiurl, opts.project)
|
2017-04-28 22:12:32 -05:00
|
|
|
config.apply_remote(api)
|
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:
|
|
|
|
CheckCommand(api).perform(None, opts.old)
|
|
|
|
else:
|
|
|
|
for prj in args[1:]:
|
|
|
|
CheckCommand(api).perform(prj, opts.old)
|
|
|
|
print()
|
2017-06-14 23:51:14 -05:00
|
|
|
elif cmd == 'check_duplicate_binaries':
|
|
|
|
CheckDuplicateBinariesCommand(api).perform(opts.save)
|
2017-10-11 17:39:42 -05:00
|
|
|
elif cmd == 'config':
|
|
|
|
projects = set()
|
|
|
|
key = value = None
|
|
|
|
stagings = api.get_staging_projects_short(None) + \
|
|
|
|
api.get_staging_projects(include_dvd=False)
|
|
|
|
for arg in args[1:]:
|
|
|
|
if arg in stagings:
|
|
|
|
projects.add(api.prj_from_short(arg))
|
|
|
|
elif key is None:
|
|
|
|
key = arg
|
|
|
|
elif value is None:
|
|
|
|
value = arg
|
|
|
|
else:
|
|
|
|
value += ' ' + arg
|
|
|
|
|
|
|
|
if not len(projects):
|
|
|
|
projects = api.get_staging_projects(include_dvd=False)
|
|
|
|
|
|
|
|
ConfigCommand(api).perform(projects, key, value, opts.append, opts.clear)
|
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-12-22 22:39:49 +01:00
|
|
|
elif cmd == 'acheck':
|
|
|
|
# Is it safe to accept? Meaning: /totest contains what it should and is not dirty
|
|
|
|
version_totest = api.get_binary_version(api.project, "openSUSE-release.rpm", repository="totest", arch="x86_64")
|
2016-05-13 15:01:37 +02:00
|
|
|
if version_totest:
|
2017-07-27 23:30:53 -05:00
|
|
|
version_openqa = api.dashboard_content_load('version_totest')
|
2016-03-25 18:53:12 +08:00
|
|
|
totest_dirty = api.is_repo_dirty(api.project, 'totest')
|
2017-01-13 01:21:47 -06:00
|
|
|
print("version_openqa: %s / version_totest: %s / totest_dirty: %s\n" % (version_openqa, version_totest, totest_dirty))
|
2016-03-25 18:53:12 +08:00
|
|
|
else:
|
2017-01-13 01:21:47 -06:00
|
|
|
print("acheck is unavailable in %s!\n" % (api.project))
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'accept':
|
2015-11-26 11:20:36 +01:00
|
|
|
# Is it safe to accept? Meaning: /totest contains what it should and is not dirty
|
|
|
|
version_totest = api.get_binary_version(api.project, "openSUSE-release.rpm", repository="totest", arch="x86_64")
|
2016-03-25 18:53:12 +08:00
|
|
|
|
2016-06-09 13:11:45 +02:00
|
|
|
if version_totest is None or opts.force:
|
2016-06-02 16:50:02 +02:00
|
|
|
# SLE does not have a totest_version or openqa_version - ignore it
|
|
|
|
version_openqa = version_totest
|
|
|
|
totest_dirty = False
|
|
|
|
else:
|
2017-07-27 23:30:53 -05:00
|
|
|
version_openqa = api.dashboard_content_load('version_totest')
|
2016-06-02 16:50:02 +02:00
|
|
|
totest_dirty = api.is_repo_dirty(api.project, 'totest')
|
|
|
|
|
|
|
|
if version_openqa == version_totest and not totest_dirty:
|
2016-03-26 02:59:28 +08:00
|
|
|
cmd = AcceptCommand(api)
|
|
|
|
for prj in args[1:]:
|
2017-03-20 19:31:17 +08:00
|
|
|
if cmd.perform(api.prj_from_letter(prj), opts.force):
|
|
|
|
cmd.reset_rebuild_data(prj)
|
|
|
|
else:
|
2016-03-26 02:59:28 +08:00
|
|
|
return
|
2016-06-02 16:50:02 +02:00
|
|
|
if not opts.no_cleanup:
|
|
|
|
if api.item_exists(api.prj_from_letter(prj)):
|
2016-05-31 15:30:29 +02:00
|
|
|
cmd.cleanup(api.prj_from_letter(prj))
|
2016-06-02 16:50:02 +02:00
|
|
|
if api.item_exists("%s:DVD" % api.prj_from_letter(prj)):
|
2016-05-31 15:30:29 +02:00
|
|
|
cmd.cleanup("%s:DVD" % api.prj_from_letter(prj))
|
2017-08-24 16:21:19 +02:00
|
|
|
cmd.accept_other_new()
|
2016-06-02 16:50:02 +02:00
|
|
|
if opts.project.startswith('openSUSE:'):
|
2016-03-25 18:53:12 +08:00
|
|
|
cmd.update_factory_version()
|
|
|
|
if api.item_exists(api.crebuild):
|
|
|
|
cmd.sync_buildfailures()
|
2016-06-02 16:50:02 +02:00
|
|
|
else:
|
2017-01-13 01:21:47 -06:00
|
|
|
print("Not safe to accept: /totest is not yet synced")
|
2015-02-10 17:22:00 +01:00
|
|
|
elif cmd == 'unselect':
|
2017-03-10 01:01:28 -06:00
|
|
|
if opts.message:
|
|
|
|
print('Ignoring requests first')
|
|
|
|
IgnoreCommand(api).perform(args[1:], opts.message)
|
2017-03-18 17:45:53 -05:00
|
|
|
UnselectCommand(api).perform(args[1:], opts.cleanup)
|
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)
|
2017-10-11 17:38:11 -05:00
|
|
|
existing_stagings += api.get_staging_projects(include_dvd=False)
|
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:
|
|
|
|
if opts.move or opts.from_:
|
|
|
|
print('--move and --from must be used with explicit staging and request list')
|
|
|
|
return
|
|
|
|
|
2017-04-12 15:52:00 -05: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:
|
|
|
|
with tempfile.NamedTemporaryFile(suffix='.yml') as temp:
|
|
|
|
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'
|
|
|
|
return_code = subprocess.call([editor, temp.name])
|
|
|
|
|
|
|
|
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:
|
|
|
|
response = raw_input().lower()
|
|
|
|
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
|
|
|
|
2017-02-17 21:51:11 -06:00
|
|
|
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])
|
|
|
|
if opts.add:
|
|
|
|
api.mark_additional_packages(target_project, [opts.add])
|
|
|
|
else:
|
|
|
|
SelectCommand(api, target_project) \
|
|
|
|
.perform(requests, opts.move, opts.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':
|
|
|
|
PrioCommand(api).perform(args[1:])
|
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)
|