Github messages for voidlinux
 help / color / mirror / Atom feed
* Re: Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
  2020-07-08 19:37 ` [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions); use them in rustup and starship ericonr
@ 2020-07-08 19:37 ` ericonr
  2020-07-08 22:17 ` jcgruenhage
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-08 19:37 UTC (permalink / raw)
  To: ml

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

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#issuecomment-655715173

Comment:
Rebased to remove conflicts.

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

* Re: Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
  2020-07-08 19:37 ` [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions); use them in rustup and starship ericonr
  2020-07-08 19:37 ` ericonr
@ 2020-07-08 22:17 ` jcgruenhage
  2020-07-20  3:36 ` [PR PATCH] [Updated] " ericonr
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: jcgruenhage @ 2020-07-08 22:17 UTC (permalink / raw)
  To: ml

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

New comment by jcgruenhage on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#issuecomment-655786711

Comment:
@ericonr gonna need another rebase soon because of #23476 

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

* Re: [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (2 preceding siblings ...)
  2020-07-08 22:17 ` jcgruenhage
@ 2020-07-20  3:36 ` ericonr
  2020-07-20  4:04 ` ericonr
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-20  3:36 UTC (permalink / raw)
  To: ml

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

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

https://github.com/ericonr/void-packages rustup
https://github.com/void-linux/void-packages/pull/22785

Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
Inspired by #22761 . Pinging @sgn 

Not revbumping because I don't think it's urgent. I could see the case for making this procedure part of the cargo build style, configurable with some variable like `clap_completions=yes`.

If you feel it adds too much complexity for little gain, I can close the PR.

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

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

From 988bf0949aaaf213d8acadff0bb43456d3a592e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:45:12 -0300
Subject: [PATCH 1/4] common/environment/setup/install.sh: add vcompletion.

Install function for installing shell completions in the appropriate
place according to the shell used.
---
 Manual.md                           |  7 +++++++
 common/environment/setup/install.sh | 30 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index 5b49dc5ddd4..a2e43334b9d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -337,6 +337,13 @@ The following functions are defined by `xbps-src` and can be used on any templat
 	Note that vsed will call the sed command for every regex specified against
 	every file specified, in the order that they are given.
 
+- *vcompletion()* `<file> <shell> [<command>]`
+
+	Installs shell completion from `file` for `command`, in the correct location
+	and with the appropriate filename for `shell`. If `command` isn't specified,
+	it will default to `pkgname`. The `shell` argument can be one of `bash`,
+	`fish` or `zsh`.
+
 > Shell wildcards must be properly quoted, Example: `vmove "usr/lib/*.a"`.
 
 <a id="global_vars"></a>
diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh
index f9a1ace90e7..742f13075f8 100644
--- a/common/environment/setup/install.sh
+++ b/common/environment/setup/install.sh
@@ -13,7 +13,7 @@ _noglob_helper() {
 }
 
 # Apply _noglob to v* commands
-for cmd in vinstall vcopy vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
+for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -258,3 +258,31 @@ _vmkdir() {
 		install -dm${mode} ${_destdir}/${dir}
 	fi
 }
+
+_vcompletion() {
+	local file="$1" shell="$2" cmd="${3:-${pkgname}}"
+	local _bash_completion_dir=usr/share/bash-completion/completions/
+	local _fish_completion_dir=usr/share/fish/vendor_completions.d/
+	local _zsh_completion_dir=usr/share/zsh/site-functions/
+
+	if [ -z "$DESTDIR" ]; then
+		msg_red "$pkgver: vcompletion: DESTDIR unset, can't continue...\n"
+		return 1
+	fi
+
+	if [ $# -lt 2 ]; then
+		msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
+		return 1
+	fi
+
+	if ! [ -f "$file" ]; then
+		msg_red "$pkgver: vcompletion: file $file doesn't exist\n"
+	fi
+
+	case "$shell" in
+		bash) vinstall "$file" 0644 $_bash_completion_dir "${cmd}" ;;
+		fish) vinstall "$file" 0644 $_fish_completion_dir "${cmd}.fish" ;;
+		zsh) vinstall "$file" 0644 $_zsh_completion_dir "_${cmd}" ;;
+		*) msg_red "$pkgver: vcompletion: unknown shell ${shell}" ;;
+	esac
+}

From 2da28afef494011415efab6dcfd79027c8d1522e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 19:00:05 -0300
Subject: [PATCH 2/4] common/build-helper/qemu.sh: add vtargetrun function.

It's a function to call the qemu executable for the target arch, or a
noop if the build isn't a cross build.
---
 Manual.md                   | 4 +++-
 common/build-helper/qemu.sh | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index a2e43334b9d..9ab6ccecedb 100644
--- a/Manual.md
+++ b/Manual.md
@@ -970,7 +970,9 @@ additional paths to be searched when linking target binaries to be introspected.
 - `qemu` sets additional variables for the `cmake` and `meson` build styles to allow
 executing cross-compiled binaries inside qemu.
 It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson
-to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`
+to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`.
+It also creates the `vtargetrun` function to call the target architecture
+`qemu-<arch>-static` executable.
 
 - `qmake` creates the `qt.conf` configuration file (cf. `qmake` `build_style`)
 needed for cross builds and a qmake-wrapper to make `qmake` use this configuration.
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index f7a1839cc3e..d6a4342f5e8 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -4,3 +4,11 @@ if [ "$CROSS_BUILD" ]; then
 		hostmakedepends+=" qemu-user-static"
 	fi
 fi
+
+vtargetrun() {
+	if [ "$CROSS_BUILD" ]; then
+		"/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static" "$@"
+	else
+		"$@"
+	fi
+}

From 5b3b282168cb77ae854e912d5f9bd924011ecaee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 11 Jun 2020 00:38:11 -0300
Subject: [PATCH 3/4] rustup: add completions for all archs.

Use qemu build_helper and vcompletion.

Completion generation is broken for armv6l-musl due to rustup not
knowing about the architecture.
---
 srcpkgs/rustup/template | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/rustup/template b/srcpkgs/rustup/template
index 96b4bee6c63..c644b44689c 100644
--- a/srcpkgs/rustup/template
+++ b/srcpkgs/rustup/template
@@ -1,8 +1,9 @@
 # Template file for 'rustup'
 pkgname=rustup
 version=1.22.0
-revision=1
+revision=2
 build_style=cargo
+build_helper=qemu
 configure_args="--features no-self-update --bin rustup-init"
 hostmakedepends="pkg-config"
 makedepends="libressl-devel zlib-devel libcurl-devel"
@@ -13,19 +14,25 @@ homepage="https://www.rustup.rs"
 distfiles="https://github.com/rust-lang/${pkgname}/archive/${version}.tar.gz"
 checksum=1810c0b12f32d85cd0302c1cc73b88893fb8aa7f20ec22cb4bf53ed25bb130fe
 
