Github messages for voidlinux
 help / color / mirror / Atom feed
From: ahesford <ahesford@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] RFC: make vsv accept relative paths and target names
Date: Fri, 04 Sep 2020 16:08:39 +0200	[thread overview]
Message-ID: <20200904140839.CX3W_yK3N0CfuiQrdlAUUmCSdnS6BO9Zbr_PnoRm4FQ@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-24612@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages vsv-enhance
https://github.com/void-linux/void-packages/pull/24612

RFC: make vsv accept relative paths and target names
A few upstream packages include runit service directories, and installing them (if the installation process doesn't take care of it) requires manually building the service directory structure and copying files. This is what `vsv` does for services in `${FILESDIR}` in one shot.

The changes here allow specification of relative or absolute paths to services in the `$wrksrc` (anywhere, really), so constructs like `vsv ./my-svc` or `vsv ./path/to/my-svc` won't forcefully prepend `${FILESDIR}`. If there is no slash in the service path, `vsv` looks in `${FILESDIR}` like it always has. I don't see any templates that would be broken by this change, and the two changed here---`runit-swap` and `zramen`--- are slightly simplified with this change.

While I was at it, I also added an optional `target` argument, so upstream service directories can be renamed in one shot. `runit-swap` is a good example of this functionality, where the upstream `swap` service can be renamed to `runit-swap` in one pass with `vsv ./swap runit-swap`.

A patch file from https://github.com/void-linux/void-packages/pull/24612.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-vsv-enhance-24612.patch --]
[-- Type: text/x-diff, Size: 7217 bytes --]

From 1a4e3d36f381fa70002afefd8b9c7d8008485869 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
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 <service>`
+- *vsv()* `vsv <service> [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 <file> -e <regex>`
 
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: <service>\n"
+		msg_red "$pkgver: vsv: missing required argument: <service> [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" <ajh@sideband.org>
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 <abc@pompel.me>"
-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" <ajh@sideband.org>
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" <ajh@sideband.org>
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
 }

      parent reply	other threads:[~2020-09-04 14:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 15:39 [PR PATCH] " ahesford
2020-09-02 15:41 ` [PR REVIEW] " ericonr
2020-09-02 15:43 ` ericonr
2020-09-02 15:47 ` ahesford
2020-09-02 15:50 ` [PR PATCH] [Updated] " ahesford
2020-09-02 15:54 ` [PR REVIEW] " ahesford
2020-09-02 16:52 ` [PR PATCH] [Updated] " ahesford
2020-09-04 14:08 ` ahesford [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200904140839.CX3W_yK3N0CfuiQrdlAUUmCSdnS6BO9Zbr_PnoRm4FQ@z \
    --to=ahesford@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).