diff options
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/port2pkg/Makefile | 37 | ||||
-rw-r--r-- | pkgtools/port2pkg/files/port2pkg.1 | 52 | ||||
-rwxr-xr-x | pkgtools/port2pkg/files/port2pkg.pl | 270 | ||||
-rw-r--r-- | pkgtools/port2pkg/pkg/COMMENT | 1 | ||||
-rw-r--r-- | pkgtools/port2pkg/pkg/DESCR | 7 | ||||
-rw-r--r-- | pkgtools/port2pkg/pkg/PLIST | 4 |
6 files changed, 371 insertions, 0 deletions
diff --git a/pkgtools/port2pkg/Makefile b/pkgtools/port2pkg/Makefile new file mode 100644 index 00000000000..e660afcbda4 --- /dev/null +++ b/pkgtools/port2pkg/Makefile @@ -0,0 +1,37 @@ +# $NetBSD: Makefile,v 1.1.1.1 1999/07/27 11:33:06 sakamoto Exp $ +# + +DISTNAME= port2pkg-1.1 +CATEGORIES= pkgtools +MASTER_SITES= # empty +DISTFILES= # empty + +MAINTAINER= sakamoto@netbsd.org + +DEPENDS+= pkglint-1.73:../../pkgtools/pkglint + +USE_PERL5= YES + +EXTRACT_ONLY= # empty +NO_WRKSUBDIR= yes +NO_CHECKSUM= yes +NO_PATCH= yes +NO_CONFIGURE= yes + +.include "../../mk/bsd.prefs.mk" + +.if ${OPSYS} == "SunOS" +NROFF= gnroff +.else +NROFF= nroff +.endif + +do-build: + ${NROFF} -mandoc ${FILESDIR}/port2pkg.1 >${WRKSRC}/port2pkg.0 + +do-install: + ${INSTALL_SCRIPT} ${FILESDIR}/port2pkg.pl ${PREFIX}/bin/port2pkg + ${INSTALL_MAN} ${WRKSRC}/port2pkg.0 ${PREFIX}/man/cat1 + ${INSTALL_MAN} ${FILESDIR}/port2pkg.1 ${PREFIX}/man/man1 + +.include "../../mk/bsd.pkg.mk" diff --git a/pkgtools/port2pkg/files/port2pkg.1 b/pkgtools/port2pkg/files/port2pkg.1 new file mode 100644 index 00000000000..5daed21749a --- /dev/null +++ b/pkgtools/port2pkg/files/port2pkg.1 @@ -0,0 +1,52 @@ +.\" $NetBSD: port2pkg.1,v 1.1.1.1 1999/07/27 11:33:06 sakamoto Exp $ +.\" +.\" Copyright (c) 1999 by Kazuki Sakamoto (sakamoto@netbsd.org) +.\" Absolutely no warranty. +.\" +.Dd July 27, 1999 +.Dt PORT2PKG 1 +.Sh NAME +.Nm port2pkg +.Nd convert FreeBSD ports to NetBSD pkgsrc +.Sh SYNOPSIS +.Nm +.Op Fl m Ar maintainer +.Ar portsdir +.Ar pkgsrcdir +.Sh DESCRIPTION +.Nm +tries convet FreeBSD ports to NetBSD pkgsrc. +.Nm +copies files +from +.Ar portsdir +to +.Ar pkgsrcdir +(if noexists, mkdir +.Ar pkgsrcdir), +and tries adapting Makefile, patches and some files +to NetBSD in +.Ar pkgsrcdir . +.Pp +.Sy Options +.Bl -tag -width Fl +.It Fl m +Adjust maintainer this package +(default: packages@netbsd.org). +.El +.Sh EXAMPLES +.Pp +.Dl port2pkg /mnt/ports/<category>/foo /usr/pkgsrc/<category>/foo +or +.Dl port2pkg -m your@email /mnt/ports/<category>/foo /usr/pkgsrc/<category>/foo +.Pp +.Sh SEE ALSO +Read +.Ar Package Constructor's Guide +in +.Ar pkgsrc/Packages.txt . +.Sh BUGS +.Nm +is not a magic wand, please double-check converted pkgsrc. +.Sh AUTHOR +Kazuki Sakamoto <sakamoto@netbsd.org> diff --git a/pkgtools/port2pkg/files/port2pkg.pl b/pkgtools/port2pkg/files/port2pkg.pl new file mode 100755 index 00000000000..91fcb61a9c4 --- /dev/null +++ b/pkgtools/port2pkg/files/port2pkg.pl @@ -0,0 +1,270 @@ +#!/usr/bin/env perl +# +# $NetBSD: port2pkg.pl,v 1.1.1.1 1999/07/27 11:33:06 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($portsdir, $pkgdir); +my(@man, @cat); + +if (! &Getopts('m:')) {&usage_and_exit();} +$|=1; + +$portsdir = shift; +$pkgdir = shift; +if (! $portsdir || ! $pkgdir) {&usage_and_exit();} + +if ($opt_m) {$maintainer = $opt_m;} +if (! -d "$portsdir") {die "$portsdir: $!\n";} +if (! -d "$pkgdir") { + if (mkdir($pkgdir, 0755) == 0) { + die "$pkgdir: $!\n"; + } +} + +system("tar cCf $portsdir - .|tar xCf $pkgdir -"); + +&read_Makefile(); +&conv_Makefile(); +&conv_PLIST(); +&add_NetBSD_ID(); + +system("(cd $pkgdir; pkglint)"); +0; + +sub usage_and_exit { + print "port2pkg [-m maintainer] portsdir pkgdir\n"; + exit; +} + +sub read_Makefile { + open(PORTS, "$portsdir/Makefile") + || die "$portsdir/Makefile: $!\n"; + while (<PORTS>) { + if (/\\$/) { + chop; + chop; + } + $makefile .= $_; + } + close(PORTS); + + my ($extract_before_args, $extract_after_args); + foreach my $line (split(/\n/, $makefile)) { + $_ = $line; + if (/^MASTER_SITE_SUBDIR\?*=\s*(.*)/) { + $master_site_subdir = $1; + if (!($master_site_subdir =~ /\/$/)) { + $master_site_subdir .= "/"; + } + } elsif (/^MAN(.)\?*=\s*(.*)/) { + $man[$1] .= $2; + } elsif (/^CAT(.)\?*=\s*(.*)/) { + $cat[$1] .= $2; + } elsif (/^EXTRACT_CMD\?*=\s*(.*)/) { + $extract_cmd = $1; + } elsif (/^EXTRACT_BEFORE_ARGS\?*=\s*(.*)/) { + $extract_before_args = $1; + } elsif (/^EXTRACT_AFTER_ARGS\?*=\s*(.*)/) { + $extract_after_args = $1; + } + } + + if (defined($extract_cmd) && $extract_cmd ne "") { + if ($extract_before_args ne "") { + $extract_before_args = " $extract_before_args"; + } + if ($extract_after_args ne "") { + $extract_after_args = " $extract_after_args"; + } + $extract_cmd = "$extract_cmd$extract_before_args" . + " \${DOWNLOADED_DISTFILE}$extract_after_args"; + } +} + +sub conv_Makefile { + open(PORTS, "$portsdir/Makefile") + || die "$portsdir/Makefile: $!\n"; + open(PKG, ">$pkgdir/Makefile") + || die "$pkgdir/Makefile: $!\n"; + + print PKG "# \$NetBSD\$\n"; + + # header + while (<PORTS>) { + if (! /^\#/) {last;} + + if (/\$(Id: .*)/) { + print PKG "\# FreeBSD $1\n"; + } else { + print; + } + } + print PKG; + + # body + my ($nextline, $remove, $master_sites, $noportdocs); + while (<PORTS>) { + if (/\\$/) { + $nextline++; + if ($remove) { + next; + } + } else { + $nextline = 0; + if ($remove) { + $remove = 0; + next; + } + } + + s|^\.include <bsd.port.mk>|.include \"../../mk/bsd.pkg.mk\"|; + s|^FETCH_(DEPENDS)|BUILD_$1|; + s|^LIB_(DEPENDS)|$1|; + s|\$\{PORTSDIR\}|../..|g; + + if (defined($master_site_subdir) && + $master_site_subdir ne "" && + ($master_sites || /^MASTER_SITES\?*=/)) { + s|([^L][^O][^C][^A][^L])\}|$1:=$master_site_subdir}|g; + + if ($nextline) { + $master_sites = 1; + } else { + $master_sites = 0; + } + } + + if (/(\/usr\/local)/ || + /(ldconfig)/i || + /(MASTERDIR)/ || + /(.*cat.*MESSAGE.*)/i) { + print "WARN: found \"$1\"\n"; + } + + if (/^MAN(.)\?*=/ || + /^CAT(.)\?*=/ || + /^MASTER_SITE_SUBDIR/ || + /^EXTRACT_BEFORE_ARGS/ || + /^EXTRACT_AFTER_ARGS/) { + if ($nextline) { + $remove = 1; + } + } elsif (/^(EXTRACT_CMD\?*=)/) { + print PKG "$1\t$extract_cmd\n"; + if ($nextline) { + $remove = 1; + } + } elsif (/^(MAINTAINER\?*=)/) { + print PKG "$1\t$maintainer\n"; + if ($nextline) { + $remove = 1; + } + } elsif ($noportdocs || /^\.if.*NOPORTDOCS/) { + if (/^\.if/) { + $noportdocs++; + if ($noportdocs > 2) {print PKG $_;} + } elsif (/^\.endif/) { + $noportdocs--; + if ($noportdocs > 2) {print PKG $_;} + } else { + print PKG $_; + } + } else { + print PKG $_; + } + } + + close(PORTS); + close(PKG); +} + +sub add_manual { + my ($FILE, $category) = @_; + + for (my $i = 1; $i <= 8; $i++) { + if (!defined(eval "\$$category\[\$i\]")) {next;} + foreach my $item (sort(split(/[ \t\n]+/, + eval "\$$category\[\$i\]"))) { + print $FILE "$category/$category$i/$item\n"; + } + } +} + +sub conv_PLIST { + my ($file, $plist); + if (opendir(PKGDIR, "$portsdir/pkg") == 0) {return 0;} + while ($plist = readdir(PKGDIR)) { + if (!($plist =~ /^PLIST/)) {next;} + + open(PORTS, "$portsdir/pkg/$plist") + || die "$portsdir/pkg/$plist: $!\n"; + open(PKG, ">$pkgdir/pkg/$plist") + || die "$pkgdir/pkg/$plist: $!\n"; + + print PKG "\@comment \$NetBSD\$\n"; + my ($cat_added, $man_added); + while (<PORTS>) { + if (/^\@.*ldconfig/) {next;} + if (defined($cat_added) && $cat_added == 0 && /^[d-z]/){ + &add_manual(*PKG, "cat"); + $cat_added++; + } + if (defined($man_added) && $man_added == 0 && /^[n-z]/){ + &add_manual(*PKG, "man"); + $man_added++; + } + + print PKG $_; + } + if (defined($cat_added) && $cat_added == 0) + {&add_manual(*PKG, "cat");} + if (defined($man_added) && $man_added == 0) + {&add_manual(*PKG, "man");} + + close(PKG); + close(PORTS); + } + closedir(PKGDIR); +} + +sub add_NetBSD_ID { + my ($patch); + if (open(MD5, "$portsdir/files/md5")) { + open(NMD5, ">$pkgdir/files/md5") + || die "$pkgdir/files/md5: $!\n"; + print NMD5 "\$NetBSD\$\n\n"; + while (<MD5>) { + print NMD5 $_; + } + close(NMD5); + close(MD5); + } + + if (opendir(PATCHDIR, "$portsdir/patches") == 0) {return 0;} + while ($patch = readdir(PATCHDIR)) { + if ($patch eq "\." || $patch eq "\.." + || $patch eq "CVS") {next;} + if (open(PATCH, "$portsdir/patches/$patch")) { + open(NPATCH, ">$pkgdir/patches/$patch") + || die "$pkgdir/patches/$patch: $!\n"; + print NPATCH "\$NetBSD\$\n\n"; + while (<PATCH>) { + if (/(FreeBSD)/i || + /(#!.*perl)/) { + print "WARN: $pkgdir/patches/" . + "$patch includes \"$1\".\n"; + } + print NPATCH $_; + } + close(NPATCH); + close(PATCH); + } + } + closedir(PATCHDIR); +} diff --git a/pkgtools/port2pkg/pkg/COMMENT b/pkgtools/port2pkg/pkg/COMMENT new file mode 100644 index 00000000000..197b3f8bf7c --- /dev/null +++ b/pkgtools/port2pkg/pkg/COMMENT @@ -0,0 +1 @@ +Converter FreeBSD port to NetBSD pkgsrc diff --git a/pkgtools/port2pkg/pkg/DESCR b/pkgtools/port2pkg/pkg/DESCR new file mode 100644 index 00000000000..e31881a1da1 --- /dev/null +++ b/pkgtools/port2pkg/pkg/DESCR @@ -0,0 +1,7 @@ +Converter FreeBSD port to NetBSD pkgsrc. + +port2pkg tries convet FreeBSD ports to NetBSD pkgsrc. port2pkg copies +files from portsdir to pkgsrcdir (if noexists, mkdir pkgsrcdir), and +tries adapting Makefile, patches and some files to NetBSD in pkgsrcdir. + +port2pkg /mnt/ports/<category>/foo /usr/pkgsrc/<category>/foo diff --git a/pkgtools/port2pkg/pkg/PLIST b/pkgtools/port2pkg/pkg/PLIST new file mode 100644 index 00000000000..5e8a76be194 --- /dev/null +++ b/pkgtools/port2pkg/pkg/PLIST @@ -0,0 +1,4 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 1999/07/27 11:33:06 sakamoto Exp $ +bin/port2pkg +man/cat1/port2pkg.0 +man/man1/port2pkg.1 |