+post_build() {
+	# rustup errors out because it doesn't know about armv6l-musl
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		RUSTUP="target/${RUST_TARGET}/release/rustup-init"
+		ln -sf "$RUSTUP" rustup
+		# generate shell completions
+		vtargetrun ./rustup completions zsh >rustup.zsh
+		vtargetrun ./rustup completions bash >rustup.bash
+		vtargetrun ./rustup completions fish >rustup.fish
+	fi
+}
+
 do_install() {
 	vbin target/${RUST_TARGET}/release/rustup-init
 
-	if ! [ "$CROSS_BUILD" ]; then
-		# generate shell completions
-		ln -s target/${RUST_TARGET}/release/rustup-init rustup
-		./rustup completions zsh > rustup.zsh
-		./rustup completions bash > rustup.bash
-		./rustup completions fish > rustup.fish
-
-		vinstall rustup.zsh 0644 usr/share/zsh/site-functions/ _rustup
-		vinstall rustup.bash 0644 usr/share/bash-completion/completions/ rustup
-		vinstall rustup.fish 0644 usr/share/fish/vendor_completions.d/
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		vcompletion rustup.bash bash
+		vcompletion rustup.fish fish
+		vcompletion rustup.zsh zsh
 	fi
 
 	vdoc README.md

From cd059744d92e99d3e84e2b8773f6eab42db6d77b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:58:48 -0300
Subject: [PATCH 4/4] starship: simplify completion generation.

Use qemu build_helper and vcompletion.
---
 srcpkgs/starship/template | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/starship/template b/srcpkgs/starship/template
index b792560ff46..eb285022859 100644
--- a/srcpkgs/starship/template
+++ b/srcpkgs/starship/template
@@ -3,7 +3,7 @@ pkgname=starship
 version=0.44.0
 revision=1
 build_style=cargo
-build_helper="rust"
+build_helper=qemu
 hostmakedepends="pkg-config"
 makedepends="libgit2-devel"
 checkdepends="git"
@@ -14,9 +14,12 @@ homepage="https://starship.rs"
 distfiles="https://github.com/starship/starship/archive/v${version}.tar.gz"
 checksum=b002fa0e2b34ad59330a543461a51648751db4ae8d439d58065a3b9656772fe3
 
-if [ "$CROSS_BUILD" ]; then
-	hostmakedepends+=" qemu-user-static"
-fi
+post_build() {
+	STARSHIP="target/${RUST_TARGET}/release/starship"
+	vtargetrun ${STARSHIP} completions zsh  >starship.zsh
+	vtargetrun ${STARSHIP} completions bash >starship.bash
+	vtargetrun ${STARSHIP} completions fish >starship.fish
+}
 
 pre_check() {
 	[ -L target/debug ] && unlink target/debug
@@ -24,19 +27,9 @@ pre_check() {
 }
 
 post_install() {
-	STARSHIP="target/${RUST_TARGET}/release/starship"
-	if [ "$CROSS_BUILD" ]; then
-		export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-		STARSHIP="/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static ${STARSHIP}"
-	fi
-
-	${STARSHIP} completions zsh  >starship.zsh
-	${STARSHIP} completions bash >starship.bash
-	${STARSHIP} completions fish >starship.fish
-
-	vinstall starship.zsh 0644 usr/share/zsh/site-functions/ _starship
-	vinstall starship.bash 0644 usr/share/bash-completion/completions/ starship
-	vinstall starship.fish 0644 usr/share/fish/vendor_completions.d/
+	vcompletion starship.bash bash
+	vcompletion starship.fish fish
+	vcompletion starship.zsh zsh
 
 	vlicense LICENSE
 }

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

* Re: [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (3 preceding siblings ...)
  2020-07-20  3:36 ` [PR PATCH] [Updated] " ericonr
@ 2020-07-20  4:04 ` ericonr
  2020-07-20  4:45 ` ericonr
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-20  4:04 UTC (permalink / raw)
  To: ml

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

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

https://github.com/ericonr/void-packages rustup
https://github.com/void-linux/void-packages/pull/22785

Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
Inspired by #22761 . Pinging @sgn 

Not revbumping because I don't think it's urgent. I could see the case for making this procedure part of the cargo build style, configurable with some variable like `clap_completions=yes`.

If you feel it adds too much complexity for little gain, I can close the PR.

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

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

From f81c02661b7e0d20a768b7058a73ebf8dec61a07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:45:12 -0300
Subject: [PATCH 1/4] common/environment/setup/install.sh: add vcompletion.

Install function for installing shell completions in the appropriate
place according to the shell used.
---
 Manual.md                           |  7 +++++++
 common/environment/setup/install.sh | 30 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index 5b49dc5ddd4..a2e43334b9d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -337,6 +337,13 @@ The following functions are defined by `xbps-src` and can be used on any templat
 	Note that vsed will call the sed command for every regex specified against
 	every file specified, in the order that they are given.
 
+- *vcompletion()* `<file> <shell> [<command>]`
+
+	Installs shell completion from `file` for `command`, in the correct location
+	and with the appropriate filename for `shell`. If `command` isn't specified,
+	it will default to `pkgname`. The `shell` argument can be one of `bash`,
+	`fish` or `zsh`.
+
 > Shell wildcards must be properly quoted, Example: `vmove "usr/lib/*.a"`.
 
 <a id="global_vars"></a>
diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh
index f9a1ace90e7..742f13075f8 100644
--- a/common/environment/setup/install.sh
+++ b/common/environment/setup/install.sh
@@ -13,7 +13,7 @@ _noglob_helper() {
 }
 
 # Apply _noglob to v* commands
-for cmd in vinstall vcopy vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
+for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -258,3 +258,31 @@ _vmkdir() {
 		install -dm${mode} ${_destdir}/${dir}
 	fi
 }
+
+_vcompletion() {
+	local file="$1" shell="$2" cmd="${3:-${pkgname}}"
+	local _bash_completion_dir=usr/share/bash-completion/completions/
+	local _fish_completion_dir=usr/share/fish/vendor_completions.d/
+	local _zsh_completion_dir=usr/share/zsh/site-functions/
+
+	if [ -z "$DESTDIR" ]; then
+		msg_red "$pkgver: vcompletion: DESTDIR unset, can't continue...\n"
+		return 1
+	fi
+
+	if [ $# -lt 2 ]; then
+		msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
+		return 1
+	fi
+
+	if ! [ -f "$file" ]; then
+		msg_red "$pkgver: vcompletion: file $file doesn't exist\n"
+	fi
+
+	case "$shell" in
+		bash) vinstall "$file" 0644 $_bash_completion_dir "${cmd}" ;;
+		fish) vinstall "$file" 0644 $_fish_completion_dir "${cmd}.fish" ;;
+		zsh) vinstall "$file" 0644 $_zsh_completion_dir "_${cmd}" ;;
+		*) msg_red "$pkgver: vcompletion: unknown shell ${shell}" ;;
+	esac
+}

From 7be5f954ea76860ac7af71c7e63945c5cf5f511d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 19:00:05 -0300
Subject: [PATCH 2/4] common/build-helper/qemu.sh: add vtargetrun function.

It's a function to call the qemu executable for the target arch, or a
noop if the build isn't a cross build.
---
 Manual.md                   | 4 +++-
 common/build-helper/qemu.sh | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index a2e43334b9d..9ab6ccecedb 100644
--- a/Manual.md
+++ b/Manual.md
@@ -970,7 +970,9 @@ additional paths to be searched when linking target binaries to be introspected.
 - `qemu` sets additional variables for the `cmake` and `meson` build styles to allow
 executing cross-compiled binaries inside qemu.
 It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson
-to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`
+to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`.
+It also creates the `vtargetrun` function to call the target architecture
+`qemu-<arch>-static` executable.
 
 - `qmake` creates the `qt.conf` configuration file (cf. `qmake` `build_style`)
 needed for cross builds and a qmake-wrapper to make `qmake` use this configuration.
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index f7a1839cc3e..d6a4342f5e8 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -4,3 +4,11 @@ if [ "$CROSS_BUILD" ]; then
 		hostmakedepends+=" qemu-user-static"
 	fi
 fi
+
+vtargetrun() {
+	if [ "$CROSS_BUILD" ]; then
+		"/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static" "$@"
+	else
+		"$@"
+	fi
+}

From 4f90fac6bbf5776c867b60814276030de49a9f54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 11 Jun 2020 00:38:11 -0300
Subject: [PATCH 3/4] rustup: add completions for all archs.

Use qemu build_helper and vcompletion.

Completion generation is broken for armv6l-musl due to rustup not
knowing about the architecture.
---
 srcpkgs/rustup/template | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/rustup/template b/srcpkgs/rustup/template
index 3cf8ccf6b78..6472ae1f10c 100644
--- a/srcpkgs/rustup/template
+++ b/srcpkgs/rustup/template
@@ -1,8 +1,9 @@
 # Template file for 'rustup'
 pkgname=rustup
 version=1.22.1
-revision=1
+revision=2
 build_style=cargo
+build_helper=qemu
 configure_args="--features no-self-update --bin rustup-init"
 hostmakedepends="pkg-config"
 makedepends="libressl-devel zlib-devel libcurl-devel"
@@ -13,19 +14,25 @@ homepage="https://www.rustup.rs"
 distfiles="https://github.com/rust-lang/${pkgname}/archive/${version}.tar.gz"
 checksum=ad46cc624f318a9493aa62fc9612a450564fe20ba93c689e0ad856bff3c64c5b
 
+post_build() {
+	# rustup errors out because it doesn't know about armv6l-musl
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		RUSTUP="target/${RUST_TARGET}/release/rustup-init"
+		ln -sf "$RUSTUP" rustup
+		# generate shell completions
+		vtargetrun ./rustup completions zsh >rustup.zsh
+		vtargetrun ./rustup completions bash >rustup.bash
+		vtargetrun ./rustup completions fish >rustup.fish
+	fi
+}
+
 do_install() {
 	vbin target/${RUST_TARGET}/release/rustup-init
 
-	if ! [ "$CROSS_BUILD" ]; then
-		# generate shell completions
-		ln -s target/${RUST_TARGET}/release/rustup-init rustup
-		./rustup completions zsh > rustup.zsh
-		./rustup completions bash > rustup.bash
-		./rustup completions fish > rustup.fish
-
-		vinstall rustup.zsh 0644 usr/share/zsh/site-functions/ _rustup
-		vinstall rustup.bash 0644 usr/share/bash-completion/completions/ rustup
-		vinstall rustup.fish 0644 usr/share/fish/vendor_completions.d/
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		vcompletion rustup.bash bash
+		vcompletion rustup.fish fish
+		vcompletion rustup.zsh zsh
 	fi
 
 	vdoc README.md

From 4663597903a4e27ec34bd95e06cab527b6a01593 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:58:48 -0300
Subject: [PATCH 4/4] starship: simplify completion generation.

Use qemu build_helper and vcompletion.
---
 srcpkgs/starship/template | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/starship/template b/srcpkgs/starship/template
index b792560ff46..eb285022859 100644
--- a/srcpkgs/starship/template
+++ b/srcpkgs/starship/template
@@ -3,7 +3,7 @@ pkgname=starship
 version=0.44.0
 revision=1
 build_style=cargo
-build_helper="rust"
+build_helper=qemu
 hostmakedepends="pkg-config"
 makedepends="libgit2-devel"
 checkdepends="git"
@@ -14,9 +14,12 @@ homepage="https://starship.rs"
 distfiles="https://github.com/starship/starship/archive/v${version}.tar.gz"
 checksum=b002fa0e2b34ad59330a543461a51648751db4ae8d439d58065a3b9656772fe3
 
-if [ "$CROSS_BUILD" ]; then
-	hostmakedepends+=" qemu-user-static"
-fi
+post_build() {
+	STARSHIP="target/${RUST_TARGET}/release/starship"
+	vtargetrun ${STARSHIP} completions zsh  >starship.zsh
+	vtargetrun ${STARSHIP} completions bash >starship.bash
+	vtargetrun ${STARSHIP} completions fish >starship.fish
+}
 
 pre_check() {
 	[ -L target/debug ] && unlink target/debug
@@ -24,19 +27,9 @@ pre_check() {
 }
 
 post_install() {
-	STARSHIP="target/${RUST_TARGET}/release/starship"
-	if [ "$CROSS_BUILD" ]; then
-		export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-		STARSHIP="/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static ${STARSHIP}"
-	fi
-
-	${STARSHIP} completions zsh  >starship.zsh
-	${STARSHIP} completions bash >starship.bash
-	${STARSHIP} completions fish >starship.fish
-
-	vinstall starship.zsh 0644 usr/share/zsh/site-functions/ _starship
-	vinstall starship.bash 0644 usr/share/bash-completion/completions/ starship
-	vinstall starship.fish 0644 usr/share/fish/vendor_completions.d/
+	vcompletion starship.bash bash
+	vcompletion starship.fish fish
+	vcompletion starship.zsh zsh
 
 	vlicense LICENSE
 }

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

* Re: Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (4 preceding siblings ...)
  2020-07-20  4:04 ` ericonr
@ 2020-07-20  4:45 ` ericonr
  2020-07-20  5:22 ` [PR REVIEW] " fosslinux
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-20  4:45 UTC (permalink / raw)
  To: ml

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

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#issuecomment-660798860

Comment:
@sgn, @Chocimier would you mind doing a final review?

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (5 preceding siblings ...)
  2020-07-20  4:45 ` ericonr
@ 2020-07-20  5:22 ` fosslinux
  2020-07-20  5:22 ` fosslinux
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: fosslinux @ 2020-07-20  5:22 UTC (permalink / raw)
  To: ml

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

New review comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457058777

Comment:
Nitpicks: the target architecture -> the target architecture's?

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (6 preceding siblings ...)
  2020-07-20  5:22 ` [PR REVIEW] " fosslinux
@ 2020-07-20  5:22 ` fosslinux
  2020-07-20 13:52 ` ericonr
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: fosslinux @ 2020-07-20  5:22 UTC (permalink / raw)
  To: ml

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

New review comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457061457

Comment:
I *think* there are a bunch more than just armv6l-musl. Going off https://forge.rust-lang.org/release/platform-support.html:

- armv5tel
- armv5tel-musl
- armv7l-musl (??)
- aarch64-musl (??)
- i686-musl
- mips* (we don't have glibc variants for mips)

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (7 preceding siblings ...)
  2020-07-20  5:22 ` fosslinux
@ 2020-07-20 13:52 ` ericonr
  2020-07-20 15:26 ` ahesford
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-20 13:52 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457404156

Comment:
So, the problem here is that `rustup` doesn't even know that `armv6l-musl` exists, so it errors out with a rather cryptic error. For the others, we might not have upstream binaries, but `rustup` knows about them and can work normally. I can try to build it for mips / armv5 to check those too.

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (8 preceding siblings ...)
  2020-07-20 13:52 ` ericonr
@ 2020-07-20 15:26 ` ahesford
  2020-07-20 15:46 ` ahesford
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ahesford @ 2020-07-20 15:26 UTC (permalink / raw)
  To: ml

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

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457492998

Comment:
I wouldn't go too crazy here. If you try building for archs that don't have binary packages, you are going to go crazy building a bunch of stuff just to get to the point where you can test your package. The main idea should be to prevent issues with trying to build official binary packages. If somebody wants to try building rustup for mips, let the user with the problem get involved with resolving any problems that shake out.

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (9 preceding siblings ...)
  2020-07-20 15:26 ` ahesford
@ 2020-07-20 15:46 ` ahesford
  2020-07-20 18:51 ` [PR PATCH] [Updated] " ericonr
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ahesford @ 2020-07-20 15:46 UTC (permalink / raw)
  To: ml

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

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457509914

Comment:
 If we're going to reword, "[...] function to call the `qemu-<arch>-static` executable for the target architecture." Possessive inanimate objects are weird.

Or maybe better, "[...] function to wrap commands in a call to `qemu-<arch>-static` for the the target architecture."

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

* Re: [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (10 preceding siblings ...)
  2020-07-20 15:46 ` ahesford
@ 2020-07-20 18:51 ` ericonr
  2020-07-20 19:06 ` [PR REVIEW] " ahesford
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-20 18:51 UTC (permalink / raw)
  To: ml

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

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

https://github.com/ericonr/void-packages rustup
https://github.com/void-linux/void-packages/pull/22785

Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
Inspired by #22761 . Pinging @sgn 

Not revbumping because I don't think it's urgent. I could see the case for making this procedure part of the cargo build style, configurable with some variable like `clap_completions=yes`.

If you feel it adds too much complexity for little gain, I can close the PR.

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

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

From f81c02661b7e0d20a768b7058a73ebf8dec61a07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:45:12 -0300
Subject: [PATCH 1/4] common/environment/setup/install.sh: add vcompletion.

Install function for installing shell completions in the appropriate
place according to the shell used.
---
 Manual.md                           |  7 +++++++
 common/environment/setup/install.sh | 30 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index 5b49dc5ddd4..a2e43334b9d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -337,6 +337,13 @@ The following functions are defined by `xbps-src` and can be used on any templat
 	Note that vsed will call the sed command for every regex specified against
 	every file specified, in the order that they are given.
 
+- *vcompletion()* `<file> <shell> [<command>]`
+
+	Installs shell completion from `file` for `command`, in the correct location
+	and with the appropriate filename for `shell`. If `command` isn't specified,
+	it will default to `pkgname`. The `shell` argument can be one of `bash`,
+	`fish` or `zsh`.
+
 > Shell wildcards must be properly quoted, Example: `vmove "usr/lib/*.a"`.
 
 <a id="global_vars"></a>
diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh
index f9a1ace90e7..742f13075f8 100644
--- a/common/environment/setup/install.sh
+++ b/common/environment/setup/install.sh
@@ -13,7 +13,7 @@ _noglob_helper() {
 }
 
 # Apply _noglob to v* commands
-for cmd in vinstall vcopy vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
+for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -258,3 +258,31 @@ _vmkdir() {
 		install -dm${mode} ${_destdir}/${dir}
 	fi
 }
+
+_vcompletion() {
+	local file="$1" shell="$2" cmd="${3:-${pkgname}}"
+	local _bash_completion_dir=usr/share/bash-completion/completions/
+	local _fish_completion_dir=usr/share/fish/vendor_completions.d/
+	local _zsh_completion_dir=usr/share/zsh/site-functions/
+
+	if [ -z "$DESTDIR" ]; then
+		msg_red "$pkgver: vcompletion: DESTDIR unset, can't continue...\n"
+		return 1
+	fi
+
+	if [ $# -lt 2 ]; then
+		msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
+		return 1
+	fi
+
+	if ! [ -f "$file" ]; then
+		msg_red "$pkgver: vcompletion: file $file doesn't exist\n"
+	fi
+
+	case "$shell" in
+		bash) vinstall "$file" 0644 $_bash_completion_dir "${cmd}" ;;
+		fish) vinstall "$file" 0644 $_fish_completion_dir "${cmd}.fish" ;;
+		zsh) vinstall "$file" 0644 $_zsh_completion_dir "_${cmd}" ;;
+		*) msg_red "$pkgver: vcompletion: unknown shell ${shell}" ;;
+	esac
+}

From 6f1cc9e89791fbfb028dece9e0776f107f74a3a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 19:00:05 -0300
Subject: [PATCH 2/4] common/build-helper/qemu.sh: add vtargetrun function.

It's a function to call the qemu executable for the target arch, or a
noop if the build isn't a cross build.
---
 Manual.md                   | 4 +++-
 common/build-helper/qemu.sh | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index a2e43334b9d..be28d89e566 100644
--- a/Manual.md
+++ b/Manual.md
@@ -970,7 +970,9 @@ additional paths to be searched when linking target binaries to be introspected.
 - `qemu` sets additional variables for the `cmake` and `meson` build styles to allow
 executing cross-compiled binaries inside qemu.
 It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson
-to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`
+to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`.
+It also creates the `vtargetrun` function to wrap commands in a call to
+`qemu-<target_arch>-static` for the target architecture.
 
 - `qmake` creates the `qt.conf` configuration file (cf. `qmake` `build_style`)
 needed for cross builds and a qmake-wrapper to make `qmake` use this configuration.
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index f7a1839cc3e..d6a4342f5e8 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -4,3 +4,11 @@ if [ "$CROSS_BUILD" ]; then
 		hostmakedepends+=" qemu-user-static"
 	fi
 fi
+
+vtargetrun() {
+	if [ "$CROSS_BUILD" ]; then
+		"/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static" "$@"
+	else
+		"$@"
+	fi
+}

From dbd3b366389028f64be0e1a80bbd48bbd139158c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 11 Jun 2020 00:38:11 -0300
Subject: [PATCH 3/4] rustup: add completions for all archs.

Use qemu build_helper and vcompletion.

Completion generation is broken for armv6l-musl due to rustup not
knowing about the architecture.
---
 srcpkgs/rustup/template | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/rustup/template b/srcpkgs/rustup/template
index 3cf8ccf6b78..6472ae1f10c 100644
--- a/srcpkgs/rustup/template
+++ b/srcpkgs/rustup/template
@@ -1,8 +1,9 @@
 # Template file for 'rustup'
 pkgname=rustup
 version=1.22.1
-revision=1
+revision=2
 build_style=cargo
+build_helper=qemu
 configure_args="--features no-self-update --bin rustup-init"
 hostmakedepends="pkg-config"
 makedepends="libressl-devel zlib-devel libcurl-devel"
@@ -13,19 +14,25 @@ homepage="https://www.rustup.rs"
 distfiles="https://github.com/rust-lang/${pkgname}/archive/${version}.tar.gz"
 checksum=ad46cc624f318a9493aa62fc9612a450564fe20ba93c689e0ad856bff3c64c5b
 
+post_build() {
+	# rustup errors out because it doesn't know about armv6l-musl
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		RUSTUP="target/${RUST_TARGET}/release/rustup-init"
+		ln -sf "$RUSTUP" rustup
+		# generate shell completions
+		vtargetrun ./rustup completions zsh >rustup.zsh
+		vtargetrun ./rustup completions bash >rustup.bash
+		vtargetrun ./rustup completions fish >rustup.fish
+	fi
+}
+
 do_install() {
 	vbin target/${RUST_TARGET}/release/rustup-init
 
-	if ! [ "$CROSS_BUILD" ]; then
-		# generate shell completions
-		ln -s target/${RUST_TARGET}/release/rustup-init rustup
-		./rustup completions zsh > rustup.zsh
-		./rustup completions bash > rustup.bash
-		./rustup completions fish > rustup.fish
-
-		vinstall rustup.zsh 0644 usr/share/zsh/site-functions/ _rustup
-		vinstall rustup.bash 0644 usr/share/bash-completion/completions/ rustup
-		vinstall rustup.fish 0644 usr/share/fish/vendor_completions.d/
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		vcompletion rustup.bash bash
+		vcompletion rustup.fish fish
+		vcompletion rustup.zsh zsh
 	fi
 
 	vdoc README.md

From 2233e7ed8980b271512958cb9bf8afbe587c0187 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:58:48 -0300
Subject: [PATCH 4/4] starship: simplify completion generation.

Use qemu build_helper and vcompletion.
---
 srcpkgs/starship/template | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/starship/template b/srcpkgs/starship/template
index b792560ff46..eb285022859 100644
--- a/srcpkgs/starship/template
+++ b/srcpkgs/starship/template
@@ -3,7 +3,7 @@ pkgname=starship
 version=0.44.0
 revision=1
 build_style=cargo
-build_helper="rust"
+build_helper=qemu
 hostmakedepends="pkg-config"
 makedepends="libgit2-devel"
 checkdepends="git"
@@ -14,9 +14,12 @@ homepage="https://starship.rs"
 distfiles="https://github.com/starship/starship/archive/v${version}.tar.gz"
 checksum=b002fa0e2b34ad59330a543461a51648751db4ae8d439d58065a3b9656772fe3
 
-if [ "$CROSS_BUILD" ]; then
-	hostmakedepends+=" qemu-user-static"
-fi
+post_build() {
+	STARSHIP="target/${RUST_TARGET}/release/starship"
+	vtargetrun ${STARSHIP} completions zsh  >starship.zsh
+	vtargetrun ${STARSHIP} completions bash >starship.bash
+	vtargetrun ${STARSHIP} completions fish >starship.fish
+}
 
 pre_check() {
 	[ -L target/debug ] && unlink target/debug
@@ -24,19 +27,9 @@ pre_check() {
 }
 
 post_install() {
-	STARSHIP="target/${RUST_TARGET}/release/starship"
-	if [ "$CROSS_BUILD" ]; then
-		export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-		STARSHIP="/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static ${STARSHIP}"
-	fi
-
-	${STARSHIP} completions zsh  >starship.zsh
-	${STARSHIP} completions bash >starship.bash
-	${STARSHIP} completions fish >starship.fish
-
-	vinstall starship.zsh 0644 usr/share/zsh/site-functions/ _starship
-	vinstall starship.bash 0644 usr/share/bash-completion/completions/ starship
-	vinstall starship.fish 0644 usr/share/fish/vendor_completions.d/
+	vcompletion starship.bash bash
+	vcompletion starship.fish fish
+	vcompletion starship.zsh zsh
 
 	vlicense LICENSE
 }

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (11 preceding siblings ...)
  2020-07-20 18:51 ` [PR PATCH] [Updated] " ericonr
@ 2020-07-20 19:06 ` ahesford
  2020-07-20 19:12 ` ericonr
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ahesford @ 2020-07-20 19:06 UTC (permalink / raw)
  To: ml

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

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457629853

Comment:
Does this really not require the rust build helper? You can specify more than one.

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (12 preceding siblings ...)
  2020-07-20 19:06 ` [PR REVIEW] " ahesford
@ 2020-07-20 19:12 ` ericonr
  2020-07-21  2:09 ` fosslinux
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-20 19:12 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457632778

Comment:
It's added by the cargo build style, so it doesn't need to be repeated.

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

* Re: [PR REVIEW] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (13 preceding siblings ...)
  2020-07-20 19:12 ` ericonr
@ 2020-07-21  2:09 ` fosslinux
  2020-07-28  2:43 ` [PR PATCH] [Updated] " ericonr
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: fosslinux @ 2020-07-21  2:09 UTC (permalink / raw)
  To: ml

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

New review comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#discussion_r457793477

Comment:
Fair enough, both good points

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

* Re: [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (14 preceding siblings ...)
  2020-07-21  2:09 ` fosslinux
@ 2020-07-28  2:43 ` ericonr
  2020-07-28  2:51 ` ericonr
  2020-07-28  4:24 ` [PR PATCH] [Merged]: " sgn
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-28  2:43 UTC (permalink / raw)
  To: ml

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

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

https://github.com/ericonr/void-packages rustup
https://github.com/void-linux/void-packages/pull/22785

Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
Inspired by #22761 . Pinging @sgn 

Not revbumping because I don't think it's urgent. I could see the case for making this procedure part of the cargo build style, configurable with some variable like `clap_completions=yes`.

If you feel it adds too much complexity for little gain, I can close the PR.

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

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

From bd3f8f5d8f99c4aa3e9f6bc0e7606344ffd1dfb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:45:12 -0300
Subject: [PATCH 1/4] common/environment/setup/install.sh: add vcompletion.

Install function for installing shell completions in the appropriate
place according to the shell used.
---
 Manual.md                           |  7 +++++++
 common/environment/setup/install.sh | 30 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index 5b49dc5ddd4..a2e43334b9d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -337,6 +337,13 @@ The following functions are defined by `xbps-src` and can be used on any templat
 	Note that vsed will call the sed command for every regex specified against
 	every file specified, in the order that they are given.
 
+- *vcompletion()* `<file> <shell> [<command>]`
+
+	Installs shell completion from `file` for `command`, in the correct location
+	and with the appropriate filename for `shell`. If `command` isn't specified,
+	it will default to `pkgname`. The `shell` argument can be one of `bash`,
+	`fish` or `zsh`.
+
 > Shell wildcards must be properly quoted, Example: `vmove "usr/lib/*.a"`.
 
 <a id="global_vars"></a>
diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh
index f9a1ace90e7..742f13075f8 100644
--- a/common/environment/setup/install.sh
+++ b/common/environment/setup/install.sh
@@ -13,7 +13,7 @@ _noglob_helper() {
 }
 
 # Apply _noglob to v* commands
-for cmd in vinstall vcopy vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
+for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -258,3 +258,31 @@ _vmkdir() {
 		install -dm${mode} ${_destdir}/${dir}
 	fi
 }
+
+_vcompletion() {
+	local file="$1" shell="$2" cmd="${3:-${pkgname}}"
+	local _bash_completion_dir=usr/share/bash-completion/completions/
+	local _fish_completion_dir=usr/share/fish/vendor_completions.d/
+	local _zsh_completion_dir=usr/share/zsh/site-functions/
+
+	if [ -z "$DESTDIR" ]; then
+		msg_red "$pkgver: vcompletion: DESTDIR unset, can't continue...\n"
+		return 1
+	fi
+
+	if [ $# -lt 2 ]; then
+		msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
+		return 1
+	fi
+
+	if ! [ -f "$file" ]; then
+		msg_red "$pkgver: vcompletion: file $file doesn't exist\n"
+	fi
+
+	case "$shell" in
+		bash) vinstall "$file" 0644 $_bash_completion_dir "${cmd}" ;;
+		fish) vinstall "$file" 0644 $_fish_completion_dir "${cmd}.fish" ;;
+		zsh) vinstall "$file" 0644 $_zsh_completion_dir "_${cmd}" ;;
+		*) msg_red "$pkgver: vcompletion: unknown shell ${shell}" ;;
+	esac
+}

From 727d913eb50c5bb7ddb0fb6205fdab6b8d74e0b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 19:00:05 -0300
Subject: [PATCH 2/4] common/build-helper/qemu.sh: add vtargetrun function.

It's a function to call the qemu executable for the target arch, or a
noop if the build isn't a cross build.
---
 Manual.md                   | 4 +++-
 common/build-helper/qemu.sh | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index a2e43334b9d..be28d89e566 100644
--- a/Manual.md
+++ b/Manual.md
@@ -970,7 +970,9 @@ additional paths to be searched when linking target binaries to be introspected.
 - `qemu` sets additional variables for the `cmake` and `meson` build styles to allow
 executing cross-compiled binaries inside qemu.
 It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson
-to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`
+to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`.
+It also creates the `vtargetrun` function to wrap commands in a call to
+`qemu-<target_arch>-static` for the target architecture.
 
 - `qmake` creates the `qt.conf` configuration file (cf. `qmake` `build_style`)
 needed for cross builds and a qmake-wrapper to make `qmake` use this configuration.
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index f7a1839cc3e..d6a4342f5e8 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -4,3 +4,11 @@ if [ "$CROSS_BUILD" ]; then
 		hostmakedepends+=" qemu-user-static"
 	fi
 fi
+
+vtargetrun() {
+	if [ "$CROSS_BUILD" ]; then
+		"/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static" "$@"
+	else
+		"$@"
+	fi
+}

From dd6cdeb006f1752869eb0635c7d84700f3086a97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 11 Jun 2020 00:38:11 -0300
Subject: [PATCH 3/4] rustup: add completions for all archs.

Use qemu build_helper and vcompletion.

Completion generation is broken for armv6l-musl due to rustup not
knowing about the architecture.
---
 srcpkgs/rustup/template | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/rustup/template b/srcpkgs/rustup/template
index 3cf8ccf6b78..6472ae1f10c 100644
--- a/srcpkgs/rustup/template
+++ b/srcpkgs/rustup/template
@@ -1,8 +1,9 @@
 # Template file for 'rustup'
 pkgname=rustup
 version=1.22.1
-revision=1
+revision=2
 build_style=cargo
+build_helper=qemu
 configure_args="--features no-self-update --bin rustup-init"
 hostmakedepends="pkg-config"
 makedepends="libressl-devel zlib-devel libcurl-devel"
@@ -13,19 +14,25 @@ homepage="https://www.rustup.rs"
 distfiles="https://github.com/rust-lang/${pkgname}/archive/${version}.tar.gz"
 checksum=ad46cc624f318a9493aa62fc9612a450564fe20ba93c689e0ad856bff3c64c5b
 
+post_build() {
+	# rustup errors out because it doesn't know about armv6l-musl
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		RUSTUP="target/${RUST_TARGET}/release/rustup-init"
+		ln -sf "$RUSTUP" rustup
+		# generate shell completions
+		vtargetrun ./rustup completions zsh >rustup.zsh
+		vtargetrun ./rustup completions bash >rustup.bash
+		vtargetrun ./rustup completions fish >rustup.fish
+	fi
+}
+
 do_install() {
 	vbin target/${RUST_TARGET}/release/rustup-init
 
-	if ! [ "$CROSS_BUILD" ]; then
-		# generate shell completions
-		ln -s target/${RUST_TARGET}/release/rustup-init rustup
-		./rustup completions zsh > rustup.zsh
-		./rustup completions bash > rustup.bash
-		./rustup completions fish > rustup.fish
-
-		vinstall rustup.zsh 0644 usr/share/zsh/site-functions/ _rustup
-		vinstall rustup.bash 0644 usr/share/bash-completion/completions/ rustup
-		vinstall rustup.fish 0644 usr/share/fish/vendor_completions.d/
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		vcompletion rustup.bash bash
+		vcompletion rustup.fish fish
+		vcompletion rustup.zsh zsh
 	fi
 
 	vdoc README.md

From 18ab51fa1f806349c3f715f17cadd2004b65c72a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:58:48 -0300
Subject: [PATCH 4/4] starship: simplify completion generation.

Use qemu build_helper and vcompletion.
---
 srcpkgs/starship/template | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/starship/template b/srcpkgs/starship/template
index b792560ff46..eb285022859 100644
--- a/srcpkgs/starship/template
+++ b/srcpkgs/starship/template
@@ -3,7 +3,7 @@ pkgname=starship
 version=0.44.0
 revision=1
 build_style=cargo
-build_helper="rust"
+build_helper=qemu
 hostmakedepends="pkg-config"
 makedepends="libgit2-devel"
 checkdepends="git"
@@ -14,9 +14,12 @@ homepage="https://starship.rs"
 distfiles="https://github.com/starship/starship/archive/v${version}.tar.gz"
 checksum=b002fa0e2b34ad59330a543461a51648751db4ae8d439d58065a3b9656772fe3
 
-if [ "$CROSS_BUILD" ]; then
-	hostmakedepends+=" qemu-user-static"
-fi
+post_build() {
+	STARSHIP="target/${RUST_TARGET}/release/starship"
+	vtargetrun ${STARSHIP} completions zsh  >starship.zsh
+	vtargetrun ${STARSHIP} completions bash >starship.bash
+	vtargetrun ${STARSHIP} completions fish >starship.fish
+}
 
 pre_check() {
 	[ -L target/debug ] && unlink target/debug
@@ -24,19 +27,9 @@ pre_check() {
 }
 
 post_install() {
-	STARSHIP="target/${RUST_TARGET}/release/starship"
-	if [ "$CROSS_BUILD" ]; then
-		export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-		STARSHIP="/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static ${STARSHIP}"
-	fi
-
-	${STARSHIP} completions zsh  >starship.zsh
-	${STARSHIP} completions bash >starship.bash
-	${STARSHIP} completions fish >starship.fish
-
-	vinstall starship.zsh 0644 usr/share/zsh/site-functions/ _starship
-	vinstall starship.bash 0644 usr/share/bash-completion/completions/ starship
-	vinstall starship.fish 0644 usr/share/fish/vendor_completions.d/
+	vcompletion starship.bash bash
+	vcompletion starship.fish fish
+	vcompletion starship.zsh zsh
 
 	vlicense LICENSE
 }

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

* Re: Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (15 preceding siblings ...)
  2020-07-28  2:43 ` [PR PATCH] [Updated] " ericonr
@ 2020-07-28  2:51 ` ericonr
  2020-07-28  4:24 ` [PR PATCH] [Merged]: " sgn
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-28  2:51 UTC (permalink / raw)
  To: ml

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

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/22785#issuecomment-664745093

Comment:
Ping? I am waiting on this one in order to update arduino-cli.

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

* Re: [PR PATCH] [Merged]: Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
                   ` (16 preceding siblings ...)
  2020-07-28  2:51 ` ericonr
@ 2020-07-28  4:24 ` sgn
  17 siblings, 0 replies; 18+ messages in thread
From: sgn @ 2020-07-28  4:24 UTC (permalink / raw)
  To: ml

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

There's a merged pull request on the void-packages repository

Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
https://github.com/void-linux/void-packages/pull/22785

Description:
Inspired by #22761 . Pinging @sgn 

Not revbumping because I don't think it's urgent. I could see the case for making this procedure part of the cargo build style, configurable with some variable like `clap_completions=yes`.

If you feel it adds too much complexity for little gain, I can close the PR.

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

* Re: [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
@ 2020-07-08 19:37 ` ericonr
  2020-07-08 19:37 ` ericonr
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: ericonr @ 2020-07-08 19:37 UTC (permalink / raw)
  To: ml

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

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

https://github.com/ericonr/void-packages rustup
https://github.com/void-linux/void-packages/pull/22785

Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions);  use them in rustup and starship
Inspired by #22761 . Pinging @sgn 

Not revbumping because I don't think it's urgent. I could see the case for making this procedure part of the cargo build style, configurable with some variable like `clap_completions=yes`.

If you feel it adds too much complexity for little gain, I can close the PR.

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

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

From 8b866f0a8a4fb5e45881cb239b7178ad68c60c56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:45:12 -0300
Subject: [PATCH 1/4] common/environment/setup/install.sh: add vcompletion.

Install function for installing shell completions in the appropriate
place according to the shell used.
---
 Manual.md                           |  7 +++++++
 common/environment/setup/install.sh | 30 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index 10082b68da5..6bd634f3a7c 100644
--- a/Manual.md
+++ b/Manual.md
@@ -331,6 +331,13 @@ The following functions are defined by `xbps-src` and can be used on any templat
 	Note that vsed will call the sed command for every regex specified against
 	every file specified, in the order that they are given.
 
+- *vcompletion()* `<file> <shell> [<command>]`
+
+	Installs shell completion from `file` for `command`, in the correct location
+	and with the appropriate filename for `shell`. If `command` isn't specified,
+	it will default to `pkgname`. The `shell` argument can be one of `bash`,
+	`fish` or `zsh`.
+
 > Shell wildcards must be properly quoted, Example: `vmove "usr/lib/*.a"`.
 
 <a id="global_vars"></a>
diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh
index f9a1ace90e7..742f13075f8 100644
--- a/common/environment/setup/install.sh
+++ b/common/environment/setup/install.sh
@@ -13,7 +13,7 @@ _noglob_helper() {
 }
 
 # Apply _noglob to v* commands
-for cmd in vinstall vcopy vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
+for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -258,3 +258,31 @@ _vmkdir() {
 		install -dm${mode} ${_destdir}/${dir}
 	fi
 }
+
+_vcompletion() {
+	local file="$1" shell="$2" cmd="${3:-${pkgname}}"
+	local _bash_completion_dir=usr/share/bash-completion/completions/
+	local _fish_completion_dir=usr/share/fish/vendor_completions.d/
+	local _zsh_completion_dir=usr/share/zsh/site-functions/
+
+	if [ -z "$DESTDIR" ]; then
+		msg_red "$pkgver: vcompletion: DESTDIR unset, can't continue...\n"
+		return 1
+	fi
+
+	if [ $# -lt 2 ]; then
+		msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
+		return 1
+	fi
+
+	if ! [ -f "$file" ]; then
+		msg_red "$pkgver: vcompletion: file $file doesn't exist\n"
+	fi
+
+	case "$shell" in
+		bash) vinstall "$file" 0644 $_bash_completion_dir "${cmd}" ;;
+		fish) vinstall "$file" 0644 $_fish_completion_dir "${cmd}.fish" ;;
+		zsh) vinstall "$file" 0644 $_zsh_completion_dir "_${cmd}" ;;
+		*) msg_red "$pkgver: vcompletion: unknown shell ${shell}" ;;
+	esac
+}

From ed2b5b1e4f71d93a2a87429517ff3bee887ffb08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 19:00:05 -0300
Subject: [PATCH 2/4] common/build-helper/qemu.sh: add vtargetrun function.

It's a function to call the qemu executable for the target arch, or a
noop if the build isn't a cross build.
---
 Manual.md                   | 4 +++-
 common/build-helper/qemu.sh | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Manual.md b/Manual.md
index 6bd634f3a7c..bd4dcb054a7 100644
--- a/Manual.md
+++ b/Manual.md
@@ -961,7 +961,9 @@ additional paths to be searched when linking target binaries to be introspected.
 - `qemu` sets additional variables for the `cmake` and `meson` build styles to allow
 executing cross-compiled binaries inside qemu.
 It sets `CMAKE_CROSSCOMPILING_EMULATOR` for cmake and `exe_wrapper` for meson
-to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`
+to `qemu-<target_arch>-static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`.
+It also creates the `vtargetrun` function to call the target architecture
+`qemu-<arch>-static` executable.
 
 - `qmake` creates the `qt.conf` configuration file (cf. `qmake` `build_style`)
 needed for cross builds and a qmake-wrapper to make `qmake` use this configuration.
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index f7a1839cc3e..d6a4342f5e8 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -4,3 +4,11 @@ if [ "$CROSS_BUILD" ]; then
 		hostmakedepends+=" qemu-user-static"
 	fi
 fi
+
+vtargetrun() {
+	if [ "$CROSS_BUILD" ]; then
+		"/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static" "$@"
+	else
+		"$@"
+	fi
+}

From e5408bf64b93cbc6a8f3e203c885fa2baa87a2ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 11 Jun 2020 00:38:11 -0300
Subject: [PATCH 3/4] rustup: add completions for all archs.

Use qemu build_helper and vcompletion.

Completion generation is broken for armv6l-musl due to rustup not
knowing about the architecture.
---
 srcpkgs/rustup/template | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/srcpkgs/rustup/template b/srcpkgs/rustup/template
index 96b4bee6c63..41447593b6d 100644
--- a/srcpkgs/rustup/template
+++ b/srcpkgs/rustup/template
@@ -3,6 +3,7 @@ pkgname=rustup
 version=1.22.0
 revision=1
 build_style=cargo
+build_helper=qemu
 configure_args="--features no-self-update --bin rustup-init"
 hostmakedepends="pkg-config"
 makedepends="libressl-devel zlib-devel libcurl-devel"
@@ -13,19 +14,25 @@ homepage="https://www.rustup.rs"
 distfiles="https://github.com/rust-lang/${pkgname}/archive/${version}.tar.gz"
 checksum=1810c0b12f32d85cd0302c1cc73b88893fb8aa7f20ec22cb4bf53ed25bb130fe
 
+post_build() {
+	# rustup errors out because it doesn't know about armv6l-musl
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		RUSTUP="target/${RUST_TARGET}/release/rustup-init"
+		ln -sf "$RUSTUP" rustup
+		# generate shell completions
+		vtargetrun ./rustup completions zsh >rustup.zsh
+		vtargetrun ./rustup completions bash >rustup.bash
+		vtargetrun ./rustup completions fish >rustup.fish
+	fi
+}
+
 do_install() {
 	vbin target/${RUST_TARGET}/release/rustup-init
 
-	if ! [ "$CROSS_BUILD" ]; then
-		# generate shell completions
-		ln -s target/${RUST_TARGET}/release/rustup-init rustup
-		./rustup completions zsh > rustup.zsh
-		./rustup completions bash > rustup.bash
-		./rustup completions fish > rustup.fish
-
-		vinstall rustup.zsh 0644 usr/share/zsh/site-functions/ _rustup
-		vinstall rustup.bash 0644 usr/share/bash-completion/completions/ rustup
-		vinstall rustup.fish 0644 usr/share/fish/vendor_completions.d/
+	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
+		vcompletion rustup.bash bash
+		vcompletion rustup.fish fish
+		vcompletion rustup.zsh zsh
 	fi
 
 	vdoc README.md

From 2098b7ca8e0621d30a8e3bf3397f6c33b5ffc543 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Sat, 13 Jun 2020 18:58:48 -0300
Subject: [PATCH 4/4] starship: simplify completion generation.

Use qemu build_helper and vcompletion.
---
 srcpkgs/starship/template | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/starship/template b/srcpkgs/starship/template
index db75c69589e..cc63f8730d2 100644
--- a/srcpkgs/starship/template
+++ b/srcpkgs/starship/template
@@ -3,7 +3,7 @@ pkgname=starship
 version=0.42.0
 revision=2
 build_style=cargo
-build_helper="rust"
+build_helper=qemu
 hostmakedepends="pkg-config"
 makedepends="libgit2-devel"
 checkdepends="git"
@@ -14,9 +14,12 @@ homepage="https://starship.rs"
 distfiles="https://github.com/starship/starship/archive/v${version}.tar.gz"
 checksum=cf7b5848949bc1e61dc771ef2a429e4ccb8d339e1ca705bdf521fc4a4fc96309
 
-if [ "$CROSS_BUILD" ]; then
-	hostmakedepends+=" qemu-user-static"
-fi
+post_build() {
+	STARSHIP="target/${RUST_TARGET}/release/starship"
+	vtargetrun ${STARSHIP} completions zsh  >starship.zsh
+	vtargetrun ${STARSHIP} completions bash >starship.bash
+	vtargetrun ${STARSHIP} completions fish >starship.fish
+}
 
 pre_check() {
 	[ -L target/debug ] && unlink target/debug
@@ -24,19 +27,9 @@ pre_check() {
 }
 
 post_install() {
-	STARSHIP="target/${RUST_TARGET}/release/starship"
-	if [ "$CROSS_BUILD" ]; then
-		export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-		STARSHIP="/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static ${STARSHIP}"
-	fi
-
-	${STARSHIP} completions zsh  >starship.zsh
-	${STARSHIP} completions bash >starship.bash
-	${STARSHIP} completions fish >starship.fish
-
-	vinstall starship.zsh 0644 usr/share/zsh/site-functions/ _starship
-	vinstall starship.bash 0644 usr/share/bash-completion/completions/ starship
-	vinstall starship.fish 0644 usr/share/fish/vendor_completions.d/
+	vcompletion starship.bash bash
+	vcompletion starship.fish fish
+	vcompletion starship.zsh zsh
 
 	vlicense LICENSE
 }

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

end of thread, other threads:[~2020-07-28  4:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
2020-07-08 19:37 ` [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions); use them in rustup and starship ericonr
2020-07-08 19:37 ` ericonr
2020-07-08 22:17 ` jcgruenhage
2020-07-20  3:36 ` [PR PATCH] [Updated] " ericonr
2020-07-20  4:04 ` ericonr
2020-07-20  4:45 ` ericonr
2020-07-20  5:22 ` [PR REVIEW] " fosslinux
2020-07-20  5:22 ` fosslinux
2020-07-20 13:52 ` ericonr
2020-07-20 15:26 ` ahesford
2020-07-20 15:46 ` ahesford
2020-07-20 18:51 ` [PR PATCH] [Updated] " ericonr
2020-07-20 19:06 ` [PR REVIEW] " ahesford
2020-07-20 19:12 ` ericonr
2020-07-21  2:09 ` fosslinux
2020-07-28  2:43 ` [PR PATCH] [Updated] " ericonr
2020-07-28  2:51 ` ericonr
2020-07-28  4:24 ` [PR PATCH] [Merged]: " sgn

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