diff options
author | garga <garga@FreeBSD.org> | 2007-12-19 16:54:37 +0000 |
---|---|---|
committer | garga <garga@FreeBSD.org> | 2007-12-19 16:54:37 +0000 |
commit | 3ba55de9f77862ae78ecbf573ee54735123bfb26 (patch) | |
tree | 0768287af70ad858afafdbd674a2bc618c6f20a5 /Tools | |
parent | 6f5686affe63d5f4f2b17e10a61ad624c2205d76 (diff) | |
download | FreeBSD-ports-3ba55de9f77862ae78ecbf573ee54735123bfb26.zip FreeBSD-ports-3ba55de9f77862ae78ecbf573ee54735123bfb26.tar.gz |
Fix a problem when add new ports on ports-mgmt category. ports-mgmt/Makefile
lines has 3 spaces before SUBDIR word and all other categories has 4.
I've asked pav@ if there is a default format of category Makefiles and he said
the number of spaces doesn't matter, so, i fix addport to respect the current
number of spaces and/or tabs the file has.
Reported by: miwi, erwin
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/scripts/addport | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Tools/scripts/addport b/Tools/scripts/addport index 11c3981..d80fef2 100755 --- a/Tools/scripts/addport +++ b/Tools/scripts/addport @@ -341,7 +341,7 @@ foreach my $thisdir (@dirs) { } # figure out where the port name belongs in category Makefile - my @ports = &lsports; + my ($spaces, @ports) = &lsports; errx(1, "Error: $portname already exists in $category\'s Makefile") if (&contains($portname, @ports)); my $port = ""; foreach my $tmp (sort(@ports)) { @@ -364,16 +364,16 @@ foreach my $thisdir (@dirs) { # there were previous SUBDIR lines, but none was greater than we are, # means, we're the last port, so, add ourselves after the last port $port = $ports[$#ports]; - $cmd = "/^ SUBDIR += $port/\na\n"; + $cmd = "/^" . $spaces . "SUBDIR += $port/\na\n"; } else { # OK, append ourselves in the right place, so things *stay* sorted. - $cmd = "/^ SUBDIR += $port/\ni\n"; + $cmd = "/^" . $spaces . "SUBDIR += $port/\ni\n"; } } print "Inserting new port into $category/Makefile...\n"; open(ED, "|ed Makefile") || die "Cannot start ed to actually insert module\n"; - print ED "$cmd SUBDIR += $portname\n.\nw\nq\n"; - close(ED); + print ED "$cmd" . $spaces . "SUBDIR += $portname\n.\nw\nq\n"; + close(ED); # commit the actual port. chdir "$tmpdir/$category" or err(1, "$tmpdir/$category"); @@ -499,18 +499,25 @@ sub contains($@) { sub lsports() { my @rv = (); + my $spaces; open(F, "Makefile") || die "can't open Makefile: $!"; while(<F>) { chomp; chomp; next if $_ !~ m/SUBDIR/; + + if ( !defined($spaces) ) { + m/^([\s\t]+)[^\s\t]/; + $spaces = $1; + } + s/^[ \t]+SUBDIR[ \t]+\+?=[\ \t]+//; push(@rv, $_); } close(F); - return @rv; + return ($spaces, @rv); } # this finds the last comment in the Makefile |