2020-03-13 07:43:54 -06:00
|
|
|
#!/bin/sh -ef
|
2020-05-01 00:07:20 -06:00
|
|
|
# Copy a package's repository files into the current directory
|
2020-03-13 07:43:54 -06:00
|
|
|
|
2020-09-09 04:58:00 -06:00
|
|
|
pkg=${1:-"${PWD##*/}"}
|
|
|
|
num=$(printf %d "${2:-0}")
|
|
|
|
|
|
|
|
dir=$(kiss search "$pkg" 2>/dev/null) || {
|
2020-04-25 08:48:44 -06:00
|
|
|
printf 'usage: [kiss-fork [pkg]] [index]\n'
|
2020-03-13 07:43:54 -06:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-09-09 04:58:00 -06:00
|
|
|
# Globbing is disabled and word splitting is intentional.
|
|
|
|
# shellcheck disable=2086
|
|
|
|
set -- $dir
|
2020-04-25 08:48:44 -06:00
|
|
|
|
2020-09-09 04:58:00 -06:00
|
|
|
[ "$num" -ge "$#" ] && {
|
|
|
|
printf 'index exceeds maximum\n'
|
|
|
|
exit 1
|
|
|
|
}
|
2020-03-13 07:43:54 -06:00
|
|
|
|
2020-09-09 04:58:00 -06:00
|
|
|
shift "$num"
|
2020-04-25 08:48:44 -06:00
|
|
|
|
2020-09-09 04:58:00 -06:00
|
|
|
[ "$1" ] || [ -d "$1" ] || {
|
|
|
|
printf 'failed to locate package\n'
|
|
|
|
exit 1
|
|
|
|
}
|
2020-03-13 07:43:54 -06:00
|
|
|
|
2020-09-09 04:58:00 -06:00
|
|
|
printf 'found package in %s\n' "$1"
|
|
|
|
cp -rf "$1" .
|
|
|
|
printf 'forked package to %s\n' "$PWD/$pkg"
|