| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #! @PERL@ | | 1 | #! @PERL@ |
2 | # $NetBSD: url2pkg.pl,v 1.41 2019/08/17 13:12:00 rillig Exp $ | | 2 | # $NetBSD: url2pkg.pl,v 1.42 2019/08/17 13:21:42 rillig Exp $ |
3 | # | | 3 | # |
4 | | | 4 | |
5 | # Copyright (c) 2010 The NetBSD Foundation, Inc. | | 5 | # Copyright (c) 2010 The NetBSD Foundation, Inc. |
6 | # All rights reserved. | | 6 | # All rights reserved. |
7 | # | | 7 | # |
8 | # This code is derived from software contributed to The NetBSD Foundation | | 8 | # This code is derived from software contributed to The NetBSD Foundation |
9 | # by Roland Illig. | | 9 | # by Roland Illig. |
10 | # | | 10 | # |
11 | # Redistribution and use in source and binary forms, with or without | | 11 | # Redistribution and use in source and binary forms, with or without |
12 | # modification, are permitted provided that the following conditions | | 12 | # modification, are permitted provided that the following conditions |
13 | # are met: | | 13 | # are met: |
14 | # 1. Redistributions of source code must retain the above copyright | | 14 | # 1. Redistributions of source code must retain the above copyright |
15 | # notice, this list of conditions and the following disclaimer. | | 15 | # notice, this list of conditions and the following disclaimer. |
| @@ -290,70 +290,66 @@ sub generate_initial_package($) { | | | @@ -290,70 +290,66 @@ sub generate_initial_package($) { |
290 | } elsif ($master_site eq "MASTER_SITE_GNU") { | | 290 | } elsif ($master_site eq "MASTER_SITE_GNU") { |
291 | $homepage = "http://www.gnu.org/software/${subdir}/"; | | 291 | $homepage = "http://www.gnu.org/software/${subdir}/"; |
292 | } else { | | 292 | } else { |
293 | $homepage = substr($url, 0, -length($distfile)); | | 293 | $homepage = substr($url, 0, -length($distfile)); |
294 | } | | 294 | } |
295 | } else { | | 295 | } else { |
296 | $master_sites = "\${${master_site}}"; | | 296 | $master_sites = "\${${master_site}}"; |
297 | } | | 297 | } |
298 | } | | 298 | } |
299 | } | | 299 | } |
300 | } | | 300 | } |
301 | close(SITES) or die; | | 301 | close(SITES) or die; |
302 | | | 302 | |
303 | if (true) { | | 303 | if ($url =~ qr"^http://(?:pr)?downloads\.sourceforge\.net/([^/]*)/([^/?]+)(?:\?(?:download|use_mirror=.*))?$") { |
304 | if ($url =~ qr"^http://(?:pr)?downloads\.sourceforge\.net/([^/]*)/([^/?]+)(?:\?(?:download|use_mirror=.*))?$") { | | 304 | my $pkgbase = $1; |
305 | my $pkgbase = $1; | | 305 | $distfile = $2; |
306 | $distfile = $2; | | 306 | |
307 | | | 307 | $master_sites = "\${MASTER_SITE_SOURCEFORGE:=${pkgbase}/}"; |
308 | $master_sites = "\${MASTER_SITE_SOURCEFORGE:=${pkgbase}/}"; | | 308 | $homepage = "http://${pkgbase}.sourceforge.net/"; |
309 | $homepage = "http://${pkgbase}.sourceforge.net/"; | | 309 | $found = true; |
| | | 310 | } |
| | | 311 | |
| | | 312 | if ($url =~ qr"^https?://github\.com/") { |
| | | 313 | if ($url =~ qr"^https?://github\.com/(.*)/(.*)/archive/(.*)(\.tar\.gz|\.zip)$") { |
| | | 314 | $master_sites = "\${MASTER_SITE_GITHUB:=$1/}"; |
| | | 315 | $homepage = "https://github.com/$1/$2/"; |
| | | 316 | $gh_project = $2; |
| | | 317 | $gh_tag = $3; |
| | | 318 | if (index($gh_tag, $gh_project) == -1 ) { |
| | | 319 | $pkgname = '${GITHUB_PROJECT}-${DISTNAME}'; |
| | | 320 | $dist_subdir = '${GITHUB_PROJECT}'; |
| | | 321 | } |
| | | 322 | $distfile = "$3$4"; |
310 | $found = true; | | 323 | $found = true; |
311 | } | | 324 | } elsif ($url =~ qr"^https?://github\.com/(.*)/(.*)/releases/download/(.*)/(.*)(\.tar\.gz|\.zip)$") { |
312 | } | | 325 | $master_sites = "\${MASTER_SITE_GITHUB:=$1/}"; |
313 | | | 326 | $homepage = "https://github.com/$1/$2/"; |
314 | if (true) { | | 327 | if (index($4, $2) == -1) { |
315 | if ($url =~ qr"^https?://github\.com/") { | | | |
316 | if ($url =~ qr"^https?://github\.com/(.*)/(.*)/archive/(.*)(\.tar\.gz|\.zip)$") { | | | |
317 | $master_sites = "\${MASTER_SITE_GITHUB:=$1/}"; | | | |
318 | $homepage = "https://github.com/$1/$2/"; | | | |
319 | $gh_project = $2; | | 328 | $gh_project = $2; |
320 | $gh_tag = $3; | | 329 | $dist_subdir = '${GITHUB_PROJECT}'; |
321 | if (index($gh_tag, $gh_project) == -1 ) { | | 330 | } |
322 | $pkgname = '${GITHUB_PROJECT}-${DISTNAME}'; | | 331 | if ($3 eq $4) { |
323 | $dist_subdir = '${GITHUB_PROJECT}'; | | 332 | $gh_release = '${DISTNAME}'; |
324 | } | | | |
325 | $distfile = "$3$4"; | | | |
326 | $found = true; | | | |
327 | } elsif ($url =~ qr"^https?://github\.com/(.*)/(.*)/releases/download/(.*)/(.*)(\.tar\.gz|\.zip)$") { | | | |
328 | $master_sites = "\${MASTER_SITE_GITHUB:=$1/}"; | | | |
329 | $homepage = "https://github.com/$1/$2/"; | | | |
330 | if (index($4, $2) == -1) { | | | |
331 | $gh_project = $2; | | | |
332 | $dist_subdir = '${GITHUB_PROJECT}'; | | | |
333 | } | | | |
334 | if ($3 eq $4) { | | | |
335 | $gh_release = '${DISTNAME}'; | | | |
336 | } else { | | | |
337 | $gh_release = $3; | | | |
338 | } | | | |
339 | $distfile = "$4$5"; | | | |
340 | $found = true; | | | |
341 | } else { | | 333 | } else { |
342 | print("$0: ERROR: Invalid GitHub URL: ${url}, handling as normal URL\n"); | | 334 | $gh_release = $3; |
343 | } | | 335 | } |
| | | 336 | $distfile = "$4$5"; |
| | | 337 | $found = true; |
344 | } else { | | 338 | } else { |
345 | $gh_project = ""; $gh_release = ""; $dist_subdir = ""; | | 339 | print("$0: ERROR: Invalid GitHub URL: ${url}, handling as normal URL\n"); |
346 | } | | 340 | } |
| | | 341 | } else { |
| | | 342 | $gh_project = ""; $gh_release = ""; $dist_subdir = ""; |
347 | } | | 343 | } |
348 | | | 344 | |
349 | if (!$found) { | | 345 | if (!$found) { |
350 | if ($url =~ qr"^(.*/)(.*)$") { | | 346 | if ($url =~ qr"^(.*/)(.*)$") { |
351 | ($master_sites, $distfile) = ($1, $2); | | 347 | ($master_sites, $distfile) = ($1, $2); |
352 | $homepage = $master_sites; | | 348 | $homepage = $master_sites; |
353 | } else { | | 349 | } else { |
354 | die("$0: ERROR: Invalid URL: ${url}\n"); | | 350 | die("$0: ERROR: Invalid URL: ${url}\n"); |
355 | } | | 351 | } |
356 | } | | 352 | } |
357 | | | 353 | |
358 | if ($distfile =~ qr"^(.*)(\.tgz|\.tar\.Z|\.tar\.gz|\.tar\.bz2|\.tar\.xz|\.tar\.7z)$") { | | 354 | if ($distfile =~ qr"^(.*)(\.tgz|\.tar\.Z|\.tar\.gz|\.tar\.bz2|\.tar\.xz|\.tar\.7z)$") { |
359 | ($distname, $dist_sufx) = ($1, $2); | | 355 | ($distname, $dist_sufx) = ($1, $2); |