common/environment/setup/install.sh: fix v* funcs for paths with spaces
also quote, fix tabs, and shellcheck the file
This commit is contained in:
parent
73eb70c7f8
commit
91367b5ab9
|
@ -8,13 +8,15 @@ unalias -a
|
||||||
|
|
||||||
# disable wildcards helper
|
# disable wildcards helper
|
||||||
_noglob_helper() {
|
_noglob_helper() {
|
||||||
set +f
|
set +f
|
||||||
"$@"
|
IFS= "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Apply _noglob to v* commands
|
# Apply _noglob to v* commands
|
||||||
for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
|
for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
|
||||||
alias ${cmd}="set -f; _noglob_helper _${cmd}"
|
# intentionally expanded when defined
|
||||||
|
# shellcheck disable=SC2139
|
||||||
|
alias ${cmd}="set -f; _noglob_helper _${cmd}"
|
||||||
done
|
done
|
||||||
|
|
||||||
_vsv() {
|
_vsv() {
|
||||||
|
@ -24,6 +26,8 @@ _vsv() {
|
||||||
local svdir="${PKGDESTDIR}/etc/sv/${service}"
|
local svdir="${PKGDESTDIR}/etc/sv/${service}"
|
||||||
|
|
||||||
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
||||||
|
# pkgver is defined in common/xbps-src/shutils/commmon.sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
msg_red "$pkgver: vsv: up to 2 arguments expected: <service> [<log facility>]\n"
|
msg_red "$pkgver: vsv: up to 2 arguments expected: <service> [<log facility>]\n"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -34,26 +38,26 @@ _vsv() {
|
||||||
|
|
||||||
vmkdir etc/sv
|
vmkdir etc/sv
|
||||||
vcopy "${FILESDIR}/$service" etc/sv
|
vcopy "${FILESDIR}/$service" etc/sv
|
||||||
if [ ! -L $svdir/run ]; then
|
if [ ! -L "$svdir/run" ]; then
|
||||||
grep -Fq 'exec 2>&1' $svdir/run || msg_warn "$pkgver: vsv: service '$service' does not contain 'exec 2>&1' to log stderr\n"
|
grep -Fq 'exec 2>&1' "$svdir/run" || msg_warn "$pkgver: vsv: service '$service' does not contain 'exec 2>&1' to log stderr\n"
|
||||||
chmod 755 $svdir/run
|
chmod 755 "$svdir/run"
|
||||||
fi
|
fi
|
||||||
if [ -e $svdir/finish ] && [ ! -L $svdir/finish ]; then
|
if [ -e "$svdir/finish" ] && [ ! -L "$svdir/finish" ]; then
|
||||||
chmod 755 $svdir/finish
|
chmod 755 "$svdir/finish"
|
||||||
fi
|
fi
|
||||||
ln ${LN_OPTS} /run/runit/supervise.${service} $svdir/supervise
|
ln ${LN_OPTS} "/run/runit/supervise.${service}" "$svdir/supervise"
|
||||||
if [ -d $svdir/log ] || [ -L $svdir/log ]; then
|
if [ -d "$svdir/log" ] || [ -L "$svdir/log" ]; then
|
||||||
msg_warn "$pkgver: vsv: overriding default log service\n"
|
msg_warn "$pkgver: vsv: overriding default log service\n"
|
||||||
else
|
else
|
||||||
mkdir $svdir/log
|
mkdir "$svdir/log"
|
||||||
cat <<-EOF > $svdir/log/run
|
cat <<-EOF > "$svdir/log/run"
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec vlogger -t $service -p $facility
|
exec vlogger -t $service -p $facility
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
ln ${LN_OPTS} /run/runit/supervise.${service}-log $svdir/log/supervise
|
ln ${LN_OPTS} "/run/runit/supervise.${service}-log" "$svdir/log/supervise"
|
||||||
if [ -e $svdir/log/run ] && [ ! -L $svdir/log/run ]; then
|
if [ -e "$svdir/log/run" ] && [ ! -L "$svdir/log/run" ]; then
|
||||||
chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run
|
chmod 755 "${PKGDESTDIR}/etc/sv/${service}/log/run"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +124,8 @@ _vdoc() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# pkgname is defined in the package
|
||||||
|
# shellcheck disable=SC2154
|
||||||
vinstall "$file" 644 "usr/share/doc/${pkgname}" "$targetfile"
|
vinstall "$file" 644 "usr/share/doc/${pkgname}" "$targetfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +181,9 @@ _vinstall() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$targetfile" ]; then
|
if [ -z "$targetfile" ]; then
|
||||||
install -Dm${mode} "${file}" "${PKGDESTDIR}/${targetdir}/${file##*/}"
|
install -Dm"${mode}" "${file}" "${PKGDESTDIR}/${targetdir}/${file##*/}"
|
||||||
else
|
else
|
||||||
install -Dm${mode} "${file}" "${PKGDESTDIR}/${targetdir}/${targetfile##*/}"
|
install -Dm"${mode}" "${file}" "${PKGDESTDIR}/${targetdir}/${targetfile##*/}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +199,9 @@ _vcopy() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -a $files ${PKGDESTDIR}/${targetdir}
|
# intentionally unquoted for globbing
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
cp -a $files "${PKGDESTDIR}/${targetdir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_vmove() {
|
_vmove() {
|
||||||
|
@ -219,13 +227,17 @@ _vmove() {
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "${_targetdir}" ]; then
|
if [ -z "${_targetdir}" ]; then
|
||||||
[ ! -d ${PKGDESTDIR} ] && install -d ${PKGDESTDIR}
|
[ ! -d "${PKGDESTDIR}" ] && install -d "${PKGDESTDIR}"
|
||||||
mv ${DESTDIR}/$files ${PKGDESTDIR}
|
# intentionally unquoted for globbing
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
mv "${DESTDIR}"/$files "${PKGDESTDIR}"
|
||||||
else
|
else
|
||||||
if [ ! -d ${PKGDESTDIR}/${_targetdir} ]; then
|
if [ ! -d "${PKGDESTDIR}/${_targetdir}" ]; then
|
||||||
install -d ${PKGDESTDIR}/${_targetdir}
|
install -d "${PKGDESTDIR}/${_targetdir}"
|
||||||
fi
|
fi
|
||||||
mv ${DESTDIR}/$files ${PKGDESTDIR}/${_targetdir}
|
# intentionally unquoted for globbing
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
mv "${DESTDIR}"/$files "${PKGDESTDIR}/${_targetdir}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,9 +255,9 @@ _vmkdir() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$mode" ]; then
|
if [ -z "$mode" ]; then
|
||||||
install -d ${PKGDESTDIR}/${dir}
|
install -d "${PKGDESTDIR}/${dir}"
|
||||||
else
|
else
|
||||||
install -dm${mode} ${PKGDESTDIR}/${dir}
|
install -dm"${mode}" "${PKGDESTDIR}/${dir}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue