Porteasy 2.3: cvspass magic for anoncvs.freebsd.org; new -w option for

displaying a port's web site URL; don't build by default (sometimes you
just want to update a port and all its dependencies); code cleanup.
This commit is contained in:
Dag-Erling Smørgrav 2001-03-11 01:14:27 +00:00
parent 8d36b6d88b
commit 5dde6f413f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=39502
8 changed files with 170 additions and 52 deletions

View file

@ -8,7 +8,7 @@
#
PORTNAME= porteasy
PORTVERSION= 2.2
PORTVERSION= 2.3
CATEGORIES= misc
MASTER_SITES= # none
DISTFILES= # none
@ -26,8 +26,12 @@ MAN8= porteasy.8
do-fetch:
@${DO_NADA}
do-configure:
@${SED} "s,%%PREFIX%%,${PREFIX}," ${SRC}/porteasy.pl >${WRKDIR}/porteasy
do-install:
@${INSTALL_SCRIPT} ${SRC}/porteasy.pl ${PREFIX}/bin/porteasy
@${INSTALL_SCRIPT} ${WRKDIR}/porteasy ${PREFIX}/bin/porteasy
@${INSTALL_MAN} ${SRC}/porteasy.8 ${PREFIX}/man/man8
@${MKDIR} ${PREFIX}/share/porteasy
@${INSTALL_DATA} ${SRC}/cvspass ${PREFIX}/share/porteasy/cvspass
.include <bsd.port.mk>

View file

@ -1 +1,3 @@
bin/porteasy
share/porteasy/cvspass
@dirrm share/porteasy

View file

@ -35,7 +35,7 @@
.Nd fetch and build ports
.Sh SYNOPSIS
.Nm porteasy
.Op Fl abCceFfhikLluVv
.Op Fl abCceFfhikLluVvw
.Op Fl D Ar date
.Op Fl d Ar dir
.Op Fl p Ar dir
@ -99,10 +99,10 @@ Show the
version number and exit.
.It Fl v
Verbose mode: show more information about what is being done.
.It Fl w
Show the URL of the port's web site if there is one listed in the port
description.
.El
.Pp
If no options are specified, the default is to build the specified
ports.
.Ss Port names
The port names listed on the command line may be either unqualified or
fully qualified.
@ -179,6 +179,13 @@ If no ports were specified,
instead prints a list of all installed ports, with unknown ports (i.e.
ports that are not in the index file, or are out of date) indicated
with a question mark.
.It Show the URLs of the selected ports' web sites
If the
.Fl w
option was specified,
.Nm
prints the URL of the web site of each port that was specified on the
command line, if a URL is listed in that port's description.
.It Clean the tree
If the
.Fl c

View file

