Merge "stx tool: repomgr: Add the support of repomgr module"
This commit is contained in:
commit
32ffad761c
@ -18,6 +18,7 @@ import logging
|
|||||||
from stx import command # pylint: disable=E0611
|
from stx import command # pylint: disable=E0611
|
||||||
from stx import stx_configparser # pylint: disable=E0611
|
from stx import stx_configparser # pylint: disable=E0611
|
||||||
from stx import stx_control # pylint: disable=E0611
|
from stx import stx_control # pylint: disable=E0611
|
||||||
|
from stx import stx_repomgr # pylint: disable=E0611
|
||||||
from stx import utils # pylint: disable=E0611
|
from stx import utils # pylint: disable=E0611
|
||||||
|
|
||||||
logger = logging.getLogger('STX')
|
logger = logging.getLogger('STX')
|
||||||
@ -88,6 +89,16 @@ settings.\t\teg: [ --show|--get|--add|--unset|--remove-section ]')
|
|||||||
required=False)
|
required=False)
|
||||||
config_subparser.set_defaults(handle=self.handleconfig.handleConfig)
|
config_subparser.set_defaults(handle=self.handleconfig.handleConfig)
|
||||||
|
|
||||||
|
repo_subparser = subparsers.add_parser('repomgr',
|
||||||
|
help='Manage source|binary \
|
||||||
|
packages.\t\teg: [ list|download|sync|mirror|clean|remove_repo|upload_pkg|\
|
||||||
|
delete_pkg ]')
|
||||||
|
repo_subparser.add_argument('repomgr_task',
|
||||||
|
help='[ list|download|sync|mirror|clean|\
|
||||||
|
remove_repo|upload_pkg|delete_pkg ]: \
|
||||||
|
Execute the management task.\n\n')
|
||||||
|
repo_subparser.set_defaults(handle=stx_repomgr.handleRepomgr)
|
||||||
|
|
||||||
parser.add_argument('-d', '--debug',
|
parser.add_argument('-d', '--debug',
|
||||||
help='Enable debug output\n\n',
|
help='Enable debug output\n\n',
|
||||||
action='store_const', const=logging.DEBUG,
|
action='store_const', const=logging.DEBUG,
|
||||||
|
44
stx/lib/stx/stx_repomgr.py
Normal file
44
stx/lib/stx/stx_repomgr.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# Copyright (c) 2021 Wind River Systems, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from stx import command # pylint: disable=E0611
|
||||||
|
from stx import utils # pylint: disable=E0611
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger('STX-Repomgr')
|
||||||
|
utils.set_logger(logger)
|
||||||
|
|
||||||
|
|
||||||
|
def handleRepomgr(args):
|
||||||
|
'''Sync the repo '''
|
||||||
|
|
||||||
|
logger.setLevel(args.loglevel)
|
||||||
|
logger.debug('Execute the repomgr command: [%s]', args.repomgr_task)
|
||||||
|
|
||||||
|
podname = command.get_pod_name('builder')
|
||||||
|
if not podname:
|
||||||
|
logger.error('The builder container does not exist, so please \
|
||||||
|
consider to use the control module')
|
||||||
|
|
||||||
|
prefix_cmd = command.generatePrefixCommand(podname, '', 1)
|
||||||
|
cmd = prefix_cmd + '"repo_manage.py ' + args.repomgr_task + '"\''
|
||||||
|
logger.debug('Manage the repo with the command [%s]', cmd)
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.check_call(cmd, shell=True)
|
||||||
|
except subprocess.CalledProcessError as exc:
|
||||||
|
raise Exception('Failed to manage the repo with the command [%s].\n \
|
||||||
|
Returncode: %s' % (cmd, exc.returncode))
|
Loading…
Reference in New Issue
Block a user