aboutsummaryrefslogtreecommitdiffstats
path: root/Tools/scripts
diff options
context:
space:
mode:
authorcrees <crees@FreeBSD.org>2011-08-29 22:54:48 +0800
committercrees <crees@FreeBSD.org>2011-08-29 22:54:48 +0800
commitbc8fb059e617bbb00630277e7cb07c64501fa662 (patch)
tree650c8e36b998f1f5cba1ff5ca21bb01ae9a50529 /Tools/scripts
parent91a978e2dfeefa6ab8428a62bb4e0eba8b38ef9e (diff)
downloadfreebsd-ports-gnome-bc8fb059e617bbb00630277e7cb07c64501fa662.tar.gz
freebsd-ports-gnome-bc8fb059e617bbb00630277e7cb07c64501fa662.tar.zst
freebsd-ports-gnome-bc8fb059e617bbb00630277e7cb07c64501fa662.zip
Add option (-y) to check for similarly named ports.
PR: ports/159841 Submitted by: crees (me) Approved by: garga (maintainer)
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-xTools/scripts/addport36
1 files changed, 35 insertions, 1 deletions
diff --git a/Tools/scripts/addport b/Tools/scripts/addport
index 52eab83ae191..16e93b0af621 100755
--- a/Tools/scripts/addport
+++ b/Tools/scripts/addport
@@ -56,7 +56,7 @@ sub lastcomment();
my %opts;
-getopts('abc:d:fh:il:L:M:mns:tu:', \%opts);
+getopts('abc:d:fh:il:L:M:mns:tu:y', \%opts);
my $autofill_l = $opts{'l'};
my $autofill_L = $opts{'L'};
@@ -76,6 +76,7 @@ my $interactive = $opts{'i'};
my $nomkdir = $opts{'m'};
my $addlchk = $opts{'a'};
my $nofetch = $opts{'f'};
+my $checkexist = $opts{'y'};
my $currentdir = abs_path(".");
my %l10nprefix = (
'chinese' => 'zh-',
@@ -180,6 +181,38 @@ if ($dir eq "") {
exit 1;
}
+# check the port doesn't exist already
+
+if ($checkexist) {
+ my $found = 0;
+ print ">> Checking out modules file to scan for duplicates...";
+ system("$cvs -q co -p modules > $tmpdir/modules") && errx(1, "Could not checkout CVSROOT/modules.");
+ print " [DONE]\n";
+ my @namepart;
+ foreach (split(/\,/, $dir)) {
+ s/^.*\///;
+ foreach (split(/[-_]/)) {
+ next if length () <=2 or /^rubygem$/;
+ push(@namepart, $_);
+ }
+ }
+ open(MODULES_FILE, "< $tmpdir/modules") or errx(1, "Modules file in $tmpdir unreadable.");
+ while (my $line = <MODULES_FILE>) {
+ next if $line =~ /^#/;
+ foreach my $dpart (@namepart) {
+ if ($line =~ /^[^ ]*\b$dpart\b/i) {
+ $line =~ s/\s+/ /g;
+ print "$dpart matches $line\n";
+ $found = 1;
+ }
+ }
+ }
+ if ($found) {
+ prompt ("Possible duplicates found -- still OK?")
+ and errx(1, "Investigating duplicates");
+ }
+}
+
# make sure we're in the right place.
chdir $currentdir;
my @dirs = split(/\,/, $dir);
@@ -447,6 +480,7 @@ OPTIONS
for downloading distfiles.
-t Do more port testing. Requires -a.
-u user Use a different username (default: $u).
+ -y Check for similarly named ports.
ENVIRONMENT VARIABLES
$0 supports the following environment variables: