From a90aab1230fdfe7f148bdfca6ad00287a1ae5883 Mon Sep 17 00:00:00 2001 From: Joseph Benden Date: Sun, 24 Apr 2022 10:16:12 -0700 Subject: [PATCH] New package: wezterm-20220905_1 Fixes: #35721 Signed-off-by: Joseph Benden --- srcpkgs/nautilus-wezterm | 1 + srcpkgs/wezterm-terminfo | 1 + ...4f05eb4de9ed44d2068355a571b117eba0e1.patch | 232 ++++++++++++++++++ srcpkgs/wezterm/template | 63 +++++ srcpkgs/wezterm/update | 2 + srcpkgs/wezterm/wezterm-terminfo.INSTALL | 6 + srcpkgs/wezterm/wezterm-terminfo.REMOVE | 6 + 7 files changed, 311 insertions(+) create mode 120000 srcpkgs/nautilus-wezterm create mode 120000 srcpkgs/wezterm-terminfo create mode 100644 srcpkgs/wezterm/patches/7b904f05eb4de9ed44d2068355a571b117eba0e1.patch create mode 100644 srcpkgs/wezterm/template create mode 100644 srcpkgs/wezterm/update create mode 100644 srcpkgs/wezterm/wezterm-terminfo.INSTALL create mode 100644 srcpkgs/wezterm/wezterm-terminfo.REMOVE diff --git a/srcpkgs/nautilus-wezterm b/srcpkgs/nautilus-wezterm new file mode 120000 index 000000000000..37d60f7b3b71 --- /dev/null +++ b/srcpkgs/nautilus-wezterm @@ -0,0 +1 @@ +wezterm \ No newline at end of file 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 +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, + 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::() { ++ if len < std::mem::size_of::() { + 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::() - 1) }; ++ unsafe { std::slice::from_raw_parts(bytes, std::mem::size_of::() - 1) }; + let len = bytes + .iter() + .position(|&b| b == 0) +- .unwrap_or(std::mem::size_of::() - 1); ++ .unwrap_or(std::mem::size_of::() - 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::() <= std::mem::size_of::(), ++ "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/template b/srcpkgs/wezterm/template new file mode 100644 index 000000000000..c7e71a356161 --- /dev/null +++ b/srcpkgs/wezterm/template @@ -0,0 +1,63 @@ +# Template file for 'wezterm' +pkgname=wezterm +version=20220905 +revision=1 +_srcver=20220905-102802-7d4b8249 +wrksrc="${pkgname}-${_srcver}" +build_style=cargo +hostmakedepends="pkg-config python3" +makedepends="nautilus-python fontconfig-devel freetype-devel harfbuzz-devel + libssh2-devel libX11-devel libxkbcommon-devel libxkbcommon-x11 + python3-devel wayland-devel xcb-util-devel xcb-util-image-devel + xcb-util-keysyms-devel xcb-util-wm-devel zlib-devel" +depends="fonts-roboto-ttf" +short_desc="GPU-accelerated cross-platform terminal emulator and multiplexer" +maintainer="Joseph Benden " +license="MIT" +homepage="https://wezfurlong.org/wezterm/" +distfiles="https://github.com/wez/wezterm/releases/download/${_srcver}/${pkgname}-${_srcver}-src.tar.gz" +checksum="5898af2bb2dbedcae2648764d5b7abd3d98b0aa3d05d171b09e0e3f76b7dd545" +python_version=3 + +do_check() { + local _args="--skip e2e::sftp" + + # cannot use build_style cargo do_check because of --release flag. + cargo test --target ${RUST_TARGET} --workspace --locked -- ${_args} +} + +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 + 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 + vinstall assets/shell-completion/bash 644 usr/share/bash-completion/completions $pkgname + vinstall assets/shell-completion/fish 644 usr/share/fish/vendor_completions.d $pkgname.fish + vinstall assets/shell-completion/zsh 644 usr/share/zsh/site-functions _$pkgname + + vdoc README.md + vlicense LICENSE.md +} + +nautilus-wezterm_package() { + short_desc+=" - Nautilus plugin" + pycompile_dirs="usr/share/nautilus-python/extensions" + depends="wezterm>=${version}_${revision} nautilus-python" + pkg_install() { + vinstall assets/wezterm-nautilus.py 644 usr/share/nautilus-python/extensions + } +} + +wezterm-terminfo_package() { + short_desc+=" - terminfo data" + depends="ncurses" + pkg_install() { + vinstall termwiz/data/wezterm.terminfo 644 usr/share/terminfo/w + } +} 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)' diff --git a/srcpkgs/wezterm/wezterm-terminfo.INSTALL b/srcpkgs/wezterm/wezterm-terminfo.INSTALL new file mode 100644 index 000000000000..74c2dcfdc3b9 --- /dev/null +++ b/srcpkgs/wezterm/wezterm-terminfo.INSTALL @@ -0,0 +1,6 @@ +case "$ACTION" in +post) + # Compile the terminfo description. + tic -xs usr/share/terminfo/w/wezterm.terminfo + ;; +esac diff --git a/srcpkgs/wezterm/wezterm-terminfo.REMOVE b/srcpkgs/wezterm/wezterm-terminfo.REMOVE new file mode 100644 index 000000000000..4fb55ac8de97 --- /dev/null +++ b/srcpkgs/wezterm/wezterm-terminfo.REMOVE @@ -0,0 +1,6 @@ +case "$ACTION" in +pre) + # Remove compiled terminfo files. + rm -f usr/share/terminfo/w/wezterm + ;; +esac