diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | lib/MGA/Advisories.pm | 19 | ||||
-rwxr-xr-x | mgaadv | 25 | ||||
-rw-r--r-- | tmpl/newadvisory.adv | 19 |
5 files changed, 64 insertions, 3 deletions
@@ -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 @@ -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; @@ -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 %] |