aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-08-14 21:46:38 -0400
committerB. Watson <urchlay@slackware.uk>2026-08-14 21:46:38 -0400
commitfa7f8341cd8db3f191e14b3869bc951ea654069f (patch)
tree574c5f21e6289c59e43f6a52df216b0643b5f52d
parent8353f5f2e895f3b0c4657ac604be38e965b11c49 (diff)
downloadsbo-maintainer-tools-fa7f8341cd8db3f191e14b3869bc951ea654069f.tar.gz
sbolint: canonicalize pypi URLs.
-rwxr-xr-xsbolint29
1 files changed, 29 insertions, 0 deletions
diff --git a/sbolint b/sbolint
index aac3d75..c85e74e 100755
--- a/sbolint
+++ b/sbolint
@@ -1249,6 +1249,7 @@ sub check_dl_and_md5 {
}
check_github_url($file, $u);
+ check_pypi_url($file, $u);
if($url_head) {
curl_head_request($file, $u) || do {
@@ -1389,6 +1390,34 @@ sub check_github_url {
}
}
+sub check_pypi_url {
+ my $file = shift;
+ my $url = shift;
+ my $filename;
+ my $initial;
+ my $newurl;
+ my $srcnam;
+
+ return unless $url =~ m{^(https?)://files.pythonhosted.org};
+
+ # don't mess with URLs that don't have the 60-digit hex hash.
+ return unless $url =~ m{/[0-9a-f]{60}/};
+
+ if($1 ne 'https') {
+ log_error("$file: pypi URL must be https://");
+ }
+
+ ($filename = $url) =~ s,.*/,,;
+ $initial = substr($filename, 0, 1);
+ # FIXME: assumes no - in the version number. So far that's true...
+ ($srcnam = $filename) =~ s,-\d[^-]*\.tar\.gz$,,;
+
+ $newurl = "https://files.pythonhosted.org/packages/source/$initial/$srcnam/$filename";
+ if($url ne $newurl) {
+ log_warning("$file: canonical pypi URL should be $newurl");
+ }
+}
+
sub script_exists {
my $file = $buildname . ".SlackBuild";
unless(-e $file) {