commit c0951be3e11149137d17e4975a06ae8221d4c2ad
parent a67e5b899453b4e86399e4ccf96ec6b449d726c9
Author: nolash <dev@holbrook.no>
Date: Sat, 8 Jan 2022 20:13:05 +0000
Initial commit
Diffstat:
A | setup.py.env | | | 2 | ++ |
M | to_debian.pl | | | 106 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- |
M | to_python.pl | | | 91 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- |
3 files changed, 164 insertions(+), 35 deletions(-)
diff --git a/setup.py.env b/setup.py.env
@@ -0,0 +1,2 @@
+[main:py]
+license_file=LICENSE
diff --git a/to_debian.pl b/to_debian.pl
@@ -3,37 +3,61 @@
use warnings;
use strict;
-use Config::Simple;
+# standard imports
use Getopt::Long qw/:config auto_help/;
+use File::Spec qw/ catfile /;
+use Cwd qw/ getcwd abs_path /;
+
+# external imports
+use Config::Simple;
my $deb_standards_version = '3.9.5';
my $deb_priority = 'optional';
my $deb_arch = 'any';
+my $deb_section = 'development';
+my $ini_dir = File::Spec->catfile(getcwd, '.bluto');
+my $out_dir = File::Spec->catfile(getcwd, 'debian');
GetOptions(
+ 'd:s', \$ini_dir,
+ 'o:s', \$out_dir,
'standards-version:s' => \$deb_standards_version,
'priority:s' => \$deb_priority,
'arch:s' => \$deb_arch,
+ 'section=s' => \$deb_section,
);
+$ini_dir = abs_path($ini_dir);
+print STDERR "using ini dir " . $ini_dir . "\n";
-Config::Simple->import_from('setup.env', \my %config);
-Config::Simple->import_from('setup.deb.env', \my %config_deb);
+my $fn = File::Spec->catfile($ini_dir, 'bluto.ini');
+Config::Simple->import_from($fn, \my %config);
+$fn = File::Spec->catfile($ini_dir, 'bluto.deb.ini');
+Config::Simple->import_from($fn, \my %config_deb);
-our $first_author;
+our $deb_first_author;
+our $deb_first_url;
+our $deb_first_license;
for my $k (keys %config) {
my @p = split(/:/, $k);
- print "processing key " . $k . " " . $p[0] . "\n";
- if ($p[0] eq 'author' && ! defined $first_author) {
+ print STDERR "processing key " . $k . " " . $p[0] . "\n";
+ if ($p[0] eq 'author' && ! defined $deb_first_author) {
my @n = split(/\./, $p[1]);
my $name = $config{'author:' . $n[0] . '.name'};
- $first_author = $name;
+ $deb_first_author = $name;
my $email = $config{'author:' . $n[0] . '.email'};
if (defined $email) {
- $first_author .= ' <' . $email . '>';
+ $deb_first_author .= ' <' . $email . '>';
}
+ } elsif ($p[0] eq 'locate' && ! defined $deb_first_url) {
+ $deb_first_url = $config{$k};
+ }
+
+ @p = split(/\./, $p[0], 2);
+ if ($p[0] eq 'license' && ! defined $deb_first_license) {
+ $deb_first_license = $p[1] . '-' . $config{$k};
}
}
@@ -54,16 +78,58 @@ for my $k (keys %config_deb) {
}
}
+my $fh;
+$fn = File::Spec->catfile($out_dir, 'control');
+open($fh, '>', $fn);
+
+print $fh "Source: " . $config{'main.name'} . "\n";
+print $fh "Section: " . $deb_section . "\n";
+print $fh "Priority: " . $deb_priority . "\n";
+print $fh "Maintainer: " . $deb_first_author . "\n";
+print $fh "Standards-Version: " . $deb_standards_version . "\n";
+print $fh "Package: " . $config{'main.name'} . "\n";
+print $fh "Architecture: " . $deb_arch . "\n";
+my $v = join(', ', @{$deb_depends{'build'}});
+if ($v ne '') {
+ print $fh "Build-Depends: " . $v . "\n";
+}
+print $fh "\n";
+
+$v = join(', ', @{$deb_depends{'install'}});
+if ($v ne '') {
+ print $fh "Pre-Depends: " . $v. "\n";
+}
+$v = join(', ', @{$deb_depends{'exec'}});
+if ($v ne '') {
+ print $fh "Depends: " . $v. "\n";
+}
+print $fh "Description: " . $config{'main.summary'} . "\n";
+close($fh);
+
+
+$fn = File::Spec->catfile($out_dir, 'compat');
+open($fh, '>', $fn);
+print $fh $config_deb{'main:deb.engine'};
+close($fh);
+
+$fn = File::Spec->catfile($out_dir, 'copyright');
+open($fh, '>', $fn);
+print $fh "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\n";
+print $fh "Upstream-Name: " . $config{'main.name'}. "\n";
+print $fh "Source: " . $deb_first_url . "\n";
+print $fh "\n";
+print $fh "Files: *\n";
+
+my @time = localtime();
+my $year = $time[5] + 1900;
+print $fh "Copyright: Copyright " . $year . " " . $deb_first_author . "\n";
+print $fh "License: " . $deb_first_license . "\n";
+close($fh);
-print "Source: " . $config{'main.name'} . "\n";
-print "Section: " . $config{'tech.name'} . "\n";
-print "Priority: " . $deb_priority . "\n";
-print "Maintainer: " . $first_author . "\n";
-print "Standards-Version: " . $deb_standards_version . "\n";
-print "Build-Depends: " . join(', ', @{$deb_depends{'build'}}) . "\n";
-print "\n";
-print "Package: " . $config{'main.name'} . "\n";
-print "Architecture: " . $deb_arch . "\n";
-print "Pre-Depends: " . join(', ', @{$deb_depends{'install'}}) . "\n";
-print "Depends: " . join(', ', @{$deb_depends{'exec'}}) . "\n";
-print "Description: " . $config{'main.summary'} . "\n";
+$fn = File::Spec->catfile($out_dir, 'changelog');
+if (! -f $fn) {
+ open($fh, '>', $fn);
+ print $fh $config{'main.name'} . " (" . $config{'main.version'} . ") UNRELEASED; urgency: low\n\n";
+ print $fh " * Automatic commit message from bluto\n\n";
+ print $fh " -- " . $first_author . " " .
+ close($fh);
diff --git a/to_python.pl b/to_python.pl
@@ -3,46 +3,107 @@
use warnings;
use strict;
-use Config::Simple;
+# standard imports
use Getopt::Long qw/ :config auto_help /;
use File::Temp qw/ tempdir /;
use File::Spec qw/ catfile /;
+use File::Basename qw/ dirname /;
+use Cwd qw/ getcwd abs_path /;
+
+# external imports
+use Config::Simple;
+
+# local imports
+use lib dirname(abs_path($0));
+use Log::Term::Ansi qw/error info debug warn trace/;
+
+my $ini_dir = File::Spec->catfile(getcwd, '.bluto');
+GetOptions(
+ 'd:s', \$ini_dir,
+);
+$ini_dir = abs_path($ini_dir);
-Config::Simple->import_from('setup.env', \my %config);
+info("using ini dir " . $ini_dir . "\n");
+
+my $fn = File::Spec->catfile($ini_dir, 'bluto.ini');
+Config::Simple->import_from($fn, \my %config);
+
+$fn = File::Spec->catfile($ini_dir, 'bluto.py.ini');
+Config::Simple->import_from($fn, \my %config_py);
+
+my $r;
my $d = tempdir( CLEANUP => 1 );
-my $fn = File::Spec->catfile($d, 'config_py.ini');
+$fn = File::Spec->catfile($d, 'config_py.ini');
my $fh;
open($fh, '>', $fn);
print $fh "[metadata]\n";
close($fh);
-our %first_author = (
+our %py_first_author = (
name => undef,
email => undef,
);
-our $first_url;
+
+our $py_first_url;
+our $py_first_license;
for my $k (keys %config) {
- my @p = split(/:/, $k);
- if ($p[0] eq 'author' && ! defined $first_author{'name'}) {
+ my @p = split(/:/, $k, 2);
+ if ($p[0] eq 'author' && ! defined $py_first_author{'name'}) {
my @n = split(/\./, $p[1]);
my $name = $config{'author:' . $n[0] . '.name'};
- $first_author{'name'} = $name;
+ $py_first_author{'name'} = $name;
my $email = $config{'author:' . $n[0] . '.email'};
if (defined $email) {
- $first_author{'email'} = $email;
+ $py_first_author{'email'} = $email;
+ }
+ } elsif ($p[0] eq 'locate' && ! defined $py_first_url) {
+ $py_first_url = $config{$k};
+ }
+
+ @p = split(/\./, $p[0], 2);
+ if ($p[0] eq 'license' && ! defined $py_first_license) {
+ $py_first_license = $p[1] . $config{$k};
+ }
+}
+
+our @py_tags;
+our @py_classifiers;
+my $fh_tag;
+$r = open($fh_tag, '<', 'bluto.tag');
+if ($r) {
+ while (<$fh_tag>) {
+ my $v = $_;
+ chomp($v);
+ my @p = split(/ :: /, $v);
+ if ($#p > 0) {
+ push(@py_classifiers, $v);
+ } else {
+ push(@py_tags, $v);
}
- } elsif ($p[0] eq 'locate' && ! defined $first_url) {
- $first_url = $config{$k};
}
}
my $py_cfg = new Config::Simple($fn);
-$py_cfg->param('metadata.author_email', $first_author{email});
-$py_cfg->param('metadata.author', $first_author{name});
+$py_cfg->param('metadata.author_email', $py_first_author{email});
+$py_cfg->param('metadata.author', $py_first_author{name});
$py_cfg->param('metadata.description', $config{'main.summary'});
-$py_cfg->param('metadata.url', $first_url);
+$py_cfg->param('metadata.url', $py_first_url);
$py_cfg->param('metadata.version', $config{'main.version'});
$py_cfg->param('metadata.name', $config{'main.name'});
+$py_cfg->param('metadata.license', $py_first_license);
+print $py_cfg->as_string();
-print $py_cfg->as_string()
+if ($#py_tags > -1) {
+ print "keywords =\n";
+ for my $v (@py_tags) {
+ print "\t" . $v . "\n";
+ }
+}
+
+if ($#py_classifiers > -1) {
+ print "classifiers =\n";
+ for my $v (@py_classifiers) {
+ print "\t" . $v . "\n";
+ }
+}