aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-06-13 15:21:44 +0000
committerNicolas Vigier <boklm@mageia.org>2013-06-13 15:21:44 +0000
commitb84016d16a0d80b05177e2fbb233a0cc9ddcfcd3 (patch)
treed0333f0c7d36deb75c512e4d2edf505933725578
parentc5083c05ff06811b88121a82916524bafab42418 (diff)
downloadmgaadvisories-b84016d16a0d80b05177e2fbb233a0cc9ddcfcd3.tar
mgaadvisories-b84016d16a0d80b05177e2fbb233a0cc9ddcfcd3.tar.gz
mgaadvisories-b84016d16a0d80b05177e2fbb233a0cc9ddcfcd3.tar.bz2
mgaadvisories-b84016d16a0d80b05177e2fbb233a0cc9ddcfcd3.tar.xz
mgaadvisories-b84016d16a0d80b05177e2fbb233a0cc9ddcfcd3.zip
Add option to load advisories db from a file dump
-rw-r--r--NEWS1
-rw-r--r--config_default1
-rw-r--r--lib/MGA/Advisories.pm12
3 files changed, 13 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 7b22f1b..85e7f1f 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
- add 'list' command to list advisories
- add 'show' command to show an advisory
- load config from home directory if file exists
+- add option to load advisories db from a file dump instead of a directory
Version 0.4
diff --git a/config_default b/config_default
index f154732..3b871a3 100644
--- a/config_default
+++ b/config_default
@@ -1,3 +1,4 @@
+mode: dump
advisories_dir: /var/lib/mga-advisories/advisories
status_dir: /var/lib/mga-advisories/status
tmpl_dir: /usr/share/mga-advisories/tmpl
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index cda9528..ec91efa 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -52,7 +52,7 @@ sub save_status {
DumpFile($statusfile, $advdb->{advisories}{$adv}{status});
}
-sub get_advisories {
+sub get_advisories_from_dir {
my %advisories;
foreach my $advfile (glob "$config->{advisories_dir}/*.adv") {
my $adv = LoadFile($advfile);
@@ -65,6 +65,16 @@ sub get_advisories {
return \%advisories;
}
+sub get_advisories_from_dump {
+ return LoadFile($_[0] || $config->{advdv_dumpfile}
+ || $ENV{HOME} . '/.mga-advisories/advisories.yaml');
+}
+
+sub get_advisories {
+ return $config->{mode} eq 'dump' ? get_advisories_from_dump
+ : get_advisories_from_dir;
+}
+
sub publish_advisories {
my ($advdb) = @_;
foreach my $adv (keys %{$advdb->{advisories}}) {