diff options
-rwxr-xr-x | sbolint | 63 |
1 files changed, 62 insertions, 1 deletions
@@ -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) { |