aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-04-02 17:46:46 -0400
committerB. Watson <urchlay@slackware.uk>2024-04-02 17:46:46 -0400
commitaaae2a487399cbb1220abe4a739534df79e65653 (patch)
treeb3b8a4a0257aa978e4667d3bff5f4e495aaa05ff
parent4ec9e1c470394e99e21ce669fb42d853c950dd94 (diff)
downloadsbo-maintainer-tools-aaae2a487399cbb1220abe4a739534df79e65653.tar.gz
sbolint: github URL checking initial (incomplete) implementation.
-rwxr-xr-xsbolint63
1 files changed, 62 insertions, 1 deletions
diff --git a/sbolint b/sbolint
index bb7355b..e08703f 100755
--- a/sbolint
+++ b/sbolint
@@ -1146,7 +1146,7 @@ sub check_dl_and_md5 {
next;
}
- #check_github_url($file, $u);
+ check_github_url($file, $u);
if($url_head) {
curl_head_request($file, $u) || do {
@@ -1235,6 +1235,67 @@ sub curl_head_request {
## # and sometimes it's a different letter (r, or g, or capital V, etc).
## }
+sub check_github_url {
+ my $file = shift;
+ my $url = shift;
+ my $old_url = $url;
+ my $new_url;
+ my $ext;
+
+ # do not police releases/ or raw/ URLs, only archive/
+ return unless $url =~ m{github\.com/.*archive/};
+
+ if($url =~ s,refs/tags/,,) {
+ log_error "$file: github URLs should not have refs/tags/";
+ }
+
+ #https: // site/ .../ .../ archive/
+ (my $proto, undef, undef, $user, $proj, undef, $tag, $filename, $extra) = split /\//, $url;
+
+ log_error "$file: github URLs must be https://" unless $proto eq 'https:';
+
+ if(!defined $filename) {
+ log_error "$file: github URL is non-canonical (not enough components)";
+ $tag =~ s,(\.tar\.gz|\.zip)$,,;
+ $ext = $1;
+ }
+
+ # TODO: this is not an error, because github projects are allowed to have /
+ # in their tag names. So we get this *valid* URL:
+ # https://github.com/zfsonlinux/zfs-auto-snapshot/archive/upstream/1.2.4/zfs-auto-snapshot-upstream-1.2.4.tar.gz
+ if(defined $extra) {
+ #log_error "$file: github URL is non-canonical (too many components)";
+ log_note "$file: github URL has extra components, don't (yet) know how to check it.";
+ return;
+ }
+
+ # TODO: commit hashes have to be complete in the filename, and may be
+ # truncated in the dir name after arvhive/
+
+ my $ver = $tag;
+ $ver =~ s,^v(\d),$1,;
+
+ if(defined $filename) {
+ $filename =~ /(\.tar\.gz|\.zip)$/;
+ $ext = $1;
+ }
+
+ if(!defined $ext) {
+ log_warning "$file: github URL not .tar.gz or .zip";
+ $ext = "";
+ }
+
+ if(defined $filename && $filename ne "$proj-$ver$ext") {
+ log_error "$file: github URL has wrong filename $filename";
+ }
+
+ $new_url = "https://github.com/$user/$proj/archive/$tag/$proj-$ver$ext";
+
+ if($old_url ne $new_url) {
+ log_warning("$file: canonical github URL should be: $new_url");
+ }
+}
+
sub script_exists {
my $file = $buildname . ".SlackBuild";
unless(-e $file) {