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

* Re: [PR REVIEW] RFC: make vsv accept relative paths and target names
  2020-09-02 15:39 [PR PATCH] RFC: make vsv accept relative paths and target names ahesford
@ 2020-09-02 15:41 ` ericonr
  2020-09-02 15:43 ` ericonr
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ericonr @ 2020-09-02 15:41 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/24612#discussion_r482171650

Comment:
I believe this chmod can be removed as well.

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

* Re: [PR REVIEW] RFC: make vsv accept relative paths and target names
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ericonr @ 2020-09-02 15:43 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/24612#discussion_r482173782

Comment:
If upstream ships a tarball with conf with `755` perms, this should be done automatically by `vsv`.

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

* Re: RFC: make vsv accept relative paths and target names
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ahesford @ 2020-09-02 15:47 UTC (permalink / raw)
  To: ml

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

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/24612#issuecomment-685824974

Comment:
> Would you mind fixing `qemuconf` as well?

`qemuconf` is a special case because its `Makefile` creates the service tree. Using the new `vsv` features would actually complicate the template.

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

* Re: [PR PATCH] [Updated] RFC: make vsv accept relative paths and target names
  2020-09-02 15:39 [PR PATCH] RFC: make vsv accept relative paths and target names ahesford
                   ` (2 preceding siblings ...)
  2020-09-02 15:47 ` ahesford
@ 2020-09-02 15:50 ` ahesford
  2020-09-02 15:54 ` [PR REVIEW] " ahesford
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ahesford @ 2020-09-02 15:50 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1382 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 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: 5857 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 25bd8cbcfa1416166f500350cc6721b5d50f6fb5 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 | 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
 }

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

* Re: [PR REVIEW] RFC: make vsv accept relative paths and target names
  2020-09-02 15:39 [PR PATCH] RFC: make vsv accept relative paths and target names ahesford
                   ` (3 preceding siblings ...)
  2020-09-02 15:50 ` [PR PATCH] [Updated] " ahesford
@ 2020-09-02 15:54 ` ahesford
  2020-09-02 16:52 ` [PR PATCH] [Updated] " ahesford
  2020-09-04 14:08 ` ahesford
  6 siblings, 0 replies; 8+ messages in thread
From: ahesford @ 2020-09-02 15:54 UTC (permalink / raw)
  To: ml

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

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/24612#discussion_r482181711

Comment:
That's a good point, looks like `conf` has the right permissions here. I'm not sure that correcting permissions on `conf` is within the scope of `vsv` because a `conf` file is a common construct but subject to variations in individual services. The behavior of `run`, `finish` and `log/run` scripts are, however, directly specified in the `runit` docs. Either way, it is definitely outside the scope of this PR.

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

* Re: [PR PATCH] [Updated] RFC: make vsv accept relative paths and target names
  2020-09-02 15:39 [PR PATCH] RFC: make vsv accept relative paths and target names ahesford
                   ` (4 preceding siblings ...)
  2020-09-02 15:54 ` [PR REVIEW] " ahesford
@ 2020-09-02 16:52 ` ahesford
  2020-09-04 14:08 ` ahesford
  6 siblings, 0 replies; 8+ messages in thread
From: ahesford @ 2020-09-02 16:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1382 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 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: 6288 bytes --]

From 3350c00348eb89ed71e57d35ed2136c1a86f77a4 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 c9df361c8e79287733bd96b7f69b7412072fadbb 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 | 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 ccd612208a081ba84e275e01d22f04eecf104ddf 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 | 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
 }

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

* Re: [PR PATCH] [Updated] RFC: make vsv accept relative paths and target names
  2020-09-02 15:39 [PR PATCH] RFC: make vsv accept relative paths and target names ahesford
                   ` (5 preceding siblings ...)
  2020-09-02 16:52 ` [PR PATCH] [Updated] " ahesford
@ 2020-09-04 14:08 ` ahesford
  6 siblings, 0 replies; 8+ messages in thread
From: ahesford @ 2020-09-04 14:08 UTC (permalink / raw)
  To: ml

[-- 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
 }

^ 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).