@ -42,6 +42,8 @@ sub REQ_EXPLICIT { 1 }
sub REQ_IMPLICIT { 2 }
sub REQ_MASTER { 4 }
sub CVS_PASSFILE { "%%PREFIX%%/share/porteasy/cvspass" }
sub PATH_CVS { "/usr/bin/cvs" }
sub PATH_LDCONFIG { "/sbin/ldconfig" }
sub PATH_MAKE { "/usr/bin/make" }
@ -68,6 +70,7 @@ my $plist = 0; # Print packing list
my $build = 0; # Build ports
my $update = 0; # Update ports tree from CVS
my $verbose = 0; # Verbose mode
my $website = 0; # Show website URL
# Global variables
my %ports; # Maps ports to their directory.
@ -604,6 +607,24 @@ sub update_ports_tree(@) {
}
}
#
# Find a specific file belonging to a specific port
#
sub find_port_file($$) {
my $port = shift; # Port
my $file = shift; # File to look for
my $master; # Master port
$master = $port;
while (!-f "$portsdir/$master/$file") {
if (!($master = $masterport{$master})) {
bsd:errx(1, "$port has no $file");
}
}
return "$portsdir/$master/$file";
}
#
# Show port info
#
@ -613,13 +634,37 @@ sub show_port_info($) {
local *FILE; # File handle
my $info; # Port info
sysopen(FILE, "$portsdir/$port/pkg-descr", O_RDONLY)
sysopen(FILE, find_port_file($port, "pkg-descr"), O_RDONLY)
or bsd::err(1, "can't read description for $port");
$info = join("| ", <FILE>);
close(FILE);
print("+--- Description for $port ($pkgname{$port}):\n| ${info}+---\n");
}
#
# Show port's website URL
#
sub show_port_website($) {
my $port = shift; # Port to show info for
local *FILE; # File handle
my $website; # Port's website
sysopen(FILE, find_port_file($port, "pkg-descr"), O_RDONLY)
or bsd::err(1, "can't read description for $port");
while (<FILE>) {
if (m/^WWW:\s*(\S+)\s*$/) {
$website = $1;
}
}
close(FILE);
if (!defined($website)) {
bsd::warnx("No website for $port");
} else {
print("$website\n");
}
}
#
# Show port plist
#
@ -634,13 +679,7 @@ sub show_port_plist($) {
$prefix = suppress(\&make, ($port, "-VPREFIX"));
chomp($prefix);
$master = $port;
while (!-f "$portsdir/$master/pkg-plist") {
if (!($master = $masterport{$master})) {
bsd:errx(1, "$port has no packing list");
}
}
sysopen(FILE, "$portsdir/$master/pkg-plist", O_RDONLY)
sysopen(FILE, find_port_file($port, "pkg-plist"), O_RDONLY)
or bsd::err(1, "can't read packing list for $port");
while (<FILE>) {
chomp();
@ -851,15 +890,13 @@ MAIN:{
"u|update" => \$update,
"V|version" => \&version,
"v|verbose" => \$verbose,
"w|website" => \$website,
"x|ecks" => \&ecks,
)
or usage();
if (!($clean || $fetch || $info || $list || $packages || $plist)) {
$build = 1;
}
if (!@ARGV && ($build || $fetch || $list || $packages || $plist)) {
if (!@ARGV &&
($build || $fetch || $list || $packages || $plist || $website)) {
usage();
}
@ -882,6 +919,9 @@ MAIN:{
# Set and check CVS root
if ($anoncvs && !$cvsroot) {
$cvsroot = &ANONCVS_ROOT;
if (-f &CVS_PASSFILE) {
$ENV{'CVS_PASSFILE'} = &CVS_PASSFILE;
}
}
if (!$cvsroot) {
$cvsroot = $ENV{'CVSROOT'};
@ -901,8 +941,8 @@ MAIN:{
}
# Step 1: read the ports index
update_index();
if ($need_index) {
update_index();
read_index();
}
@ -915,9 +955,6 @@ MAIN:{
}
# Step 3: update port directories and discover dependencies
if (!($build || $fetch || ($info && @ARGV) || $list)) {
$update = 0;
}
update_ports_tree(keys(%reqd));
# Step 4: deselect ports which are already installed
@ -961,8 +998,17 @@ MAIN:{
}
}
}
# Step 8: show website URL
if ($website) {
foreach $port (keys(%reqd)) {
if ($reqd{$port} & &REQ_EXPLICIT) {
show_port_website($port);
}
}
}
# Step 8: clean the ports directories (or the entire tree)
# Step 9: clean the ports directories (or the entire tree)
if ($clean) {
if (!@ARGV) {
clean_tree();
@ -975,7 +1021,7 @@ MAIN:{
}
}
# Step 9: fetch distfiles
# Step A: fetch distfiles
if ($fetch) {
foreach $port (keys(%reqd)) {
if ($reqd{$port} != &REQ_MASTER) {
@ -984,7 +1030,7 @@ MAIN:{
}
}
# Step A: build ports - only the explicitly required ones, since
# Step B: build ports - only the explicitly required ones, since
# some dependencies (most commonly XFree86) may be bogus.
if ($build || $packages) {
foreach $port (keys(%reqd)) {

View file

@ -8,7 +8,7 @@
#
PORTNAME= porteasy
PORTVERSION= 2.2
PORTVERSION= 2.3
CATEGORIES= misc
MASTER_SITES= # none
DISTFILES= # none
@ -26,8 +26,12 @@ MAN8= porteasy.8
do-fetch:
@${DO_NADA}
do-configure:
@${SED} "s,%%PREFIX%%,${PREFIX}," ${SRC}/porteasy.pl >${WRKDIR}/porteasy
do-install:
@${INSTALL_SCRIPT} ${SRC}/porteasy.pl ${PREFIX}/bin/porteasy
@${INSTALL_SCRIPT} ${WRKDIR}/porteasy ${PREFIX}/bin/porteasy
@${INSTALL_MAN} ${SRC}/porteasy.8 ${PREFIX}/man/man8
@${MKDIR} ${PREFIX}/share/porteasy
@${INSTALL_DATA} ${SRC}/cvspass ${PREFIX}/share/porteasy/cvspass
.include <bsd.port.mk>

View file

@ -1 +1,3 @@
bin/porteasy
share/porteasy/cvspass
@dirrm share/porteasy

View file

@ -35,7 +35,7 @@
.Nd fetch and build ports
.Sh SYNOPSIS
.Nm porteasy
.Op Fl abCceFfhikLluVv
.Op Fl abCceFfhikLluVvw
.Op Fl D Ar date
.Op Fl d Ar dir
.Op Fl p Ar dir
@ -99,10 +99,10 @@ Show the
version number and exit.
.It Fl v
Verbose mode: show more information about what is being done.
.It Fl w
Show the URL of the port's web site if there is one listed in the port
description.
.El
.Pp
If no options are specified, the default is to build the specified
ports.
.Ss Port names
The port names listed on the command line may be either unqualified or
fully qualified.
@ -179,6 +179,13 @@ If no ports were specified,
instead prints a list of all installed ports, with unknown ports (i.e.
ports that are not in the index file, or are out of date) indicated
with a question mark.
.It Show the URLs of the selected ports' web sites
If the
.Fl w
option was specified,
.Nm
prints the URL of the web site of each port that was specified on the
command line, if a URL is listed in that port's description.
.It Clean the tree
If the
.Fl c

View file

@ -42,6 +42,8 @@ sub REQ_EXPLICIT { 1 }
sub REQ_IMPLICIT { 2 }
sub REQ_MASTER { 4 }
sub CVS_PASSFILE { "%%PREFIX%%/share/porteasy/cvspass" }
sub PATH_CVS { "/usr/bin/cvs" }
sub PATH_LDCONFIG { "/sbin/ldconfig" }
sub PATH_MAKE { "/usr/bin/make" }
@ -68,6 +70,7 @@ my $plist = 0; # Print packing list
my $build = 0; # Build ports
my $update = 0; # Update ports tree from CVS
my $verbose = 0; # Verbose mode
my $website = 0; # Show website URL
# Global variables
my %ports; # Maps ports to their directory.
@ -604,6 +607,24 @@ sub update_ports_tree(@) {
}
}
#
# Find a specific file belonging to a specific port
#
sub find_port_file($$) {
my $port = shift; # Port
my $file = shift; # File to look for
my $master; # Master port
$master = $port;
while (!-f "$portsdir/$master/$file") {
if (!($master = $masterport{$master})) {
bsd:errx(1, "$port has no $file");
}
}
return "$portsdir/$master/$file";
}
#
# Show port info
#
@ -613,13 +634,37 @@ sub show_port_info($) {
local *FILE; # File handle
my $info; # Port info
sysopen(FILE, "$portsdir/$port/pkg-descr", O_RDONLY)
sysopen(FILE, find_port_file($port, "pkg-descr"), O_RDONLY)
or bsd::err(1, "can't read description for $port");
$info = join("| ", <FILE>);
close(FILE);
print("+--- Description for $port ($pkgname{$port}):\n| ${info}+---\n");
}
#
# Show port's website URL
#
sub show_port_website($) {
my $port = shift; # Port to show info for
local *FILE; # File handle
my $website; # Port's website
sysopen(FILE, find_port_file($port, "pkg-descr"), O_RDONLY)
or bsd::err(1, "can't read description for $port");
while (<FILE>) {
if (m/^WWW:\s*(\S+)\s*$/) {
$website = $1;
}
}
close(FILE);
if (!defined($website)) {
bsd::warnx("No website for $port");
} else {
print("$website\n");
}
}
#
# Show port plist
#
@ -634,13 +679,7 @@ sub show_port_plist($) {
$prefix = suppress(\&make, ($port, "-VPREFIX"));
chomp($prefix);
$master = $port;
while (!-f "$portsdir/$master/pkg-plist") {
if (!($master = $masterport{$master})) {
bsd:errx(1, "$port has no packing list");
}
}
sysopen(FILE, "$portsdir/$master/pkg-plist", O_RDONLY)
sysopen(FILE, find_port_file($port, "pkg-plist"), O_RDONLY)
or bsd::err(1, "can't read packing list for $port");
while (<FILE>) {
chomp();
@ -851,15 +890,13 @@ MAIN:{
"u|update" => \$update,
"V|version" => \&version,
"v|verbose" => \$verbose,
"w|website" => \$website,
"x|ecks" => \&ecks,
)
or usage();
if (!($clean || $fetch || $info || $list || $packages || $plist)) {
$build = 1;
}
if (!@ARGV && ($build || $fetch || $list || $packages || $plist)) {
if (!@ARGV &&
($build || $fetch || $list || $packages || $plist || $website)) {
usage();
}
@ -882,6 +919,9 @@ MAIN:{
# Set and check CVS root
if ($anoncvs && !$cvsroot) {
$cvsroot = &ANONCVS_ROOT;
if (-f &CVS_PASSFILE) {
$ENV{'CVS_PASSFILE'} = &CVS_PASSFILE;
}
}
if (!$cvsroot) {
$cvsroot = $ENV{'CVSROOT'};
@ -901,8 +941,8 @@ MAIN:{
}
# Step 1: read the ports index
update_index();
if ($need_index) {
update_index();
read_index();
}
@ -915,9 +955,6 @@ MAIN:{
}
# Step 3: update port directories and discover dependencies
if (!($build || $fetch || ($info && @ARGV) || $list)) {
$update = 0;
}
update_ports_tree(keys(%reqd));
# Step 4: deselect ports which are already installed
@ -961,8 +998,17 @@ MAIN:{
}
}
}
# Step 8: show website URL
if ($website) {
foreach $port (keys(%reqd)) {
if ($reqd{$port} & &REQ_EXPLICIT) {
show_port_website($port);
}
}
}
# Step 8: clean the ports directories (or the entire tree)
# Step 9: clean the ports directories (or the entire tree)
if ($clean) {
if (!@ARGV) {
clean_tree();
@ -975,7 +1021,7 @@ MAIN:{
}
}
# Step 9: fetch distfiles
# Step A: fetch distfiles
if ($fetch) {
foreach $port (keys(%reqd)) {
if ($reqd{$port} != &REQ_MASTER) {
@ -984,7 +1030,7 @@ MAIN:{
}
}
# Step A: build ports - only the explicitly required ones, since
# Step B: build ports - only the explicitly required ones, since
# some dependencies (most commonly XFree86) may be bogus.
if ($build || $packages) {
foreach $port (keys(%reqd)) {