commit 4eaef31533f15ab39381be8eb8e8e65d709196c0
parent a9624a027b6e00ee191613cac8c49db7fcd3c5e7
Author: lash <dev@holbrook.no>
Date: Mon, 30 Sep 2024 02:38:25 +0100
Bundle external modules, makemaker, executables
Diffstat:
12 files changed, 275 insertions(+), 249 deletions(-)
diff --git a/Bluto.pm b/Bluto.pm
@@ -1,18 +1,17 @@
package Bluto;
use File::Basename qw/ basename /;
-use SemVer;
+use File::Path qw / make_path /;
-use Log::Term::Ansi qw/error info debug warn trace/;
+use Bluto::Log qw/error info debug warn trace/;
use Bluto::Archive;
use Bluto::Announce;
use Bluto::Tree;
-use File::Path qw / make_path /;
-
-use Log::Term::Ansi qw/info debug/;
+use Bluto::SemVer;
use constant { VCS_TAG_PREFIX => 'v' };
-use constant { VERSION => '0.0.1' };
+#use constant { VERSION => '0.0.1' };
+our $VERSION = '0.0.1' ;
our %config;
our $have_version_match = undef;
@@ -46,6 +45,10 @@ our %m_main = (
engine => undef,
);
+sub version {
+ return $VERSION;
+}
+
sub _set_single {
my $cfg = shift;
my $cfg_k = shift;
diff --git a/Bluto/Announce.pm b/Bluto/Announce.pm
@@ -2,7 +2,7 @@ package Bluto::Announce;
use Template;
-use Log::Term::Ansi qw/error info debug warn trace/;
+use Bluto::Log qw/error info debug warn trace/;
my $pos;
diff --git a/Bluto/Archive.pm b/Bluto/Archive.pm
@@ -4,7 +4,7 @@ use Cwd;
use File::Basename qw/basename fileparse/;
use Digest::SHA;
-use Log::Term::Ansi qw/error info debug warn trace/;
+use Bluto::Log qw/error info debug warn trace/;
use Bluto::Tree qw/release_path/;
use File::Path qw / make_path /;
diff --git a/Bluto/Log.pm b/Bluto/Log.pm
@@ -0,0 +1,33 @@
+package Bluto::Log;
+
+use Exporter qw/import/;
+our @EXPORT = qw/error info debug warn trace/;
+our $VERSION = 0.0.1;
+
+our $fh = STDERR;
+
+sub error($) {
+ print $fh "\e[0;91m" . shift . "\e[0m\n";
+}
+
+sub warn($) {
+ print $fh "\e[0;93m" . shift . "\e[0m\n";
+}
+
+sub debug($) {
+ print $fh "\e[0;90m" . shift . "\e[0m\n";
+}
+
+sub info($) {
+ print $fh "\e[0;92m" . shift . "\e[0m\n";
+}
+
+sub debug($) {
+ print $fh "\e[0;94m" . shift . "\e[0m\n";
+}
+
+sub trace($) {
+ print $fh "\e[0;90m" . shift . "\e[0m\n";
+}
+
+1;
diff --git a/Bluto/RSS.pm b/Bluto/RSS.pm
@@ -5,7 +5,7 @@ use DateTime;
use XML::RSS;
-use Log::Term::Ansi qw/error info debug warn trace/;
+use Bluto::Log qw/error info debug warn trace/;
use Bluto::Tree qw/announce_path/;
diff --git a/SemVer.pm b/Bluto/SemVer.pm
diff --git a/Log/Term/Ansi.pm b/Log/Term/Ansi.pm
@@ -1,32 +0,0 @@
-package Log::Term::Ansi;
-
-use Exporter qw/import/;
-our @EXPORT = qw/error info debug warn trace/;
-
-our $fh = STDERR;
-
-sub error($) {
- print $fh "\e[0;91m" . shift . "\e[0m\n";
-}
-
-sub warn($) {
- print $fh "\e[0;93m" . shift . "\e[0m\n";
-}
-
-sub debug($) {
- print $fh "\e[0;90m" . shift . "\e[0m\n";
-}
-
-sub info($) {
- print $fh "\e[0;92m" . shift . "\e[0m\n";
-}
-
-sub debug($) {
- print $fh "\e[0;94m" . shift . "\e[0m\n";
-}
-
-sub trace($) {
- print $fh "\e[0;90m" . shift . "\e[0m\n";
-}
-
-1;
diff --git a/Makefile.PL b/Makefile.PL
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+use lib '.';
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Bluto',
+ AUTHOR => q(Louis Holbrook <dev@holbrook.no>),
+ VERSION_FROM => 'Bluto.pm',
+ ABSTRACT => 'A simple-minded software packager',
+ LICENSE => 'perl',
+ EXE_FILES => [
+ 'bluto-gen',
+ 'bluto-pub',
+ ],
+ PREREQ_PM => {
+ 'SemVer' => 0.10.1,
+ 'Template' => 2.66,
+ 'Digest::SHA' => 2.13,
+ 'XML::RSS' => 1.63,
+ },
+ TEST_REQUIRES => {},
+);
diff --git a/bluto-gen b/bluto-gen
@@ -0,0 +1,93 @@
+#!/usr/bin/env perl
+
+use v5.10.1;
+use warnings;
+use strict;
+
+use Getopt::Long qw/ :config auto_help /;
+use File::Basename qw/ dirname /;
+use File::Spec;
+use File::Copy;
+use Cwd qw/ getcwd abs_path /;
+use lib (dirname(abs_path($0)));
+use Digest::SHA;
+
+use SemVer;
+use YAML::Tiny;
+
+use Bluto::Log qw/debug/;
+
+# TODO: export to perl modules
+
+
+sub croak {
+ die(shift);
+}
+
+sub help() {
+ print("$0\n\nwould have shown help...\n");
+ exit 0;
+}
+
+my $force_version = undef;
+my $loglevel = 0;
+my $force_help = 0;
+my %env = (
+ src_dir => File::Spec->catfile(getcwd, '.bluto'),
+ changelog_file => undef,
+ version => undef,
+ loglevel => undef,
+);
+GetOptions(
+ 'd:s', \$env{src_dir},
+ 'f:s', \$env{changelog_file},
+ 'v+', \$loglevel,
+ 'h+', \$force_help,
+ 'help+', \$force_help,
+ 'version=s', \$force_version,
+);
+
+if ($force_help > 0) {
+ help;
+}
+
+foreach my $k (keys %env ) {
+ if (defined $env{$k}) {
+ $env{$k} = abs_path($env{$k});
+ }
+}
+
+if (defined $force_version) {
+ $env{version} = SemVer->new($force_version);
+}
+
+my $fn = File::Spec->catfile($env{src_dir}, 'bluto.yml');
+my $yi = YAML::Tiny->read($fn);
+
+my @contributors;
+my $yd = $yi->[0];
+my $yv = {
+ changelog => 'sha256:' . process_changelog(\%env, 1),
+ author => $yd->{author}->{name},
+ maintainer => $yd->{maintainer}->{name},
+ contributors => \@contributors,
+};
+my $yo = YAML::Tiny->new($yv);
+$fn = File::Spec->catfile($env{src_dir}, $env{version} . '.yml');
+$yo->write($fn);
+
+
+sub process_changelog {
+ my $env = shift;
+ my $copy = shift;
+
+ my $h = Digest::SHA->new('sha256');
+ $h->addfile($env->{changelog_file});
+ my $z = $h->hexdigest;
+ debug('calculated sha256 ' . $z . ' for changelog ' . $env->{changelog_file});
+ if ($copy) {
+ my $fp = File::Spec->catfile($env->{src_dir}, 'CHANGELOG.' . $env->{version});
+ copy($env->{changelog_file}, $fp);
+ }
+ return $z;
+}
diff --git a/bluto-pub b/bluto-pub
@@ -0,0 +1,114 @@
+#!/usr/bin/env perl
+
+use v5.10.1;
+use warnings;
+use strict;
+
+# standard imports
+use Getopt::Long qw/ :config auto_help /;
+#use File::Temp qw/ tempdir /;
+use File::Basename qw/ dirname /;
+use File::Spec;
+use Cwd qw/ getcwd abs_path /;
+use lib (dirname(abs_path($0)));
+
+# external imports
+use Config::Simple;
+use YAML::Tiny;
+
+# local imports
+use Bluto::Log qw/debug/;
+use Bluto;
+use Bluto::RSS;
+use Bluto::SemVer;
+
+sub croak {
+ die(shift);
+}
+
+sub help() {
+ print("$0\n\nwould have shown help...\n");
+ exit 0;
+}
+
+# TODO: export to perl modules
+
+my $force_version = undef;
+my $loglevel = 0;
+my $force_help = 0;
+my %env = (
+ src_dir => File::Spec->catfile(getcwd, '.bluto'),
+ out_dir => File::Spec->catfile(getcwd, 'bluto_build'),
+ feed_dir => undef,
+ content_dir => getcwd,
+ template_path => undef,
+ engine => undef,
+ readme => undef,
+ version => undef,
+ loglevel => undef,
+);
+GetOptions(
+ 'd:s', \$env{src_dir},
+ 'o:s', \$env{out_dir},
+ 'f:s', \$env{feed_dir},
+ 'c:s', \$env{content_dir},
+ 'v+', \$loglevel,
+ 'h+', \$force_help,
+ 'help+', \$force_help,
+ 'version=s', \$force_version,
+);
+
+if ($force_help > 0) {
+ help;
+}
+
+foreach my $k (keys %env ) {
+ if (defined $env{$k}) {
+ $env{$k} = abs_path($env{$k});
+ }
+}
+
+if (!defined $env{feed_dir}) {
+ $env{feed_dir} = $env{out_dir};
+}
+
+if (defined $force_version) {
+ $env{version} = SemVer->new($force_version);
+}
+
+$env{loglevel} = $loglevel;
+
+$env{engine} = 'bluto v' . SemVer->new(Bluto::version()). " (perl $^V)";
+foreach my $k (keys %env ) {
+ if (defined $env{$k}) {
+ debug('environment "' . $k . '": ' . $env{$k});
+ }
+}
+
+if (Bluto::check_sanity(\%env)) {
+ croak('sanity check fail');
+}
+
+my $fn = File::Spec->catfile($env{src_dir}, 'bluto.yml');
+my $yi = YAML::Tiny->read($fn);
+my $ym = $yi->[0];
+
+$fn = File::Spec->catfile($env{src_dir}, $env{version} . '.yml');
+$yi = YAML::Tiny->read($fn);
+my $yv = $yi->[0];
+debug('have changelog ' . $yv->{changelog} . ' for version ' . $env{version});
+
+my $version = Bluto::from_yaml($ym, $yv, \%env);
+if (!defined $version) {
+ die("config processing failed");
+}
+
+my $announce = Bluto::create_announce(\%env);
+if (!defined $announce) {
+ die("announce processing failed");
+}
+
+my $rss = Bluto::create_rss(\%env);
+if (!defined $rss) {
+ die("rss processing failed");
+}
diff --git a/gen.pl b/gen.pl
@@ -1,92 +0,0 @@
-#!/usr/bin/perl
-
-use v5.10.1;
-use warnings;
-use strict;
-
-use Getopt::Long qw/ :config auto_help /;
-use File::Basename qw/ dirname /;
-use File::Spec;
-use File::Copy;
-use Cwd qw/ getcwd abs_path /;
-use lib (dirname(abs_path($0)));
-use Digest::SHA;
-
-use SemVer;
-use Log::Term::Ansi qw/debug/;
-use YAML::Tiny;
-
-# TODO: export to perl modules
-
-
-sub croak {
- die(shift);
-}
-
-sub help() {
- print("$0\n\nwould have shown help...\n");
- exit 0;
-}
-
-my $force_version = undef;
-my $loglevel = 0;
-my $force_help = 0;
-my %env = (
- src_dir => File::Spec->catfile(getcwd, '.bluto'),
- changelog_file => undef,
- version => undef,
- loglevel => undef,
-);
-GetOptions(
- 'd:s', \$env{src_dir},
- 'f:s', \$env{changelog_file},
- 'v+', \$loglevel,
- 'h+', \$force_help,
- 'help+', \$force_help,
- 'version=s', \$force_version,
-);
-
-if ($force_help > 0) {
- help;
-}
-
-foreach my $k (keys %env ) {
- if (defined $env{$k}) {
- $env{$k} = abs_path($env{$k});
- }
-}
-
-if (defined $force_version) {
- $env{version} = SemVer->new($force_version);
-}
-
-my $fn = File::Spec->catfile($env{src_dir}, 'bluto.yml');
-my $yi = YAML::Tiny->read($fn);
-
-my @contributors;
-my $yd = $yi->[0];
-my $yv = {
- changelog => 'sha256:' . process_changelog(\%env, 1),
- author => $yd->{author}->{name},
- maintainer => $yd->{maintainer}->{name},
- contributors => \@contributors,
-};
-my $yo = YAML::Tiny->new($yv);
-$fn = File::Spec->catfile($env{src_dir}, $env{version} . '.yml');
-$yo->write($fn);
-
-
-sub process_changelog {
- my $env = shift;
- my $copy = shift;
-
- my $h = Digest::SHA->new('sha256');
- $h->addfile($env->{changelog_file});
- my $z = $h->hexdigest;
- debug('calculated sha256 ' . $z . ' for changelog ' . $env->{changelog_file});
- if ($copy) {
- my $fp = File::Spec->catfile($env->{src_dir}, 'CHANGELOG.' . $env->{version});
- copy($env->{changelog_file}, $fp);
- }
- return $z;
-}
diff --git a/pub.pl b/pub.pl
@@ -1,116 +0,0 @@
-#!/usr/bin/perl
-
-use v5.10.1;
-use warnings;
-use strict;
-
-# standard imports
-use Getopt::Long qw/ :config auto_help /;
-#use File::Temp qw/ tempdir /;
-use File::Basename qw/ dirname /;
-use File::Spec;
-use Cwd qw/ getcwd abs_path /;
-use lib (dirname(abs_path($0)));
-
-# external imports
-use Config::Simple;
-use YAML::Tiny;
-
-# bundled external imports
-use SemVer;
-
-# local imports
-use Log::Term::Ansi qw/debug/;
-use Bluto;
-use Bluto::RSS;
-
-sub croak {
- die(shift);
-}
-
-sub help() {
- print("$0\n\nwould have shown help...\n");
- exit 0;
-}
-
-# TODO: export to perl modules
-
-my $force_version = undef;
-my $loglevel = 0;
-my $force_help = 0;
-my %env = (
- src_dir => File::Spec->catfile(getcwd, '.bluto'),
- out_dir => File::Spec->catfile(getcwd, 'bluto_build'),
- feed_dir => undef,
- content_dir => getcwd,
- template_path => undef,
- engine => undef,
- readme => undef,
- version => undef,
- loglevel => undef,
-);
-GetOptions(
- 'd:s', \$env{src_dir},
- 'o:s', \$env{out_dir},
- 'f:s', \$env{feed_dir},
- 'c:s', \$env{content_dir},
- 'v+', \$loglevel,
- 'h+', \$force_help,
- 'help+', \$force_help,
- 'version=s', \$force_version,
-);
-
-if ($force_help > 0) {
- help;
-}
-
-foreach my $k (keys %env ) {
- if (defined $env{$k}) {
- $env{$k} = abs_path($env{$k});
- }
-}
-
-if (!defined $env{feed_dir}) {
- $env{feed_dir} = $env{out_dir};
-}
-
-if (defined $force_version) {
- $env{version} = SemVer->new($force_version);
-}
-
-$env{loglevel} = $loglevel;
-
-$env{engine} = 'bluto v' . SemVer->new(Bluto::VERSION). " (perl $^V)";
-foreach my $k (keys %env ) {
- if (defined $env{$k}) {
- debug('environment "' . $k . '": ' . $env{$k});
- }
-}
-
-if (Bluto::check_sanity(\%env)) {
- croak('sanity check fail');
-}
-
-my $fn = File::Spec->catfile($env{src_dir}, 'bluto.yml');
-my $yi = YAML::Tiny->read($fn);
-my $ym = $yi->[0];
-
-$fn = File::Spec->catfile($env{src_dir}, $env{version} . '.yml');
-$yi = YAML::Tiny->read($fn);
-my $yv = $yi->[0];
-debug('have changelog ' . $yv->{changelog} . ' for version ' . $env{version});
-
-my $version = Bluto::from_yaml($ym, $yv, \%env);
-if (!defined $version) {
- die("config processing failed");
-}
-
-my $announce = Bluto::create_announce(\%env);
-if (!defined $announce) {
- die("announce processing failed");
-}
-
-my $rss = Bluto::create_rss(\%env);
-if (!defined $rss) {
- die("rss processing failed");
-}