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ý <mkonecny@redhat.com>
This commit is contained in:
Michal Konečný 2021-02-25 13:48:09 +01:00
parent b6d333ab47
commit 0d832c631a
8 changed files with 76 additions and 23 deletions

View file

@ -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

View file

@ -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

View file

@ -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']),]
)

View file

@ -16,5 +16,5 @@
from centpkg.__main__ import main
if __name__ == "__main__":
main()
main(sig=False)

21
src/bin/centpkg-sig Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python
'''
centpkg - a script to interact with CentOS Packages
'''
#
# Author(s):
# Brian Stinson <bstinson@ksu.edu>
# Pat Riehecky <riehecky@fnal.gov>
# Michal Konecny <michal.konecny@psmail.xyz>
#
# 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)

View file

@ -1,4 +1,4 @@
[centpkg]
[centpkg-sig]
lookaside = https://git.centos.org/sources
lookasidehash = sha512
lookaside_cgi = https://git.centos.org/sources/upload.cgi

View file

@ -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()

View file

@ -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