- Obsolete and made unusable by changes in the Ports Collection

This commit is contained in:
Alex Kozlov 2015-04-09 04:45:25 +00:00
parent 98d9fcefa0
commit 4a5d17fd60
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=383621
7 changed files with 0 additions and 867 deletions

View File

@ -1,68 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (c) 2001 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
use strict;
my $path_tmp = "/tmp";
eval {
require 'paths.ph';
$path_tmp = &_PATH_TMP;
};
sub testdir (@) {
my $d; # currently tested dir
foreach $d (@_) {
next unless defined($d);
$d =~ s,/$,,;
return $d if ((-d $d) && (-w $d));
}
return "";
}
my ($user, $group, $origdir, $portname, $tmpbase, $tmpdir, $wdpdir, $predir, $hmake);
chomp ($user = `id -un`);
chomp ($group = `id -gn`);
chomp ($origdir = `pwd`);
chomp ($portname = `basename $origdir`);
$tmpbase = testdir($ENV{'TMPDIR'}, $ENV{'TMP'}, $path_tmp);
($tmpbase eq "") and die("No temp dir, please define either TMPDIR or TMP\n");
$tmpdir = "$tmpbase/$user.$portname";
$wdpdir = "$tmpdir/wdp";
$predir = "$tmpdir/prefix";
$hmake = "env WRKDIRPREFIX=$wdpdir PREFIX=$predir NO_PKG_REGISTER=1 ";
foreach (qw"SHARE MAN LIB BIN") {
$hmake .= $_ . "OWN=$user ";
$hmake .= $_ . "GRP=$group ";
}
$hmake .= "PREFIX=$predir NO_PKG_REGISTER=1 make";
open(BUILD, "$hmake |");
while(<BUILD>) {
print;
}
close(BUILD);

View File

@ -1,30 +0,0 @@
#!/usr/bin/perl
#
# Copyright (c) 2000 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
unlink("Makefile.old");
unlink("Makefile.extr");
`make clean NOCLEANDEPENDS=1`;

View File

