From: ericonr <ericonr@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] Add vtargetrun (run executables with qemu) and vcompletion (install helper for shell completions); use them in rustup and starship
Date: Wed, 08 Jul 2020 21:37:08 +0200 [thread overview]
Message-ID: <20200708193708.cIc9UPPA54Q9u8Rte-P9cfJuvSEVnQAaWnXTky6TSCs@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
[-- 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
}
next parent reply other threads:[~2020-07-08 19:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22785@inbox.vuxu.org>
2020-07-08 19:37 ` ericonr [this message]
2020-07-20 3:36 ` ericonr
2020-07-20 4:04 ` ericonr
2020-07-20 18:51 ` ericonr
2020-07-28 2:43 ` ericonr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200708193708.cIc9UPPA54Q9u8Rte-P9cfJuvSEVnQAaWnXTky6TSCs@z \
--to=ericonr@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).