From 698b5748a94ef80e1379810818d27b0b4f9bee87 Mon Sep 17 00:00:00 2001 From: Joseph Benden 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 --- 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 +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/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 " +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 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 --- 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()* ` []` +- *vcompletion()* `vcompletion []` Installs shell completion from `file` for `command`, in the correct location and with the appropriate filename for `shell`. If `command` isn't specified, it will default to `pkgname`. The `shell` argument can be one of `bash`, `fish` or `zsh`. +- *vterminfo()* `vterminfo [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"`. 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: [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