aboutsummaryrefslogtreecommitdiffstats
path: root/mgaadv
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-06-13 15:21:50 +0000
committerNicolas Vigier <boklm@mageia.org>2013-06-13 15:21:50 +0000
commit50b8ed2bfef1ff58a2cadf9f2f016fe6a6988da2 (patch)
treeeece3c432800972cdfb56bf6703a7e1aaccdceab /mgaadv
parentfbc35fd95c230d9b7459db1cb88670938a16274d (diff)
downloadmgaadvisories-50b8ed2bfef1ff58a2cadf9f2f016fe6a6988da2.tar
mgaadvisories-50b8ed2bfef1ff58a2cadf9f2f016fe6a6988da2.tar.gz
mgaadvisories-50b8ed2bfef1ff58a2cadf9f2f016fe6a6988da2.tar.bz2
mgaadvisories-50b8ed2bfef1ff58a2cadf9f2f016fe6a6988da2.tar.xz
mgaadvisories-50b8ed2bfef1ff58a2cadf9f2f016fe6a6988da2.zip
Add 'initqaconf' command to initialize config for QA team members
Diffstat (limited to 'mgaadv')
-rwxr-xr-xmgaadv44
1 files changed, 42 insertions, 2 deletions
diff --git a/mgaadv b/mgaadv
index 216d052..05308a3 100755
--- a/mgaadv
+++ b/mgaadv
@@ -3,8 +3,20 @@
use strict;
use MGA::Advisories;
use Template;
+use YAML qw(LoadFile DumpFile);
+use File::Basename;
my %actions = (
+ initqaconf => {
+ run => \&initqaconf,
+ descr => 'Initialize configuration for QA team members',
+ usage => <<END,
+$0 initqaconf
+
+Initialize a default configuration for QA team members, and open an
+editor on the file.
+END
+ },
list => {
run => \&listadv,
descr => 'List advisories',
@@ -88,13 +100,14 @@ sub mksite {
MGA::Advisories::send_report_mail(\%advdb);
}
+sub editor { $ENV{EDITOR} || $ENV{VISUAL} || '/usr/bin/editor' }
+
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);
+ system(editor, $file);
}
}
@@ -118,6 +131,33 @@ sub updateadv {
MGA::Advisories::download_advisories;
}
+sub initqaconf {
+ my $c = $MGA::Advisories::home_config_file;
+ if (-f $c) {
+ print STDERR "File $c already exists\n";
+ exit 1;
+ }
+ my %defaultconf = (
+ mode => 'qa',
+ out_dir => $ENV{HOME} . '/mageia-advisories/html',
+ status_dir => $ENV{HOME} . '/mageia-advisories/status',
+ advisories_dir => $ENV{HOME} . '/mageia-advisories/advisories',
+ );
+ DumpFile($c, \%defaultconf);
+ system(editor, $c);
+ my $newconf = LoadFile($c);
+ foreach my $n ('out_dir', 'status_dir', 'advisories_dir') {
+ mkdir dirname($newconf->{$n}) unless -d dirname($newconf->{$n});
+ }
+ foreach my $n ('out_dir', 'status_dir') {
+ mkdir $newconf->{$n} unless -d $newconf->{$n};
+ }
+ if (! -d $newconf->{advisories_dir}) {
+ system('svn', 'co', $MGA::Advisories::config->{advisories_repo_url},
+ $newconf->{advisories_dir});
+ }
+}
+
if (@ARGV == 0 || !$actions{$ARGV[0]}) {
usageexit();
}