@ -1,255 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (c) 2000 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
use strict;
use Getopt::Std qw( getopts );
my ($initdir, $distname);
my ($makefile, $wrksrc);
my ($portname, $portversion);
my (%cap); # persistent version of the make variables
my (%tmp); # temporary version of the make variables
chomp($initdir = `pwd`);
getopts('o');
#&usage if $#ARGV != 0;
&initmk;
&chk_scripts;
chdir($initdir);
open(MAKEFILE, ">Makefile.extr");
&writemk;
exit;
sub nl {
print MAKEFILE "\n";
}
sub writeiffound {
my($var) = (@_);
if ($tmp{"$var"}) {
print MAKEFILE "$var=\t". $tmp{$var} . "\n";
delete($tmp{$var});
return 1;
}
return 0;
}
sub appendvar {
my ($var, $item) = (@_);
if ($tmp{$var}) {
$tmp{$var} .= "\t\\\n\t\t$item";
} else {
$tmp{$var} = "$item";
}
}
sub writemk {
my (@freeform);
my ($key);
foreach $key (keys %cap) {
$tmp{$key} = $cap{$key};
}
foreach $key (keys %tmp) {
if ($tmp{"USE_KDE"}) {
appendvar("LIB_DEPENDS",
"kdecore.4:\${PORTSDIR}/x11/kdelibs2");
delete($tmp{"USE_KDE"});
}
if ($tmp{"USE_GNOME"}) {
appendvar("LIB_DEPENDS",
"gnome.4:\${PORTSDIR}/x11/gnomelibs");
delete($tmp{"USE_GNOME"});
}
if ($tmp{"USE_GTK"}) {
appendvar("LIB_DEPENDS",
"gtk12.2:\${PORTSDIR}/x11-toolkits/gtk12");
$tmp{"GTK_CONFIG"} =
"\${LOCALBASE}/bin/gtk12-config";
appendvar("CONFIGURE_ENV",
"GTK_CONFIG=\"\${GTK_CONFIG}\"");
delete($tmp{"USE_GTK"});
}
}
my ($date);
chomp($date = `date +"\%d \%b \%Y"`);
nl if writeiffound("LIB_DEPENDS");
nl if (writeiffound("GNU_CONFIGURE") +
writeiffound("HAS_CONFIGURE") +
writeiffound("CONFIGURE_ARGS") +
writeiffound("CONFIGURE_ENV"));
#second group
foreach $key (keys %tmp) {
my($tmp) = $tmp{$key};
print MAKEFILE "$key=\t$tmp\n";
}
print MAKEFILE @freeform;
print MAKEFILE "\n.include <bsd.port.mk>\n";
close (MAKEFILE);
}
sub initmk {
chomp($portname = `make -V PORTNAME`);
chomp($portversion = `make -V PORTVERSION`);
`make extract`;
}
sub getwrksrc {
my (@files);
my ($wrkdir);
$wrkdir = "work";
chdir ($initdir);
chdir ($wrkdir);
if (-d "$portname-$portversion") {
$wrksrc = $wrkdir . "$portname-$portversion";
chdir ("$portname-$portversion");
return;
}
opendir(DIR, ".");
@files = grep { ! /^\./ } readdir(DIR);
closedir DIR;
if ($#files > 1) { # more than one entry in dir
$cap{"NO_WRKSUBDIR"} = "YES";
$wrksrc = $wrkdir;
} else { # just one, so change to directory
$cap{"WRKSRC"} = '${WRKDIR}/' . $files[0];
$wrksrc = $wrkdir . $files[0];
chdir ($files[0]);
}
}
sub getmkfile {
if ((! -f "Makefile")) {
if (-f "Makefile.in") {
$makefile = "Makefile.in";
} elsif (-f "makefile") {
$cap{"MAKEFILE"} = "makefile";
$makefile = "makefile";
} elsif (-f "GNUmakefile") {
$cap{"MAKEFILE"} = "GNUmakefile";
$cap{"USE_GMAKE"} = "YES";
$makefile = "GNUmakefile";
} else {
print STDERR "No Makefile!\n";
$cap{"NO_BUILD"} = "YES";
$cap{"NO_INSTALL"} = "YES";
}
} else {
$makefile = "Makefile";
}
}
sub gettargets {
my($targets);
$targets = "";
$targets = `make -f $makefile -dg1 -q | grep "^[^.#][-_.a-zA-Z ]*:" | awk "{\$1}"` if defined($makefile);
print $targets;
}
sub getconfinfo {
if (-f "configure") { # ooh, but HAS_CONFIGURE or GNU_CONFIGURE?
if (`./configure --version` =~ /autoconf/) {
$cap{"GNU_CONFIGURE"} = "YES";
$cap{"USE_QT"} = "YES" if (`./configure --help | grep -Fe --with-qt`);
$cap{"USE_GTK"} = "YES" if (`./configure --help | grep -Fe --with-gtk`);
$cap{"USE_GNOME"} = "YES" if (`./configure --help | grep -Fe --with-gnome`);
$cap{"USE_KDE"} = "YES" if (`grep -F "checking for KDE" configure`);
$cap{"USE_OPENSSL"} = "MUST" if (`grep -F 'configure: error: --with-openssl must be specified' configure`);
$cap{"USE_OPENSSL"} = "OPTIONAL" if ( (`grep -F 'configure: error: "OpenSSL not in ' configure`) && !($cap{"USE_OPENSSL"}) );
} else {
$cap{"HAS_CONFIGURE"} = "YES";
}
} else { # maybe they expect us to build configure for them?!
if (-f "configure.in") {
$cap{"USE_AUTOCONF"} = "YES";
} elsif (-f "Configure") {
$cap{"HAS_CONFIGURE"} = "YES";
$cap{"CONFIGURE_SCRIPT"} = "Configure";
}
}
if (!$cap{"USE_QT"}) { # haven't seen QT yet, let's try some more
if ($cap{"USE_KDE"}) {
$cap{"USE_QT"} = "YES";
} elsif (-f "automoc") {
$cap{"USE_QT"} = "YES";
} elsif (-d "moc") {
$cap{"USE_QT"} = "YES";
} elsif (defined($makefile) && -f $makefile && `grep -F -e -lqt $makefile`) { # more insane.
$cap{"USE_QT"} = "YES";
}
}
}
sub chk_scripts {
&getwrksrc;
&getmkfile;
#&gettargets;
&getconfinfo;
if (-f "ltconfig") {
$cap{"USE_LIBTOOL"} = "YES";
}
if (-f "Imakefile") {
$cap{"USE_IMAKE"} = "YES";
}
}
sub usage {
print STDERR <<"EOF";
usage: $0 filename
generates a ports skeleton for port based on filename
EOF
exit;
}

View File

