Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve detection of X-MEDIA-VERSION #550

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions lib/Directory/Scanner/OBSMediaVersion.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@ sub parse_version($filename) {
$f = $f->basename;

if ($filename =~ /.*(Build|Snapshot)((\d)+(\.\d+)?).*/) {
return $2
return $2;
}

if ($filename =~ /.*-(\d+\.?\d*\.?\d*\.?\d*)-(\d*\.?\d*)?.*(\.d?rpm)?$/) {
if ($filename =~ /.*-(\d+\.?\d*\.?\d*\.?\d*)-(\d*\.?\d*)?.*(\.d?rpm)$/) {
return $1;
}

return undef unless $filename =~ /.*_(\d+\.?\d*\.?\d*\.?\d*)-(\d*\.?\d*)?.*(\.deb)?$/;
if ($filename =~ m/(.*)_([^-]+)-([^-]+)\.(x86_64|noarch|i[3-6]86|ppc64|aarch64|arm64|amd64|s390|src).*\.drpm$/) {
return $2;
}

my $fil = Mojo::File->new($filename);
my $ext = $fil->extname;
my $basename = $fil->basename(".$ext");

if ($basename =~ m/(.*)(_|-)([^-]+)\.(x86_64|noarch|i[3-6]86|ppc64|aarch64|arm64|amd64|s390|src)$/) {
return $3;
}

return undef unless $filename =~ /.*_(\d+\.?\d*\.?\d*\.?\d*)-(\d*\.?\d*)?.*(\.deb)$/;
return $1
}

Expand All @@ -28,18 +40,18 @@ sub parse_pkg($filename) {
my $f = $fil->basename;
my $ext = $fil->extname;
if ($ext eq "rpm") {
my @res = parse_pkg_rpm( $fil->basename($ext) );
my @res = parse_pkg_rpm( $fil->basename(".$ext") );
return ( @res, "rpm" );
} elsif ($ext eq "deb") {
my @res = parse_pkg_deb( $fil->basename($ext) );
my @res = parse_pkg_deb( $fil->basename(".$ext") );
return ( @res, "deb" );
}
return undef;
}

# return name, version, build, arch
sub parse_pkg_rpm($basename) {
return undef unless ($basename =~ m/(.*)-([^-]+)-([^-]+)\.(x86_64|noarch|i[3-6]86|ppc64|aarch64|arm64|amd64|s390|src)/);
return undef unless ($basename =~ m/(.*)-([^-]+)-([^-]+)\.(x86_64|noarch|i[3-6]86|ppc64|aarch64|arm64|amd64|s390|src)$/);
return ($1, $2, $3, $4);
}

Expand Down
10 changes: 10 additions & 0 deletions t/environ/02-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ for x in $mc $ap7 $ap8; do
echo $x/dt/folder1/file1.dat | xargs -n 1 touch
echo $x/dt/Folder1/file1.1.DAT | xargs -n 1 touch
echo $x/dt/Folder1/repodata/repomd.xml | xargs -n 1 touch
( cd $x/dt/folder1/ ; touch GNOME_3.6.2.x86_64.iso ; ln -s GNOME_3.6.2.x86_64.iso GNOME_Next.x86_64.iso )
mkdir -p $x/dt/folder1.11test/
for f in $unversionedfiles; do
str=1
Expand Down Expand Up @@ -207,5 +208,14 @@ $mc/curl -i -H "Accept: */*, application/metalink+xml" /download/Folder1/repodat
$mc/curl -i /download/folder1/file1.1.dat | grep Cache-Control
$mc/curl -i /download/Folder1/file1.1.DAT | grep Cache-Control

echo check x-media-version
$mc/curl -i /download/folder1/GNOME_3.6.2.x86_64.iso | grep 'X-MEDIA-VERSION: 3.6.2'

$mc/curl -i /download/folder1/GNOME_Next.x86_64.iso | grep 'X-MEDIA-VERSION: 3.6.2'

echo check dont detect x-media-version in openSUSE-Leap-15.3-NET-x86_64.iso
rc=0
$mc/curl -i /download/folder1.11test/openSUSE-Leap-15.3-NET-x86_64.iso | grep 'X-MEDIA-VERSION:' || rc=$?
test $rc -gt 0

echo success
Loading