diff --git a/assets/javascripts/package.js b/assets/javascripts/package.js index 5221c7dc..51e8fe62 100644 --- a/assets/javascripts/package.js +++ b/assets/javascripts/package.js @@ -7,6 +7,7 @@ var pkg_param_os_ver; var pkg_param_repo; var pkg_param_ign_path; var pkg_param_ign_file; +var pkg_param_strict; function initPackageParams() { @@ -22,6 +23,7 @@ function initPackageParams() { pkg_param_repo = urlParams.get('repo'); pkg_param_ign_path = urlParams.get('ignore_path'); pkg_param_ign_file = urlParams.get('ignore_file'); + pkg_param_strict = urlParams.get('strict'); if (pkg_param_pkg) { ( document.getElementById("packag") || {} ).value = pkg_param_pkg; @@ -47,7 +49,9 @@ function initPackageParams() { if (pkg_param_ign_file) { document.getElementById("ign_file").value = pkg_param_ign_file; } - + if (pkg_param_strict) { + ( document.getElementById("strict") || {} ).checked = pkg_param_strict? 1 : 0; + } } function setupPackages() { @@ -151,6 +155,7 @@ function setupPackageLocations(name) { pkg_param_repo = document.getElementById("repo").value; pkg_param_ign_path = document.getElementById("ign_path").value; pkg_param_ign_file = document.getElementById("ign_file").value; + pkg_param_strict = document.getElementById("strict").checked ? 1 : ''; var dataTable = table.DataTable({ ajax: { @@ -164,6 +169,7 @@ function setupPackageLocations(name) { "repo": pkg_param_repo, "ignore_path": pkg_param_ign_path, "ignore_file": pkg_param_ign_file, + "strict" : pkg_param_strict, }, }, deferRender: true, diff --git a/lib/MirrorCache/WebAPI/Controller/Rest/Metapkg.pm b/lib/MirrorCache/WebAPI/Controller/Rest/Metapkg.pm index 421c8961..1e7028e6 100644 --- a/lib/MirrorCache/WebAPI/Controller/Rest/Metapkg.pm +++ b/lib/MirrorCache/WebAPI/Controller/Rest/Metapkg.pm @@ -39,6 +39,7 @@ sub search_locations { my $p_repo = $self->param('repo'); my $p_ign_path = $self->param('ignore_path'); my $p_ign_file = $self->param('ignore_file'); + my $p_strict = $self->param('strict'); my $sql_from = <<'END_SQL'; select metapkg.name, folder.path as path, file.name as file, file.size as size, file.mtime as time @@ -71,7 +72,7 @@ END_SQL my $sql_where = "WHERE file.name like ? and metapkg.name = ?"; push @parms, "$package$arch%"; - push @parms, "$package"; + push @parms, $package; if ($p_repo) { $sql_where = "$sql_where and folder.path like concat('%/', ?::text, '/', ?::text)"; push @parms, $p_repo; @@ -85,6 +86,11 @@ END_SQL $sql_where = "$sql_where and file.name not like concat('%', ?::text, '%')"; push @parms, $p_ign_file; } + if ($p_strict) { + $sql_where = "$sql_where and file.name ~ ?"; + my $qm = quotemeta($package); + push @parms, "^$qm-([^-]+)-([^-]+)\.(x86_64|noarch|i[3-6]86|ppc64|aarch64|arm64|amd64|s390|src)"; + } my $sql = $sql_from . "\n" . $sql_where; @@ -107,6 +113,7 @@ sub search { my $p_repo = $self->param('repo'); my $p_ign_path = $self->param('ignore_path'); my $p_ign_file = $self->param('ignore_file'); + my $p_strict = $self->param('strict'); my $sql_from = <<'END_SQL'; select distinct metapkg.name diff --git a/t/environ/24-pkg-update.sh b/t/environ/24-pkg-update.sh index 45720db5..834b340f 100755 --- a/t/environ/24-pkg-update.sh +++ b/t/environ/24-pkg-update.sh @@ -14,6 +14,7 @@ ap7=$(environ ap7) files=( /folder1/x86_64/mypkg-1.1-1.1.x86_64.rpm + /folder1/x86_64/mypkg-doc-1.1-1.1.x86_64.rpm /folder1/x86_64/yourpkg-1.1-1.1.x86_64.rpm ) @@ -39,8 +40,8 @@ done $mc/backstage/job -e folder_sync -a '["/folder1/x86_64"]' $mc/backstage/shoot -$mc/sql_test 2 == "select count(*) from pkg" -$mc/sql_test 2 == "select count(*) from metapkg" +$mc/sql_test 3 == "select count(*) from pkg" +$mc/sql_test 3 == "select count(*) from metapkg" $mc/curl /rest/package/mypkg @@ -66,8 +67,8 @@ $mc/backstage/job -e folder_sync -a '["/folder1/x86_64"]' $mc/backstage/job -e folder_sync -a '["/folder2/x86_64"]' $mc/backstage/shoot -$mc/sql_test 3 == "select count(*) from pkg" -$mc/sql_test 3 == "select count(*) from metapkg" +$mc/sql_test 4 == "select count(*) from pkg" +$mc/sql_test 4 == "select count(*) from metapkg" $mc/curl /rest/search/packages?package=mypkg @@ -75,4 +76,11 @@ $mc/curl '/rest/search/package_locations?package=mypkg&repo=folder2' $mc/curl /rest/search/package_locations?package=yourpkg +rc=0 +$mc/curl "/rest/search/package_locations?package=mypkg&strict=1" | grep mypkg-doc || rc=$? +test $rc -gt 0 + +$mc/curl /rest/search/package_locations?package=mypkg | grep mypkg-doc +$mc/curl --globoff '/rest/search/package_locations?package=^([a-zA-Z0-9])(([\-.]|[_]+)?([a-zA-Z0-9]+))*(@){1}[a-z0-9]+[.]{1}(([a-z]{2,3})|([a-z]{2,3}[.]{1}[a-z]{2,3}))$' + echo success diff --git a/templates/app/package/show.html.ep b/templates/app/package/show.html.ep index 10c087b3..98008810 100644 --- a/templates/app/package/show.html.ep +++ b/templates/app/package/show.html.ep @@ -154,6 +154,15 @@ input[type = text] { +
+
+
+ +
+
+ +
+