@ -1,109 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (c) 2001 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
use strict;
my $path_tmp = "/tmp";
eval {
require 'paths.ph';
$path_tmp = &_PATH_TMP;
};
sub testdir (@) {
my $d; # currently tested dir
foreach $d (@_) {
next unless defined($d);
$d =~ s,/$,,;
return $d if ((-d $d) && (-w $d));
}
return "";
}
my ($user, $group, $origdir, $portname, $tmpbase, $tmpdir, $wdpdir, $predir, $hmake);
chomp ($user = `id -un`);
chomp ($group = `id -gn`);
chomp ($origdir = `pwd`);
chomp ($portname = `basename $origdir`);
$tmpbase = testdir($ENV{'TMPDIR'}, $ENV{'TMP'}, $path_tmp);
($tmpbase eq "") and die("No temp dir, please define either TMPDIR or TMP\n");
$tmpdir = "$tmpbase/$user.$portname";
$wdpdir = "$tmpdir/wdp";
$predir = "$tmpdir/prefix";
$hmake = "env WRKDIRPREFIX=$wdpdir PREFIX=$predir NO_PKG_REGISTER=1 ";
foreach (qw"SHARE MAN LIB BIN") {
$hmake .= $_ . "OWN=$user ";
$hmake .= $_ . "GRP=$group ";
}
$hmake .= "PREFIX=$predir NO_PKG_REGISTER=1 make";
my ($origdirs) = "$tmpdir/dirs.orig";
my ($currdirs) = "$tmpdir/dirs.curr";
my ($mtreedist) = "/etc/mtree/BSD.local.dist";
my ($redest) = "mtree -d -f $mtreedist -r -U -p $predir";
my ($ff) = "(cd $predir && find . ! -type d | cut -d/ -f2- | grep -v man/man | sort)";
my ($fd) = "(cd $predir && find . -type d | cut -d/ -f2- | grep -v '^\.\$'| sort)";
system("mkdir $tmpdir");
system("mkdir $predir");
open(MT, "<$mtreedist") || die "Cannot open mtree file";
open(TMT, ">$origdirs") || die "Cannot open temporary dirs file $origdirs: $!";
my($mydir) = "";
while (<MT>) {
chomp;
/^#/ && next;
/^\// && next;
/^\s*$/ && next;
s/^\s*//;
/^\.$/ && next;
/^\.\.$/ && do {
$mydir =~ s#/[^/]*$##;
next;
};
s/\s+\S+$//g;
#print "$_\n";
$mydir = "$mydir/$_";
my ($acwrite) = $mydir;
$acwrite =~ s#^/##;
print TMT "$acwrite\n";
}
close(TMT);
system("$redest >/dev/null");
open(INSTALL, "$hmake install |");
while(<INSTALL>) {
print;
}
close(INSTALL);
die "abnormal program completion ($?): $!" if $?;
system($ff);
system("$fd > $currdirs");
system("comm -23 $currdirs $origdirs | sort -r | xargs -n1 echo \@dirrm");

View File

@ -1,48 +0,0 @@
#!/usr/bin/perl
#
# Copyright (c) 2000 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
open(OLDMAKE, "<Makefile") || die "$!";
open(EXTMAKE, "<Makefile.extr") || die "Makefile.extr - $! - run mpkextr\n";
open(NEWMAKE, ">Makefile.new") || die "$!";
while(<OLDMAKE>) {
print NEWMAKE $_;
last if /^# -- eos --$/;
}
print NEWMAKE "\n";
while(<EXTMAKE>) {
print NEWMAKE $_;
}
close(NEWMAKE);
close(EXTMAKE);
close(OLDMAKE);
`cp -f Makefile Makefile.old`;
`mv -f Makefile.new Makefile`;

View File

