From 0d832c631a53a25874b97ef4bdb5a133e2a644b9 Mon Sep 17 00:00:00 2001 From: Michal Konečný Date: Feb 25 2021 12:53:23 +0000 Subject: Add centpkg-sig Add executable centpkg-sig which allows user to interact with CentOS Linux dist-git and CentOS Linux koji instance. Signed-off-by: Michal Konečný --- diff --git a/README.md b/README.md index 5b9d7b7..bcbc2fe 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,14 @@ For now only a very small subset of rpkg commands are enabled. Exception handling at the top level has been disabled for now to get better tracebacks during development. +This repository provides two executable scripts centpkg and centpkg-sig. + +## centpkg +Executable centpkg allows you to interact with CentOS Stream dist-git and CentOS Stream koji instance. + +## centpkg-sig +Executable centpkg-sig allows you to interact with CentOS Linux dist-git and CentOS Linux koji instance. + ## Supported commands Here is the list currently supported commands by centpkg: @@ -17,17 +25,21 @@ Here is the list currently supported commands by centpkg: * sources * new-sources +Here is the list currently supported commands by centpkg-sig: + +* clone + ## Current workflow For a sig working on a package in git.centos.org, the following workflow is recommended: # In this example a member of the virt sig would like to scratch-build a2ps on EL6 - $ centpkg clone -b virt6 a2ps + $ centpkg-sig clone -b virt6 a2ps $ cd a2ps - $ centpkg build --srpm --scratch + $ centpkg-sig build --srpm --scratch # Tagged builds can be done also - $ centpkg build --srpm + $ centpkg-sig build --srpm ## License diff --git a/centpkg.spec b/centpkg.spec index 80a886a..6e23b6a 100644 --- a/centpkg.spec +++ b/centpkg.spec @@ -28,7 +28,7 @@ BuildRequires: python-devel, python-setuptools BuildRequires: pyrpkg %description -Provides the centpkg command for working with dist-git +Provides the centpkg and centpkg-sig commands for working with dist-git %prep %setup -q -c @@ -48,11 +48,15 @@ rm -rf %{buildroot} %defattr(-,root,root,-) %doc README.md COPYING %config %{_sysconfdir}/rpkg/centpkg.conf +%config %{_sysconfdir}/rpkg/centpkg-sig.conf %{_bindir}/%{name} %{python_sitelib}/* %changelog +* Thu Feb 25 2021 mkonecny@redhat.com 0.5.0-1 +- Add centpkg-sig command + * Mon Nov 28 2016 brian@bstinson.com 0.4.6-1 - Tracking updates to rpkg (thanks pavlix) - Fix the URL building code in the sources method diff --git a/setup.py b/setup.py index 77756b0..dc83136 100644 --- a/setup.py +++ b/setup.py @@ -40,6 +40,6 @@ setup( package_dir={'': 'src'}, packages=['centpkg'], install_requires=get_requirements(), - scripts=['src/bin/centpkg'], - data_files=[('/etc/rpkg',['src/centpkg.conf']),] + scripts=['src/bin/centpkg', 'src/bin/centpkg-sig'], + data_files=[('/etc/rpkg',['src/centpkg.conf', 'src/centpkg-sig.conf']),] ) diff --git a/src/bin/centpkg b/src/bin/centpkg index adc5811..040626d 100755 --- a/src/bin/centpkg +++ b/src/bin/centpkg @@ -16,5 +16,5 @@ from centpkg.__main__ import main if __name__ == "__main__": - main() + main(sig=False) diff --git a/src/bin/centpkg-sig b/src/bin/centpkg-sig new file mode 100644 index 0000000..156c43a --- /dev/null +++ b/src/bin/centpkg-sig @@ -0,0 +1,21 @@ +#!/usr/bin/env python +''' + centpkg - a script to interact with CentOS Packages +''' +# +# Author(s): +# Brian Stinson +# Pat Riehecky +# Michal Konecny +# +# 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. See http://www.gnu.org/copyleft/gpl.html for +# the full text of the license. + +from centpkg.__main__ import main + +if __name__ == "__main__": + main(sig=True) + diff --git a/src/centpkg-sig.conf b/src/centpkg-sig.conf index 590e4b2..0e9ac51 100644 --- a/src/centpkg-sig.conf +++ b/src/centpkg-sig.conf @@ -1,4 +1,4 @@ -[centpkg] +[centpkg-sig] lookaside = https://git.centos.org/sources lookasidehash = sha512 lookaside_cgi = https://git.centos.org/sources/upload.cgi diff --git a/src/centpkg/__main__.py b/src/centpkg/__main__.py index c394ae3..d6b599f 100644 --- a/src/centpkg/__main__.py +++ b/src/centpkg/__main__.py @@ -24,7 +24,13 @@ import pyrpkg.utils import centpkg.cli -def main(): +def main(sig: bool): + """ + Centpkg main. + + Params: + sig: Flag to switch between centpkg-sig and centpkg. + """ # Setup an argparser and parse the known commands to get the config file program_name = os.path.basename(sys.argv[0]) @@ -32,20 +38,16 @@ def main(): # of commandline arguments with common prefix). Generaly it is available since python3.6. # This enables "allow_abbrev" for older python versions. parser = pyrpkg.cli.ArgumentParser(add_help=False) - parser.add_argument('-S', '--sig', help='Operate as a CentOS SIG user instead of using the Stream distro environment', - default=False, - action='store_true') - parser.add_argument('-C', '--config', help='Specify a config file to use') + if sig: + parser.add_argument('-C', '--config', help='Specify a config file to use', + default='/etc/rpkg/centpkg-sig.conf') + else: + parser.add_argument('-C', '--config', help='Specify a config file to use', + default='/etc/rpkg/centpkg.conf') (args, other) = parser.parse_known_args() - if not args.config: - if args.sig: - args.config = '/etc/rpkg/centpkg-sig.conf' - else: - args.config = '/etc/rpkg/centpkg.conf' - # Make sure we have a sane config file if not os.path.exists(args.config) and not other[-1] in ['--help', '-h', 'help']: sys.stderr.write('Invalid config file %s\n' % args.config) @@ -55,7 +57,10 @@ def main(): config = ConfigParser.SafeConfigParser() config.read(args.config) - client = centpkg.cli.centpkgClient(config) + if sig: + client = centpkg.cli.centpkgClientSig(config) + else: + client = centpkg.cli.centpkgClient(config) client.do_imports(site='centpkg') client.parse_cmdline() diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index 3fc5a8f..2bd69d7 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -28,7 +28,18 @@ class centpkgClient(cliClient): self.register_parser() def register_parser(self): - self.parser.add_argument('-S', '--sig', help='Operate as a CentOS SIG user instead of using the Stream distro environment', - default=False, - action='store_true') + pass + +class centpkgClientSig(cliClient): + def __init__(self, config, name=None): + self.DEFAULT_CLI_NAME = 'centpkg-sig' + super(centpkgClientSig, self).__init__(config, name) + + self.setup_centos_subparsers() + + def setup_centos_subparsers(self): + self.register_parser() + + def register_parser(self): + pass