Remove pkgbuilder help text from repomgr commands
Repomgr commands are often forwarded into the
package builder for execution. They are run under the
user's id, and a help text is displayed as if the
'stx control enter' command had been used. That help
text is confusing in this context.
The mechanism to run these commands failed to distinguish
'user' from 'interactive'. This update adds that distinction.
Only an interactive session should display the help text.
Repomgr will use the non-interactive method, avoiding the
unwanted help text.
This update also adds some missing repomgr sub-commands supported
by the repo_manage.py back end, e.g. search_pkg. It also fixes
arguement passing so that --help functions as expected on sub-commands.
NOTE: While testing, I noticed that two recently added repomgr commands,
'merge' and 'search_pkg', available within the build container, were
reflected in the external wrapper. I've added them
Testing
stx control enter ... displays help text
stx repomgr list ... shows repo list without help text
stx repomgr search_pkg --help ...
command is valid and help functions as expected
stx repomgr merge --help
command is valid and help functions as expected
Story: 2008862
Task: 44683
Signed-off-by: Scott Little <scott.little@windriver.com>
Change-Id: Iad96b3f93ce15c52837ddebed16b9f67899ea27c
This commit is contained in:
@@ -71,20 +71,27 @@ class KubeHelper:
|
||||
else:
|
||||
return False
|
||||
|
||||
def generatePrefixCommand(self, podname, command, enableuser):
|
||||
def generatePrefixCommand(self, podname, command, enableuser, interactive=False):
|
||||
'''Generate the command executed in the host'''
|
||||
|
||||
prefix_exec_cmd = self.config.kubectl() + ' exec -ti '
|
||||
builder_exec_cmd = prefix_exec_cmd + podname
|
||||
prefix_bash_cmd = ' -- bash -l -c '
|
||||
prefix_bash_with_user_cmd = ' -- bash -l -c \'sudo -u ${MYUNAME} bash \
|
||||
prefix_bash_with_user_cmd = ' -- bash -l -c \'sudo -u ${MYUNAME} \
|
||||
BASH_ENV=/home/$MYUNAME/userenv bash --rcfile /home/$MYUNAME/userenv -c '
|
||||
prefix_bash_with_interactive_user_cmd = ' -- bash -l -i -c \'sudo -u ${MYUNAME} bash \
|
||||
--rcfile /home/$MYUNAME/userenv -i -c '
|
||||
builder_exec_bash_cmd = builder_exec_cmd + prefix_bash_cmd
|
||||
builder_exec_bash_with_user_cmd = builder_exec_cmd + \
|
||||
prefix_bash_with_user_cmd
|
||||
builder_exec_bash_with_interactive_user_cmd = builder_exec_cmd + \
|
||||
prefix_bash_with_interactive_user_cmd
|
||||
|
||||
if enableuser:
|
||||
cmd = builder_exec_bash_with_user_cmd + command
|
||||
if interactive:
|
||||
cmd = builder_exec_bash_with_interactive_user_cmd + command
|
||||
else:
|
||||
cmd = builder_exec_bash_with_user_cmd + command
|
||||
else:
|
||||
cmd = builder_exec_bash_cmd + command
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class HandleBuildTask:
|
||||
'***********************************')
|
||||
sys.exit(1)
|
||||
|
||||
prefix_cmd = self.k8s.generatePrefixCommand(podname, '', 1)
|
||||
prefix_cmd = self.k8s.generatePrefixCommand(podname, '', 1, 1)
|
||||
|
||||
if args.build_task == 'image':
|
||||
cmd = self.buildImageCMD(args, prefix_cmd)
|
||||
|
||||
@@ -127,12 +127,14 @@ image.\t\teg: [ prepare|layer|image|download|world|${pkgname}]')
|
||||
|
||||
repo_subparser = subparsers.add_parser('repomgr',
|
||||
help='Manage source|binary \
|
||||
packages.\t\teg: [ list|download|sync|mirror|clean|remove_repo|upload_pkg|\
|
||||
delete_pkg ]')
|
||||
packages.\t\teg: [ list|download|sync|merge|mirror|clean|\
|
||||
remove_repo|search_pkg|upload_pkg|delete_pkg ]')
|
||||
repo_subparser.add_argument('repomgr_task',
|
||||
help='[ list|download|sync|mirror|clean|\
|
||||
remove_repo|upload_pkg|delete_pkg ]: \
|
||||
help='[ list|download|sync|merge|mirror|clean|\
|
||||
remove_repo|search_pkg|upload_pkg|delete_pkg ]: \
|
||||
Execute the management task.\n\n')
|
||||
# Pass remaining arguements into repo_manage.py for additional processing
|
||||
repo_subparser.add_argument('args', nargs=argparse.REMAINDER)
|
||||
repo_subparser.set_defaults(handle=self.handlerepomgr.handleCommand)
|
||||
|
||||
parser.add_argument('-d', '--debug',
|
||||
|
||||
@@ -16,6 +16,7 @@ import logging
|
||||
from stx.k8s import KubeHelper
|
||||
from stx import utils # pylint: disable=E0611
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger('STX-Repomgr')
|
||||
utils.set_logger(logger)
|
||||
@@ -38,12 +39,14 @@ class HandleRepomgrTask:
|
||||
logger.error('The builder container does not exist, so please \
|
||||
consider to use the control module')
|
||||
|
||||
prefix_cmd = self.k8s.generatePrefixCommand(podname, '', 1)
|
||||
cmd = prefix_cmd + '"repo_manage.py ' + args.repomgr_task + '"\''
|
||||
prefix_cmd = self.k8s.generatePrefixCommand(podname, '', 1, 0)
|
||||
cmd = prefix_cmd + ' '.join(['"repo_manage.py', args.repomgr_task, ' '.join(args.args), '"\''])
|
||||
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 \
|
||||
# raise Exception('Failed to manage the repo with the command [%s].\n \
|
||||
logger.error('Failed to manage the repo with the command [%s].\n \
|
||||
Returncode: %s' % (cmd, exc.returncode))
|
||||
sys.exit(2)
|
||||
|
||||
@@ -19,6 +19,7 @@ if [ ! -d $MY_WORKSPACE ]; then
|
||||
mkdir -p $MY_WORKSPACE > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
if echo $- | grep -q i ; then
|
||||
cat <<EOF
|
||||
To ease checkout do:
|
||||
!!!! Mandatory:
|
||||
@@ -47,5 +48,5 @@ To make image:
|
||||
build-image [ -t std|rt ]
|
||||
|
||||
EOF
|
||||
|
||||
fi
|
||||
cd ${MY_WORKSPACE}
|
||||
|
||||
Reference in New Issue
Block a user