aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--NEWS1
-rw-r--r--config_default1
-rw-r--r--lib/MGA/Advisories.pm6
-rwxr-xr-xmgaadv44
4 files changed, 47 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 153b845..b4756f1 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@
- load config from home directory if file exists
- add option to load advisories db from a file dump instead of a directory
- add 'update' command to download new advisories db
+- add 'initqaconf' command to initialize config for QA team members
Version 0.4
diff --git a/config_default b/config_default
index 7f7cb05..af2560c 100644
--- a/config_default
+++ b/config_default
@@ -12,3 +12,4 @@ adv_mail_from: Mageia Updates <buildsystem-daemon@mageia.org>
report_mail_to: qa-reports@ml.mageia.org
report_mail_from: Mageia Advisories <buildsystem-daemon@mageia.org>
site_url: http://advisories.mageia.org
+advisories_repo_url: svn+ssh://svn.mageia.org/svn/advisories
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index b89ad60..0bafc88 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -12,9 +12,9 @@ use LWP::UserAgent;
use File::Basename;
#use Data::Dump qw(dd);
-my $config_file = '/usr/share/mga-advisories/config';
-my $config = LoadFile($ENV{MGAADV_CONF} || $config_file);
-my $home_config_file = $ENV{HOME} . '/.mga-advisories/mga-advisories.conf';
+our $config_file = '/usr/share/mga-advisories/config';
+our $config = LoadFile($ENV{MGAADV_CONF} || $config_file);
+our $home_config_file = $ENV{HOME} . '/.mga-advisories/mga-advisories.conf';
my $custom_config_file = -f $home_config_file ? $home_config_file
: '/etc/mga-advisories.conf';
my $custom_config = LoadFile($custom_config_file);
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();
}