aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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}}) {