From f81c02661b7e0d20a768b7058a73ebf8dec61a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= 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()* ` []` + + 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"`. 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: \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?= 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--static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE` +to `qemu--static` and `QEMU_LD_PREFIX` to `XBPS_CROSS_BASE`. +It also creates the `vtargetrun` function to call the target architecture +`qemu--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?= 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?= 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 }