From 6c70d20e30ac2e1d5c57d0eb790be1c6d4c9ee45 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 2 Sep 2020 11:22:24 -0400 Subject: [PATCH 1/3] 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 65cc6420ab0cdacbf5f3c700940c155cce7cf994 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 2 Sep 2020 11:29:08 -0400 Subject: [PATCH 2/3] runit-swap: use expanded vsv for service install --- srcpkgs/runit-swap/template | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/srcpkgs/runit-swap/template b/srcpkgs/runit-swap/template index 20147c8555d..c4deeffaf2f 100644 --- a/srcpkgs/runit-swap/template +++ b/srcpkgs/runit-swap/template @@ -16,9 +16,6 @@ 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 84c3ffb7cfbdae243c3463040174fa82b881e22d Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 2 Sep 2020 11:29:24 -0400 Subject: [PATCH 3/3] zramen: use expanded vsv for service install --- srcpkgs/zramen/template | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/srcpkgs/zramen/template b/srcpkgs/zramen/template index 8245a3b7c25..e5c81996ed0 100644 --- a/srcpkgs/zramen/template +++ b/srcpkgs/zramen/template @@ -16,10 +16,6 @@ do_install() { vbin zramen vlicense UNLICENSE vdoc README.md - vmkdir etc/sv - vcopy sv/zramen etc/sv + vsv sv/zramen 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" }