Commit bfc517c0 authored by Dietmar Maurer's avatar Dietmar Maurer

APLInfo: split out code into read_aplinfo_from_fh

So that we can call the parser for any $fh. Add new type 'lxc'.
parent 2b2502c0
...@@ -48,15 +48,11 @@ sub logmsg { ...@@ -48,15 +48,11 @@ sub logmsg {
} }
} }
sub read_aplinfo { sub read_aplinfo_from_fh {
my ($filename, $list, $source, $update) = @_; my ($fh, $list, $source, $update) = @_;
my $fh = IO::File->new("<$filename") ||
die "unable to open file '$filename' - $!\n";
local $/ = ""; local $/ = "";
eval {
while (my $rec = <$fh>) { while (my $rec = <$fh>) {
chomp $rec; chomp $rec;
...@@ -81,7 +77,7 @@ sub read_aplinfo { ...@@ -81,7 +77,7 @@ sub read_aplinfo {
} }
} elsif ($rec =~ s/^Type:\s*(.*\S)\s*\n//i) { } elsif ($rec =~ s/^Type:\s*(.*\S)\s*\n//i) {
my $type = $1; my $type = $1;
if ($type =~ m/^(openvz)$/) { if ($type =~ m/^(openvz|lxc)$/) {
$res->{type} = $type; $res->{type} = $type;
} else { } else {
my $msg = "unable to parse appliance record: unknown type '$type'\n"; my $msg = "unable to parse appliance record: unknown type '$type'\n";
...@@ -123,7 +119,15 @@ sub read_aplinfo { ...@@ -123,7 +119,15 @@ sub read_aplinfo {
$update ? die $msg : warn $msg; $update ? die $msg : warn $msg;
} }
} }
}; }
sub read_aplinfo {
my ($filename, $list, $source, $update) = @_;
my $fh = IO::File->new("<$filename") ||
die "unable to open file '$filename' - $!\n";
eval { read_aplinfo_from_fh($fh, $list, $source, $update); };
my $err = $@; my $err = $@;
close($fh); close($fh);
......
...@@ -27,7 +27,7 @@ Package, Section, Version, Maintainer, Description ...@@ -27,7 +27,7 @@ Package, Section, Version, Maintainer, Description
Additionally we define the following fields: Additionally we define the following fields:
Type: openvz | qemu Type: openvz | qemu | lxc
OS: Operating system type OS: Operating system type
Location: download url Location: download url
Infopage: url to additional info Infopage: url to additional info
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment