From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E1841159C9B for ; Sun, 11 Aug 2024 15:41:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E60852BC029; Sun, 11 Aug 2024 15:41:10 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CAEB12BC029 for ; Sun, 11 Aug 2024 15:41:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B722F34313A for ; Sun, 11 Aug 2024 15:41:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id ED5E21ED0 for ; Sun, 11 Aug 2024 15:41:07 +0000 (UTC) From: "Michal Vu" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michal Vu" Message-ID: <1723390790.7b3994dc74526c1a79b45893bbcc7d5f831f5d85.saigon-tech@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: x11-misc/ly/ X-VCS-Repository: repo/proj/guru X-VCS-Files: x11-misc/ly/ly-9999.ebuild X-VCS-Directories: x11-misc/ly/ X-VCS-Committer: saigon-tech X-VCS-Committer-Name: Michal Vu X-VCS-Revision: 7b3994dc74526c1a79b45893bbcc7d5f831f5d85 X-VCS-Branch: dev Date: Sun, 11 Aug 2024 15:41:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9bf497ef-9821-41a0-bb19-a3a2f1952df0 X-Archives-Hash: e144be2db07b38ca2003647ae8e51b79 commit: 7b3994dc74526c1a79b45893bbcc7d5f831f5d85 Author: Michal Vu tuta io> AuthorDate: Sun Aug 11 15:39:50 2024 +0000 Commit: Michal Vu tuta io> CommitDate: Sun Aug 11 15:39:50 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=7b3994dc x11-misc/ly: Adding a live ebuild for ly login manager Signed-off-by: Michal Vu tuta.io> x11-misc/ly/ly-9999.ebuild | 217 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) diff --git a/x11-misc/ly/ly-9999.ebuild b/x11-misc/ly/ly-9999.ebuild new file mode 100644 index 000000000..bbe2980fb --- /dev/null +++ b/x11-misc/ly/ly-9999.ebuild @@ -0,0 +1,217 @@ +# Copyright 2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit edo pam systemd git-r3 + +DESCRIPTION="Ly - a TUI display manager (live ebuild)" +HOMEPAGE="https://github.com/fairyglade/ly" + +EGIT_REPO_URI="https://github.com/fairyglade/ly.git" + +LICENSE="WTFPL-2" +SLOT="0" + +# KEYWORDS is omitted for live ebuilds + +# Specify the required Zig version range +EZIG_MIN="0.12" +EZIG_MAX_EXCLUSIVE="0.13" + +DEPEND=" + || ( dev-lang/zig-bin:${EZIG_MIN} dev-lang/zig:${EZIG_MIN} ) + sys-libs/pam + x11-libs/libxcb +" +RDEPEND=" + x11-base/xorg-server + x11-apps/xauth + sys-libs/ncurses +" + +# Ignore QA warnings about missing build-id for Zig binaries +# https://github.com/ziglang/zig/issues/3382 +QA_FLAGS_IGNORED="usr/bin/ly" + +RES="${S}/res" + +# Function to dynamically fetch dependency versions from build.zig.zon +fetch_deps_dynamically() { + local build_zig_zon="${S}/build.zig.zon" + local content + + if [[ ! -f "${build_zig_zon}" ]]; then + eerror "build.zig.zon not found at ${build_zig_zon}" + return 1 + fi + + content=$(<"${build_zig_zon}") + + # Extract CLAP version + if [[ "${content}" =~ clap.*?refs/tags/([0-9]+\.[0-9]+\.[0-9]+) ]]; then + CLAP="refs/tags/${BASH_REMATCH[1]}" + else + eerror "Failed to extract CLAP version" + return 1 + fi + + # Extract ZIGINI commit hash + if [[ "${content}" =~ zigini.*?/([a-f0-9]{40})\.tar\.gz ]]; then + ZIGINI="${BASH_REMATCH[1]}" + else + eerror "Failed to extract ZIGINI commit hash" + return 1 + fi + + einfo "Extracted CLAP version: ${CLAP}" + einfo "Extracted ZIGINI commit: ${ZIGINI}" + + #CLAP="refs/tags/0.9.1" + #ZIGINI="0bba97a12582928e097f4074cc746c43351ba4c8" + #ZIGLIBINI="e18d36665905c1e7ba0c1ce3e8780076b33e3002" +} + +# Function to fetch nested dependency versions +fetch_nested_deps_dynamically() { + local root_build_zig_zon="${S}/build.zig.zon" + local root_content + local zigini_hash + local nested_build_zig_zon + local nested_content + + # Read the root build.zig.zon + root_content=$(<"${root_build_zig_zon}") + + # Extract the hash for the zigini dependency + if [[ "${root_content}" =~ zigini.*hash[[:space:]]*=[[:space:]]*\"([a-f0-9]+)\" ]]; then + zigini_hash="${BASH_REMATCH[1]}" + else + eerror "Failed to extract zigini hash from root build.zig.zon" + return 1 + fi + + # Construct the path to the nested build.zig.zon + nested_build_zig_zon="${WORKDIR}/deps/p/${zigini_hash}/build.zig.zon" + + if [[ ! -f "${nested_build_zig_zon}" ]]; then + eerror "Nested build.zig.zon not found at ${nested_build_zig_zon}" + return 1 + fi + + # Read the nested build.zig.zon + nested_content=$(<"${nested_build_zig_zon}") + + # Extract the ZIGLIBINI value + if [[ "${nested_content}" =~ ini.*?/([a-f0-9]{40})\.tar\.gz ]]; then + ZIGLIBINI="${BASH_REMATCH[1]}" + else + eerror "Failed to extract ZIGLIBINI commit hash" + return 1 + fi + + einfo "Extracted ZIGLIBINI commit: ${ZIGLIBINI}" +} + +# Function to set the EZIG environment variable +zig-set_EZIG() { + [[ -n ${EZIG} ]] && return + if [[ -n ${EZIG_OVERWRITE} ]]; then + export EZIG="${EZIG_OVERWRITE}" + return + fi + local candidate selected selected_ver ver + for candidate in "${BROOT}"/usr/bin/zig-*; do + if [[ ! -L ${candidate} || ${candidate} != */zig?(-bin)-+([0-9.]) ]]; then + continue + fi + ver=${candidate##*-} + if [[ -n ${EZIG_EXACT_VER} ]]; then + ver_test "${ver}" -ne "${EZIG_EXACT_VER}" && continue + selected="${candidate}" + selected_ver="${ver}" + break + fi + if [[ -n ${EZIG_MIN} ]] \ + && ver_test "${ver}" -lt "${EZIG_MIN}"; then + # Candidate does not satisfy EZIG_MIN condition. + continue + fi + if [[ -n ${EZIG_MAX_EXCLUSIVE} ]] \ + && ver_test "${ver}" -ge "${EZIG_MAX_EXCLUSIVE}"; then + # Candidate does not satisfy EZIG_MAX_EXCLUSIVE condition. + continue + fi + if [[ -n ${selected_ver} ]] \ + && ver_test "${selected_ver}" -gt "${ver}"; then + # Candidate is older than the currently selected candidate. + continue + fi + selected="${candidate}" + selected_ver="${ver}" + done + if [[ -z ${selected} ]]; then + die "Could not find (suitable) zig installation in ${BROOT}/usr/bin" + fi + export EZIG="${selected}" + export EZIG_VER="${selected_ver}" +} + +# Wrapper function for zig command +ezig() { + zig-set_EZIG + edo "${EZIG}" "${@}" +} + +# Check if git is installed +pkg_setup() { + if ! type -P git >/dev/null; then + eerror "git not found. Please install dev-vcs/git." + die "git not found" + fi +} + +# Unpack source and fetch dependencies +src_unpack() { + git-r3_src_unpack + fetch_deps_dynamically + mkdir "${WORKDIR}/deps" || die + ezig fetch --global-cache-dir "${WORKDIR}/deps" "https://github.com/Hejsil/zig-clap/archive/${CLAP}.tar.gz" + ezig fetch --global-cache-dir "${WORKDIR}/deps" "https://github.com/Kawaii-Ash/zigini/archive/${ZIGINI}.tar.gz" + + fetch_nested_deps_dynamically + ezig fetch --global-cache-dir "${WORKDIR}/deps" "https://github.com/ziglibs/ini/archive/${ZIGLIBINI}.tar.gz" +} + +# Compile the project +src_compile() { + ezig build --system "${WORKDIR}/deps/p" -Doptimize=ReleaseSafe +} + +# Install the binary and configuration files +src_install() { + dobin "${S}/zig-out/bin/${PN}" + newinitd "${RES}/${PN}-openrc" ly + systemd_dounit "${RES}/${PN}.service" + insinto /etc/ly + doins "${RES}/config.ini" "${RES}/setup.sh" + insinto /etc/ly/lang + doins "${RES}"/lang/*.ini + newpamd "${RES}/pam.d/ly" ly + fperms +x /etc/${PN}/setup.sh +} + +# Post-installation messages and warnings +pkg_postinst() { + systemd_reenable "${PN}.service" + ewarn + ewarn "The init scripts are installed only for systemd/openrc" + ewarn "If you are using something else like runit etc." + ewarn "Please check upstream for get some help" + ewarn "You may need to take a look at /etc/ly/config.ini" + ewarn "If you are using a window manager as DWM" + ewarn "Please make sure there is a .desktop file in /usr/share/xsessions for it" + ewarn + ewarn "This is a live ebuild, which means it will always install the latest commit." + ewarn "If you encounter any issues, please report them to the upstream project." +}