From 9c4dd9da7931f80e43c6f5300f9821305c11d3c7 Mon Sep 17 00:00:00 2001 From: diviocity Date: Sun, 29 Nov 2026 23:22:55 +0100 Subject: [PATCH] Package zsh with loadable editor, completion, PCRE2 and capability modules --- zsh/PKGBUILD.vile | 49 ++++++++++++++++++++++++++++++++++++ zsh/zprofile | 10 ++++++++ zsh/zshenv | 13 ++++++++++ zsh/zshrc | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 zsh/PKGBUILD.vile create mode 100644 zsh/zprofile create mode 100644 zsh/zshenv create mode 100644 zsh/zshrc diff --git a/zsh/PKGBUILD.vile b/zsh/PKGBUILD.vile new file mode 100644 index 0000000..063c3b2 --- /dev/null +++ b/zsh/PKGBUILD.vile @@ -0,0 +1,49 @@ +; 5.9.2 supports PCRE2 and keeps the /bin/zsh and /etc/zsh layout used by Vinix. +defpkgbuild(zsh, + #:pkgname, "zsh", + #:pkgver, "5.9.2", + #:pkgrel, 1, + #:pkgdesc, "Interactive shell with line editing, completions and loadable modules", + #:arch, [#:x86-64], + #:url, "https://www.zsh.org/", + #:license, "MIT-Modern-Variant AND GPL-2.0-only", + #:depends, ["musl", "ncurses", "pcre2", "libcap"], + #:makedepends, ["linux-headers"], + #:backup, ["etc/zsh/zshenv", "etc/zsh/zprofile", "etc/zsh/zshrc"], + #:source, ["https://distfiles.alpinelinux.org/distfiles/edge/zsh-5.9.2.tar.xz", + "zprofile", "zshenv", "zshrc"], + #:sha256sums, ["36fa734374b44783582cec09bcd67822e2f992c779ec1624ab5596df078d2f81", + "5b7382c22b140b2d1027d2c1cc1805498bcd12ea508b1b76c333b952da52599a", + "798b8e41ed0ed2ffdc4a2d6fabf3099063e40b74b51fe03631305edeb7607e07", + "75fb7b825e3f7a3d63257c98ef5d55819179902585a3ec6459c2b4fbb20ed38f"], + #:build, fn() { + root := get-environment-variable("VINIX_SYSROOT") + run("test", "-e", string-append(root, "/usr/lib/libncursesw.so")) + ; Define ELF symbol properties that configure cannot test by executing + ; a target program on the build host. The package phase loads the modules. + run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH", + "-C", "zsh-5.9.2", "PKG_CONFIG_PATH=", string-append("PKG_CONFIG_SYSROOT_DIR=", root), + string-append("PKG_CONFIG_LIBDIR=", root, "/usr/lib/pkgconfig"), + string-append("PCRE_CONFIG=", root, "/usr/bin/pcre2-config"), + "CC=vinix-cc", "CFLAGS=-O2", "zsh_cv_shared_environ=yes", "zsh_cv_shared_tgetent=yes", + "zsh_cv_shared_tigetstr=yes", "zsh_cv_sys_dynamic_execsyms=yes", + "zsh_cv_sys_dynamic_rtld_global=yes", "zsh_cv_sys_dynamic_clash_ok=yes", + "./configure", "--build=x86_64-pc-linux-gnu", "--host=x86_64-linux-musl", + "--prefix=/usr", "--bindir=/bin", "--sysconfdir=/etc", "--enable-etcdir=/etc/zsh", + "--with-term-lib=ncursesw", "--enable-multibyte", "--enable-function-subdirs", + "--enable-pcre", "--enable-cap", "--enable-zsh-secure-free", "--with-tcsetpgrp") + run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH", "make", "-C", "zsh-5.9.2") + }, + #:package, fn() { + root := get-environment-variable("VINIX_SYSROOT") + run("make", "-j1", "-C", "zsh-5.9.2", string-append("DESTDIR=", pkgdir()), "install") + for-each(fn(file) { + run("install", "-Dm644", file, string-append(pkgdir(), "/etc/zsh/", file)) + }, list("zprofile", "zshenv", "zshrc")) + run("install", "-d", string-append(pkgdir(), "/etc/zsh/zshrc.d"), string-append(pkgdir(), "/usr/share/zsh/plugins")) + run("install", "-Dm644", "zsh-5.9.2/LICENCE", string-append(pkgdir(), "/usr/share/licenses/zsh/LICENCE")) + run(string-append(root, "/lib/ld-musl-x86_64.so.1"), "--library-path", + string-append(root, "/usr/lib:", root, "/lib"), string-append(pkgdir(), "/bin/zsh"), + "-fc", "module_path=($1); zmodload zsh/zle && zmodload zsh/complete && zmodload zsh/terminfo && zmodload zsh/pcre && zmodload zsh/cap && setopt RE_MATCH_PCRE && [[ ab =~ '^(?=a)a' ]]", + "zsh", string-append(pkgdir(), "/usr/lib/zsh/5.9.2")) + }) diff --git a/zsh/zprofile b/zsh/zprofile new file mode 100644 index 0000000..9e3fd97 --- /dev/null +++ b/zsh/zprofile @@ -0,0 +1,10 @@ +# System-wide .zprofile file for zsh(1) - sourced only for login shells. +# +# Global Order: zshenv, zprofile, zshrc, zlogin + +# Source /etc/profile to the current shell. +if [ -f /etc/profile ]; then + emulate sh -c 'source /etc/profile' +fi + +# vim: set ft=zsh ts=4: diff --git a/zsh/zshenv b/zsh/zshenv new file mode 100644 index 0000000..f249e33 --- /dev/null +++ b/zsh/zshenv @@ -0,0 +1,13 @@ +# System-wide .zshenv file for zsh(1), sourced on all invocations of the shell. +# +# Global order: zshenv, zprofile, zshrc, zlogin + +# If $ZDOTDIR is not set and none of .zshenv, .zprofile, .zshrc, .zlogin exist +# in $HOME, read ZSH startup files from $XDG_CONFIG_HOME/zsh/ instead of $HOME. +# The point is to promote XDG-based location, but don't break existing setups. +if [[ -z "${ZDOTDIR-}" ]] && _x=("$HOME"/.z{shenv,profile,shrc,login}(N)) && (( ! $#_x )); then + ZDOTDIR=${XDG_CONFIG_HOME:-$HOME/.config}/zsh +fi +unset _x + +# vim: set ft=zsh ts=4: diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100644 index 0000000..02d9d83 --- /dev/null +++ b/zsh/zshrc @@ -0,0 +1,63 @@ +# System-wide .zshrc file for zsh(1), sourced only for interactive shells. +# +# Global order: zshenv, zprofile, zshrc, zlogin + +# If ZSH startup files exist both in $HOME and XDG-based config directory, +# print a warning (but only if running as a login shell). Note that XDG-based +# config directory is used only when no ZSH startup files are found in $HOME +# (see /etc/zsh/zshenv). +if [[ -z "${ZDOTDIR-}" && -o login ]]; then + _xdgdir=${XDG_CONFIG_HOME:-$HOME/.config}/zsh + if _xdgrcs=("$_xdgdir"/.z{shenv,profile,shrc,login}(N)) && (( $#_xdgrcs )); then + _homercs=("$HOME"/.z{shenv,profile,shrc,login}(N:t)) + print "Warning: Found Zsh startup files both in ~/ and ${_xdgdir/$HOME/\~}/, the latter will\n" \ + " be ignored (tip: move $_homercs to ${_xdgdir/$HOME/\~}/)." >&2 + fi + unset _xdgdir _xdgrcs _homercs +fi + +# TIP: If you don't want any plugins to be automatically loaded here, add +# `zsh_plugin_dirs=()` to your $ZDOTDIR/.zshenv. +if (( ! ${+zsh_plugin_dirs} )); then + zsh_plugin_dirs=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins") +fi + +# TIP: If you want to automatically use all ZSH plugins installed from Alpine +# packages, add `ZSH_LOAD_SYSTEM_PLUGINS=yes` to your $ZDOTDIR/.zshenv. +if [[ "${ZSH_LOAD_SYSTEM_PLUGINS-}" = [1ty]* ]]; then + zsh_plugin_dirs+=('/usr/share/zsh/plugins') +fi + +# Find plugins (per Oh-My-Zsh convention) under $zsh_plugin_dirs (array of +# paths) and add them to $fpath. +_plugins=() +for _dir ($zsh_plugin_dirs); do + for _name ("$_dir"/*(N:t)); do # equivalent of 'basename $i' + if [[ -f "$_dir/$_name/$_name.plugin.zsh" ]]; then + _plugins+=("$_dir/$_name/$_name.plugin.zsh") + fpath=("$_dir/$_name" $fpath) + fi + done +done + +# Source each .zsh script in /etc/zsh/zshrc.d/ which is not +# included in $zshrcd_blacklist. +# +# TIP: If you want to prevent some scripts in /etc/zsh/zshrc.d from being +# loaded, say a.zsh and b.zsh, add `zshrcd_blacklist=(a b)` to your +# $ZDOTDIR/.zshenv ($XDG_CONFIG_HOME/zsh/.zshenv). +zshrcd_blacklist+=() +_scripts=(/etc/zsh/zshrc.d/*.zsh(N:t:r)) # equivalent of 'basename $i .zsh' +for _name (${_scripts:|zshrcd_blacklist}); do # :| is a set difference A \ B + source "/etc/zsh/zshrc.d/$_name.zsh" +done + +# Source all plugins found in $zsh_plugin_dirs. +for _plugin ($_plugins); do + source "$_plugin" +done + +unset _dir _name _plugin _plugins _scripts +unset zsh_plugin_dirs zshrcd_blacklist ZSH_LOAD_SYSTEM_PLUGINS + +# vim: set ft=zsh ts=4: -- 2.56.1