@ -1,71 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (c) 2001 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
use strict;
my $path_tmp = "/tmp";
eval {
require 'paths.ph';
$path_tmp = &_PATH_TMP;
};
sub testdir (@) {
my $d; # currently tested dir
foreach $d (@_) {
next unless defined($d);
$d =~ s,/$,,;
return $d if ((-d $d) && (-w $d));
}
return "";
}
my ($user, $group, $origdir, $portname, $tmpbase, $tmpdir, $wdpdir, $predir, $hmake);
chomp ($user = `id -un`);
chomp ($group = `id -gn`);
chomp ($origdir = `pwd`);
chomp ($portname = `basename $origdir`);
$tmpbase = testdir($ENV{'TMPDIR'}, $ENV{'TMP'}, $path_tmp);
($tmpbase eq "") and die("No temp dir, please define either TMPDIR or TMP\n");
$tmpdir = "$tmpbase/$user.$portname";
$wdpdir = "$tmpdir/wdp";
$predir = "$tmpdir/prefix";
$hmake = "env WRKDIRPREFIX=$wdpdir EXTRA_PKG_ARGS='-s $predir' NO_PKG_REGISTER=1 ";
foreach (qw"SHARE MAN LIB BIN") {
$hmake .= $_ . "OWN=$user ";
$hmake .= $_ . "GRP=$group ";
}
$hmake .= "NO_PKG_REGISTER=1 make";
open(INSTALL, "$hmake repackage |");
while(<INSTALL>) {
print;
}
close(INSTALL);
die "abnormal program completion ($?): $!" if $?;

View File

