Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] RFC: make vsv accept relative paths and target names
@ 2020-09-02 15:39 ahesford
  2020-09-02 15:41 ` [PR REVIEW] " ericonr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ahesford @ 2020-09-02 15:39 UTC (permalink / raw)
  To: ml

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

There is a new 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 append `${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: 5856 bytes --]

From 6c70d20e30ac2e1d5c57d0eb790be1c6d4c9ee45 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/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 <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 65cc6420ab0cdacbf5f3c700940c155cce7cf994 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/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" <ajh@sideband.org>
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"
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-04 14:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02 15:39 [PR PATCH] RFC: make vsv accept relative paths and target names 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 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).