aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-01-06 11:14:15 +0000
committermerakor <cem@ckyln.com>2021-01-06 11:14:15 +0000
commite31f8c482bacb62014fa0f1a35d9044bb6823147 (patch)
tree07614b2ef2d3a2c9b97155cf24c40b71945e87b0
parent4494a117ed31897513235090b8282c2b033b6407 (diff)
parent3b4066c8578048927cf6af8fdde8fb912cb3392a (diff)
downloadcpt-e31f8c482bacb62014fa0f1a35d9044bb6823147.tar.gz
Merge branch 'shellspec' into experiment/lazyload
FossilOrigin-Name: 11ae70cbe0647be23283d7669438b81c4e80b9ed4c6351bb5494193e148aeb6d
-rw-r--r--src/cpt-lib.in1
-rwxr-xr-xtools/install.sh24
2 files changed, 19 insertions, 6 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 0c46dbe..9aa232c 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -1040,6 +1040,7 @@ pkg_build() {
for pkg do
log "$pkg" "Building package ($((in = in + 1))/$#)"
+ mkdir -p "$mak_dir/$pkg"
pkg_extract "$pkg"
repo_dir=$(pkg_find "$pkg")
diff --git a/tools/install.sh b/tools/install.sh
index f79cb3b..086c47d 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -1,13 +1,16 @@
#!/bin/sh -e
# Portable install version that supports -D -m and -t
+# We have our own extension flag -s for running sed on the given files while
+# installing.
usage() {
- printf '%s\n' "usage: $0 [-D] [-m mode] source dest" \
- " or: $0 [-D] [-m mode] [-t dir] [source...]" >&2
- exit 1
+ printf '%s\n' "usage: $0 [-D] [-m mode] [-s sedcmd] source dest" \
+ " or: $0 [-D] [-m mode] [-s sedcmd] [-t dir] [source...]" >&2
+ exit 0
}
die() { printf '%s\n' "$@" >&2; exit 1;}
+sed=''
mkdirp=''
target=''
mode=''
@@ -16,7 +19,7 @@ parse() {
OPTIND=$(($#+1))
while OPTARG= && [ $# -gt 0 ]; do
case $1 in
- -[tm]?*) OPTARG=$1; shift
+ -[stm]?*) OPTARG=$1; shift
eval 'set -- "${OPTARG%"${OPTARG#??}"}" "${OPTARG#??}"' ${1+'"$@"'}
;;
-[!-]?*) OPTARG=$1; shift
@@ -29,6 +32,11 @@ parse() {
eval '[ ${OPTARG+x} ] &&:' && OPTARG='1' || OPTARG=''
mkdirp="$OPTARG"
;;
+ '-s')
+ [ $# -le 1 ] && set "required" "$1" && break
+ OPTARG=$2
+ sed="$OPTARG"
+ shift ;;
'-t')
[ $# -le 1 ] && set "required" "$1" && break
OPTARG=$2
@@ -75,7 +83,11 @@ if [ "$target" ]; then
mkdir -p "$target"
for arg; do
[ -d "$target/${arg##*/}" ] && die "$target/${arg##*/} is a directory"
- cp "$arg" "$target/${arg##*/}"
+ if [ "$sed" ]; then
+ sed "$sed" < "$arg" > "$target/${arg##*/}"
+ else
+ cp "$arg" "$target"
+ fi
# Most implementations set the mode to 0755 by default when -t is set.
chmod "${mode:=0755}" "$target/${arg##*/}"
@@ -85,6 +97,6 @@ else
mkdir -p "${2%/*}"
esac
[ -d "$2" ] && die "$2 is a directory"
- cp "$1" "$2"
+ if [ "$sed" ]; then sed "$sed" < "$1" > "$2"; else cp "$1" "$2"; fi
chmod "${mode:=0755}" "$2"
fi