From 543061d149e356be0fc8b3fbaf524e80e8abe70e Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Sun, 11 Dec 2011 15:55:00 +0000 Subject: Revert to previous test structure + updated regexp. Changed regexp did not validate all needed test cases. --- Tools.pm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Tools.pm b/Tools.pm index 54d4f66..2342992 100644 --- a/Tools.pm +++ b/Tools.pm @@ -31,16 +31,25 @@ use base 'Exporter'; our @EXPORT = qw(parse_mageia_iso_name); +# Check image filename if it is valid (see https://wiki.mageia.org/en/Product_naming) +# +# In: filename +# Out: populated hash if valid, empty hash otherwise. +# sub parse_mageia_iso_name { my ($name) = @_; my %info; - if ((@info{qw(name version release variant arch medium build ext)}) - = $name =~ m/^(Mageia)-(\d+)-((?:alpha|beta|RC)\d*)?(-(?:.*))?-(i586|x86_64|dual)?(?:-(CD|DVD|BD))?(?:-(build_\w+))?\.(.*)$/) - { - $info{full} = $name; - } else { - %info = (); + if ($name =~ m/^(Mageia)-(\d+)(-((nightly|alpha|beta|RC)\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BR))?(-(build_\w+))?\.(.*)$/) { + $info{full} = $name; + $info{name} = $1 if defined $1; + $info{version} = $2 if defined $2; + $info{release} = $4 if defined $4; + $info{variant} = $7 if defined $7; + $info{arch} = $8 if defined $8; + $info{medium} = $10 if defined $10; + $info{build} = $12 if defined $12; + $info{ext} = $13 if defined $13; } return %info; -- cgit v1.2.1