From d3671bcb629260b2a0acfa0357df6d15903ba898 Mon Sep 17 00:00:00 2001 From: merakor Date: Fri, 12 Mar 2021 12:22:51 +0000 Subject: cpt-link: change usage, add documentation cpt-link now uses '-p' flag for specifying a package. FossilOrigin-Name: 74b38d49d091c6daeb93a27882906117bdaf655c79d4264474517253fab1d696 --- contrib/cpt-link | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'contrib') 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" -- cgit v1.2.3