diff options
-rw-r--r-- | Tools.pm | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -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; |