From 1a4e3d36f381fa70002afefd8b9c7d8008485869 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 2 Sep 2020 11:22:24 -0400 Subject: [PATCH 1/4] xbps-src: make vsv accept target argument and relative paths If vsv is provided a relative or absolute path for the service, it will not look for the service at that path; otherwise, if it is provided a simple directory base name, it will look relative to `${FILESDIR}` as is done currently. If vsv is provided an optional second argument, it will use that argument as the target service name, allowing services to be renamed during installation. Without the target name, the basename of the source path will be used. --- Manual.md | 16 +++++++++----- common/environment/setup/install.sh | 34 +++++++++++++++++++---------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/Manual.md b/Manual.md index 5502c6e26f8..9a88c140ec1 100644 --- a/Manual.md +++ b/Manual.md @@ -321,14 +321,18 @@ The following functions are defined by `xbps-src` and can be used on any templat `$DESTDIR`. The optional 2nd argument can be used to change the `file name`. See [license](#var_license) for when to use it. -- *vsv()* `vsv ` +- *vsv()* `vsv [target]` + + Installs `service` to `/etc/sv/target`. If `target` is not provided, the base + name of `service` will be used instead. The service must be a directory + containing at least a `run` script. If `service` contains a `/` character, it + is used as a source path without modification. Otherwise, `service` is + assumed to be a directory within `${FILESDIR}`. Note the `supervise` symlink + will be created automatically by `vsv` and that the run script is + automatically made executable by this function. - Installs `service` from `${FILESDIR}` to /etc/sv. The service must - be a directory containing at least a run script. Note the `supervise` - symlink will be created automatically by `vsv` and that the run script - is automatically made executable by this function. For further information on how to create a new service directory see - [The corresponding section the FAQ](http://smarden.org/runit/faq.html#create). + [the corresponding section the FAQ](http://smarden.org/runit/faq.html#create). - *vsed()* `vsed -i -e ` diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh index 742f13075f8..39042374dc4 100644 --- a/common/environment/setup/install.sh +++ b/common/environment/setup/install.sh @@ -18,11 +18,13 @@ for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf v done _vsv() { - local service="$1" + local svsrc="$1" + local target="$2" local LN_OPTS="-s" + local svbase="${svsrc##*/}" if [ $# -lt 1 ]; then - msg_red "$pkgver: vsv: 1 argument expected: \n" + msg_red "$pkgver: vsv: missing required argument: [target]\n" return 1 fi @@ -30,16 +32,26 @@ _vsv() { LN_OPTS+="f" fi - vmkdir etc/sv - vcopy "${FILESDIR}/$service" etc/sv - chmod 755 ${PKGDESTDIR}/etc/sv/${service}/run - if [ -r ${PKGDESTDIR}/etc/sv/${service}/finish ]; then - chmod 755 ${PKGDESTDIR}/etc/sv/${service}/finish + if [ -z "$target" ]; then + target="${svbase}" fi - ln ${LN_OPTS} /run/runit/supervise.${service} ${PKGDESTDIR}/etc/sv/${service}/supervise - if [ -r ${PKGDESTDIR}/etc/sv/${service}/log/run ]; then - chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run - ln ${LN_OPTS} /run/runit/supervise.${service}-log ${PKGDESTDIR}/etc/sv/${service}/log/supervise + + local svdir="etc/sv/$target" + + if [[ "$svsrc" == "$svbase" ]]; then + svsrc="${FILESDIR}/$svbase" + fi + + vmkdir "$svdir" + vcopy "${svsrc}/*" "$svdir" + chmod 755 "${PKGDESTDIR}/${svdir}/run" + if [ -r "${PKGDESTDIR}/${svdir}/finish" ]; then + chmod 755 "${PKGDESTDIR}/${svdir}/finish" + fi + ln ${LN_OPTS} "/run/runit/supervise.${target}" "${PKGDESTDIR}/${svdir}/supervise" + if [ -r ${PKGDESTDIR}/${svdir}/log/run ]; then + chmod 755 ${PKGDESTDIR}/${svdir}/log/run + ln ${LN_OPTS} /run/runit/supervise.${target}-log ${PKGDESTDIR}/${svdir}/log/supervise fi } From 0821dfa0d127f87733868deb6336028e21e40e92 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 2 Sep 2020 11:29:08 -0400 Subject: [PATCH 2/4] runit-swap: use expanded vsv for service install --- srcpkgs/runit-swap/template | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/srcpkgs/runit-swap/template b/srcpkgs/runit-swap/template index 20147c8555d..67b0207a422 100644 --- a/srcpkgs/runit-swap/template +++ b/srcpkgs/runit-swap/template @@ -2,23 +2,19 @@ pkgname=runit-swap version=2.0.0 revision=1 +archs=noarch build_style=meta depends="runit bash util-linux>=2.26" -hostmakedepends="git" short_desc="Script to manage swapspaces" maintainer="Andrea Brancaleoni " -license="GPL-3" +license="GPL-3.0-or-later" homepage="https://github.com/thypon/runit-swap" conf_files="/etc/runit/swap.conf" -archs=noarch distfiles="$homepage/archive/v$version.tar.gz" checksum=a66730777fb084564e7fae67f2017d775b757b6b6c0c319802f71bed2184e958 do_install() { vbin runit-swap + vsv ./swap runit-swap vinstall swap.conf 644 etc/runit - - vinstall swap/run 755 etc/sv/runit-swap - vinstall swap/finish 755 etc/sv/runit-swap - ln -s /run/runit/supervise.runit-swap ${PKGDESTDIR}/etc/sv/runit-swap/supervise } From cde7a54ec4fd7a74827b4729d66e958e15749f4c Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 2 Sep 2020 11:29:24 -0400 Subject: [PATCH 3/4] zramen: use expanded vsv for service install --- srcpkgs/zramen/template | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/srcpkgs/zramen/template b/srcpkgs/zramen/template index 8245a3b7c25..987ed2a143c 100644 --- a/srcpkgs/zramen/template +++ b/srcpkgs/zramen/template @@ -16,10 +16,5 @@ do_install() { vbin zramen vlicense UNLICENSE vdoc README.md - vmkdir etc/sv - vcopy sv/zramen etc/sv - chmod 644 "${PKGDESTDIR}/etc/sv/zramen/conf" - chmod 755 "${PKGDESTDIR}/etc/sv/zramen/finish" - chmod 755 "${PKGDESTDIR}/etc/sv/zramen/run" - ln -s /run/runit/supervise.zramen "${PKGDESTDIR}/etc/sv/zramen/supervise" + vsv sv/zramen } From 72619227844306f60ed460c06eaa499d055f735c Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Fri, 4 Sep 2020 10:07:55 -0400 Subject: [PATCH 4/4] trident-automount: use expanded vsv for service install --- srcpkgs/trident-automount/template | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/srcpkgs/trident-automount/template b/srcpkgs/trident-automount/template index d5955aab883..65fd8f1909c 100644 --- a/srcpkgs/trident-automount/template +++ b/srcpkgs/trident-automount/template @@ -16,7 +16,6 @@ distfiles="https://github.com/project-trident/trident-utilities/archive/v${versi checksum=0bf0991c815b56b0143106e29ff2ab952416fd63d1810a6aa51fd95a0de4c48d post_install() { - vinstall sv/run 0755 /etc/sv/trident-automount - ln -s /run/runit/supervise.trident-automount $DESTDIR/etc/sv/trident-automount/supervise + vsv ./sv trident-automount vlicense ${wrksrc}/LICENSE }