@ -1,286 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (c) 2000 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# a script to gain a bit of knowledge about a supplied distfile
use strict;
use vars qw/ $opt_n /;
use File::Basename qw( basename dirname );
use Getopt::Std qw( getopts );
my ($filename, $ver, $initdir, $distdir, $wrkdir, $tmpdir);
my ($makefile, $wrksrc);
my (%cap);
chomp($initdir = `pwd`);
$cap{"MAINTAINER"} = ($ENV{"MAINTAINER"} || $ENV{"PKGMAINTAINER"} || "ports\@freebsd.org");
getopts('n');
&usage if $#ARGV != 0;
$filename = $ARGV[0];
if ($filename =~ m#^(f|ht)tp\://#) {
print `fetch $filename`;
$cap{"MASTER_SITES"} = dirname($filename) . '/';
$filename = basename($filename);
}
chdir(dirname($filename));
chomp($distdir = `pwd`);
chdir ($initdir);
&chk_extract; # .tar.gz vs .tgz vs .tar.bz2, &c.
&enh_distname;
if ($opt_n) {
print "filename is $filename\n";
print "PORTNAME is " . $cap{"PORTNAME"} . "\n";
print "PORTVERSION is " . $cap{"PORTVERSION"} . "\n";
exit;
}
&bareskel;
&md5;
&writemk;
exit;
sub bareskel {
$tmpdir = $cap{'PORTNAME'};
$tmpdir .= ".$$" while -e $tmpdir;
mkdir($tmpdir,0777);
`printf "\n" > $tmpdir/pkg-plist`;
`printf "\n" > $tmpdir/pkg-descr`;
}
sub writemk {
my (%tmp);
my ($key);
my ($distname);
$distname = $cap{"PORTNAME"};
foreach $key (keys %cap) {
$tmp{$key} = $cap{$key};
}
open(MAKEFILE, ">$tmpdir/Makefile");
my ($date);
chomp($date = `date +"\%d \%b \%Y"`);
print MAKEFILE <<EOF;
# New ports collection makefile for: $distname
# Date created: $date
# Whom: makeport.pl
#
# \$FreeBSD\$
#
EOF
print MAKEFILE "PORTNAME= " . $tmp{"PORTNAME"} . "\n";
print MAKEFILE "PORTVERSION= " . $tmp{"PORTVERSION"} . "\n";
delete($tmp{"PORTNAME"});
delete($tmp{"PORTVERSION"});
print MAKEFILE "CATEGORIES= misc\n";
foreach $key (keys %tmp) {
my($tmp) = $tmp{$key};
if (($key eq "DISTNAME") || ($key eq "EXTRACT_SUFX")) {
print MAKEFILE "$key=\t$tmp\n";
delete($tmp{$key});
}
}
if ($tmp{"MASTER_SITES"}) {
print MAKEFILE "MASTER_SITES= ". $tmp{"MASTER_SITES"} . "\n\n";
delete($tmp{"MASTER_SITES"});
}
print MAKEFILE "\nMAINTAINER=\t" . $tmp{"MAINTAINER"} . "\n";
delete($tmp{"MAINTAINER"});
print MAKEFILE "COMMENT=\t" . "A" . "\n\n";
if ($tmp{"LIB_DEPENDS"}) {
print MAKEFILE "LIB_DEPENDS=". $tmp{"LIB_DEPENDS"} . "\n\n";
delete($tmp{"LIB_DEPENDS"});
}
#second group
foreach $key (keys %tmp) {
my($tmp) = $tmp{$key};
print MAKEFILE "$key=\t$tmp\n";
}
print MAKEFILE "# -- eos --\n\n";
print MAKEFILE ".include <bsd.port.mk>\n";
close (MAKEFILE);
}
sub md5 {
my $tmp = basename($filename);
chdir ($initdir);
`md5 $filename | perl -pe "s#$filename#$tmp#" > $tmpdir/distinfo`;
}
sub chk_extract {
my $tmp = basename($filename);
$tmp =~ s/(\.tgz)$// && do {
$cap{"DISTNAME"} = $tmp;
$cap{"EXTRACT_SUFX"} = $1;
return;
};
$tmp =~ s/(\.tar\.bz2)$// && do {
$cap{"DISTNAME"} = $tmp;
$cap{"EXTRACT_SUFX"} = $1 if ($1 ne ".tar.bz2");
$cap{"USE_BZIP2"} = "YES";
return;
};
$tmp =~ s/(\.tar)$// && do {
$cap{"DISTNAME"} = $tmp;
$cap{"EXTRACT_SUFX"} = $1;
return;
};
$tmp =~ s/(\.tar.*)$// && do {
$cap{"DISTNAME"} = $tmp;
$cap{"EXTRACT_SUFX"} = $1 if ($1 ne ".tar.gz");
return;
};
}
sub add_extsuffix {
return if $cap{"EXTRACT_SUFX"};
if ($cap{"USE_BZIP2"}) {
$cap{"EXTRACT_SUFX"} = ".tar.bz2";
} else {
$cap{"EXTRACT_SUFX"} = ".tar.gz";
}
}
sub enh_distname {
my($changes) = 0;
my($play) = $cap{"DISTNAME"};
#print "starting play...\n";
my($firstshot) = 0;
my($portname, $portversion);
if (defined($play) eq "") {
die "can't make heads or tails of $filename";
}
while ($changes == 0) {
$changes = 1;
$firstshot++;
$_ = $play;
#print "using $play\n";
/^(.*[0-9][a-z]?)([-._][a-z]*)$/i && do {
print "Door #1\n";
$cap{"DISTNAME"} = $1;
$play = $1;
&add_extsuffix;
$cap{"EXTRACT_SUFX"} = $2 . $cap{"EXTRACT_SUFX"};
$changes = 0;
next;
};
/^([a-z]*)([0-9]+)([-._])([0-9]+([-._]).*)$/i && do {
print "Door #2\n";
if ($5 eq $3) {
$play = "$1-$2.$4";
#$cap{"PORTNAME"} = $1;
#$cap{"PORTVERSION"} = "$2.$4";
$portname = $1;
$portversion = "$2.$4";
$changes = 0;
next;
}
};
/^(.*?[^-._])([0-9])([-._])([^v]?[0-9]*[a-z]*)([-._]?)(.*)$/i &&( $firstshot == 1) && do {
print "Door #4\n";
if (($5 eq $3) || ($5 eq "")) {
#$cap{"PORTNAME"} = $1;
#$cap{"PORTVERSION"} = "$2$3$4$5$6";
$portname = $1;
$portversion = "$2$3$4$5$6";
next;
}
};
/^(.*?)([-._])(v?)((?:[0-9][-._])*[0-9][a-z]?.*)$/i && do {
print "Door #3\n";
my($tmp);
$tmp = $1;
$ver = "$4";
if ($ver =~ /^(.*)([-._])([0-9]?)([a-z])[a-z]+([0-9]?)$/) {
print "Door #3.1\n";
my($foo) = "";
#print "1 - $1\n";
#print "2 - $2\n";
#print "3 - $3\n";
#print "4 - $4\n";
#print "5 - $5\n";
$foo = "." if $2;
#$ver = "$1$foo$3$4$5";
$ver = "$1$foo$3$4$5";
}
$portname = $tmp;
$portversion = $ver;
next;
};
}
if (defined($portversion) eq "") {
die "can't make heads or tails of $filename";
}
$portversion =~ s/_/./g;
$portversion =~ s/-/./g;
$cap{"PORTNAME"} = $portname;
$cap{"PORTVERSION"} = $portversion;
my ($temp1);
my ($temp2);
$temp1 = $cap{"DISTNAME"};
$temp2 = $cap{"PORTNAME"} . "-" . $cap{"PORTVERSION"};
if ($temp1 eq $temp2) {
delete($cap{"DISTNAME"});
}
}
sub usage {
print STDERR <<"EOF";
usage: $0 filename
generates a ports skeleton for port based on filename
EOF
exit;
}