Skip to content

Commit

Permalink
Update port2pkg to 1.4
Browse files Browse the repository at this point in the history
Changes:
	Support PORTNAME/PORTVERSION variables.
  • Loading branch information
sakamoto committed Apr 26, 2000
1 parent 8ec6999 commit b804cbd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
10 changes: 6 additions & 4 deletions pkgtools/port2pkg/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# $NetBSD: Makefile,v 1.4 1999/11/24 10:36:53 agc Exp $
# $NetBSD: Makefile,v 1.5 2000/04/26 16:18:58 sakamoto Exp $
#

DISTNAME= port2pkg-1.2
DISTNAME= port2pkg-1.4
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty

MAINTAINER= [email protected]

DEPENDS+= pkglint-*:../../pkgtools/pkglint
RUN_DEPENDS+= pkglint:../../pkgtools/pkglint

USE_PERL5= YES

Expand All @@ -28,9 +28,11 @@ NROFF= nroff

do-build:
${NROFF} -mandoc ${FILESDIR}/port2pkg.1 >${WRKSRC}/port2pkg.0
${SED} -e 's|$${GTAR}|${GTAR}|g' ${FILESDIR}/port2pkg.pl \
> ${WRKSRC}/port2pkg

do-install:
${INSTALL_SCRIPT} ${FILESDIR}/port2pkg.pl ${PREFIX}/bin/port2pkg
${INSTALL_SCRIPT} ${WRKSRC}/port2pkg ${PREFIX}/bin
${INSTALL_MAN} ${WRKSRC}/port2pkg.0 ${PREFIX}/man/cat1
${INSTALL_MAN} ${FILESDIR}/port2pkg.1 ${PREFIX}/man/man1

Expand Down
51 changes: 34 additions & 17 deletions pkgtools/port2pkg/files/port2pkg.pl
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/env perl
#
# $NetBSD: port2pkg.pl,v 1.3 1999/09/14 00:43:20 sakamoto Exp $
# $NetBSD: port2pkg.pl,v 1.4 2000/04/26 16:18:59 sakamoto Exp $
#

require 'getopts.pl';
$^W=1;
use strict;
use vars qw($opt_m);
my($maintainer) = "packages\@netbsd.org";
my($makefile,$master_site_subdir,$extract_cmd);
my($makefile, $master_site_subdir, $extract_cmd);
my($portsdir, $pkgdir);
my($namespace, $portname, $portversion, $distname, $pkgname);
my(@man, @cat);

if (! &Getopts('m:')) {&usage_and_exit();}
Expand All @@ -27,7 +28,7 @@
}
}

system("tar cCf $portsdir - .|tar xCf $pkgdir -");
system("${GTAR} cCf $portsdir - .|${GTAR} xCf $pkgdir -");

&read_Makefile();
&conv_Makefile();
Expand Down Expand Up @@ -57,7 +58,14 @@ sub read_Makefile {
my ($extract_before_args, $extract_after_args);
foreach my $line (split(/\n/, $makefile)) {
$_ = $line;
if (/^MASTER_SITE_SUBDIR\?*=\s*(.*)/) {
if (/^PORTNAME\?*=(\s*)(.*)/) {
$namespace = $1;
$portname = $2;
} elsif (/^PORTVERSION\?*=\s*(.*)/) {
$portversion = $1;
} elsif (/^DISTNAME\?*=\s*(.*)/) {
$distname = $1;
} elsif (/^MASTER_SITE_SUBDIR\?*=\s*(.*)/) {
$master_site_subdir = $1;
if (!($master_site_subdir =~ /\/$/)) {
$master_site_subdir .= "/";
Expand Down Expand Up @@ -85,6 +93,17 @@ sub read_Makefile {
$extract_cmd = "$extract_cmd$extract_before_args" .
" \${DOWNLOADED_DISTFILE}$extract_after_args";
}

if (defined($distname)) {
$distname =~ s/\${PORTNAME}/$portname/;
$distname =~ s/\${PORTVERSION}/$portversion/;

if ($distname ne "$portname-$portversion") {
$pkgname = "$portname-$portversion";
}
} else {
$distname = "$portname-$portversion";
}
}

sub conv_Makefile {
Expand Down Expand Up @@ -112,9 +131,7 @@ sub conv_Makefile {
while (<PORTS>) {
if (/\\$/) {
$nextline++;
if ($remove) {
next;
}
next if ($remove);
} else {
$nextline = 0;
if ($remove) {
Expand Down Expand Up @@ -150,24 +167,24 @@ sub conv_Makefile {
print "WARN: found \"$1\"\n";
}

if (/^MAN(.)\?*=/ ||
if (/^PORTVERSION/ ||
/^DISTNAME/ ||
/^MAN(.)\?*=/ ||
/^CAT(.)\?*=/ ||
/^MASTER_SITE_SUBDIR/ ||
/^EXTRACT_BEFORE_ARGS/ ||
/^EXTRACT_AFTER_ARGS/) {
if ($nextline) {
$remove = 1;
}
$remove if ($nextline);
} elsif (/^PORTNAME/) {
print PKG "DISTNAME=$namespace$distname\n";
print PKG "PKGNAME=$namespace$pkgname\n" if defined($pkgname);
$remove if ($nextline);
} elsif (/^(EXTRACT_CMD\?*=)/) {
print PKG "$1\t$extract_cmd\n";
if ($nextline) {
$remove = 1;
}
$remove if ($nextline);
} elsif (/^(MAINTAINER\?*=)/) {
print PKG "$1\t$maintainer\n";
if ($nextline) {
$remove = 1;
}
$remove if ($nextline);

open(DESCR, "$pkgdir/pkg/DESCR")
|| die "$pkgdir/pkg/DESCR: $!\n";
Expand Down

0 comments on commit b804cbd

Please sign in to comment.