commit c3ef0ab6b260f4d670eb67cc885aa0c74159fee7
parent 8b8855b54aa7432fd440da63ff99c58bb6ec2f5c
Author: lash <dev@holbrook.no>
Date: Tue, 18 Jun 2024 21:37:29 +0100
Prevent duplicate rss publish
Diffstat:
M | README.md | | | 2 | ++ |
M | to_std.pl | | | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- |
2 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
@@ -2,4 +2,6 @@
## License
+Copyright held by Louis Holbrook <[dev@holbrook.no](mailto:dev.holbrook.no))> 2022-
+
Artistic License, as deferred by the Perl License by Larry Wall.
diff --git a/to_std.pl b/to_std.pl
@@ -11,6 +11,7 @@ use File::Spec qw/ catfile /;
use Cwd qw/ getcwd abs_path /;
use Template;
use SemVer;
+use XML::RSS;
# external imports
use Config::Simple;
@@ -35,15 +36,18 @@ my %m_main = (
summary => undef,
tech_main => undef,
tech => \@m_tech,
+ vcs_upstream => undef,
author_maintainer => \@m_author_maintainer,
author_origin => \@m_author_origin,
);
my $ini_dir = File::Spec->catfile(getcwd, '.bluto');
my $out_dir = getcwd;
+my $feed_dir = getcwd;
GetOptions(
'd:s', \$ini_dir,
'o:s', \$out_dir,
+ 'f:s', \$feed_dir,
);
$ini_dir = abs_path($ini_dir);
@@ -60,14 +64,19 @@ $m_main{summary} = $cfg->param('main.summary');
$m_main{author_maintainer}[0] = $cfg->param('author:maintainer.name') . " <" . $cfg->param('author:maintainer.email') . ">";
$m_main{author_maintainer}[1] = $cfg->param('author:maintainer.pgp');
+my $feed_file = File::Spec->catfile( $feed_dir, $m_main{slug} ) . ".rss";
+
if (!defined $cfg->param('author:origin')) {
$m_main{author_origin}[0] = $m_main{author_maintainer}[0];
$m_main{author_origin}[1] = $m_main{author_maintainer}[1];
}
-
my @urls = $cfg->param('locate.url');
my @gits = $cfg->param('locate.git');
+if ($#gits < 0) {
+ die('no vcs found');
+}
+$m_main{git_upstream} = $gits[0];
my @change = $cfg->vars();
my $have_version_match = undef;
@@ -88,8 +97,9 @@ if (!defined $have_version_match) {
croak("no changelog found for version " . $m_main{version});
}
-my $targz = File::Spec->catfile($ini_dir, $m_main{slug} . '-' . $have_version_match . '.tar.gz');
-if (! -f $targz ) {
+my $targz = $m_main{slug} . '-' . $have_version_match . '.tar.gz';
+my $targz_local = File::Spec->catfile($ini_dir, $targz);
+if (! -f $targz_local ) {
#croak("no package file found, looked for: " . $targz);
debug("no package file found, looked for: " . $targz);
}
@@ -100,4 +110,54 @@ my $tt = Template->new({
});
my $out;
$tt->process('base.tt', \%m_main, \$out) or croak($tt->error());
-print($out);
+
+my $rss;
+
+$rss = XML::RSS->new;
+if ( -f $feed_file ) {
+ info('found existing feed file ' . $feed_file);
+ $rss->parsefile( $feed_file );
+} else {
+ my $rss = XML::RSS->new(version => '1.0');
+ $rss->channel (
+ title => $m_main{name},
+ link => $m_main{git_upstream},
+ description => $m_main{summary},
+ # dc => {
+ # date => '2000-08-23T07:00+00:00',
+ # subject => "Linux Software",
+ # creator => 'scoop@freshmeat.net',
+ # publisher => 'scoop@freshmeat.net',
+ # rights => 'Copyright 1999, Freshmeat.net',
+ # language => 'en-us',
+ # },
+ # taxo => [
+ # 'http://dmoz.org/Computers/Internet',
+ # 'http://dmoz.org/Computers/PC'
+ # ]
+ );
+}
+
+# check if we already have the title
+my $rss_title = $m_main{slug} . ' ' . $m_main{version};
+foreach my $item ( $rss->{items}) {
+ if ( defined $item->[0] && $item->[0]{title} eq $rss_title ) {
+ die('already have published record for ' . $rss_title);
+ }
+}
+
+$rss->add_item (
+ title => $rss_title,
+ link => $targz,
+ description => $out,
+# dc => {
+ # subject => "X11/Utilities",
+ # creator => "David Allen (s2mdalle at titan.vcu.edu)",
+ # },
+ # taxo => [
+ # 'http://dmoz.org/Computers/Internet',
+ # 'http://dmoz.org/Computers/PC'
+ # ]
+);
+
+$rss->save($feed_file);