summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/checklinks29
-rwxr-xr-xbin/ct37
2 files changed, 44 insertions, 22 deletions
diff --git a/bin/checklinks b/bin/checklinks
index 358b3e1..af0357c 100755
--- a/bin/checklinks
+++ b/bin/checklinks
@@ -14,6 +14,7 @@ my $remove = 0;
my %substitute;
my $linkfile;
my $exit = 0;
+my $ct_auto = 0;
sub mkdirs {
@@ -146,12 +147,15 @@ sub loop_links {
my $dir;
my $cwd = cwd();
- if (-e 'etc') {
+ if (-d 'etc') {
$dir = 'etc';
}
- else {
+ elsif (!$ct_auto) {
$dir = '.';
}
+ else {
+ return;
+ }
foreach my $entry (dir_content($dir)) {
my $source = $entry;
@@ -166,9 +170,18 @@ sub loop_links {
check_symlink($source, "$cwd/$dir/$entry");
}
}
+ return;
}
+GetOptions(
+ 'ct-auto' => \$ct_auto,
+ 'm|msglevel=i' => \$msglevel,
+ 'p|parameter=s' => \%substitute,
+ 'q|quiet' => sub {$msglevel = 1},
+ 'r|remove' => \$remove,
+);
+
if (-f '.links') {
$linkfile = '.links';
}
@@ -176,16 +189,12 @@ elsif (-f 'links') {
$linkfile = 'links';
}
else {
+ if ($ct_auto) {
+ loop_links();
+ }
exit(0);
}
-GetOptions(
- 'm|msglevel=i' => \$msglevel,
- 'p|parameter=s' => \%substitute,
- 'q|quiet' => sub {$msglevel = 1},
- 'r|remove' => \$remove,
-);
-
open(my $links, '<', $linkfile) or die("Can't open $linkfile: $!");
while (my $line = <$links>) {
chomp($line);
@@ -199,7 +208,7 @@ while (my $line = <$links>) {
next unless ($type ~~ ['soft', 'hard', 'auto']);
if ($type eq 'auto') {
- loop_links($src, $dst);
+ loop_links();
}
else {
if ($remove) {
diff --git a/bin/ct b/bin/ct
index 56a9048..9b450ed 100755
--- a/bin/ct
+++ b/bin/ct
@@ -56,14 +56,16 @@ if [[ -r $XDG_CONFIG_HOME/caretaker/caretaker.conf ]] {
# Parse commandline options
while [[ $1 == --* ]] {
case $1 in
- --auto-update) (( AUTOUPDATE = 1)) ;;
- --no-auto-update) (( AUTOUPDATE = 0)) ;;
- --coluors) (( COLOURS = 1 )) ;;
- --no-colours) (( COLOURS = 0 )) ;;
- --progress) (( PROGRESS = 1 )) ;;
- --no-progress) (( PROGRESS = 0 )) ;;
- --quiet) (( SILENT = 1 )) ;;
- --no-quiiet) (( SILENT = 0 )) ;;
+ --auto-update) (( AUTOUPDATE = 1 )) ;;
+ --no-auto-update) (( AUTOUPDATE = 0 )) ;;
+ --coluors) (( COLOURS = 1 )) ;;
+ --no-colours) (( COLOURS = 0 )) ;;
+ --magic-etc) (( MAGIC_ETC = 1 )) ;;
+ --no-magic-etc) (( MAGIC_ETC = 0 )) ;;
+ --progress) (( PROGRESS = 1 )) ;;
+ --no-progress) (( PROGRESS = 0 )) ;;
+ --quiet) (( SILENT = 1 )) ;;
+ --no-quiiet) (( SILENT = 0 )) ;;
--version) die "see '$0 version'\n" ;;
--help) die "see '$0 help'\n" ;;
@@ -96,6 +98,7 @@ if (( $#PKG_ROOTS == 0 )) {
: ${AUTOUPDATE=1}
: ${GIT_USE_ORIGIN=1}
: ${COLOURS=1}
+: ${MAGIC_ETC=1}
: ${PROGRESS=1}
export PKG_DIR
export PKG_ROOT
@@ -416,6 +419,17 @@ function priority_name {
esac
}
+function run_checklinks {
+ if [[ -e links ]] {
+ checklinks $* $CL_OPTIONS \
+ --parameter package=${${PWD#$HOME}#/##} \
+ --parameter etc=${${PWD#$HOME}#/##}/etc
+ } elif [[ -d etc && $MAGIC_ETC == 1 ]] {
+ checklinks --ct-auto $CL_OPTIONS $*
+ }
+}
+
+
function exec_hook {
typeset package=$1
typeset hook=$2
@@ -444,9 +458,7 @@ function global_hook {
info "$1: Running make\n"
make
}
- checklinks $CL_OPTIONS \
- --parameter package=${${PWD#$HOME}#/##} \
- --parameter etc=${${PWD#$HOME}#/##}/etc
+ run_checklinks
update_collected $1
update_provides $1
list_package_update $1
@@ -454,7 +466,7 @@ function global_hook {
pre-remove)
exec_hook $1 pre-remove
genocide_collected $1
- checklinks $CL_OPTIONS --remove
+ run_checklinks --remove
list_package_remove $1
update_provides $1
;;
@@ -740,6 +752,7 @@ function pkg_debug {
echo " COLOURS $COLOURS"
echo " PROGRESS $PROGRESS"
echo " AUTOUPDATE $AUTOUPDATE"
+ echo " MAGIC_ETC $MAGIC_ETC"
echo " GIT_USE_ORIGIN $GIT_USE_ORIGIN"
}