aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--NEWS2
-rw-r--r--lib/MGA/Advisories.pm19
-rwxr-xr-xmgaadv25
-rw-r--r--tmpl/newadvisory.adv19
5 files changed, 64 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 76f4685..3fcf89e 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ VERSION=0.4
PROJECTNAME=mga-advisories
BINFILES=mkadvisories
CFGFILES=mga-advisories.conf
-TMPLFILES=tmpl/*.html tmpl/*.txt
+TMPLFILES=tmpl/*.html tmpl/*.txt tmpl/*.adv
sysconfdir=/etc
bindir=/usr/bin
diff --git a/NEWS b/NEWS
index b65b454..9027dd5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- add command to add a new advisory
+
Version 0.4
- advisory.{html,txt}: don't add a CVE line when there is no CVE
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index b82f181..c5a31e1 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -208,4 +208,23 @@ sub dumpdb {
DumpFile($config->{out_dir} . '/advisories.yaml', $advdb->{advisories});
}
+sub newadv {
+ my ($type, $bugnum) = @_;
+ my $file = $config->{advisories_dir} . '/' . $bugnum . '.adv';
+ if (-f $file) {
+ print STDERR "File $file already exists\n";
+ return undef;
+ }
+ my $template = Template->new(
+ INCLUDE_PATH => $config->{tmpl_dir},
+ OUTPUT_PATH => $config->{advisories_dir},
+ );
+ my $vars = {
+ type => $type,
+ bugnum => $bugnum,
+ };
+ process_template($template, 'newadvisory', $vars, $bugnum, 'adv');
+ return $file;
+}
+
1;
diff --git a/mgaadv b/mgaadv
index d40762c..99371e9 100755
--- a/mgaadv
+++ b/mgaadv
@@ -2,9 +2,11 @@
use strict;
use MGA::Advisories;
+use Template;
my %actions = (
mksite => \&mksite,
+ new => \&newadv,
usage => \&usage,
);
@@ -19,6 +21,12 @@ $0 usage [action]
Show action usage
END
+ new => <<END,
+$0 new [type] [bugnum]
+
+Create a new advisory file. [type] should be security or bugfix and
+[bugnum] is the bugzilla bug number.
+END
);
sub usage {
@@ -31,6 +39,10 @@ sub usage {
print STDERR map { " - $_\n" } keys %actions;
}
}
+sub usageexit {
+ usage(@_);
+ exit 1;
+}
sub mksite {
my %advdb;
@@ -43,9 +55,18 @@ sub mksite {
MGA::Advisories::send_report_mail(\%advdb);
}
+sub newadv {
+ usageexit('usage', $_[0]) unless @_ == 3;
+ my ($new, $type, $bugnum) = @_;
+ my $file = MGA::Advisories::newadv($type, $bugnum);
+ if ($file) {
+ my $editor = $ENV{EDITOR} || $ENV{VISUAL} || '/usr/bin/editor';
+ system($editor, $file);
+ }
+}
+
if (@ARGV == 0 || !$actions{$ARGV[0]}) {
- usage();
- exit 1;
+ usageexit();
}
$actions{$ARGV[0]}->(@ARGV);
diff --git a/tmpl/newadvisory.adv b/tmpl/newadvisory.adv
new file mode 100644
index 0000000..0b7ea2d
--- /dev/null
+++ b/tmpl/newadvisory.adv
@@ -0,0 +1,19 @@
+type: [% type %]
+subject: Updated [package] package fixes [something]
+[% IF type == 'security' -%]
+CVE:
+ - first CVE
+ - second CVE
+[% END -%]
+src:
+ 2:
+ core:
+ - something-1.0-1.mga2
+ 3:
+ core:
+ - something-1.0-1.mga3
+description: |
+ Advisory text to describe the update.
+ Wrap lines at ~75 chars.
+references:
+ - https://bugs.mageia.org/show_bug.cgi?id=[% bugnum %]