aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/cpt-link39
1 files changed, 32 insertions, 7 deletions
diff --git a/contrib/cpt-link b/contrib/cpt-link
index b6a0c57..7b1226e 100755
--- a/contrib/cpt-link
+++ b/contrib/cpt-link
@@ -1,16 +1,41 @@
#!/bin/sh -ef
# Link a forked package's files to the other repository
-case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[musage: %s [file...]\n' "${0##*/}" ; exit 0 ; esac
+## SYNOPSIS:
+## .Nm
+## .Op Fl p Ar package
+## .Op Ar file...
-# Check if the package exists in a repository and error out here
-# if it does not. The error message from the package manager will
-# be displayed.
-cpt-search "${PKG:=${PWD##*/}}" >/dev/null
+## DESCRIPTION:
+## .Nm
+## symlinks files to the current package directory from a separate instance of
+## the same package. If the
+## .Fl p
+## flag and a
+## .Ar package
+## is specified,
+## .Nm
+## will link files from the given package instead.
+##
+## .Nm
+## creates symbolic links of package files using the realpath of the file, so it
+## is therefore not suitable for using within a git repository, and should only
+## be used internally.
+## see: cpt-fork.1
-oPKG="$(cpt-search "$PKG" | grep -v "^$PWD\$\|/var/db/cpt/installed/$PKG" | sed 1q)"
+usage() {
+ printf 'usage: %s [-p package] [file...]\n' "${0##*/}"
+ exit 0
+}
-for file in "$@" ; do
+case "$1" in
+ -p) pkg=$2; shift 2 ;;
+ -h|--help|'') usage ;;
+esac
+
+oPKG="$(cpt-search -sd "${pkg:--o}")"
+
+for file; do
[ -e "${oPKG:?}/$file" ]
[ -d "$file" ] && rm -rf "$file"
ln -sf "$oPKG/$file" "$file"