2014-02-12 12:15:01 +00:00
|
|
|
# -*-* shell *-*-
|
|
|
|
|
|
|
|
# enable aliases
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
|
|
|
# clear all aliases
|
|
|
|
unalias -a
|
|
|
|
|
|
|
|
# disable wildcards helper
|
|
|
|
_noglob_helper() {
|
|
|
|
set +f
|
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Apply _noglob to v* commands
|
2020-06-13 21:45:12 +00:00
|
|
|
for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
|
2014-02-12 12:15:01 +00:00
|
|
|
alias ${cmd}="set -f; _noglob_helper _${cmd}"
|
|
|
|
done
|
|
|
|
|
2014-10-13 09:03:14 +00:00
|
|
|
_vsv() {
|
|
|
|
local service="$1"
|
2019-04-13 09:18:41 +00:00
|
|
|
local LN_OPTS="-s"
|
2021-10-07 13:44:32 +00:00
|
|
|
local svdir="${PKGDESTDIR}/etc/sv/${service}"
|
2014-10-13 09:03:14 +00:00
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vsv: 1 argument expected: <service>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2019-04-13 09:18:41 +00:00
|
|
|
if [ -n "$XBPS_BUILD_FORCEMODE" ]; then
|
|
|
|
LN_OPTS+="f"
|
|
|
|
fi
|
|
|
|
|
2014-10-13 09:03:14 +00:00
|
|
|
vmkdir etc/sv
|
|
|
|
vcopy "${FILESDIR}/$service" etc/sv
|
2021-10-07 13:44:32 +00:00
|
|
|
if [ ! -L $svdir/run ]; then
|
|
|
|
chmod 755 $svdir/run
|
2014-10-13 10:37:33 +00:00
|
|
|
fi
|
2021-10-07 13:44:32 +00:00
|
|
|
if [ -e $svdir/finish ] && [ ! -L $svdir/finish ]; then
|
|
|
|
chmod 755 $svdir/finish
|
|
|
|
fi
|
|
|
|
ln ${LN_OPTS} /run/runit/supervise.${service} $svdir/supervise
|
|
|
|
if [ -d $svdir/log ]; then
|
|
|
|
ln ${LN_OPTS} /run/runit/supervise.${service}-log $svdir/log/supervise
|
|
|
|
if [ -e $svdir/log/run ] && [ ! -L $svdir/log/run ]; then
|
|
|
|
chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run
|
|
|
|
fi
|
2014-10-13 11:02:04 +00:00
|
|
|
fi
|
2014-10-13 09:03:14 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 05:42:16 +00:00
|
|
|
_vbin() {
|
|
|
|
local file="$1" targetfile="$2"
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vbin: 1 argument expected: <file>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
vinstall "$file" 755 usr/bin "$targetfile"
|
|
|
|
}
|
|
|
|
|
|
|
|
_vman() {
|
2014-07-06 21:15:30 +00:00
|
|
|
local file="$1" target="${2:-${1##*/}}"
|
2014-07-04 05:42:16 +00:00
|
|
|
|
2014-07-04 14:15:00 +00:00
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vman: 1 argument expected: <file>\n"
|
2014-07-04 05:42:16 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2014-07-04 14:15:00 +00:00
|
|
|
suffix=${target##*.}
|
|
|
|
|
2018-08-07 20:55:59 +00:00
|
|
|
if [[ $suffix == gz ]]
|
|
|
|
then
|
|
|
|
gunzip "$file"
|
|
|
|
file="${file:0:-3}"
|
|
|
|
target="${target:0:-3}"
|
|
|
|
suffix=${target##*.}
|
|
|
|
fi
|
|
|
|
|
2018-10-14 19:23:04 +00:00
|
|
|
if [[ $suffix == bz2 ]]
|
|
|
|
then
|
|
|
|
bunzip2 "$file"
|
|
|
|
file="${file:0:-4}"
|
|
|
|
target="${target:0:-4}"
|
|
|
|
suffix=${target##*.}
|
|
|
|
fi
|
|
|
|
|
2014-07-04 14:15:00 +00:00
|
|
|
if [[ $target =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]]
|
|
|
|
then
|
2014-07-06 21:15:30 +00:00
|
|
|
name=${BASH_REMATCH[1]}.${BASH_REMATCH[4]}
|
2014-07-04 14:15:00 +00:00
|
|
|
mandir=${BASH_REMATCH[2]}/man${suffix:0:1}
|
|
|
|
else
|
2014-07-06 21:15:30 +00:00
|
|
|
name=$target
|
2014-07-04 14:15:00 +00:00
|
|
|
mandir=man${suffix:0:1}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${mandir} == *man[0-9n] ]] ; then
|
|
|
|
vinstall "$file" 644 "usr/share/man/${mandir}" "$name"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
msg_red "$pkgver: vman: Filename '${target}' does not look like a man page\n"
|
|
|
|
return 1
|
2014-07-04 05:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vdoc() {
|
|
|
|
local file="$1" targetfile="$2"
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vdoc: 1 argument expected: <file>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
vinstall "$file" 644 "usr/share/doc/${pkgname}" "$targetfile"
|
|
|
|
}
|
|
|
|
|
2014-07-17 17:36:52 +00:00
|
|
|
_vconf() {
|
|
|
|
local file="$1" targetfile="$2"
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vconf: 1 argument expected: <file>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2014-07-26 15:10:10 +00:00
|
|
|
vinstall "$file" 644 etc "$targetfile"
|
2014-07-17 17:36:52 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 05:42:16 +00:00
|
|
|
_vsconf() {
|
|
|
|
local file="$1" targetfile="$2"
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vsconf: 1 argument expected: <file>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
vinstall "$file" 644 "usr/share/examples/${pkgname}" "$targetfile"
|
|
|
|
}
|
|
|
|
|
|
|
|
_vlicense() {
|
|
|
|
local file="$1" targetfile="$2"
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vlicense: 1 argument expected: <file>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
vinstall "$file" 644 "usr/share/licenses/${pkgname}" "$targetfile"
|
|
|
|
}
|
|
|
|
|
2014-02-12 12:15:01 +00:00
|
|
|
_vinstall() {
|
|
|
|
local file="$1" mode="$2" targetdir="$3" targetfile="$4"
|
|
|
|
|
2021-07-03 03:50:39 +00:00
|
|
|
if [ -z "$PKGDESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vinstall: PKGDESTDIR unset, can't continue...\n"
|
2014-02-12 12:15:01 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -lt 3 ]; then
|
|
|
|
msg_red "$pkgver: vinstall: 3 arguments expected: <file> <mode> <target-directory>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2016-10-20 23:45:26 +00:00
|
|
|
if [ ! -r "${file}" ]; then
|
2014-02-12 12:15:01 +00:00
|
|
|
msg_red "$pkgver: vinstall: cannot find '$file'...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$targetfile" ]; then
|
2021-07-03 03:50:39 +00:00
|
|
|
install -Dm${mode} "${file}" "${PKGDESTDIR}/${targetdir}/${file##*/}"
|
2014-02-12 12:15:01 +00:00
|
|
|
else
|
2021-07-03 03:50:39 +00:00
|
|
|
install -Dm${mode} "${file}" "${PKGDESTDIR}/${targetdir}/${targetfile##*/}"
|
2014-02-12 12:15:01 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_vcopy() {
|
2021-07-03 03:50:39 +00:00
|
|
|
local files="$1" targetdir="$2"
|
2014-02-12 12:15:01 +00:00
|
|
|
|
2021-07-03 03:50:39 +00:00
|
|
|
if [ -z "$PKGDESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vcopy: PKGDESTDIR unset, can't continue...\n"
|
2014-02-12 12:15:01 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
msg_red "$pkgver: vcopy: 2 arguments expected: <files> <target-directory>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2021-07-03 03:50:39 +00:00
|
|
|
cp -a $files ${PKGDESTDIR}/${targetdir}
|
2014-02-12 12:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vmove() {
|
2021-07-03 03:50:39 +00:00
|
|
|
local f files="$1" _targetdir
|
2014-02-12 12:15:01 +00:00
|
|
|
|
|
|
|
if [ -z "$DESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vmove: DESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
|
|
|
elif [ -z "$PKGDESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vmove: PKGDESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
2021-07-03 03:50:39 +00:00
|
|
|
elif [ "$DESTDIR" = "$PKGDESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vmove is intended to be used in pkg_install\n"
|
|
|
|
return 1
|
2014-02-12 12:15:01 +00:00
|
|
|
fi
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
msg_red "$pkgver: vmove: 1 argument expected: <files>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
for f in ${files}; do
|
2019-04-13 20:44:01 +00:00
|
|
|
_targetdir=${f%/*}/
|
2014-02-12 12:15:01 +00:00
|
|
|
break
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "${_targetdir}" ]; then
|
2021-07-03 03:50:39 +00:00
|
|
|
[ ! -d ${PKGDESTDIR} ] && install -d ${PKGDESTDIR}
|
|
|
|
mv ${DESTDIR}/$files ${PKGDESTDIR}
|
2014-02-12 12:15:01 +00:00
|
|
|
else
|
2021-07-03 03:50:39 +00:00
|
|
|
if [ ! -d ${PKGDESTDIR}/${_targetdir} ]; then
|
|
|
|
install -d ${PKGDESTDIR}/${_targetdir}
|
2014-02-12 12:15:01 +00:00
|
|
|
fi
|
2021-07-03 03:50:39 +00:00
|
|
|
mv ${DESTDIR}/$files ${PKGDESTDIR}/${_targetdir}
|
2014-02-12 12:15:01 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_vmkdir() {
|
2021-07-03 03:50:39 +00:00
|
|
|
local dir="$1" mode="$2"
|
2014-02-12 12:15:01 +00:00
|
|
|
|
2021-07-03 03:50:39 +00:00
|
|
|
if [ -z "$PKGDESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vmkdir: PKGDESTDIR unset, can't continue...\n"
|
2014-02-12 12:15:01 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$dir" ]; then
|
|
|
|
msg_red "vmkdir: directory argument unset.\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$mode" ]; then
|
2021-07-03 03:50:39 +00:00
|
|
|
install -d ${PKGDESTDIR}/${dir}
|
2014-02-12 12:15:01 +00:00
|
|
|
else
|
2021-07-03 03:50:39 +00:00
|
|
|
install -dm${mode} ${PKGDESTDIR}/${dir}
|
2014-02-12 12:15:01 +00:00
|
|
|
fi
|
|
|
|
}
|
2020-06-13 21:45:12 +00:00
|
|
|
|
|
|
|
_vcompletion() {
|
|
|
|
local file="$1" shell="$2" cmd="${3:-${pkgname}}"
|
|
|
|
local _bash_completion_dir=usr/share/bash-completion/completions/
|
|
|
|
local _fish_completion_dir=usr/share/fish/vendor_completions.d/
|
|
|
|
local _zsh_completion_dir=usr/share/zsh/site-functions/
|
|
|
|
|
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ -f "$file" ]; then
|
|
|
|
msg_red "$pkgver: vcompletion: file $file doesn't exist\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$shell" in
|
|
|
|
bash) vinstall "$file" 0644 $_bash_completion_dir "${cmd}" ;;
|
|
|
|
fish) vinstall "$file" 0644 $_fish_completion_dir "${cmd}.fish" ;;
|
|
|
|
zsh) vinstall "$file" 0644 $_zsh_completion_dir "_${cmd}" ;;
|
2021-08-08 04:23:37 +00:00
|
|
|
*)
|
|
|
|
msg_red "$pkgver: vcompletion: unknown shell ${shell}"
|
|
|
|
return 1
|
|
|
|
;;
|
2020-06-13 21:45:12 +00:00
|
|
|
esac
|
|
|
|
}
|