From 25f0301bc442f2cf67a7bacf58f8f549380ff26e Mon Sep 17 00:00:00 2001 From: u Date: Jan 03 2025 16:51:35 +0000 Subject: update --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92417c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc* diff --git a/obs-service-py2pack_generate.spec b/obs-service-py2pack_generate.spec new file mode 100644 index 0000000..37f85bb --- /dev/null +++ b/obs-service-py2pack_generate.spec @@ -0,0 +1,51 @@ +# +# spec file for package obs-service-cpanspec +# +# Copyright (c) 2024 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# +%global service py2pack_generate + +Name: obs-service-py2pack_generate +Summary: An OBS source service: Create spec files for cpan sources +License: GPL-2.0-or-later +Group: Development/Tools/Building +Version: 0.1 +Release: 0 +Source: py2pack_generate +Source1: py2pack_generate.service +Requires: python3-py2pack +BuildArch: noarch +BuildRequires: rpm_macro(_obs_service_dir) + +%description +This is a source service for openSUSE Build Service. + +It's a wrapper around cpanspec script + +%prep +%setup -q -D -T 0 -c +sed -i 's~/usr/bin~%{_bindir}~' %{SOURCE0} + +%build + +%install +install -Dm 0755 %{SOURCE0} %{buildroot}%{_obs_service_dir}/py2pack_generate +install -Dm 0644 %{SOURCE1} %{buildroot}%{_obs_service_dir}/py2pack_generate.service + +%files +%defattr(-,root,root) +%{_obs_service_dir}/py2pack_generate +%{_obs_service_dir}/py2pack_generate.service + +%changelog diff --git a/py2pack_generate b/py2pack_generate new file mode 100644 index 0000000..52b4083 --- /dev/null +++ b/py2pack_generate @@ -0,0 +1,34 @@ +#!/usr/bin/python3 +from py2pack import generate, file_template_list +import argparse +from pathlib import Path +import sys +from os import getcwd +parser_generate = argparse.ArgumentParser(description='generate RPM spec or DEB dsc file from a package') +parser_generate.add_argument('--name', help='package name') +parser_generate.add_argument('--version', nargs='?', help='package version (optional)') +parser_generate.add_argument('--source-url', default=None, help='source url (optional)') +parser_generate.add_argument('--source-glob', help='source glob template (optional)') +parser_generate.add_argument('--local', default='disable', choices=['enable', 'disable'], help='build from local package') +parser_generate.add_argument('--noop', default='disable', choices=['enable', 'disable'], help='do nothing') +parser_generate.add_argument('--localfile', default='', help='path to the local PKG-INFO or json metadata (optional)') +parser_generate.add_argument('--template', choices=file_template_list(), default='opensuse.spec', help='file template') +parser_generate.add_argument('--filename', help='output filename (optional)') +parser_generate.add_argument('--outdir', help='output directory', default=getcwd()) +args = parser_generate.parse_args(sys.argv[1:]) +if args.noop == 'enable': + exit(0) + +args.run = None +args.local = args.local == 'enable' + +filename = args.filename +if not filename: + filename = 'python-'+args.name+Path(args.template).suffix +filename = Path(filename) +if not filename.is_absolute(): + filename = Path(args.outdir) / filename +args.filename = str(filename) + +generate(args) + diff --git a/py2pack_generate.service b/py2pack_generate.service new file mode 100644 index 0000000..eaa476e --- /dev/null +++ b/py2pack_generate.service @@ -0,0 +1,35 @@ + + Use of the py2pack_generate command + Generate a spec file for a PyPI module + + Package name. + + + Package version (optional) + + + Source url (optional) + + + Source glob template (optional) + + + Build from local package + enable + disable + + + Do nothing (default: disable) + enable + disable + + + Path to the local PKG-INFO or json metadata (optional) + + + File template + + + Output filename (optional) + +