From c6795cae8dd0f3dac2abbdbb6d7bc49ed45b941c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 8 Mar 2009 22:27:07 +0100 Subject: Support $package and $etc in links file --- bin/checklinks | 11 +++++++++++ bin/pkg | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/checklinks b/bin/checklinks index 5016aba..442cf10 100755 --- a/bin/checklinks +++ b/bin/checklinks @@ -3,12 +3,14 @@ ## License: WTFPL use strict; use warnings; +use Getopt::Long; use Term::ANSIColor; my $base = $ENV{HOME}; my ($type, $src, $dst); my $quiet = 0; my $remove = 0; +my %substitute; my $linkfile; if (-f '.links') { @@ -19,6 +21,12 @@ if (-f '.links') { exit(0); } +GetOptions( + 'q|quiet' => \$quiet, + 'r|remove' => \$remove, + 'p|parameter=s' => \%substitute, +); + if (defined($ARGV[0])) { if ($ARGV[0] eq '-q') { $quiet = 1; @@ -31,6 +39,9 @@ if (defined($ARGV[0])) { open(LINKS, '<', $linkfile) or die($!); while() { chomp; + foreach my $key (keys(%substitute)) { + s/\$$key/$substitute{$key}/g; + } ($type, $src, $dst) = split; next unless ($type eq 'soft' or $type eq 'hard'); if ($remove) { diff --git a/bin/pkg b/bin/pkg index 1266f21..0d98959 100755 --- a/bin/pkg +++ b/bin/pkg @@ -14,6 +14,7 @@ ## ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ## OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +setopt extended_glob typeset -a -U triggers ## @@ -366,7 +367,11 @@ function global_hook { info "Running make\n" make } - checklinks $CL_OPTIONS + # TODO: cover cases where $HOME ends in a / + # (just to be on the safe side) + checklinks $CL_OPTIONS \ + --parameter package=${PWD#$HOME/} \ + --parameter etc=${PWD#$HOME/}/etc populate_collected $1 update_provides $1 list_update_package $1 -- cgit v1.2.3