4 shopt -s expand_aliases
9 # disable wildcards helper
15 # Apply _noglob to v* commands
16 for cmd
in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv
; do
17 # intentionally expanded when defined
18 # shellcheck disable=SC2139
19 alias ${cmd}="set -f; _noglob_helper _${cmd}"
24 local facility
="${2:-daemon}"
26 local svdir
="${PKGDESTDIR}/etc/sv/${service}"
28 if [ $# -lt 1 ] ||
[ $# -gt 2 ]; then
29 # pkgver is defined in common/xbps-src/shutils/commmon.sh
30 # shellcheck disable=SC2154
31 msg_red
"$pkgver: vsv: up to 2 arguments expected: <service> [<log facility>]\n"
35 if [ -n "$XBPS_BUILD_FORCEMODE" ]; then
40 vcopy
"${FILESDIR}/$service" etc
/sv
41 grep -Fq 'exec 2>&1' "$svdir/run" || msg_warn
"$pkgver: vsv: service '$service' does not contain 'exec 2>&1' to log stderr\n"
42 for f
in run finish check control
/{a
,c
,d
,h
,i
,k
,p
,q
,t
,u
,x
,1,2}; do
43 [ -e "$svdir/$f" ] && [ ! -L "$svdir/$f" ] && chmod 755 "$svdir/$f"
45 ln ${LN_OPTS} "/run/runit/supervise.${service}" "$svdir/supervise"
46 if [ -d "$svdir/log" ] ||
[ -L "$svdir/log" ]; then
47 msg_warn
"$pkgver: vsv: overriding default log service\n"
50 cat <<-EOF > "$svdir/log/run"
52 exec vlogger -t $service -p $facility
55 ln ${LN_OPTS} "/run/runit/supervise.${service}-log" "$svdir/log/supervise"
56 if [ -e "$svdir/log/run" ] && [ ! -L "$svdir/log/run" ]; then
57 chmod 755 "${PKGDESTDIR}/etc/sv/${service}/log/run"
62 local file="$1" targetfile
="$2"
65 msg_red
"$pkgver: vbin: 1 argument expected: <file>\n"
69 vinstall
"$file" 755 usr
/bin
"$targetfile"
73 local file="$1" target
="${2:-${1##*/}}"
76 msg_red
"$pkgver: vman: 1 argument expected: <file>\n"
82 if [[ $suffix == gz
]]
86 target
="${target:0:-3}"
90 if [[ $suffix == bz2
]]
94 target
="${target:0:-4}"
98 if [[ $target =~
(.
*)\.
([a-z
][a-z
](_
[A-Z
][A-Z
])?
(\.
[^.
]+)?
)\.
(.
*) ]]
100 name
=${BASH_REMATCH[1]}.
${BASH_REMATCH[5]}
101 mandir
=${BASH_REMATCH[2]}/man
${suffix:0:1}
104 mandir
=man
${suffix:0:1}
107 if [[ ${mandir} == *man
[0-9n] ]] ; then
108 vinstall
"$file" 644 "usr/share/man/${mandir}" "$name"
112 msg_red
"$pkgver: vman: Filename '${target}' does not look like a man page\n"
117 local file="$1" targetfile
="$2"
119 if [ $# -lt 1 ]; then
120 msg_red
"$pkgver: vdoc: 1 argument expected: <file>\n"
124 # pkgname is defined in the package
125 # shellcheck disable=SC2154
126 vinstall
"$file" 644 "usr/share/doc/${pkgname}" "$targetfile"
130 local file="$1" targetfile
="$2"
132 if [ $# -lt 1 ]; then
133 msg_red
"$pkgver: vconf: 1 argument expected: <file>\n"
137 vinstall
"$file" 644 etc
"$targetfile"
141 local file="$1" targetfile
="$2"
143 if [ $# -lt 1 ]; then
144 msg_red
"$pkgver: vsconf: 1 argument expected: <file>\n"
148 vinstall
"$file" 644 "usr/share/examples/${pkgname}" "$targetfile"
152 local file="$1" targetfile
="$2"
154 if [ $# -lt 1 ]; then
155 msg_red
"$pkgver: vlicense: 1 argument expected: <file>\n"
159 vinstall
"$file" 644 "usr/share/licenses/${pkgname}" "$targetfile"
163 local file="$1" mode
="$2" targetdir
="$3" targetfile
="$4"
165 if [ -z "$PKGDESTDIR" ]; then
166 msg_red
"$pkgver: vinstall: PKGDESTDIR unset, can't continue...\n"
170 if [ $# -lt 3 ]; then
171 msg_red
"$pkgver: vinstall: 3 arguments expected: <file> <mode> <target-directory>\n"
175 if [ ! -r "${file}" ]; then
176 msg_red
"$pkgver: vinstall: cannot find '$file'...\n"
180 if [ -z "$targetfile" ]; then
181 install -Dm"${mode}" "${file}" "${PKGDESTDIR}/${targetdir}/${file##*/}"
183 install -Dm"${mode}" "${file}" "${PKGDESTDIR}/${targetdir}/${targetfile##*/}"
188 local files
="$1" targetdir
="$2"
190 if [ -z "$PKGDESTDIR" ]; then
191 msg_red
"$pkgver: vcopy: PKGDESTDIR unset, can't continue...\n"
194 if [ $# -ne 2 ]; then
195 msg_red
"$pkgver: vcopy: 2 arguments expected: <files> <target-directory>\n"
199 # intentionally unquoted for globbing
200 # shellcheck disable=SC2086
201 cp -a $files "${PKGDESTDIR}/${targetdir}"
205 local f files
="$1" _targetdir
207 if [ -z "$DESTDIR" ]; then
208 msg_red
"$pkgver: vmove: DESTDIR unset, can't continue...\n"
210 elif [ -z "$PKGDESTDIR" ]; then
211 msg_red
"$pkgver: vmove: PKGDESTDIR unset, can't continue...\n"
213 elif [ "$DESTDIR" = "$PKGDESTDIR" ]; then
214 msg_red
"$pkgver: vmove is intended to be used in pkg_install\n"
217 if [ $# -ne 1 ]; then
218 msg_red
"$pkgver: vmove: 1 argument expected: <files>\n"
221 for f
in ${files}; do
226 if [ -z "${_targetdir}" ]; then
227 [ ! -d "${PKGDESTDIR}" ] && install -d "${PKGDESTDIR}"
228 # intentionally unquoted for globbing
229 # shellcheck disable=SC2086
230 mv "${DESTDIR}"/$files "${PKGDESTDIR}"
232 if [ ! -d "${PKGDESTDIR}/${_targetdir}" ]; then
233 install -d "${PKGDESTDIR}/${_targetdir}"
235 # intentionally unquoted for globbing
236 # shellcheck disable=SC2086
237 mv "${DESTDIR}"/$files "${PKGDESTDIR}/${_targetdir}"
242 local dir
="$1" mode
="$2"
244 if [ -z "$PKGDESTDIR" ]; then
245 msg_red
"$pkgver: vmkdir: PKGDESTDIR unset, can't continue...\n"
249 if [ -z "$dir" ]; then
250 msg_red
"vmkdir: directory argument unset.\n"
254 if [ -z "$mode" ]; then
255 install -d "${PKGDESTDIR}/${dir}"
257 install -dm"${mode}" "${PKGDESTDIR}/${dir}"
262 local file="$1" shell
="$2" cmd
="${3:-${pkgname}}"
263 local _bash_completion_dir
=usr
/share
/bash-completion
/completions
/
264 local _fish_completion_dir
=usr
/share
/fish
/vendor_completions.d
/
265 local _zsh_completion_dir
=usr
/share
/zsh
/site-functions
/
267 if [ $# -lt 2 ]; then
268 msg_red
"$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
272 if ! [ -f "$file" ]; then
273 msg_red
"$pkgver: vcompletion: file $file doesn't exist\n"
277 bash
) vinstall
"$file" 0644 $_bash_completion_dir "${cmd}" ;;
278 fish
) vinstall
"$file" 0644 $_fish_completion_dir "${cmd}.fish" ;;
279 zsh
) vinstall
"$file" 0644 $_zsh_completion_dir "_${cmd}" ;;
281 msg_red
"$pkgver: vcompletion: unknown shell ${shell}"