Sun Aug 18 07:51:40 2019 UTC ()
pkgtools/url2pkg: remove unnecessary local variable


(rillig)
diff -r1.54 -r1.55 pkgsrc/pkgtools/url2pkg/files/url2pkg.pl

cvs diff -r1.54 -r1.55 pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl 2019/08/18 07:47:58 1.54
+++ pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl 2019/08/18 07:51:40 1.55
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! @PERL@ 1#! @PERL@
2# $NetBSD: url2pkg.pl,v 1.54 2019/08/18 07:47:58 rillig Exp $ 2# $NetBSD: url2pkg.pl,v 1.55 2019/08/18 07:51:40 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.
@@ -296,113 +296,111 @@ sub adjust_use_languages() { @@ -296,113 +296,111 @@ sub adjust_use_languages() {
296sub generate_initial_package_Makefile_lines($) { 296sub generate_initial_package_Makefile_lines($) {
297 my ($url) = @_; 297 my ($url) = @_;
298 298
299 my $master_site = ""; 299 my $master_site = "";
300 my $master_sites = ""; 300 my $master_sites = "";
301 my $distfile = ""; 301 my $distfile = "";
302 my $homepage = ""; 302 my $homepage = "";
303 my $extract_sufx = ""; 303 my $extract_sufx = "";
304 my $categories = ""; 304 my $categories = "";
305 my $github_project = ""; 305 my $github_project = "";
306 my $github_release = ""; 306 my $github_release = "";
307 my $dist_subdir = ""; 307 my $dist_subdir = "";
308 308
309 my $found = false; 
310 open(SITES, "<", "../../mk/fetch/sites.mk") or die; 309 open(SITES, "<", "../../mk/fetch/sites.mk") or die;
311 while (defined(my $line = <SITES>)) { 310 while (defined(my $line = <SITES>)) {
312 chomp($line); 311 chomp($line);
313 312
314 if ($line =~ qr"^(MASTER_SITE_.*)\+=") { 313 if ($line =~ qr"^(MASTER_SITE_.*)\+=") {
315 $master_site = $1; 314 $master_site = $1;
316 315
317 } elsif ($line =~ qr"^\t(.*?)(?:\s+\\)?$") { 316 } elsif ($line =~ qr"^\t(.*?)(?:\s+\\)?$") {
318 my ($site) = ($1); 317 my ($site) = ($1);
319 318
320 if (index($url, $site) == 0) { 319 if (index($url, $site) == 0) {
321 $found = true; 
322 
323 if ($url =~ qr"^\Q${site}\E(.+)/([^/]+)$") { 320 if ($url =~ qr"^\Q${site}\E(.+)/([^/]+)$") {
324 my $subdir = $1; 321 my $subdir = $1;
325 $distfile = $2; 322 $distfile = $2;
326 323
327 $master_sites = "\${${master_site}:=${subdir}/}"; 324 $master_sites = "\${${master_site}:=${subdir}/}";
328 if ($master_site eq "MASTER_SITE_SOURCEFORGE") { 325 if ($master_site eq "MASTER_SITE_SOURCEFORGE") {
329 $homepage = "http://${subdir}.sourceforge.net/"; 326 $homepage = "http://${subdir}.sourceforge.net/";
330 } elsif ($master_site eq "MASTER_SITE_GNU") { 327 } elsif ($master_site eq "MASTER_SITE_GNU") {
331 $homepage = "http://www.gnu.org/software/${subdir}/"; 328 $homepage = "http://www.gnu.org/software/${subdir}/";
332 } else { 329 } else {
333 $homepage = substr($url, 0, -length($distfile)); 330 $homepage = substr($url, 0, -length($distfile));
334 } 331 }
335 } else { 332 } else {
336 $master_sites = "\${${master_site}}"; 333 $master_sites = "\${${master_site}}";
337 } 334 }
338 } 335 }
339 } 336 }
340 } 337 }
341 close(SITES) or die; 338 close(SITES) or die;
342 339
343 if ($url =~ qr"^https://downloads\.sourceforge\.net/project/([^/?]+)/[^?]+/([^/?]+)(?:[?].*)?$") { 340 if ($url =~ qr"^https://downloads\.sourceforge\.net/project/([^/?]+)/[^?]+/([^/?]+)(?:[?].*)?$") {
344 my ($project, $filename) = ($1, $2); 341 my ($project, $filename) = ($1, $2);
345 342
346 $master_sites = "\${MASTER_SITE_SOURCEFORGE:=${project}/}"; 343 $master_sites = "\${MASTER_SITE_SOURCEFORGE:=${project}/}";
347 $homepage = "https://${project}.sourceforge.net/"; 344 $homepage = "https://${project}.sourceforge.net/";
348 $distfile = $filename; 345 $distfile = $filename;
349 $found = true; 
350 } 346 }
351 347
352 if ($url =~ qr"^https://github\.com/") { 348 if ($url =~ qr"^https://github\.com/") {
353 if ($url =~ qr"^https://github\.com/(.*)/(.*)/archive/(.*)(\.tar\.gz|\.zip)$") { 349 if ($url =~ qr"^https://github\.com/(.*)/(.*)/archive/(.*)(\.tar\.gz|\.zip)$") {
354 my ($org, $proj, $tag, $ext) = ($1, $2, $3, $4); 350 my ($org, $proj, $tag, $ext) = ($1, $2, $3, $4);
355 351
356 $master_sites = "\${MASTER_SITE_GITHUB:=$org/}"; 352 $master_sites = "\${MASTER_SITE_GITHUB:=$org/}";
357 $homepage = "https://github.com/$org/$proj/"; 353 $homepage = "https://github.com/$org/$proj/";
358 $github_project = $proj; 354 $github_project = $proj;
359 if (index($tag, $github_project) == -1) { 355 if (index($tag, $github_project) == -1) {
360 $pkgname = '${GITHUB_PROJECT}-${DISTNAME}'; 356 $pkgname = '${GITHUB_PROJECT}-${DISTNAME}';
361 $dist_subdir = '${GITHUB_PROJECT}'; 357 $dist_subdir = '${GITHUB_PROJECT}';
362 } 358 }
363 $distfile = "$tag$ext"; 359 $distfile = "$tag$ext";
364 $found = true; 
365 360
366 } elsif ($url =~ qr"^https://github\.com/(.*)/(.*)/releases/download/(.*)/(.*)(\.tar\.gz|\.zip)$") { 361 } elsif ($url =~ qr"^https://github\.com/(.*)/(.*)/releases/download/(.*)/(.*)(\.tar\.gz|\.zip)$") {
367 my ($org, $proj, $tag, $base, $ext) = ($1, $2, $3, $4, $5); 362 my ($org, $proj, $tag, $base, $ext) = ($1, $2, $3, $4, $5);
368 363
369 $master_sites = "\${MASTER_SITE_GITHUB:=$org/}"; 364 $master_sites = "\${MASTER_SITE_GITHUB:=$org/}";
370 $homepage = "https://github.com/$org/$proj/"; 365 $homepage = "https://github.com/$org/$proj/";
371 if (index($base, $proj) == -1) { 366 if (index($base, $proj) == -1) {
372 $github_project = $proj; 367 $github_project = $proj;
373 $dist_subdir = '${GITHUB_PROJECT}'; 368 $dist_subdir = '${GITHUB_PROJECT}';
374 } 369 }
375 $github_release = $tag eq $base ? '${DISTNAME}' : $tag; 370 $github_release = $tag eq $base ? '${DISTNAME}' : $tag;
376 $distfile = "$base$ext"; 371 $distfile = "$base$ext";
377 $found = true; 372
378 } else { 373 } else {
379 print("$0: ERROR: Invalid GitHub URL: ${url}, handling as normal URL\n"); 374 print("$0: ERROR: Invalid GitHub URL: ${url}, handling as normal URL\n");
380 } 375 }
381 } 376 }
382 377
383 if (!$found) { 378 if ($master_sites eq "") {
384 if ($url =~ qr"^(.*/)(.*)$") { 379 if ($url =~ qr"^(.*/)(.*)$") {
385 ($master_sites, $distfile) = ($1, $2); 380 $master_sites = $1;
 381 $distfile = $2;
386 $homepage = $master_sites; 382 $homepage = $master_sites;
387 } else { 383 } else {
388 die("$0: ERROR: Invalid URL: ${url}\n"); 384 die("$0: ERROR: Invalid URL: ${url}\n");
389 } 385 }
390 } 386 }
391 387
392 if ($distfile =~ qr"^(.*?)((?:\.tar)?\.\w+)$") { 388 if ($distfile =~ qr"^(.*?)((?:\.tar)?\.\w+)$") {
393 ($distname, $extract_sufx) = ($1, $2); 389 $distname = $1;
 390 $extract_sufx = $2;
394 } else { 391 } else {
395 ($distname, $extract_sufx) = ($distfile, "# none"); 392 $distname = $distfile;
 393 $extract_sufx = "# none";
396 } 394 }
397 395
398 rename("Makefile", "Makefile-url2pkg.bak") or do {}; 396 rename("Makefile", "Makefile-url2pkg.bak") or do {};
399 397
400 `pwd` =~ qr".*/([^/]+)/[^/]+$" or die; 398 `pwd` =~ qr".*/([^/]+)/[^/]+$" or die;
401 $categories = $1; 399 $categories = $1;
402 400
403 if ($extract_sufx eq ".tar.gz" || $extract_sufx eq ".gem") { 401 if ($extract_sufx eq ".tar.gz" || $extract_sufx eq ".gem") {
404 $extract_sufx = ""; 402 $extract_sufx = "";
405 } 403 }
406 404
407 my @lines; 405 my @lines;
408 push(@lines, "# \$" . "NetBSD\$"); 406 push(@lines, "# \$" . "NetBSD\$");