Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] Add vterminfo template function
@ 2022-10-26 16:47 jbenden
  2022-10-26 16:52 ` [PR PATCH] [Updated] " jbenden
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: jbenden @ 2022-10-26 16:47 UTC (permalink / raw)
  To: ml

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

There is a new pull request by jbenden against master on the void-packages repository

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From 59ab3e1684f3c487935024b78d0b09d5f0979731 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Sun, 24 Apr 2022 10:16:12 -0700
Subject: [PATCH 1/2] New package: wezterm-20220905_1

Fixes: #35721
Signed-off-by: Joseph Benden <joe@benden.us>
---
 srcpkgs/wezterm-terminfo                      |   1 +
 ...4f05eb4de9ed44d2068355a571b117eba0e1.patch | 232 ++++++++++++++++++
 .../wezterm/patches/remove-distro-fonts.patch |  22 ++
 srcpkgs/wezterm/template                      |  68 +++++
 srcpkgs/wezterm/update                        |   2 +
 5 files changed, 325 insertions(+)
 create mode 120000 srcpkgs/wezterm-terminfo
 create mode 100644 srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
 create mode 100644 srcpkgs/wezterm/patches/remove-distro-fonts.patch
 create mode 100644 srcpkgs/wezterm/template
 create mode 100644 srcpkgs/wezterm/update

diff --git a/srcpkgs/wezterm-terminfo b/srcpkgs/wezterm-terminfo
new file mode 120000
index 000000000000..37d60f7b3b71
--- /dev/null
+++ b/srcpkgs/wezterm-terminfo
@@ -0,0 +1 @@
+wezterm
\ No newline at end of file
diff --git a/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
new file mode 100644
index 000000000000..d374a275d235
--- /dev/null
+++ b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
@@ -0,0 +1,232 @@
+From 7b904f05eb4de9ed44d2068355a571b117eba0e1 Mon Sep 17 00:00:00 2001
+From: Wez Furlong <wez@wezfurlong.org>
+Date: Sat, 15 Oct 2022 16:45:02 -0700
+Subject: [PATCH] termwiz: fixup for 32-bit systems
+
+I noticed from https://github.com/void-linux/void-packages/pull/36903
+that 32-bit systems were failing to pass the test suite.
+
+Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
+teeny_string` showed that we were faulting in the teenystring code
+and digging a bit deeper showed that it was because our assumptions
+about the high bits were wrong for 32-bit systems.
+
+Fix this by making TeenyString based around a u64 rather than usize
+so that we guarantee its size on all current systems.
+---
+ Cargo.lock          |  1 -
+ termwiz/Cargo.toml  |  1 -
+ termwiz/src/cell.rs | 87 ++++++++++++++-------------------------------
+ 3 files changed, 26 insertions(+), 63 deletions(-)
+
+diff --git a/Cargo.lock b/Cargo.lock
+index 4f976535be..243e3a2b24 100644
+--- a/Cargo.lock
++++ b/Cargo.lock
+@@ -4739,7 +4739,6 @@ dependencies = [
+  "base64",
+  "bitflags",
+  "cassowary",
+- "cfg-if 1.0.0",
+  "criterion",
+  "env_logger",
+  "filedescriptor",
+diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
+index d8d7ab543c..e843bac261 100644
+--- a/termwiz/Cargo.toml
++++ b/termwiz/Cargo.toml
+@@ -15,7 +15,6 @@ readme = "README.md"
+ base64 = "0.13"
+ bitflags = "1.3"
+ cassowary = {version="0.3", optional=true}
+-cfg-if = "1.0"
+ anyhow = "1.0"
+ filedescriptor = { version="0.8", path = "../filedescriptor" }
+ finl_unicode = "1.1"
+diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs
+index ddf38a93bb..70d6099dd0 100644
+--- a/termwiz/src/cell.rs
++++ b/termwiz/src/cell.rs
+@@ -590,7 +590,7 @@ where
+     s.serialize(serializer)
+ }
+ 
+-/// TeenyString encodes string storage in a single machine word.
++/// TeenyString encodes string storage in a single u64.
+ /// The scheme is simple but effective: strings that encode into a
+ /// byte slice that is 1 less byte than the machine word size can
+ /// be encoded directly into the usize bits stored in the struct.
+@@ -603,60 +603,40 @@ where
+ /// calling grapheme_column_width; if it is set, then the TeenyString
+ /// has length 2, otherwise, it has length 1 (we don't allow zero-length
+ /// strings).
+-struct TeenyString(usize);
++struct TeenyString(u64);
+ struct TeenyStringHeap {
+     bytes: Vec<u8>,
+     width: usize,
+ }
+ 
+ impl TeenyString {
+-    const fn marker_mask() -> usize {
++    const fn marker_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000000
+         } else {
+             0x1
+         }
+     }
+ 
+-    const fn double_wide_mask() -> usize {
++    const fn double_wide_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0xc0000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0xc0000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0xc000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0xc0000000_00000000
+         } else {
+             0x3
+         }
+     }
+ 
+-    const fn is_marker_bit_set(word: usize) -> bool {
++    const fn is_marker_bit_set(word: u64) -> bool {
+         let mask = Self::marker_mask();
+         word & mask == mask
+     }
+ 
+-    const fn is_double_width(word: usize) -> bool {
++    const fn is_double_width(word: u64) -> bool {
+         let mask = Self::double_wide_mask();
+         word & mask == mask
+     }
+ 
+-    const fn set_marker_bit(word: usize, width: usize) -> usize {
++    const fn set_marker_bit(word: u64, width: usize) -> u64 {
+         if width > 1 {
+             word | Self::double_wide_mask()
+         } else {
+@@ -689,18 +669,18 @@ impl TeenyString {
+         let len = bytes.len();
+         let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));
+ 
+-        if len < std::mem::size_of::<usize>() {
++        if len < std::mem::size_of::<u64>() {
+             debug_assert!(width < 3);
+ 
+-            let mut word = 0usize;
++            let mut word = 0u64;
+             unsafe {
+                 std::ptr::copy_nonoverlapping(
+                     bytes.as_ptr(),
+-                    &mut word as *mut usize as *mut u8,
++                    &mut word as *mut u64 as *mut u8,
+                     len,
+                 );
+             }
+-            let word = Self::set_marker_bit(word, width);
++            let word = Self::set_marker_bit(word as u64, width);
+             Self(word)
+         } else {
+             let vec = Box::new(TeenyStringHeap {
+@@ -708,35 +688,15 @@ impl TeenyString {
+                 width,
+             });
+             let ptr = Box::into_raw(vec);
+-            Self(ptr as usize)
++            Self(ptr as u64)
+         }
+     }
+ 
+     pub const fn space() -> Self {
+         Self(if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000020
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000020
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8020
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000020
+         } else {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x20000000_00000001
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x20000001
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x2001
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x20000000_00000001
+         })
+     }
+ 
+@@ -753,7 +713,7 @@ impl TeenyString {
+                 1
+             }
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).width }
+         }
+     }
+@@ -766,17 +726,17 @@ impl TeenyString {
+ 
+     pub fn as_bytes(&self) -> &[u8] {
+         if Self::is_marker_bit_set(self.0) {
+-            let bytes = &self.0 as *const usize as *const u8;
++            let bytes = &self.0 as *const u64 as *const u8;
+             let bytes =
+-                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<usize>() - 1) };
++                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<u64>() - 1) };
+             let len = bytes
+                 .iter()
+                 .position(|&b| b == 0)
+-                .unwrap_or(std::mem::size_of::<usize>() - 1);
++                .unwrap_or(std::mem::size_of::<u64>() - 1);
+ 
+             &bytes[0..len]
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).bytes.as_slice() }
+         }
+     }
+@@ -1072,6 +1032,11 @@ mod test {
+ 
+     #[test]
+     fn teeny_string() {
++        assert!(
++            std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
++            "if a pointer doesn't fit in u64 then we need to change TeenyString"
++        );
++
+         let s = TeenyString::from_char('a');
+         assert_eq!(s.as_bytes(), &[b'a']);
+ 
diff --git a/srcpkgs/wezterm/patches/remove-distro-fonts.patch b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
new file mode 100644
index 000000000000..1d8e21384ae9
--- /dev/null
+++ b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
@@ -0,0 +1,22 @@
+--- a/wezterm-font/src/parser.rs	2022-09-05 10:28:02.000000000 -0700
++++ b/wezterm-font/src/parser.rs	2022-10-24 09:06:02.529054286 -0700
+@@ -715,19 +715,6 @@
+         font!("../../assets/fonts/JetBrainsMono-Regular.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-ThinItalic.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-Black.ttf"),
+-        font!("../../assets/fonts/Roboto-BlackItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Bold.ttf"),
+-        font!("../../assets/fonts/Roboto-BoldItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Italic.ttf"),
+-        font!("../../assets/fonts/Roboto-Light.ttf"),
+-        font!("../../assets/fonts/Roboto-LightItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Medium.ttf"),
+-        font!("../../assets/fonts/Roboto-MediumItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Regular.ttf"),
+-        font!("../../assets/fonts/Roboto-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-ThinItalic.ttf"),
+-        font!("../../assets/fonts/NotoColorEmoji.ttf"),
+         font!("../../assets/fonts/Symbols-Nerd-Font-Mono.ttf"),
+         font!("../../assets/fonts/LastResortHE-Regular.ttf"),
+     ] {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
new file mode 100644
index 000000000000..02ee8a2e90a9
--- /dev/null
+++ b/srcpkgs/wezterm/template
@@ -0,0 +1,68 @@
+# Template file for 'wezterm'
+pkgname=wezterm
+version=20220905
+revision=1
+_srcver=20220905-102802-7d4b8249
+wrksrc="${pkgname}-${_srcver}"
+build_style=cargo
+hostmakedepends="pkg-config"
+makedepends="fontconfig-devel freetype-devel harfbuzz-devel openssl-devel
+ libX11-devel libxkbcommon-devel libxkbcommon-x11 wayland-devel xcb-util-devel
+ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel"
+depends="noto-fonts-emoji fonts-roboto-ttf"
+short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer"
+maintainer="Joseph Benden <joe@benden.us>"
+license="MIT"
+homepage="https://wezfurlong.org/wezterm/"
+distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/wezterm-${_srcver}-src.tar.gz"
+checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545"
+nocross=yes # ftbfs in libgit+libssh
+
+do_check() {
+	# NOTE: cannot use build_style cargo do_check because of --release flag.
+	# NOTE: e2e::sftp is skipped due to missing ssh
+	# NOTE: shapecache::test::ligatures_jetbrains is skipped due to removal of fonts
+	cargo test --target ${RUST_TARGET} --workspace --locked -- \
+		--skip e2e::sftp \
+		--skip shapecache::test::ligatures_jetbrains
+}
+
+do_build() {
+	for _target in wezterm wezterm-mux-server strip-ansi-escapes; do
+		cargo build --target ${RUST_TARGET} --release -p ${_target} \
+			--no-default-features
+	done
+	cargo build --target ${RUST_TARGET} --release -p wezterm-gui \
+		--no-default-features \
+		--features distro-defaults,wayland
+}
+
+do_install() {
+	vbin target/${RUST_TARGET}/release/wezterm
+	vbin target/${RUST_TARGET}/release/wezterm-gui
+	vbin target/${RUST_TARGET}/release/wezterm-mux-server
+	vbin target/${RUST_TARGET}/release/strip-ansi-escapes
+
+	vinstall assets/shell-integration/wezterm.sh 644 etc/profile.d org_wezfurlong_wezterm.sh
+	vinstall assets/icon/terminal.png 644 usr/share/icons/hicolor/128x128/apps org.wezfurlong.wezterm.png
+	vinstall assets/icon/wezterm-icon.svg 644 usr/share/icons/hicolor/scalable/apps org.wezfurlong.wezterm.svg
+	vinstall assets/wezterm.desktop 644 usr/share/applications org.wezfurlong.wezterm.desktop
+	vinstall assets/wezterm.appdata.xml 644 usr/share/metainfo org.wezfurlong.wezterm.appdata.xml
+
+	vcompletion assets/shell-completion/bash bash
+	vcompletion assets/shell-completion/fish fish
+	vcompletion assets/shell-completion/zsh  zsh
+
+	vmkdir usr/share/terminfo
+	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+
+	vdoc README.md
+	vlicense LICENSE.md
+}
+
+wezterm-terminfo_package() {
+	short_desc+=" - terminfo data"
+	pkg_install() {
+		vmove usr/share/terminfo
+	}
+}
diff --git a/srcpkgs/wezterm/update b/srcpkgs/wezterm/update
new file mode 100644
index 000000000000..4d2ef98f356b
--- /dev/null
+++ b/srcpkgs/wezterm/update
@@ -0,0 +1,2 @@
+site="https://github.com/wez/wezterm/releases"
+pattern='/tags/\K[\d.]+(?=-\d+-[a-f0-9]+.tar.gz)'

From aabd286305812564fd9365d9ad2be97fa10f51ac Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH 2/2] Add vterminfo template function

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index 3452b38c1332..a748fdc7fb6d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..0843059b30cc 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if ! [ -z "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..df7834c457da 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index 02ee8a2e90a9..18662737bae3 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -53,8 +53,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh  zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
@ 2022-10-26 16:52 ` jbenden
  2022-10-26 17:06 ` jbenden
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-10-26 16:52 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From 59ab3e1684f3c487935024b78d0b09d5f0979731 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Sun, 24 Apr 2022 10:16:12 -0700
Subject: [PATCH 1/2] New package: wezterm-20220905_1

Fixes: #35721
Signed-off-by: Joseph Benden <joe@benden.us>
---
 srcpkgs/wezterm-terminfo                      |   1 +
 ...4f05eb4de9ed44d2068355a571b117eba0e1.patch | 232 ++++++++++++++++++
 .../wezterm/patches/remove-distro-fonts.patch |  22 ++
 srcpkgs/wezterm/template                      |  68 +++++
 srcpkgs/wezterm/update                        |   2 +
 5 files changed, 325 insertions(+)
 create mode 120000 srcpkgs/wezterm-terminfo
 create mode 100644 srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
 create mode 100644 srcpkgs/wezterm/patches/remove-distro-fonts.patch
 create mode 100644 srcpkgs/wezterm/template
 create mode 100644 srcpkgs/wezterm/update

diff --git a/srcpkgs/wezterm-terminfo b/srcpkgs/wezterm-terminfo
new file mode 120000
index 000000000000..37d60f7b3b71
--- /dev/null
+++ b/srcpkgs/wezterm-terminfo
@@ -0,0 +1 @@
+wezterm
\ No newline at end of file
diff --git a/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
new file mode 100644
index 000000000000..d374a275d235
--- /dev/null
+++ b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
@@ -0,0 +1,232 @@
+From 7b904f05eb4de9ed44d2068355a571b117eba0e1 Mon Sep 17 00:00:00 2001
+From: Wez Furlong <wez@wezfurlong.org>
+Date: Sat, 15 Oct 2022 16:45:02 -0700
+Subject: [PATCH] termwiz: fixup for 32-bit systems
+
+I noticed from https://github.com/void-linux/void-packages/pull/36903
+that 32-bit systems were failing to pass the test suite.
+
+Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
+teeny_string` showed that we were faulting in the teenystring code
+and digging a bit deeper showed that it was because our assumptions
+about the high bits were wrong for 32-bit systems.
+
+Fix this by making TeenyString based around a u64 rather than usize
+so that we guarantee its size on all current systems.
+---
+ Cargo.lock          |  1 -
+ termwiz/Cargo.toml  |  1 -
+ termwiz/src/cell.rs | 87 ++++++++++++++-------------------------------
+ 3 files changed, 26 insertions(+), 63 deletions(-)
+
+diff --git a/Cargo.lock b/Cargo.lock
+index 4f976535be..243e3a2b24 100644
+--- a/Cargo.lock
++++ b/Cargo.lock
+@@ -4739,7 +4739,6 @@ dependencies = [
+  "base64",
+  "bitflags",
+  "cassowary",
+- "cfg-if 1.0.0",
+  "criterion",
+  "env_logger",
+  "filedescriptor",
+diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
+index d8d7ab543c..e843bac261 100644
+--- a/termwiz/Cargo.toml
++++ b/termwiz/Cargo.toml
+@@ -15,7 +15,6 @@ readme = "README.md"
+ base64 = "0.13"
+ bitflags = "1.3"
+ cassowary = {version="0.3", optional=true}
+-cfg-if = "1.0"
+ anyhow = "1.0"
+ filedescriptor = { version="0.8", path = "../filedescriptor" }
+ finl_unicode = "1.1"
+diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs
+index ddf38a93bb..70d6099dd0 100644
+--- a/termwiz/src/cell.rs
++++ b/termwiz/src/cell.rs
+@@ -590,7 +590,7 @@ where
+     s.serialize(serializer)
+ }
+ 
+-/// TeenyString encodes string storage in a single machine word.
++/// TeenyString encodes string storage in a single u64.
+ /// The scheme is simple but effective: strings that encode into a
+ /// byte slice that is 1 less byte than the machine word size can
+ /// be encoded directly into the usize bits stored in the struct.
+@@ -603,60 +603,40 @@ where
+ /// calling grapheme_column_width; if it is set, then the TeenyString
+ /// has length 2, otherwise, it has length 1 (we don't allow zero-length
+ /// strings).
+-struct TeenyString(usize);
++struct TeenyString(u64);
+ struct TeenyStringHeap {
+     bytes: Vec<u8>,
+     width: usize,
+ }
+ 
+ impl TeenyString {
+-    const fn marker_mask() -> usize {
++    const fn marker_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000000
+         } else {
+             0x1
+         }
+     }
+ 
+-    const fn double_wide_mask() -> usize {
++    const fn double_wide_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0xc0000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0xc0000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0xc000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0xc0000000_00000000
+         } else {
+             0x3
+         }
+     }
+ 
+-    const fn is_marker_bit_set(word: usize) -> bool {
++    const fn is_marker_bit_set(word: u64) -> bool {
+         let mask = Self::marker_mask();
+         word & mask == mask
+     }
+ 
+-    const fn is_double_width(word: usize) -> bool {
++    const fn is_double_width(word: u64) -> bool {
+         let mask = Self::double_wide_mask();
+         word & mask == mask
+     }
+ 
+-    const fn set_marker_bit(word: usize, width: usize) -> usize {
++    const fn set_marker_bit(word: u64, width: usize) -> u64 {
+         if width > 1 {
+             word | Self::double_wide_mask()
+         } else {
+@@ -689,18 +669,18 @@ impl TeenyString {
+         let len = bytes.len();
+         let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));
+ 
+-        if len < std::mem::size_of::<usize>() {
++        if len < std::mem::size_of::<u64>() {
+             debug_assert!(width < 3);
+ 
+-            let mut word = 0usize;
++            let mut word = 0u64;
+             unsafe {
+                 std::ptr::copy_nonoverlapping(
+                     bytes.as_ptr(),
+-                    &mut word as *mut usize as *mut u8,
++                    &mut word as *mut u64 as *mut u8,
+                     len,
+                 );
+             }
+-            let word = Self::set_marker_bit(word, width);
++            let word = Self::set_marker_bit(word as u64, width);
+             Self(word)
+         } else {
+             let vec = Box::new(TeenyStringHeap {
+@@ -708,35 +688,15 @@ impl TeenyString {
+                 width,
+             });
+             let ptr = Box::into_raw(vec);
+-            Self(ptr as usize)
++            Self(ptr as u64)
+         }
+     }
+ 
+     pub const fn space() -> Self {
+         Self(if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000020
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000020
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8020
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000020
+         } else {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x20000000_00000001
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x20000001
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x2001
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x20000000_00000001
+         })
+     }
+ 
+@@ -753,7 +713,7 @@ impl TeenyString {
+                 1
+             }
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).width }
+         }
+     }
+@@ -766,17 +726,17 @@ impl TeenyString {
+ 
+     pub fn as_bytes(&self) -> &[u8] {
+         if Self::is_marker_bit_set(self.0) {
+-            let bytes = &self.0 as *const usize as *const u8;
++            let bytes = &self.0 as *const u64 as *const u8;
+             let bytes =
+-                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<usize>() - 1) };
++                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<u64>() - 1) };
+             let len = bytes
+                 .iter()
+                 .position(|&b| b == 0)
+-                .unwrap_or(std::mem::size_of::<usize>() - 1);
++                .unwrap_or(std::mem::size_of::<u64>() - 1);
+ 
+             &bytes[0..len]
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).bytes.as_slice() }
+         }
+     }
+@@ -1072,6 +1032,11 @@ mod test {
+ 
+     #[test]
+     fn teeny_string() {
++        assert!(
++            std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
++            "if a pointer doesn't fit in u64 then we need to change TeenyString"
++        );
++
+         let s = TeenyString::from_char('a');
+         assert_eq!(s.as_bytes(), &[b'a']);
+ 
diff --git a/srcpkgs/wezterm/patches/remove-distro-fonts.patch b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
new file mode 100644
index 000000000000..1d8e21384ae9
--- /dev/null
+++ b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
@@ -0,0 +1,22 @@
+--- a/wezterm-font/src/parser.rs	2022-09-05 10:28:02.000000000 -0700
++++ b/wezterm-font/src/parser.rs	2022-10-24 09:06:02.529054286 -0700
+@@ -715,19 +715,6 @@
+         font!("../../assets/fonts/JetBrainsMono-Regular.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-ThinItalic.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-Black.ttf"),
+-        font!("../../assets/fonts/Roboto-BlackItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Bold.ttf"),
+-        font!("../../assets/fonts/Roboto-BoldItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Italic.ttf"),
+-        font!("../../assets/fonts/Roboto-Light.ttf"),
+-        font!("../../assets/fonts/Roboto-LightItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Medium.ttf"),
+-        font!("../../assets/fonts/Roboto-MediumItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Regular.ttf"),
+-        font!("../../assets/fonts/Roboto-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-ThinItalic.ttf"),
+-        font!("../../assets/fonts/NotoColorEmoji.ttf"),
+         font!("../../assets/fonts/Symbols-Nerd-Font-Mono.ttf"),
+         font!("../../assets/fonts/LastResortHE-Regular.ttf"),
+     ] {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
new file mode 100644
index 000000000000..02ee8a2e90a9
--- /dev/null
+++ b/srcpkgs/wezterm/template
@@ -0,0 +1,68 @@
+# Template file for 'wezterm'
+pkgname=wezterm
+version=20220905
+revision=1
+_srcver=20220905-102802-7d4b8249
+wrksrc="${pkgname}-${_srcver}"
+build_style=cargo
+hostmakedepends="pkg-config"
+makedepends="fontconfig-devel freetype-devel harfbuzz-devel openssl-devel
+ libX11-devel libxkbcommon-devel libxkbcommon-x11 wayland-devel xcb-util-devel
+ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel"
+depends="noto-fonts-emoji fonts-roboto-ttf"
+short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer"
+maintainer="Joseph Benden <joe@benden.us>"
+license="MIT"
+homepage="https://wezfurlong.org/wezterm/"
+distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/wezterm-${_srcver}-src.tar.gz"
+checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545"
+nocross=yes # ftbfs in libgit+libssh
+
+do_check() {
+	# NOTE: cannot use build_style cargo do_check because of --release flag.
+	# NOTE: e2e::sftp is skipped due to missing ssh
+	# NOTE: shapecache::test::ligatures_jetbrains is skipped due to removal of fonts
+	cargo test --target ${RUST_TARGET} --workspace --locked -- \
+		--skip e2e::sftp \
+		--skip shapecache::test::ligatures_jetbrains
+}
+
+do_build() {
+	for _target in wezterm wezterm-mux-server strip-ansi-escapes; do
+		cargo build --target ${RUST_TARGET} --release -p ${_target} \
+			--no-default-features
+	done
+	cargo build --target ${RUST_TARGET} --release -p wezterm-gui \
+		--no-default-features \
+		--features distro-defaults,wayland
+}
+
+do_install() {
+	vbin target/${RUST_TARGET}/release/wezterm
+	vbin target/${RUST_TARGET}/release/wezterm-gui
+	vbin target/${RUST_TARGET}/release/wezterm-mux-server
+	vbin target/${RUST_TARGET}/release/strip-ansi-escapes
+
+	vinstall assets/shell-integration/wezterm.sh 644 etc/profile.d org_wezfurlong_wezterm.sh
+	vinstall assets/icon/terminal.png 644 usr/share/icons/hicolor/128x128/apps org.wezfurlong.wezterm.png
+	vinstall assets/icon/wezterm-icon.svg 644 usr/share/icons/hicolor/scalable/apps org.wezfurlong.wezterm.svg
+	vinstall assets/wezterm.desktop 644 usr/share/applications org.wezfurlong.wezterm.desktop
+	vinstall assets/wezterm.appdata.xml 644 usr/share/metainfo org.wezfurlong.wezterm.appdata.xml
+
+	vcompletion assets/shell-completion/bash bash
+	vcompletion assets/shell-completion/fish fish
+	vcompletion assets/shell-completion/zsh  zsh
+
+	vmkdir usr/share/terminfo
+	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+
+	vdoc README.md
+	vlicense LICENSE.md
+}
+
+wezterm-terminfo_package() {
+	short_desc+=" - terminfo data"
+	pkg_install() {
+		vmove usr/share/terminfo
+	}
+}
diff --git a/srcpkgs/wezterm/update b/srcpkgs/wezterm/update
new file mode 100644
index 000000000000..4d2ef98f356b
--- /dev/null
+++ b/srcpkgs/wezterm/update
@@ -0,0 +1,2 @@
+site="https://github.com/wez/wezterm/releases"
+pattern='/tags/\K[\d.]+(?=-\d+-[a-f0-9]+.tar.gz)'

From c77c1b94d870057b6e554e498805a4f437c3d472 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH 2/2] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index 3452b38c1332..a748fdc7fb6d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..0843059b30cc 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if ! [ -z "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..df7834c457da 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index 02ee8a2e90a9..18662737bae3 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -53,8 +53,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh  zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
  2022-10-26 16:52 ` [PR PATCH] [Updated] " jbenden
@ 2022-10-26 17:06 ` jbenden
  2022-10-28  1:12 ` jbenden
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-10-26 17:06 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From 59ab3e1684f3c487935024b78d0b09d5f0979731 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Sun, 24 Apr 2022 10:16:12 -0700
Subject: [PATCH 1/2] New package: wezterm-20220905_1

Fixes: #35721
Signed-off-by: Joseph Benden <joe@benden.us>
---
 srcpkgs/wezterm-terminfo                      |   1 +
 ...4f05eb4de9ed44d2068355a571b117eba0e1.patch | 232 ++++++++++++++++++
 .../wezterm/patches/remove-distro-fonts.patch |  22 ++
 srcpkgs/wezterm/template                      |  68 +++++
 srcpkgs/wezterm/update                        |   2 +
 5 files changed, 325 insertions(+)
 create mode 120000 srcpkgs/wezterm-terminfo
 create mode 100644 srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
 create mode 100644 srcpkgs/wezterm/patches/remove-distro-fonts.patch
 create mode 100644 srcpkgs/wezterm/template
 create mode 100644 srcpkgs/wezterm/update

diff --git a/srcpkgs/wezterm-terminfo b/srcpkgs/wezterm-terminfo
new file mode 120000
index 000000000000..37d60f7b3b71
--- /dev/null
+++ b/srcpkgs/wezterm-terminfo
@@ -0,0 +1 @@
+wezterm
\ No newline at end of file
diff --git a/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
new file mode 100644
index 000000000000..d374a275d235
--- /dev/null
+++ b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
@@ -0,0 +1,232 @@
+From 7b904f05eb4de9ed44d2068355a571b117eba0e1 Mon Sep 17 00:00:00 2001
+From: Wez Furlong <wez@wezfurlong.org>
+Date: Sat, 15 Oct 2022 16:45:02 -0700
+Subject: [PATCH] termwiz: fixup for 32-bit systems
+
+I noticed from https://github.com/void-linux/void-packages/pull/36903
+that 32-bit systems were failing to pass the test suite.
+
+Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
+teeny_string` showed that we were faulting in the teenystring code
+and digging a bit deeper showed that it was because our assumptions
+about the high bits were wrong for 32-bit systems.
+
+Fix this by making TeenyString based around a u64 rather than usize
+so that we guarantee its size on all current systems.
+---
+ Cargo.lock          |  1 -
+ termwiz/Cargo.toml  |  1 -
+ termwiz/src/cell.rs | 87 ++++++++++++++-------------------------------
+ 3 files changed, 26 insertions(+), 63 deletions(-)
+
+diff --git a/Cargo.lock b/Cargo.lock
+index 4f976535be..243e3a2b24 100644
+--- a/Cargo.lock
++++ b/Cargo.lock
+@@ -4739,7 +4739,6 @@ dependencies = [
+  "base64",
+  "bitflags",
+  "cassowary",
+- "cfg-if 1.0.0",
+  "criterion",
+  "env_logger",
+  "filedescriptor",
+diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
+index d8d7ab543c..e843bac261 100644
+--- a/termwiz/Cargo.toml
++++ b/termwiz/Cargo.toml
+@@ -15,7 +15,6 @@ readme = "README.md"
+ base64 = "0.13"
+ bitflags = "1.3"
+ cassowary = {version="0.3", optional=true}
+-cfg-if = "1.0"
+ anyhow = "1.0"
+ filedescriptor = { version="0.8", path = "../filedescriptor" }
+ finl_unicode = "1.1"
+diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs
+index ddf38a93bb..70d6099dd0 100644
+--- a/termwiz/src/cell.rs
++++ b/termwiz/src/cell.rs
+@@ -590,7 +590,7 @@ where
+     s.serialize(serializer)
+ }
+ 
+-/// TeenyString encodes string storage in a single machine word.
++/// TeenyString encodes string storage in a single u64.
+ /// The scheme is simple but effective: strings that encode into a
+ /// byte slice that is 1 less byte than the machine word size can
+ /// be encoded directly into the usize bits stored in the struct.
+@@ -603,60 +603,40 @@ where
+ /// calling grapheme_column_width; if it is set, then the TeenyString
+ /// has length 2, otherwise, it has length 1 (we don't allow zero-length
+ /// strings).
+-struct TeenyString(usize);
++struct TeenyString(u64);
+ struct TeenyStringHeap {
+     bytes: Vec<u8>,
+     width: usize,
+ }
+ 
+ impl TeenyString {
+-    const fn marker_mask() -> usize {
++    const fn marker_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000000
+         } else {
+             0x1
+         }
+     }
+ 
+-    const fn double_wide_mask() -> usize {
++    const fn double_wide_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0xc0000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0xc0000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0xc000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0xc0000000_00000000
+         } else {
+             0x3
+         }
+     }
+ 
+-    const fn is_marker_bit_set(word: usize) -> bool {
++    const fn is_marker_bit_set(word: u64) -> bool {
+         let mask = Self::marker_mask();
+         word & mask == mask
+     }
+ 
+-    const fn is_double_width(word: usize) -> bool {
++    const fn is_double_width(word: u64) -> bool {
+         let mask = Self::double_wide_mask();
+         word & mask == mask
+     }
+ 
+-    const fn set_marker_bit(word: usize, width: usize) -> usize {
++    const fn set_marker_bit(word: u64, width: usize) -> u64 {
+         if width > 1 {
+             word | Self::double_wide_mask()
+         } else {
+@@ -689,18 +669,18 @@ impl TeenyString {
+         let len = bytes.len();
+         let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));
+ 
+-        if len < std::mem::size_of::<usize>() {
++        if len < std::mem::size_of::<u64>() {
+             debug_assert!(width < 3);
+ 
+-            let mut word = 0usize;
++            let mut word = 0u64;
+             unsafe {
+                 std::ptr::copy_nonoverlapping(
+                     bytes.as_ptr(),
+-                    &mut word as *mut usize as *mut u8,
++                    &mut word as *mut u64 as *mut u8,
+                     len,
+                 );
+             }
+-            let word = Self::set_marker_bit(word, width);
++            let word = Self::set_marker_bit(word as u64, width);
+             Self(word)
+         } else {
+             let vec = Box::new(TeenyStringHeap {
+@@ -708,35 +688,15 @@ impl TeenyString {
+                 width,
+             });
+             let ptr = Box::into_raw(vec);
+-            Self(ptr as usize)
++            Self(ptr as u64)
+         }
+     }
+ 
+     pub const fn space() -> Self {
+         Self(if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000020
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000020
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8020
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000020
+         } else {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x20000000_00000001
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x20000001
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x2001
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x20000000_00000001
+         })
+     }
+ 
+@@ -753,7 +713,7 @@ impl TeenyString {
+                 1
+             }
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).width }
+         }
+     }
+@@ -766,17 +726,17 @@ impl TeenyString {
+ 
+     pub fn as_bytes(&self) -> &[u8] {
+         if Self::is_marker_bit_set(self.0) {
+-            let bytes = &self.0 as *const usize as *const u8;
++            let bytes = &self.0 as *const u64 as *const u8;
+             let bytes =
+-                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<usize>() - 1) };
++                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<u64>() - 1) };
+             let len = bytes
+                 .iter()
+                 .position(|&b| b == 0)
+-                .unwrap_or(std::mem::size_of::<usize>() - 1);
++                .unwrap_or(std::mem::size_of::<u64>() - 1);
+ 
+             &bytes[0..len]
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).bytes.as_slice() }
+         }
+     }
+@@ -1072,6 +1032,11 @@ mod test {
+ 
+     #[test]
+     fn teeny_string() {
++        assert!(
++            std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
++            "if a pointer doesn't fit in u64 then we need to change TeenyString"
++        );
++
+         let s = TeenyString::from_char('a');
+         assert_eq!(s.as_bytes(), &[b'a']);
+ 
diff --git a/srcpkgs/wezterm/patches/remove-distro-fonts.patch b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
new file mode 100644
index 000000000000..1d8e21384ae9
--- /dev/null
+++ b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
@@ -0,0 +1,22 @@
+--- a/wezterm-font/src/parser.rs	2022-09-05 10:28:02.000000000 -0700
++++ b/wezterm-font/src/parser.rs	2022-10-24 09:06:02.529054286 -0700
+@@ -715,19 +715,6 @@
+         font!("../../assets/fonts/JetBrainsMono-Regular.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-ThinItalic.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-Black.ttf"),
+-        font!("../../assets/fonts/Roboto-BlackItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Bold.ttf"),
+-        font!("../../assets/fonts/Roboto-BoldItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Italic.ttf"),
+-        font!("../../assets/fonts/Roboto-Light.ttf"),
+-        font!("../../assets/fonts/Roboto-LightItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Medium.ttf"),
+-        font!("../../assets/fonts/Roboto-MediumItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Regular.ttf"),
+-        font!("../../assets/fonts/Roboto-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-ThinItalic.ttf"),
+-        font!("../../assets/fonts/NotoColorEmoji.ttf"),
+         font!("../../assets/fonts/Symbols-Nerd-Font-Mono.ttf"),
+         font!("../../assets/fonts/LastResortHE-Regular.ttf"),
+     ] {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
new file mode 100644
index 000000000000..02ee8a2e90a9
--- /dev/null
+++ b/srcpkgs/wezterm/template
@@ -0,0 +1,68 @@
+# Template file for 'wezterm'
+pkgname=wezterm
+version=20220905
+revision=1
+_srcver=20220905-102802-7d4b8249
+wrksrc="${pkgname}-${_srcver}"
+build_style=cargo
+hostmakedepends="pkg-config"
+makedepends="fontconfig-devel freetype-devel harfbuzz-devel openssl-devel
+ libX11-devel libxkbcommon-devel libxkbcommon-x11 wayland-devel xcb-util-devel
+ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel"
+depends="noto-fonts-emoji fonts-roboto-ttf"
+short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer"
+maintainer="Joseph Benden <joe@benden.us>"
+license="MIT"
+homepage="https://wezfurlong.org/wezterm/"
+distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/wezterm-${_srcver}-src.tar.gz"
+checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545"
+nocross=yes # ftbfs in libgit+libssh
+
+do_check() {
+	# NOTE: cannot use build_style cargo do_check because of --release flag.
+	# NOTE: e2e::sftp is skipped due to missing ssh
+	# NOTE: shapecache::test::ligatures_jetbrains is skipped due to removal of fonts
+	cargo test --target ${RUST_TARGET} --workspace --locked -- \
+		--skip e2e::sftp \
+		--skip shapecache::test::ligatures_jetbrains
+}
+
+do_build() {
+	for _target in wezterm wezterm-mux-server strip-ansi-escapes; do
+		cargo build --target ${RUST_TARGET} --release -p ${_target} \
+			--no-default-features
+	done
+	cargo build --target ${RUST_TARGET} --release -p wezterm-gui \
+		--no-default-features \
+		--features distro-defaults,wayland
+}
+
+do_install() {
+	vbin target/${RUST_TARGET}/release/wezterm
+	vbin target/${RUST_TARGET}/release/wezterm-gui
+	vbin target/${RUST_TARGET}/release/wezterm-mux-server
+	vbin target/${RUST_TARGET}/release/strip-ansi-escapes
+
+	vinstall assets/shell-integration/wezterm.sh 644 etc/profile.d org_wezfurlong_wezterm.sh
+	vinstall assets/icon/terminal.png 644 usr/share/icons/hicolor/128x128/apps org.wezfurlong.wezterm.png
+	vinstall assets/icon/wezterm-icon.svg 644 usr/share/icons/hicolor/scalable/apps org.wezfurlong.wezterm.svg
+	vinstall assets/wezterm.desktop 644 usr/share/applications org.wezfurlong.wezterm.desktop
+	vinstall assets/wezterm.appdata.xml 644 usr/share/metainfo org.wezfurlong.wezterm.appdata.xml
+
+	vcompletion assets/shell-completion/bash bash
+	vcompletion assets/shell-completion/fish fish
+	vcompletion assets/shell-completion/zsh  zsh
+
+	vmkdir usr/share/terminfo
+	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+
+	vdoc README.md
+	vlicense LICENSE.md
+}
+
+wezterm-terminfo_package() {
+	short_desc+=" - terminfo data"
+	pkg_install() {
+		vmove usr/share/terminfo
+	}
+}
diff --git a/srcpkgs/wezterm/update b/srcpkgs/wezterm/update
new file mode 100644
index 000000000000..4d2ef98f356b
--- /dev/null
+++ b/srcpkgs/wezterm/update
@@ -0,0 +1,2 @@
+site="https://github.com/wez/wezterm/releases"
+pattern='/tags/\K[\d.]+(?=-\d+-[a-f0-9]+.tar.gz)'

From 8a8873575f34bd14d8b3c3d788fcd7bc90ba68c3 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH 2/2] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index 3452b38c1332..a748fdc7fb6d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..0843059b30cc 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if ! [ -z "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..f6e0c8d471cd 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm -f ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index 02ee8a2e90a9..18662737bae3 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -53,8 +53,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh  zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
  2022-10-26 16:52 ` [PR PATCH] [Updated] " jbenden
  2022-10-26 17:06 ` jbenden
@ 2022-10-28  1:12 ` jbenden
  2022-10-28  2:03 ` jbenden
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-10-28  1:12 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From bef7a67a37016d3dbc25e16eb00053b23bd1df98 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Sun, 24 Apr 2022 10:16:12 -0700
Subject: [PATCH 1/2] New package: wezterm-20220905_1

Fixes: #35721
Signed-off-by: Joseph Benden <joe@benden.us>
---
 srcpkgs/wezterm-terminfo                      |   1 +
 ...4f05eb4de9ed44d2068355a571b117eba0e1.patch | 232 ++++++++++++++++++
 .../wezterm/patches/remove-distro-fonts.patch |  22 ++
 srcpkgs/wezterm/template                      |  69 ++++++
 srcpkgs/wezterm/update                        |   2 +
 5 files changed, 326 insertions(+)
 create mode 120000 srcpkgs/wezterm-terminfo
 create mode 100644 srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
 create mode 100644 srcpkgs/wezterm/patches/remove-distro-fonts.patch
 create mode 100644 srcpkgs/wezterm/template
 create mode 100644 srcpkgs/wezterm/update

diff --git a/srcpkgs/wezterm-terminfo b/srcpkgs/wezterm-terminfo
new file mode 120000
index 000000000000..37d60f7b3b71
--- /dev/null
+++ b/srcpkgs/wezterm-terminfo
@@ -0,0 +1 @@
+wezterm
\ No newline at end of file
diff --git a/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
new file mode 100644
index 000000000000..d374a275d235
--- /dev/null
+++ b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
@@ -0,0 +1,232 @@
+From 7b904f05eb4de9ed44d2068355a571b117eba0e1 Mon Sep 17 00:00:00 2001
+From: Wez Furlong <wez@wezfurlong.org>
+Date: Sat, 15 Oct 2022 16:45:02 -0700
+Subject: [PATCH] termwiz: fixup for 32-bit systems
+
+I noticed from https://github.com/void-linux/void-packages/pull/36903
+that 32-bit systems were failing to pass the test suite.
+
+Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
+teeny_string` showed that we were faulting in the teenystring code
+and digging a bit deeper showed that it was because our assumptions
+about the high bits were wrong for 32-bit systems.
+
+Fix this by making TeenyString based around a u64 rather than usize
+so that we guarantee its size on all current systems.
+---
+ Cargo.lock          |  1 -
+ termwiz/Cargo.toml  |  1 -
+ termwiz/src/cell.rs | 87 ++++++++++++++-------------------------------
+ 3 files changed, 26 insertions(+), 63 deletions(-)
+
+diff --git a/Cargo.lock b/Cargo.lock
+index 4f976535be..243e3a2b24 100644
+--- a/Cargo.lock
++++ b/Cargo.lock
+@@ -4739,7 +4739,6 @@ dependencies = [
+  "base64",
+  "bitflags",
+  "cassowary",
+- "cfg-if 1.0.0",
+  "criterion",
+  "env_logger",
+  "filedescriptor",
+diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
+index d8d7ab543c..e843bac261 100644
+--- a/termwiz/Cargo.toml
++++ b/termwiz/Cargo.toml
+@@ -15,7 +15,6 @@ readme = "README.md"
+ base64 = "0.13"
+ bitflags = "1.3"
+ cassowary = {version="0.3", optional=true}
+-cfg-if = "1.0"
+ anyhow = "1.0"
+ filedescriptor = { version="0.8", path = "../filedescriptor" }
+ finl_unicode = "1.1"
+diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs
+index ddf38a93bb..70d6099dd0 100644
+--- a/termwiz/src/cell.rs
++++ b/termwiz/src/cell.rs
+@@ -590,7 +590,7 @@ where
+     s.serialize(serializer)
+ }
+ 
+-/// TeenyString encodes string storage in a single machine word.
++/// TeenyString encodes string storage in a single u64.
+ /// The scheme is simple but effective: strings that encode into a
+ /// byte slice that is 1 less byte than the machine word size can
+ /// be encoded directly into the usize bits stored in the struct.
+@@ -603,60 +603,40 @@ where
+ /// calling grapheme_column_width; if it is set, then the TeenyString
+ /// has length 2, otherwise, it has length 1 (we don't allow zero-length
+ /// strings).
+-struct TeenyString(usize);
++struct TeenyString(u64);
+ struct TeenyStringHeap {
+     bytes: Vec<u8>,
+     width: usize,
+ }
+ 
+ impl TeenyString {
+-    const fn marker_mask() -> usize {
++    const fn marker_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000000
+         } else {
+             0x1
+         }
+     }
+ 
+-    const fn double_wide_mask() -> usize {
++    const fn double_wide_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0xc0000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0xc0000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0xc000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0xc0000000_00000000
+         } else {
+             0x3
+         }
+     }
+ 
+-    const fn is_marker_bit_set(word: usize) -> bool {
++    const fn is_marker_bit_set(word: u64) -> bool {
+         let mask = Self::marker_mask();
+         word & mask == mask
+     }
+ 
+-    const fn is_double_width(word: usize) -> bool {
++    const fn is_double_width(word: u64) -> bool {
+         let mask = Self::double_wide_mask();
+         word & mask == mask
+     }
+ 
+-    const fn set_marker_bit(word: usize, width: usize) -> usize {
++    const fn set_marker_bit(word: u64, width: usize) -> u64 {
+         if width > 1 {
+             word | Self::double_wide_mask()
+         } else {
+@@ -689,18 +669,18 @@ impl TeenyString {
+         let len = bytes.len();
+         let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));
+ 
+-        if len < std::mem::size_of::<usize>() {
++        if len < std::mem::size_of::<u64>() {
+             debug_assert!(width < 3);
+ 
+-            let mut word = 0usize;
++            let mut word = 0u64;
+             unsafe {
+                 std::ptr::copy_nonoverlapping(
+                     bytes.as_ptr(),
+-                    &mut word as *mut usize as *mut u8,
++                    &mut word as *mut u64 as *mut u8,
+                     len,
+                 );
+             }
+-            let word = Self::set_marker_bit(word, width);
++            let word = Self::set_marker_bit(word as u64, width);
+             Self(word)
+         } else {
+             let vec = Box::new(TeenyStringHeap {
+@@ -708,35 +688,15 @@ impl TeenyString {
+                 width,
+             });
+             let ptr = Box::into_raw(vec);
+-            Self(ptr as usize)
++            Self(ptr as u64)
+         }
+     }
+ 
+     pub const fn space() -> Self {
+         Self(if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000020
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000020
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8020
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000020
+         } else {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x20000000_00000001
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x20000001
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x2001
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x20000000_00000001
+         })
+     }
+ 
+@@ -753,7 +713,7 @@ impl TeenyString {
+                 1
+             }
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).width }
+         }
+     }
+@@ -766,17 +726,17 @@ impl TeenyString {
+ 
+     pub fn as_bytes(&self) -> &[u8] {
+         if Self::is_marker_bit_set(self.0) {
+-            let bytes = &self.0 as *const usize as *const u8;
++            let bytes = &self.0 as *const u64 as *const u8;
+             let bytes =
+-                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<usize>() - 1) };
++                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<u64>() - 1) };
+             let len = bytes
+                 .iter()
+                 .position(|&b| b == 0)
+-                .unwrap_or(std::mem::size_of::<usize>() - 1);
++                .unwrap_or(std::mem::size_of::<u64>() - 1);
+ 
+             &bytes[0..len]
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).bytes.as_slice() }
+         }
+     }
+@@ -1072,6 +1032,11 @@ mod test {
+ 
+     #[test]
+     fn teeny_string() {
++        assert!(
++            std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
++            "if a pointer doesn't fit in u64 then we need to change TeenyString"
++        );
++
+         let s = TeenyString::from_char('a');
+         assert_eq!(s.as_bytes(), &[b'a']);
+ 
diff --git a/srcpkgs/wezterm/patches/remove-distro-fonts.patch b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
new file mode 100644
index 000000000000..1d8e21384ae9
--- /dev/null
+++ b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
@@ -0,0 +1,22 @@
+--- a/wezterm-font/src/parser.rs	2022-09-05 10:28:02.000000000 -0700
++++ b/wezterm-font/src/parser.rs	2022-10-24 09:06:02.529054286 -0700
+@@ -715,19 +715,6 @@
+         font!("../../assets/fonts/JetBrainsMono-Regular.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-ThinItalic.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-Black.ttf"),
+-        font!("../../assets/fonts/Roboto-BlackItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Bold.ttf"),
+-        font!("../../assets/fonts/Roboto-BoldItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Italic.ttf"),
+-        font!("../../assets/fonts/Roboto-Light.ttf"),
+-        font!("../../assets/fonts/Roboto-LightItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Medium.ttf"),
+-        font!("../../assets/fonts/Roboto-MediumItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Regular.ttf"),
+-        font!("../../assets/fonts/Roboto-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-ThinItalic.ttf"),
+-        font!("../../assets/fonts/NotoColorEmoji.ttf"),
+         font!("../../assets/fonts/Symbols-Nerd-Font-Mono.ttf"),
+         font!("../../assets/fonts/LastResortHE-Regular.ttf"),
+     ] {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
new file mode 100644
index 000000000000..ab6fb201e20a
--- /dev/null
+++ b/srcpkgs/wezterm/template
@@ -0,0 +1,69 @@
+# Template file for 'wezterm'
+pkgname=wezterm
+version=20220905
+revision=1
+_srcver=20220905-102802-7d4b8249
+wrksrc="${pkgname}-${_srcver}"
+build_style=cargo
+hostmakedepends="pkg-config"
+makedepends="fontconfig-devel freetype-devel harfbuzz-devel openssl-devel
+ libX11-devel libxkbcommon-devel libxkbcommon-x11 wayland-devel xcb-util-devel
+ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel"
+depends="noto-fonts-emoji fonts-roboto-ttf"
+short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer"
+maintainer="Joseph Benden <joe@benden.us>"
+license="MIT"
+homepage="https://wezfurlong.org/wezterm/"
+changelog="https://wezfurlong.org/wezterm/changelog.html"
+distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/wezterm-${_srcver}-src.tar.gz"
+checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545"
+nocross=yes # ftbfs in libgit+libssh
+
+do_check() {
+	# NOTE: cannot use build_style cargo do_check because of --release flag.
+	# NOTE: e2e::sftp is skipped due to missing ssh
+	# NOTE: shapecache::test::ligatures_jetbrains is skipped due to removal of fonts
+	cargo test --target ${RUST_TARGET} --workspace --locked -- \
+		--skip e2e::sftp \
+		--skip shapecache::test::ligatures_jetbrains
+}
+
+do_build() {
+	for _target in wezterm wezterm-mux-server strip-ansi-escapes; do
+		cargo build --target ${RUST_TARGET} --release -p ${_target} \
+			--no-default-features
+	done
+	cargo build --target ${RUST_TARGET} --release -p wezterm-gui \
+		--no-default-features \
+		--features distro-defaults,wayland
+}
+
+do_install() {
+	vbin target/${RUST_TARGET}/release/wezterm
+	vbin target/${RUST_TARGET}/release/wezterm-gui
+	vbin target/${RUST_TARGET}/release/wezterm-mux-server
+	vbin target/${RUST_TARGET}/release/strip-ansi-escapes
+
+	vinstall assets/shell-integration/wezterm.sh 644 etc/profile.d org_wezfurlong_wezterm.sh
+	vinstall assets/icon/terminal.png 644 usr/share/icons/hicolor/128x128/apps org.wezfurlong.wezterm.png
+	vinstall assets/icon/wezterm-icon.svg 644 usr/share/icons/hicolor/scalable/apps org.wezfurlong.wezterm.svg
+	vinstall assets/wezterm.desktop 644 usr/share/applications org.wezfurlong.wezterm.desktop
+	vinstall assets/wezterm.appdata.xml 644 usr/share/metainfo org.wezfurlong.wezterm.appdata.xml
+
+	vcompletion assets/shell-completion/bash bash
+	vcompletion assets/shell-completion/fish fish
+	vcompletion assets/shell-completion/zsh zsh
+
+	vmkdir usr/share/terminfo
+	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+
+	vdoc README.md
+	vlicense LICENSE.md
+}
+
+wezterm-terminfo_package() {
+	short_desc+=" - terminfo data"
+	pkg_install() {
+		vmove usr/share/terminfo
+	}
+}
diff --git a/srcpkgs/wezterm/update b/srcpkgs/wezterm/update
new file mode 100644
index 000000000000..4d2ef98f356b
--- /dev/null
+++ b/srcpkgs/wezterm/update
@@ -0,0 +1,2 @@
+site="https://github.com/wez/wezterm/releases"
+pattern='/tags/\K[\d.]+(?=-\d+-[a-f0-9]+.tar.gz)'

From 2d1b09f14176a1b3e413ee9c1fe8b01693a5dd1c Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH 2/2] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index 3452b38c1332..a748fdc7fb6d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..0843059b30cc 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if ! [ -z "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..f6e0c8d471cd 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm -f ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index ab6fb201e20a..c74cc2a5b69a 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -54,8 +54,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (2 preceding siblings ...)
  2022-10-28  1:12 ` jbenden
@ 2022-10-28  2:03 ` jbenden
  2022-10-28  2:35 ` [PR REVIEW] " sgn
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-10-28  2:03 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From 3e510eddc12d152b2a8bc735b603e3b98a05da89 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Sun, 24 Apr 2022 10:16:12 -0700
Subject: [PATCH 1/2] New package: wezterm-20220905_1

Fixes: #35721
Signed-off-by: Joseph Benden <joe@benden.us>
---
 srcpkgs/wezterm-terminfo                      |   1 +
 ...4f05eb4de9ed44d2068355a571b117eba0e1.patch | 232 ++++++++++++++++++
 .../wezterm/patches/remove-distro-fonts.patch |  22 ++
 srcpkgs/wezterm/template                      |  69 ++++++
 srcpkgs/wezterm/update                        |   2 +
 5 files changed, 326 insertions(+)
 create mode 120000 srcpkgs/wezterm-terminfo
 create mode 100644 srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
 create mode 100644 srcpkgs/wezterm/patches/remove-distro-fonts.patch
 create mode 100644 srcpkgs/wezterm/template
 create mode 100644 srcpkgs/wezterm/update

diff --git a/srcpkgs/wezterm-terminfo b/srcpkgs/wezterm-terminfo
new file mode 120000
index 000000000000..37d60f7b3b71
--- /dev/null
+++ b/srcpkgs/wezterm-terminfo
@@ -0,0 +1 @@
+wezterm
\ No newline at end of file
diff --git a/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
new file mode 100644
index 000000000000..d374a275d235
--- /dev/null
+++ b/srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch
@@ -0,0 +1,232 @@
+From 7b904f05eb4de9ed44d2068355a571b117eba0e1 Mon Sep 17 00:00:00 2001
+From: Wez Furlong <wez@wezfurlong.org>
+Date: Sat, 15 Oct 2022 16:45:02 -0700
+Subject: [PATCH] termwiz: fixup for 32-bit systems
+
+I noticed from https://github.com/void-linux/void-packages/pull/36903
+that 32-bit systems were failing to pass the test suite.
+
+Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
+teeny_string` showed that we were faulting in the teenystring code
+and digging a bit deeper showed that it was because our assumptions
+about the high bits were wrong for 32-bit systems.
+
+Fix this by making TeenyString based around a u64 rather than usize
+so that we guarantee its size on all current systems.
+---
+ Cargo.lock          |  1 -
+ termwiz/Cargo.toml  |  1 -
+ termwiz/src/cell.rs | 87 ++++++++++++++-------------------------------
+ 3 files changed, 26 insertions(+), 63 deletions(-)
+
+diff --git a/Cargo.lock b/Cargo.lock
+index 4f976535be..243e3a2b24 100644
+--- a/Cargo.lock
++++ b/Cargo.lock
+@@ -4739,7 +4739,6 @@ dependencies = [
+  "base64",
+  "bitflags",
+  "cassowary",
+- "cfg-if 1.0.0",
+  "criterion",
+  "env_logger",
+  "filedescriptor",
+diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
+index d8d7ab543c..e843bac261 100644
+--- a/termwiz/Cargo.toml
++++ b/termwiz/Cargo.toml
+@@ -15,7 +15,6 @@ readme = "README.md"
+ base64 = "0.13"
+ bitflags = "1.3"
+ cassowary = {version="0.3", optional=true}
+-cfg-if = "1.0"
+ anyhow = "1.0"
+ filedescriptor = { version="0.8", path = "../filedescriptor" }
+ finl_unicode = "1.1"
+diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs
+index ddf38a93bb..70d6099dd0 100644
+--- a/termwiz/src/cell.rs
++++ b/termwiz/src/cell.rs
+@@ -590,7 +590,7 @@ where
+     s.serialize(serializer)
+ }
+ 
+-/// TeenyString encodes string storage in a single machine word.
++/// TeenyString encodes string storage in a single u64.
+ /// The scheme is simple but effective: strings that encode into a
+ /// byte slice that is 1 less byte than the machine word size can
+ /// be encoded directly into the usize bits stored in the struct.
+@@ -603,60 +603,40 @@ where
+ /// calling grapheme_column_width; if it is set, then the TeenyString
+ /// has length 2, otherwise, it has length 1 (we don't allow zero-length
+ /// strings).
+-struct TeenyString(usize);
++struct TeenyString(u64);
+ struct TeenyStringHeap {
+     bytes: Vec<u8>,
+     width: usize,
+ }
+ 
+ impl TeenyString {
+-    const fn marker_mask() -> usize {
++    const fn marker_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000000
+         } else {
+             0x1
+         }
+     }
+ 
+-    const fn double_wide_mask() -> usize {
++    const fn double_wide_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0xc0000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0xc0000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0xc000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0xc0000000_00000000
+         } else {
+             0x3
+         }
+     }
+ 
+-    const fn is_marker_bit_set(word: usize) -> bool {
++    const fn is_marker_bit_set(word: u64) -> bool {
+         let mask = Self::marker_mask();
+         word & mask == mask
+     }
+ 
+-    const fn is_double_width(word: usize) -> bool {
++    const fn is_double_width(word: u64) -> bool {
+         let mask = Self::double_wide_mask();
+         word & mask == mask
+     }
+ 
+-    const fn set_marker_bit(word: usize, width: usize) -> usize {
++    const fn set_marker_bit(word: u64, width: usize) -> u64 {
+         if width > 1 {
+             word | Self::double_wide_mask()
+         } else {
+@@ -689,18 +669,18 @@ impl TeenyString {
+         let len = bytes.len();
+         let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));
+ 
+-        if len < std::mem::size_of::<usize>() {
++        if len < std::mem::size_of::<u64>() {
+             debug_assert!(width < 3);
+ 
+-            let mut word = 0usize;
++            let mut word = 0u64;
+             unsafe {
+                 std::ptr::copy_nonoverlapping(
+                     bytes.as_ptr(),
+-                    &mut word as *mut usize as *mut u8,
++                    &mut word as *mut u64 as *mut u8,
+                     len,
+                 );
+             }
+-            let word = Self::set_marker_bit(word, width);
++            let word = Self::set_marker_bit(word as u64, width);
+             Self(word)
+         } else {
+             let vec = Box::new(TeenyStringHeap {
+@@ -708,35 +688,15 @@ impl TeenyString {
+                 width,
+             });
+             let ptr = Box::into_raw(vec);
+-            Self(ptr as usize)
++            Self(ptr as u64)
+         }
+     }
+ 
+     pub const fn space() -> Self {
+         Self(if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000020
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000020
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8020
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000020
+         } else {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x20000000_00000001
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x20000001
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x2001
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x20000000_00000001
+         })
+     }
+ 
+@@ -753,7 +713,7 @@ impl TeenyString {
+                 1
+             }
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).width }
+         }
+     }
+@@ -766,17 +726,17 @@ impl TeenyString {
+ 
+     pub fn as_bytes(&self) -> &[u8] {
+         if Self::is_marker_bit_set(self.0) {
+-            let bytes = &self.0 as *const usize as *const u8;
++            let bytes = &self.0 as *const u64 as *const u8;
+             let bytes =
+-                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<usize>() - 1) };
++                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<u64>() - 1) };
+             let len = bytes
+                 .iter()
+                 .position(|&b| b == 0)
+-                .unwrap_or(std::mem::size_of::<usize>() - 1);
++                .unwrap_or(std::mem::size_of::<u64>() - 1);
+ 
+             &bytes[0..len]
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).bytes.as_slice() }
+         }
+     }
+@@ -1072,6 +1032,11 @@ mod test {
+ 
+     #[test]
+     fn teeny_string() {
++        assert!(
++            std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
++            "if a pointer doesn't fit in u64 then we need to change TeenyString"
++        );
++
+         let s = TeenyString::from_char('a');
+         assert_eq!(s.as_bytes(), &[b'a']);
+ 
diff --git a/srcpkgs/wezterm/patches/remove-distro-fonts.patch b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
new file mode 100644
index 000000000000..1d8e21384ae9
--- /dev/null
+++ b/srcpkgs/wezterm/patches/remove-distro-fonts.patch
@@ -0,0 +1,22 @@
+--- a/wezterm-font/src/parser.rs	2022-09-05 10:28:02.000000000 -0700
++++ b/wezterm-font/src/parser.rs	2022-10-24 09:06:02.529054286 -0700
+@@ -715,19 +715,6 @@
+         font!("../../assets/fonts/JetBrainsMono-Regular.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-ThinItalic.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-Black.ttf"),
+-        font!("../../assets/fonts/Roboto-BlackItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Bold.ttf"),
+-        font!("../../assets/fonts/Roboto-BoldItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Italic.ttf"),
+-        font!("../../assets/fonts/Roboto-Light.ttf"),
+-        font!("../../assets/fonts/Roboto-LightItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Medium.ttf"),
+-        font!("../../assets/fonts/Roboto-MediumItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Regular.ttf"),
+-        font!("../../assets/fonts/Roboto-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-ThinItalic.ttf"),
+-        font!("../../assets/fonts/NotoColorEmoji.ttf"),
+         font!("../../assets/fonts/Symbols-Nerd-Font-Mono.ttf"),
+         font!("../../assets/fonts/LastResortHE-Regular.ttf"),
+     ] {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
new file mode 100644
index 000000000000..1cd9c38ebc62
--- /dev/null
+++ b/srcpkgs/wezterm/template
@@ -0,0 +1,69 @@
+# Template file for 'wezterm'
+pkgname=wezterm
+version=20220905
+revision=1
+_srcver=20220905-102802-7d4b8249
+wrksrc="${pkgname}-${_srcver}"
+build_style=cargo
+hostmakedepends="pkg-config"
+makedepends="fontconfig-devel freetype-devel harfbuzz-devel openssl-devel
+ libX11-devel libxkbcommon-devel libxkbcommon-x11 wayland-devel xcb-util-devel
+ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel"
+depends="noto-fonts-emoji fonts-roboto-ttf"
+short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer"
+maintainer="Joseph Benden <joe@benden.us>"
+license="MIT"
+homepage="https://wezfurlong.org/wezterm/"
+changelog="https://wezfurlong.org/wezterm/changelog.html"
+distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/wezterm-${_srcver}-src.tar.gz"
+checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545"
+nocross=yes # ftbfs in libgit+libssh
+
+do_build() {
+	for _target in wezterm wezterm-mux-server strip-ansi-escapes; do
+		cargo build --target ${RUST_TARGET} --release -p ${_target} \
+			--no-default-features
+	done
+	cargo build --target ${RUST_TARGET} --release -p wezterm-gui \
+		--no-default-features \
+		--features distro-defaults,wayland
+}
+
+do_check() {
+	# NOTE: cannot use build_style cargo do_check because of --release flag.
+	# NOTE: e2e::sftp is skipped due to missing ssh
+	# NOTE: shapecache::test::ligatures_jetbrains is skipped due to removal of fonts
+	cargo test --target ${RUST_TARGET} --workspace --locked -- \
+		--skip e2e::sftp \
+		--skip shapecache::test::ligatures_jetbrains
+}
+
+do_install() {
+	vbin target/${RUST_TARGET}/release/wezterm
+	vbin target/${RUST_TARGET}/release/wezterm-gui
+	vbin target/${RUST_TARGET}/release/wezterm-mux-server
+	vbin target/${RUST_TARGET}/release/strip-ansi-escapes
+
+	vinstall assets/shell-integration/wezterm.sh 644 etc/profile.d org_wezfurlong_wezterm.sh
+	vinstall assets/icon/terminal.png 644 usr/share/icons/hicolor/128x128/apps org.wezfurlong.wezterm.png
+	vinstall assets/icon/wezterm-icon.svg 644 usr/share/icons/hicolor/scalable/apps org.wezfurlong.wezterm.svg
+	vinstall assets/wezterm.desktop 644 usr/share/applications org.wezfurlong.wezterm.desktop
+	vinstall assets/wezterm.appdata.xml 644 usr/share/metainfo org.wezfurlong.wezterm.appdata.xml
+
+	vcompletion assets/shell-completion/bash bash
+	vcompletion assets/shell-completion/fish fish
+	vcompletion assets/shell-completion/zsh zsh
+
+	vmkdir usr/share/terminfo
+	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+
+	vdoc README.md
+	vlicense LICENSE.md
+}
+
+wezterm-terminfo_package() {
+	short_desc+=" - terminfo data"
+	pkg_install() {
+		vmove usr/share/terminfo
+	}
+}
diff --git a/srcpkgs/wezterm/update b/srcpkgs/wezterm/update
new file mode 100644
index 000000000000..4d2ef98f356b
--- /dev/null
+++ b/srcpkgs/wezterm/update
@@ -0,0 +1,2 @@
+site="https://github.com/wez/wezterm/releases"
+pattern='/tags/\K[\d.]+(?=-\d+-[a-f0-9]+.tar.gz)'

From efe87d11d3ec82369d07178ccc753675333d9cc9 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH 2/2] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index 3452b38c1332..a748fdc7fb6d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..0843059b30cc 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if ! [ -z "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..f6e0c8d471cd 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm -f ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index 1cd9c38ebc62..9076c072baaa 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -54,8 +54,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: [PR REVIEW] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (3 preceding siblings ...)
  2022-10-28  2:03 ` jbenden
@ 2022-10-28  2:35 ` sgn
  2022-10-28 15:18 ` [PR PATCH] [Updated] " jbenden
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: sgn @ 2022-10-28  2:35 UTC (permalink / raw)
  To: ml

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

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/40168#discussion_r1007551778

Comment:
without any opinion about this proposal, double negative is hard to reason. `if [ -n "$entries" ]` instead.

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (4 preceding siblings ...)
  2022-10-28  2:35 ` [PR REVIEW] " sgn
@ 2022-10-28 15:18 ` jbenden
  2022-10-28 15:18 ` [PR REVIEW] " jbenden
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-10-28 15:18 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From 698b5748a94ef80e1379810818d27b0b4f9bee87 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Sun, 24 Apr 2022 10:16:12 -0700
Subject: [PATCH 1/2] New package: wezterm-20220905_1

Fixes: #35721
Signed-off-by: Joseph Benden <joe@benden.us>
---
 srcpkgs/wezterm-terminfo                      |   1 +
 srcpkgs/wezterm/patches/0001-32bit.patch      | 232 ++++++++++++++++++
 .../patches/0002-remove-distro-fonts.patch    |  22 ++
 srcpkgs/wezterm/template                      |  69 ++++++
 srcpkgs/wezterm/update                        |   2 +
 5 files changed, 326 insertions(+)
 create mode 120000 srcpkgs/wezterm-terminfo
 create mode 100644 srcpkgs/wezterm/patches/0001-32bit.patch
 create mode 100644 srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch
 create mode 100644 srcpkgs/wezterm/template
 create mode 100644 srcpkgs/wezterm/update

diff --git a/srcpkgs/wezterm-terminfo b/srcpkgs/wezterm-terminfo
new file mode 120000
index 000000000000..37d60f7b3b71
--- /dev/null
+++ b/srcpkgs/wezterm-terminfo
@@ -0,0 +1 @@
+wezterm
\ No newline at end of file
diff --git a/srcpkgs/wezterm/patches/0001-32bit.patch b/srcpkgs/wezterm/patches/0001-32bit.patch
new file mode 100644
index 000000000000..d374a275d235
--- /dev/null
+++ b/srcpkgs/wezterm/patches/0001-32bit.patch
@@ -0,0 +1,232 @@
+From 7b904f05eb4de9ed44d2068355a571b117eba0e1 Mon Sep 17 00:00:00 2001
+From: Wez Furlong <wez@wezfurlong.org>
+Date: Sat, 15 Oct 2022 16:45:02 -0700
+Subject: [PATCH] termwiz: fixup for 32-bit systems
+
+I noticed from https://github.com/void-linux/void-packages/pull/36903
+that 32-bit systems were failing to pass the test suite.
+
+Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
+teeny_string` showed that we were faulting in the teenystring code
+and digging a bit deeper showed that it was because our assumptions
+about the high bits were wrong for 32-bit systems.
+
+Fix this by making TeenyString based around a u64 rather than usize
+so that we guarantee its size on all current systems.
+---
+ Cargo.lock          |  1 -
+ termwiz/Cargo.toml  |  1 -
+ termwiz/src/cell.rs | 87 ++++++++++++++-------------------------------
+ 3 files changed, 26 insertions(+), 63 deletions(-)
+
+diff --git a/Cargo.lock b/Cargo.lock
+index 4f976535be..243e3a2b24 100644
+--- a/Cargo.lock
++++ b/Cargo.lock
+@@ -4739,7 +4739,6 @@ dependencies = [
+  "base64",
+  "bitflags",
+  "cassowary",
+- "cfg-if 1.0.0",
+  "criterion",
+  "env_logger",
+  "filedescriptor",
+diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
+index d8d7ab543c..e843bac261 100644
+--- a/termwiz/Cargo.toml
++++ b/termwiz/Cargo.toml
+@@ -15,7 +15,6 @@ readme = "README.md"
+ base64 = "0.13"
+ bitflags = "1.3"
+ cassowary = {version="0.3", optional=true}
+-cfg-if = "1.0"
+ anyhow = "1.0"
+ filedescriptor = { version="0.8", path = "../filedescriptor" }
+ finl_unicode = "1.1"
+diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs
+index ddf38a93bb..70d6099dd0 100644
+--- a/termwiz/src/cell.rs
++++ b/termwiz/src/cell.rs
+@@ -590,7 +590,7 @@ where
+     s.serialize(serializer)
+ }
+ 
+-/// TeenyString encodes string storage in a single machine word.
++/// TeenyString encodes string storage in a single u64.
+ /// The scheme is simple but effective: strings that encode into a
+ /// byte slice that is 1 less byte than the machine word size can
+ /// be encoded directly into the usize bits stored in the struct.
+@@ -603,60 +603,40 @@ where
+ /// calling grapheme_column_width; if it is set, then the TeenyString
+ /// has length 2, otherwise, it has length 1 (we don't allow zero-length
+ /// strings).
+-struct TeenyString(usize);
++struct TeenyString(u64);
+ struct TeenyStringHeap {
+     bytes: Vec<u8>,
+     width: usize,
+ }
+ 
+ impl TeenyString {
+-    const fn marker_mask() -> usize {
++    const fn marker_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000000
+         } else {
+             0x1
+         }
+     }
+ 
+-    const fn double_wide_mask() -> usize {
++    const fn double_wide_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0xc0000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0xc0000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0xc000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0xc0000000_00000000
+         } else {
+             0x3
+         }
+     }
+ 
+-    const fn is_marker_bit_set(word: usize) -> bool {
++    const fn is_marker_bit_set(word: u64) -> bool {
+         let mask = Self::marker_mask();
+         word & mask == mask
+     }
+ 
+-    const fn is_double_width(word: usize) -> bool {
++    const fn is_double_width(word: u64) -> bool {
+         let mask = Self::double_wide_mask();
+         word & mask == mask
+     }
+ 
+-    const fn set_marker_bit(word: usize, width: usize) -> usize {
++    const fn set_marker_bit(word: u64, width: usize) -> u64 {
+         if width > 1 {
+             word | Self::double_wide_mask()
+         } else {
+@@ -689,18 +669,18 @@ impl TeenyString {
+         let len = bytes.len();
+         let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));
+ 
+-        if len < std::mem::size_of::<usize>() {
++        if len < std::mem::size_of::<u64>() {
+             debug_assert!(width < 3);
+ 
+-            let mut word = 0usize;
++            let mut word = 0u64;
+             unsafe {
+                 std::ptr::copy_nonoverlapping(
+                     bytes.as_ptr(),
+-                    &mut word as *mut usize as *mut u8,
++                    &mut word as *mut u64 as *mut u8,
+                     len,
+                 );
+             }
+-            let word = Self::set_marker_bit(word, width);
++            let word = Self::set_marker_bit(word as u64, width);
+             Self(word)
+         } else {
+             let vec = Box::new(TeenyStringHeap {
+@@ -708,35 +688,15 @@ impl TeenyString {
+                 width,
+             });
+             let ptr = Box::into_raw(vec);
+-            Self(ptr as usize)
++            Self(ptr as u64)
+         }
+     }
+ 
+     pub const fn space() -> Self {
+         Self(if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000020
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000020
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8020
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000020
+         } else {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x20000000_00000001
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x20000001
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x2001
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x20000000_00000001
+         })
+     }
+ 
+@@ -753,7 +713,7 @@ impl TeenyString {
+                 1
+             }
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).width }
+         }
+     }
+@@ -766,17 +726,17 @@ impl TeenyString {
+ 
+     pub fn as_bytes(&self) -> &[u8] {
+         if Self::is_marker_bit_set(self.0) {
+-            let bytes = &self.0 as *const usize as *const u8;
++            let bytes = &self.0 as *const u64 as *const u8;
+             let bytes =
+-                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<usize>() - 1) };
++                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<u64>() - 1) };
+             let len = bytes
+                 .iter()
+                 .position(|&b| b == 0)
+-                .unwrap_or(std::mem::size_of::<usize>() - 1);
++                .unwrap_or(std::mem::size_of::<u64>() - 1);
+ 
+             &bytes[0..len]
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).bytes.as_slice() }
+         }
+     }
+@@ -1072,6 +1032,11 @@ mod test {
+ 
+     #[test]
+     fn teeny_string() {
++        assert!(
++            std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
++            "if a pointer doesn't fit in u64 then we need to change TeenyString"
++        );
++
+         let s = TeenyString::from_char('a');
+         assert_eq!(s.as_bytes(), &[b'a']);
+ 
diff --git a/srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch b/srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch
new file mode 100644
index 000000000000..1d8e21384ae9
--- /dev/null
+++ b/srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch
@@ -0,0 +1,22 @@
+--- a/wezterm-font/src/parser.rs	2022-09-05 10:28:02.000000000 -0700
++++ b/wezterm-font/src/parser.rs	2022-10-24 09:06:02.529054286 -0700
+@@ -715,19 +715,6 @@
+         font!("../../assets/fonts/JetBrainsMono-Regular.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-ThinItalic.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-Black.ttf"),
+-        font!("../../assets/fonts/Roboto-BlackItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Bold.ttf"),
+-        font!("../../assets/fonts/Roboto-BoldItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Italic.ttf"),
+-        font!("../../assets/fonts/Roboto-Light.ttf"),
+-        font!("../../assets/fonts/Roboto-LightItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Medium.ttf"),
+-        font!("../../assets/fonts/Roboto-MediumItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Regular.ttf"),
+-        font!("../../assets/fonts/Roboto-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-ThinItalic.ttf"),
+-        font!("../../assets/fonts/NotoColorEmoji.ttf"),
+         font!("../../assets/fonts/Symbols-Nerd-Font-Mono.ttf"),
+         font!("../../assets/fonts/LastResortHE-Regular.ttf"),
+     ] {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
new file mode 100644
index 000000000000..aacb21d029a1
--- /dev/null
+++ b/srcpkgs/wezterm/template
@@ -0,0 +1,69 @@
+# Template file for 'wezterm'
+pkgname=wezterm
+version=20220905
+revision=1
+_srcver=${version}-102802-7d4b8249
+wrksrc="${pkgname}-${_srcver}"
+build_style=cargo
+hostmakedepends="pkg-config"
+makedepends="fontconfig-devel freetype-devel harfbuzz-devel openssl-devel
+ libX11-devel libxkbcommon-devel libxkbcommon-x11 wayland-devel xcb-util-devel
+ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel"
+depends="noto-fonts-emoji fonts-roboto-ttf"
+short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer"
+maintainer="Joseph Benden <joe@benden.us>"
+license="MIT"
+homepage="https://wezfurlong.org/wezterm/"
+changelog="https://wezfurlong.org/wezterm/changelog.html"
+distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/wezterm-${_srcver}-src.tar.gz"
+checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545"
+nocross=yes # ftbfs in libgit+libssh
+
+do_build() {
+	for _target in wezterm wezterm-mux-server strip-ansi-escapes; do
+		cargo build --target ${RUST_TARGET} --release -p ${_target} \
+			--no-default-features
+	done
+	cargo build --target ${RUST_TARGET} --release -p wezterm-gui \
+		--no-default-features \
+		--features distro-defaults,wayland
+}
+
+do_check() {
+	# NOTE: cannot use build_style cargo do_check because of --release flag.
+	# NOTE: e2e::sftp is skipped due to missing ssh
+	# NOTE: shapecache::test::ligatures_jetbrains is skipped due to removal of fonts
+	cargo test --target ${RUST_TARGET} --workspace --locked -- \
+		--skip e2e::sftp \
+		--skip shapecache::test::ligatures_jetbrains
+}
+
+do_install() {
+	vbin target/${RUST_TARGET}/release/wezterm
+	vbin target/${RUST_TARGET}/release/wezterm-gui
+	vbin target/${RUST_TARGET}/release/wezterm-mux-server
+	vbin target/${RUST_TARGET}/release/strip-ansi-escapes
+
+	vinstall assets/shell-integration/wezterm.sh 644 etc/profile.d org_wezfurlong_wezterm.sh
+	vinstall assets/icon/terminal.png 644 usr/share/icons/hicolor/128x128/apps org.wezfurlong.wezterm.png
+	vinstall assets/icon/wezterm-icon.svg 644 usr/share/icons/hicolor/scalable/apps org.wezfurlong.wezterm.svg
+	vinstall assets/wezterm.desktop 644 usr/share/applications org.wezfurlong.wezterm.desktop
+	vinstall assets/wezterm.appdata.xml 644 usr/share/metainfo org.wezfurlong.wezterm.appdata.xml
+
+	vcompletion assets/shell-completion/bash bash
+	vcompletion assets/shell-completion/fish fish
+	vcompletion assets/shell-completion/zsh zsh
+
+	vmkdir usr/share/terminfo
+	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+
+	vdoc README.md
+	vlicense LICENSE.md
+}
+
+wezterm-terminfo_package() {
+	short_desc+=" - terminfo data"
+	pkg_install() {
+		vmove usr/share/terminfo
+	}
+}
diff --git a/srcpkgs/wezterm/update b/srcpkgs/wezterm/update
new file mode 100644
index 000000000000..4d2ef98f356b
--- /dev/null
+++ b/srcpkgs/wezterm/update
@@ -0,0 +1,2 @@
+site="https://github.com/wez/wezterm/releases"
+pattern='/tags/\K[\d.]+(?=-\d+-[a-f0-9]+.tar.gz)'

From 482c9528fad042a029fefbcc3ed4566b4696f744 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH 2/2] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index 3452b38c1332..a748fdc7fb6d 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..dfee3c9aafe0 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if [ -n "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..f6e0c8d471cd 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm -f ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index aacb21d029a1..fac637e92f3e 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -54,8 +54,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: [PR REVIEW] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (5 preceding siblings ...)
  2022-10-28 15:18 ` [PR PATCH] [Updated] " jbenden
@ 2022-10-28 15:18 ` jbenden
  2022-11-10 17:19 ` [PR PATCH] [Updated] " jbenden
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-10-28 15:18 UTC (permalink / raw)
  To: ml

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

New review comment by jbenden on void-packages repository

https://github.com/void-linux/void-packages/pull/40168#discussion_r1008181742

Comment:
Thanks for the review!

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (6 preceding siblings ...)
  2022-10-28 15:18 ` [PR REVIEW] " jbenden
@ 2022-11-10 17:19 ` jbenden
  2022-11-23 17:28 ` jbenden
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-11-10 17:19 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From 857cf02a18f041b645b057b3d8b8387a58c59318 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Sun, 24 Apr 2022 10:16:12 -0700
Subject: [PATCH 1/2] New package: wezterm-20220905_1

Fixes: #35721
Signed-off-by: Joseph Benden <joe@benden.us>
---
 srcpkgs/wezterm-terminfo                      |   1 +
 srcpkgs/wezterm/patches/0001-32bit.patch      | 232 ++++++++++++++++++
 .../patches/0002-remove-distro-fonts.patch    |  22 ++
 srcpkgs/wezterm/template                      |  68 +++++
 srcpkgs/wezterm/update                        |   2 +
 5 files changed, 325 insertions(+)
 create mode 120000 srcpkgs/wezterm-terminfo
 create mode 100644 srcpkgs/wezterm/patches/0001-32bit.patch
 create mode 100644 srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch
 create mode 100644 srcpkgs/wezterm/template
 create mode 100644 srcpkgs/wezterm/update

diff --git a/srcpkgs/wezterm-terminfo b/srcpkgs/wezterm-terminfo
new file mode 120000
index 000000000000..37d60f7b3b71
--- /dev/null
+++ b/srcpkgs/wezterm-terminfo
@@ -0,0 +1 @@
+wezterm
\ No newline at end of file
diff --git a/srcpkgs/wezterm/patches/0001-32bit.patch b/srcpkgs/wezterm/patches/0001-32bit.patch
new file mode 100644
index 000000000000..d374a275d235
--- /dev/null
+++ b/srcpkgs/wezterm/patches/0001-32bit.patch
@@ -0,0 +1,232 @@
+From 7b904f05eb4de9ed44d2068355a571b117eba0e1 Mon Sep 17 00:00:00 2001
+From: Wez Furlong <wez@wezfurlong.org>
+Date: Sat, 15 Oct 2022 16:45:02 -0700
+Subject: [PATCH] termwiz: fixup for 32-bit systems
+
+I noticed from https://github.com/void-linux/void-packages/pull/36903
+that 32-bit systems were failing to pass the test suite.
+
+Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
+teeny_string` showed that we were faulting in the teenystring code
+and digging a bit deeper showed that it was because our assumptions
+about the high bits were wrong for 32-bit systems.
+
+Fix this by making TeenyString based around a u64 rather than usize
+so that we guarantee its size on all current systems.
+---
+ Cargo.lock          |  1 -
+ termwiz/Cargo.toml  |  1 -
+ termwiz/src/cell.rs | 87 ++++++++++++++-------------------------------
+ 3 files changed, 26 insertions(+), 63 deletions(-)
+
+diff --git a/Cargo.lock b/Cargo.lock
+index 4f976535be..243e3a2b24 100644
+--- a/Cargo.lock
++++ b/Cargo.lock
+@@ -4739,7 +4739,6 @@ dependencies = [
+  "base64",
+  "bitflags",
+  "cassowary",
+- "cfg-if 1.0.0",
+  "criterion",
+  "env_logger",
+  "filedescriptor",
+diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
+index d8d7ab543c..e843bac261 100644
+--- a/termwiz/Cargo.toml
++++ b/termwiz/Cargo.toml
+@@ -15,7 +15,6 @@ readme = "README.md"
+ base64 = "0.13"
+ bitflags = "1.3"
+ cassowary = {version="0.3", optional=true}
+-cfg-if = "1.0"
+ anyhow = "1.0"
+ filedescriptor = { version="0.8", path = "../filedescriptor" }
+ finl_unicode = "1.1"
+diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs
+index ddf38a93bb..70d6099dd0 100644
+--- a/termwiz/src/cell.rs
++++ b/termwiz/src/cell.rs
+@@ -590,7 +590,7 @@ where
+     s.serialize(serializer)
+ }
+ 
+-/// TeenyString encodes string storage in a single machine word.
++/// TeenyString encodes string storage in a single u64.
+ /// The scheme is simple but effective: strings that encode into a
+ /// byte slice that is 1 less byte than the machine word size can
+ /// be encoded directly into the usize bits stored in the struct.
+@@ -603,60 +603,40 @@ where
+ /// calling grapheme_column_width; if it is set, then the TeenyString
+ /// has length 2, otherwise, it has length 1 (we don't allow zero-length
+ /// strings).
+-struct TeenyString(usize);
++struct TeenyString(u64);
+ struct TeenyStringHeap {
+     bytes: Vec<u8>,
+     width: usize,
+ }
+ 
+ impl TeenyString {
+-    const fn marker_mask() -> usize {
++    const fn marker_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000000
+         } else {
+             0x1
+         }
+     }
+ 
+-    const fn double_wide_mask() -> usize {
++    const fn double_wide_mask() -> u64 {
+         if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0xc0000000_00000000
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0xc0000000
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0xc000
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0xc0000000_00000000
+         } else {
+             0x3
+         }
+     }
+ 
+-    const fn is_marker_bit_set(word: usize) -> bool {
++    const fn is_marker_bit_set(word: u64) -> bool {
+         let mask = Self::marker_mask();
+         word & mask == mask
+     }
+ 
+-    const fn is_double_width(word: usize) -> bool {
++    const fn is_double_width(word: u64) -> bool {
+         let mask = Self::double_wide_mask();
+         word & mask == mask
+     }
+ 
+-    const fn set_marker_bit(word: usize, width: usize) -> usize {
++    const fn set_marker_bit(word: u64, width: usize) -> u64 {
+         if width > 1 {
+             word | Self::double_wide_mask()
+         } else {
+@@ -689,18 +669,18 @@ impl TeenyString {
+         let len = bytes.len();
+         let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));
+ 
+-        if len < std::mem::size_of::<usize>() {
++        if len < std::mem::size_of::<u64>() {
+             debug_assert!(width < 3);
+ 
+-            let mut word = 0usize;
++            let mut word = 0u64;
+             unsafe {
+                 std::ptr::copy_nonoverlapping(
+                     bytes.as_ptr(),
+-                    &mut word as *mut usize as *mut u8,
++                    &mut word as *mut u64 as *mut u8,
+                     len,
+                 );
+             }
+-            let word = Self::set_marker_bit(word, width);
++            let word = Self::set_marker_bit(word as u64, width);
+             Self(word)
+         } else {
+             let vec = Box::new(TeenyStringHeap {
+@@ -708,35 +688,15 @@ impl TeenyString {
+                 width,
+             });
+             let ptr = Box::into_raw(vec);
+-            Self(ptr as usize)
++            Self(ptr as u64)
+         }
+     }
+ 
+     pub const fn space() -> Self {
+         Self(if cfg!(target_endian = "little") {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x80000000_00000020
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x80000020
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x8020
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x80000000_00000020
+         } else {
+-            cfg_if::cfg_if! {
+-                if #[cfg(target_pointer_width = "64")] {
+-                    0x20000000_00000001
+-                } else if #[cfg(target_pointer_width = "32")] {
+-                    0x20000001
+-                } else if #[cfg(target_pointer_width = "16")] {
+-                    0x2001
+-                } else {
+-                    panic!("unsupported target");
+-                }
+-            }
++            0x20000000_00000001
+         })
+     }
+ 
+@@ -753,7 +713,7 @@ impl TeenyString {
+                 1
+             }
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).width }
+         }
+     }
+@@ -766,17 +726,17 @@ impl TeenyString {
+ 
+     pub fn as_bytes(&self) -> &[u8] {
+         if Self::is_marker_bit_set(self.0) {
+-            let bytes = &self.0 as *const usize as *const u8;
++            let bytes = &self.0 as *const u64 as *const u8;
+             let bytes =
+-                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<usize>() - 1) };
++                unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::<u64>() - 1) };
+             let len = bytes
+                 .iter()
+                 .position(|&b| b == 0)
+-                .unwrap_or(std::mem::size_of::<usize>() - 1);
++                .unwrap_or(std::mem::size_of::<u64>() - 1);
+ 
+             &bytes[0..len]
+         } else {
+-            let heap = self.0 as *const usize as *const TeenyStringHeap;
++            let heap = self.0 as *const u64 as *const TeenyStringHeap;
+             unsafe { (*heap).bytes.as_slice() }
+         }
+     }
+@@ -1072,6 +1032,11 @@ mod test {
+ 
+     #[test]
+     fn teeny_string() {
++        assert!(
++            std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
++            "if a pointer doesn't fit in u64 then we need to change TeenyString"
++        );
++
+         let s = TeenyString::from_char('a');
+         assert_eq!(s.as_bytes(), &[b'a']);
+ 
diff --git a/srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch b/srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch
new file mode 100644
index 000000000000..1d8e21384ae9
--- /dev/null
+++ b/srcpkgs/wezterm/patches/0002-remove-distro-fonts.patch
@@ -0,0 +1,22 @@
+--- a/wezterm-font/src/parser.rs	2022-09-05 10:28:02.000000000 -0700
++++ b/wezterm-font/src/parser.rs	2022-10-24 09:06:02.529054286 -0700
+@@ -715,19 +715,6 @@
+         font!("../../assets/fonts/JetBrainsMono-Regular.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-ThinItalic.ttf"),
+         font!("../../assets/fonts/JetBrainsMono-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-Black.ttf"),
+-        font!("../../assets/fonts/Roboto-BlackItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Bold.ttf"),
+-        font!("../../assets/fonts/Roboto-BoldItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Italic.ttf"),
+-        font!("../../assets/fonts/Roboto-Light.ttf"),
+-        font!("../../assets/fonts/Roboto-LightItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Medium.ttf"),
+-        font!("../../assets/fonts/Roboto-MediumItalic.ttf"),
+-        font!("../../assets/fonts/Roboto-Regular.ttf"),
+-        font!("../../assets/fonts/Roboto-Thin.ttf"),
+-        font!("../../assets/fonts/Roboto-ThinItalic.ttf"),
+-        font!("../../assets/fonts/NotoColorEmoji.ttf"),
+         font!("../../assets/fonts/Symbols-Nerd-Font-Mono.ttf"),
+         font!("../../assets/fonts/LastResortHE-Regular.ttf"),
+     ] {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
new file mode 100644
index 000000000000..2c03ea294cf4
--- /dev/null
+++ b/srcpkgs/wezterm/template
@@ -0,0 +1,68 @@
+# Template file for 'wezterm'
+pkgname=wezterm
+version=20220905
+revision=1
+_srcver=${version}-102802-7d4b8249
+build_style=cargo
+hostmakedepends="pkg-config"
+makedepends="fontconfig-devel freetype-devel harfbuzz-devel openssl-devel
+ libX11-devel libxkbcommon-devel libxkbcommon-x11 wayland-devel xcb-util-devel
+ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel"
+depends="noto-fonts-emoji fonts-roboto-ttf"
+short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer"
+maintainer="Joseph Benden <joe@benden.us>"
+license="MIT"
+homepage="https://wezfurlong.org/wezterm/"
+changelog="https://wezfurlong.org/wezterm/changelog.html"
+distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/wezterm-${_srcver}-src.tar.gz"
+checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545"
+nocross=yes # ftbfs in libgit+libssh
+
+do_build() {
+	for _target in wezterm wezterm-mux-server strip-ansi-escapes; do
+		cargo build --target ${RUST_TARGET} --release -p ${_target} \
+			--no-default-features
+	done
+	cargo build --target ${RUST_TARGET} --release -p wezterm-gui \
+		--no-default-features \
+		--features distro-defaults,wayland
+}
+
+do_check() {
+	# NOTE: cannot use build_style cargo do_check because of --release flag.
+	# NOTE: e2e::sftp is skipped due to missing ssh
+	# NOTE: shapecache::test::ligatures_jetbrains is skipped due to removal of fonts
+	cargo test --target ${RUST_TARGET} --workspace --locked -- \
+		--skip e2e::sftp \
+		--skip shapecache::test::ligatures_jetbrains
+}
+
+do_install() {
+	vbin target/${RUST_TARGET}/release/wezterm
+	vbin target/${RUST_TARGET}/release/wezterm-gui
+	vbin target/${RUST_TARGET}/release/wezterm-mux-server
+	vbin target/${RUST_TARGET}/release/strip-ansi-escapes
+
+	vinstall assets/shell-integration/wezterm.sh 644 etc/profile.d org_wezfurlong_wezterm.sh
+	vinstall assets/icon/terminal.png 644 usr/share/icons/hicolor/128x128/apps org.wezfurlong.wezterm.png
+	vinstall assets/icon/wezterm-icon.svg 644 usr/share/icons/hicolor/scalable/apps org.wezfurlong.wezterm.svg
+	vinstall assets/wezterm.desktop 644 usr/share/applications org.wezfurlong.wezterm.desktop
+	vinstall assets/wezterm.appdata.xml 644 usr/share/metainfo org.wezfurlong.wezterm.appdata.xml
+
+	vcompletion assets/shell-completion/bash bash
+	vcompletion assets/shell-completion/fish fish
+	vcompletion assets/shell-completion/zsh zsh
+
+	vmkdir usr/share/terminfo
+	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+
+	vdoc README.md
+	vlicense LICENSE.md
+}
+
+wezterm-terminfo_package() {
+	short_desc+=" - terminfo data"
+	pkg_install() {
+		vmove usr/share/terminfo
+	}
+}
diff --git a/srcpkgs/wezterm/update b/srcpkgs/wezterm/update
new file mode 100644
index 000000000000..4d2ef98f356b
--- /dev/null
+++ b/srcpkgs/wezterm/update
@@ -0,0 +1,2 @@
+site="https://github.com/wez/wezterm/releases"
+pattern='/tags/\K[\d.]+(?=-\d+-[a-f0-9]+.tar.gz)'

From 596b7e394177b464ee701880b4254aabb0994e10 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH 2/2] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index fa552f65ba5d..577911161d73 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..dfee3c9aafe0 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if [ -n "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..f6e0c8d471cd 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm -f ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index 2c03ea294cf4..0ee473a32fd7 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -53,8 +53,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (7 preceding siblings ...)
  2022-11-10 17:19 ` [PR PATCH] [Updated] " jbenden
@ 2022-11-23 17:28 ` jbenden
  2023-02-22  2:01 ` github-actions
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2022-11-23 17:28 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From 2229451f235b341bbfa97f3052f3ba7f0b1389c8 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index fa552f65ba5d..577911161d73 100644
--- a/Manual.md
+++ b/Manual.md
@@ -323,13 +323,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 5f0571de14ae..dfee3c9aafe0 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -265,3 +265,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if [ -n "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 599fa463410d..c47c0e146904 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..f6e0c8d471cd 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm -f ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index abd2a245845c..ab76fa37c5b1 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -44,8 +44,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (8 preceding siblings ...)
  2022-11-23 17:28 ` jbenden
@ 2023-02-22  2:01 ` github-actions
  2023-02-22 15:57 ` [PR PATCH] [Updated] " jbenden
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: github-actions @ 2023-02-22  2:01 UTC (permalink / raw)
  To: ml

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

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/40168#issuecomment-1439331597

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

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

* Re: [PR PATCH] [Updated] Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (9 preceding siblings ...)
  2023-02-22  2:01 ` github-actions
@ 2023-02-22 15:57 ` jbenden
  2023-02-22 17:33 ` jbenden
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2023-02-22 15:57 UTC (permalink / raw)
  To: ml

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

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

https://github.com/jbenden/void-packages vterminfo
https://github.com/void-linux/void-packages/pull/40168

Add vterminfo template function
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

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

From c564a9e8d41f8aec6ddccfbb7693cfa209bb1105 Mon Sep 17 00:00:00 2001
From: Joseph Benden <joe@benden.us>
Date: Wed, 26 Oct 2022 09:39:06 -0700
Subject: [PATCH] common/environment/setup/install.sh: add vterminfo

Signed-off-by: Joseph Benden <joe@benden.us>
---
 Manual.md                           |  9 +++++++-
 common/environment/setup/install.sh | 32 ++++++++++++++++++++++++++++-
 srcpkgs/alacritty/template          |  3 +--
 srcpkgs/mtm/template                |  3 +--
 srcpkgs/ncurses/template            |  1 +
 srcpkgs/wezterm/template            |  3 +--
 6 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/Manual.md b/Manual.md
index 0b6b5ab645fc..c48b517397bf 100644
--- a/Manual.md
+++ b/Manual.md
@@ -328,13 +328,20 @@ 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>]`
+- *vcompletion()* `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`.
 
+- *vterminfo()* `vterminfo <file> [entries]`
+
+	Processes `file` document via `tic(1)` to generate a terminfo database entry,
+	optionally for each of the specified `entries` terminfo entries. The produced
+	terminfo file is written to `masterdir/destdir` ready for package inclusion,
+	using say `vmove usr/share/terminfo`.
+
 > 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 b0c5b22f4c2a..7eaf7cbb1b04 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 vcompletion 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 vterminfo; do
        alias ${cmd}="set -f; _noglob_helper _${cmd}"
 done
 
@@ -274,3 +274,33 @@ _vcompletion() {
 			;;
 	esac
 }
+
+_vterminfo() {
+	local file="$1" entries="$2"
+	local _terminfo_dir=usr/share/terminfo
+	local _args=
+
+	if [ $# -lt 1 ]; then
+		msg_red "$pkgver: vterminfo: at least 1 argument expected: <file> [entries]\n"
+		return 1
+	elif ! [ -f "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' does not exist.\n"
+		return 1
+	elif ! [ -r "$file" ]; then
+		msg_red "$pkgver: vterminfo: file '$file' is not readable.\n"
+		return 1
+	elif  [ -z "$PKGDESTDIR" ]; then
+		msg_red "$pkgver: vterminfo: PKGDESTDIR unset, can't continue...\n"
+		return 1
+	elif ! [ -x /usr/bin/tic ]; then
+		msg_red "$pkgver: vterminfo: 'tic' binary is missing, can't continue...\n"
+		return 1
+	fi
+
+	if [ -n "$entries" ]; then
+		_args="-e ${entries}"
+	fi
+
+	vmkdir "${_terminfo_dir}"
+	/usr/bin/tic -sx ${_args} -o "${PKGDESTDIR}/${_terminfo_dir}" "$file"
+}
diff --git a/srcpkgs/alacritty/template b/srcpkgs/alacritty/template
index 57873e263b55..b993f7a6927b 100644
--- a/srcpkgs/alacritty/template
+++ b/srcpkgs/alacritty/template
@@ -30,8 +30,7 @@ post_install() {
 	vinstall extra/logo/alacritty-term.svg 644 usr/share/icons/hicolor/scalable/apps Alacritty.svg
 	vman extra/alacritty.man alacritty.1
 	vsconf alacritty.yml
-
-	tic -o ${DESTDIR}/usr/share/terminfo -xe alacritty,alacritty-direct extra/alacritty.info
+	vterminfo extra/alacritty.info alacritty,alacritty-direct
 }
 
 alacritty-terminfo_package() {
diff --git a/srcpkgs/mtm/template b/srcpkgs/mtm/template
index 94376fdb8ca7..05ea7003602a 100644
--- a/srcpkgs/mtm/template
+++ b/srcpkgs/mtm/template
@@ -17,8 +17,7 @@ do_build() {
 
 do_install() {
 	vbin mtm
-	mkdir -p ${DESTDIR}/usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo mtm.ti
+	vterminfo mtm.ti mtm,mtm-256color,mtm-noutf
 	vman mtm.1
 }
 
diff --git a/srcpkgs/ncurses/template b/srcpkgs/ncurses/template
index 7a56c537bf2e..f6e0c8d471cd 100644
--- a/srcpkgs/ncurses/template
+++ b/srcpkgs/ncurses/template
@@ -103,6 +103,7 @@ post_install() {
 	rm ${DESTDIR}/usr/share/terminfo/d/dvtm{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/s/st{,-256color}
 	rm ${DESTDIR}/usr/share/terminfo/f/foot{,-direct,+base}
+	rm -f ${DESTDIR}/usr/share/terminfo/w/wezterm
 }
 
 ncurses-libs_package() {
diff --git a/srcpkgs/wezterm/template b/srcpkgs/wezterm/template
index 8c075920877c..a684223e7534 100644
--- a/srcpkgs/wezterm/template
+++ b/srcpkgs/wezterm/template
@@ -48,8 +48,7 @@ do_install() {
 	vcompletion assets/shell-completion/fish fish
 	vcompletion assets/shell-completion/zsh zsh
 
-	vmkdir usr/share/terminfo
-	tic -sx -o ${DESTDIR}/usr/share/terminfo termwiz/data/wezterm.terminfo
+	vterminfo termwiz/data/wezterm.terminfo
 
 	vdoc README.md
 	vlicense LICENSE.md

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

* Re: Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (10 preceding siblings ...)
  2023-02-22 15:57 ` [PR PATCH] [Updated] " jbenden
@ 2023-02-22 17:33 ` jbenden
  2023-05-25  1:53 ` github-actions
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2023-02-22 17:33 UTC (permalink / raw)
  To: ml

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

New comment by jbenden on void-packages repository

https://github.com/void-linux/void-packages/pull/40168#issuecomment-1440480031

Comment:
bump

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

* Re: Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (11 preceding siblings ...)
  2023-02-22 17:33 ` jbenden
@ 2023-05-25  1:53 ` github-actions
  2023-05-25 17:06 ` jbenden
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: github-actions @ 2023-05-25  1:53 UTC (permalink / raw)
  To: ml

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

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/40168#issuecomment-1562147572

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

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

* Re: Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (12 preceding siblings ...)
  2023-05-25  1:53 ` github-actions
@ 2023-05-25 17:06 ` jbenden
  2023-08-25  1:44 ` github-actions
  2023-09-08  1:45 ` [PR PATCH] [Closed]: " github-actions
  15 siblings, 0 replies; 17+ messages in thread
From: jbenden @ 2023-05-25 17:06 UTC (permalink / raw)
  To: ml

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

New comment by jbenden on void-packages repository

https://github.com/void-linux/void-packages/pull/40168#issuecomment-1563237292

Comment:
bump

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

* Re: Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (13 preceding siblings ...)
  2023-05-25 17:06 ` jbenden
@ 2023-08-25  1:44 ` github-actions
  2023-09-08  1:45 ` [PR PATCH] [Closed]: " github-actions
  15 siblings, 0 replies; 17+ messages in thread
From: github-actions @ 2023-08-25  1:44 UTC (permalink / raw)
  To: ml

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

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/40168#issuecomment-1692635216

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

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

* Re: [PR PATCH] [Closed]: Add vterminfo template function
  2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
                   ` (14 preceding siblings ...)
  2023-08-25  1:44 ` github-actions
@ 2023-09-08  1:45 ` github-actions
  15 siblings, 0 replies; 17+ messages in thread
From: github-actions @ 2023-09-08  1:45 UTC (permalink / raw)
  To: ml

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

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

Add vterminfo template function
https://github.com/void-linux/void-packages/pull/40168

Description:
#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (`x86_64`-`glibc`)

#### Notes
During development of the `wezterm` package, it became apparent that no helpers exists to assist in the creation of terminfo compilation databases and multiple packages did their own "thing"(tm). This patch aims to resolve this situation.

This patch *includes* changes from another PR. It must **NOT** be merged until #36903.

@classabbyamp  

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

end of thread, other threads:[~2023-09-08  1:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 16:47 [PR PATCH] Add vterminfo template function jbenden
2022-10-26 16:52 ` [PR PATCH] [Updated] " jbenden
2022-10-26 17:06 ` jbenden
2022-10-28  1:12 ` jbenden
2022-10-28  2:03 ` jbenden
2022-10-28  2:35 ` [PR REVIEW] " sgn
2022-10-28 15:18 ` [PR PATCH] [Updated] " jbenden
2022-10-28 15:18 ` [PR REVIEW] " jbenden
2022-11-10 17:19 ` [PR PATCH] [Updated] " jbenden
2022-11-23 17:28 ` jbenden
2023-02-22  2:01 ` github-actions
2023-02-22 15:57 ` [PR PATCH] [Updated] " jbenden
2023-02-22 17:33 ` jbenden
2023-05-25  1:53 ` github-actions
2023-05-25 17:06 ` jbenden
2023-08-25  1:44 ` github-actions
2023-09-08  1:45 ` [PR PATCH] [Closed]: " github-actions

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