2014-02-12 13:15:01 +01: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
|
2014-10-13 11:03:14 +02:00
|
|
|
for cmd in vinstall vcopy vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
|
2014-02-12 13:15:01 +01:00
|
|
|
alias ${cmd}="set -f; _noglob_helper _${cmd}"
|
|
|
|
done
|
|
|
|
|
2014-10-13 11:03:14 +02:00
|
|
|
_vsv() {
|
|
|
|
local service="$1"
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vsv: 1 argument expected: <service>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
vmkdir etc/sv
|
|
|
|
vcopy "${FILESDIR}/$service" etc/sv
|
2014-11-03 17:03:27 +01:00
|
|
|
chmod 755 ${PKGDESTDIR}/etc/sv/${service}/run
|
2014-10-13 12:37:33 +02:00
|
|
|
if [ -r ${PKGDESTDIR}/etc/sv/${service}/finish ]; then
|
2014-11-03 17:03:27 +01:00
|
|
|
chmod 755 ${PKGDESTDIR}/etc/sv/${service}/finish
|
2014-10-13 12:37:33 +02:00
|
|
|
fi
|
|
|
|
ln -s /run/runit/supervise.${service} ${PKGDESTDIR}/etc/sv/${service}/supervise
|
2014-10-13 13:02:04 +02:00
|
|
|
if [ -r ${PKGDESTDIR}/etc/sv/${service}/log/run ]; then
|
2014-11-03 17:03:27 +01:00
|
|
|
chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run
|
2014-10-13 13:02:04 +02:00
|
|
|
ln -s /run/runit/supervise.${service}-log ${PKGDESTDIR}/etc/sv/${service}/log/supervise
|
|
|
|
fi
|
2014-10-13 11:03:14 +02:00
|
|
|
}
|
|
|
|
|
2014-07-04 07:42:16 +02: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 23:15:30 +02:00
|
|
|
local file="$1" target="${2:-${1##*/}}"
|
2014-07-04 07:42:16 +02:00
|
|
|
|
2014-07-04 16:15:00 +02:00
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "$pkgver: vman: 1 argument expected: <file>\n"
|
2014-07-04 07:42:16 +02:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2014-07-04 16:15:00 +02:00
|
|
|
suffix=${target##*.}
|
|
|
|
|
2018-08-07 22:55:59 +02:00
|
|
|
if [[ $suffix == gz ]]
|
|
|
|
then
|
|
|
|
gunzip "$file"
|
|
|
|
file="${file:0:-3}"
|
|
|
|
target="${target:0:-3}"
|
|
|
|
suffix=${target##*.}
|
|
|
|
fi
|
|
|
|
|
2018-10-14 21:23:04 +02:00
|
|
|
if [[ $suffix == bz2 ]]
|
|
|
|
then
|
|
|
|
bunzip2 "$file"
|
|
|
|
file="${file:0:-4}"
|
|
|
|
target="${target:0:-4}"
|
|
|
|
suffix=${target##*.}
|
|
|
|
fi
|
|
|
|
|
2014-07-04 16:15:00 +02:00
|
|
|
if [[ $target =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]]
|
|
|
|
then
|
2014-07-06 23:15:30 +02:00
|
|
|
name=${BASH_REMATCH[1]}.${BASH_REMATCH[4]}
|
2014-07-04 16:15:00 +02:00
|
|
|
mandir=${BASH_REMATCH[2]}/man${suffix:0:1}
|
|
|
|
else
|
2014-07-06 23:15:30 +02:00
|
|
|
name=$target
|
2014-07-04 16:15:00 +02: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 07:42:16 +02: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 19:36:52 +02: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 17:10:10 +02:00
|
|
|
vinstall "$file" 644 etc "$targetfile"
|
2014-07-17 19:36:52 +02:00
|
|
|
}
|
|
|
|
|
2014-07-04 07:42:16 +02: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 13:15:01 +01:00
|
|
|
_vinstall() {
|
|
|
|
local file="$1" mode="$2" targetdir="$3" targetfile="$4"
|
|
|
|
local _destdir=
|
|
|
|
|
|
|
|
if [ -z "$DESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vinstall: DESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -lt 3 ]; then
|
|
|
|
msg_red "$pkgver: vinstall: 3 arguments expected: <file> <mode> <target-directory>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2016-10-21 01:45:26 +02:00
|
|
|
if [ ! -r "${file}" ]; then
|
2014-02-12 13:15:01 +01:00
|
|
|
msg_red "$pkgver: vinstall: cannot find '$file'...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$XBPS_PKGDESTDIR" ]; then
|
|
|
|
_destdir="$PKGDESTDIR"
|
|
|
|
else
|
|
|
|
_destdir="$DESTDIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$targetfile" ]; then
|
2016-10-21 01:45:26 +02:00
|
|
|
install -Dm${mode} "${file}" "${_destdir}/${targetdir}/${file##*/}"
|
2014-02-12 13:15:01 +01:00
|
|
|
else
|
2016-10-21 01:45:26 +02:00
|
|
|
install -Dm${mode} "${file}" "${_destdir}/${targetdir}/${targetfile##*/}"
|
2014-02-12 13:15:01 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_vcopy() {
|
|
|
|
local files="$1" targetdir="$2" _destdir
|
|
|
|
|
|
|
|
if [ -z "$DESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vcopy: DESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
msg_red "$pkgver: vcopy: 2 arguments expected: <files> <target-directory>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$XBPS_PKGDESTDIR" ]; then
|
|
|
|
_destdir="$PKGDESTDIR"
|
|
|
|
else
|
|
|
|
_destdir="$DESTDIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp -a $files ${_destdir}/${targetdir}
|
|
|
|
}
|
|
|
|
|
|
|
|
_vmove() {
|
2014-11-30 21:13:45 +01:00
|
|
|
local f files="$1" _destdir _pkgdestdir _targetdir
|
2014-02-12 13:15:01 +01: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
|
|
|
|
fi
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
msg_red "$pkgver: vmove: 1 argument expected: <files>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
for f in ${files}; do
|
|
|
|
_targetdir=$(dirname $f)
|
|
|
|
break
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "$XBPS_PKGDESTDIR" ]; then
|
|
|
|
_pkgdestdir="$PKGDESTDIR"
|
|
|
|
_destdir="$DESTDIR"
|
|
|
|
else
|
|
|
|
_pkgdestdir="$DESTDIR"
|
|
|
|
_destdir="$DESTDIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${_targetdir}" ]; then
|
|
|
|
[ ! -d ${_pkgdestdir} ] && install -d ${_pkgdestdir}
|
|
|
|
mv ${_destdir}/$files ${_pkgdestdir}
|
|
|
|
else
|
|
|
|
if [ ! -d ${_pkgdestdir}/${_targetdir} ]; then
|
|
|
|
install -d ${_pkgdestdir}/${_targetdir}
|
|
|
|
fi
|
|
|
|
mv ${_destdir}/$files ${_pkgdestdir}/${_targetdir}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_vmkdir() {
|
|
|
|
local dir="$1" mode="$2" _destdir
|
|
|
|
|
|
|
|
if [ -z "$DESTDIR" ]; then
|
|
|
|
msg_red "$pkgver: vmkdir: DESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$dir" ]; then
|
|
|
|
msg_red "vmkdir: directory argument unset.\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$XBPS_PKGDESTDIR" ]; then
|
|
|
|
_destdir="$PKGDESTDIR"
|
|
|
|
else
|
|
|
|
_destdir="$DESTDIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$mode" ]; then
|
|
|
|
install -d ${_destdir}/${dir}
|
|
|
|
else
|
|
|
|
install -dm${mode} ${_destdir}/${dir}
|
|
|
|
fi
|
|
|
|
}
|