diff --git a/ublue/brew/src/profile.d/brew-bash-completion.sh b/ublue/brew/src/profile.d/brew-bash-completion.sh new file mode 100644 index 0000000..424ac4a --- /dev/null +++ b/ublue/brew/src/profile.d/brew-bash-completion.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# shellcheck shell=sh disable=SC1091,SC2039,SC2166 +# Check for interactive bash and that we haven't already been sourced. +if [ "x${BASH_VERSION-}" != x -a "x${PS1-}" != x -a "x${BREW_BASH_COMPLETION-}" = x ]; then + + # Check for recent enough version of bash. + if [ "${BASH_VERSINFO[0]}" -gt 4 ] || + [ "${BASH_VERSINFO[0]}" -eq 4 -a "${BASH_VERSINFO[1]}" -ge 2 ]; then + if [ -w /home/linuxbrew/.linuxbrew ]; then + if ! test -L /home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew; then + /home/linuxbrew/.linuxbrew/bin/brew completions link > /dev/null + fi + fi + if test -d /home/linuxbrew/.linuxbrew/etc/bash_completion.d; then + for rc in /home/linuxbrew/.linuxbrew/etc/bash_completion.d/*; do + if test -r "$rc"; then + . "$rc" + fi + done + unset rc + fi + fi + BREW_BASH_COMPLETION=1 + export BREW_BASH_COMPLETION +fi diff --git a/ublue/brew/src/profile.d/brew.sh b/ublue/brew/src/profile.d/brew.sh new file mode 100755 index 0000000..ea2ca28 --- /dev/null +++ b/ublue/brew/src/profile.d/brew.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +[[ -d /home/linuxbrew/.linuxbrew && $- == *i* ]] && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" diff --git a/ublue/brew/src/security/limits.d/30-brew-limits.conf b/ublue/brew/src/security/limits.d/30-brew-limits.conf new file mode 100644 index 0000000..45d18f4 --- /dev/null +++ b/ublue/brew/src/security/limits.d/30-brew-limits.conf @@ -0,0 +1,9 @@ +#This file sets the resource limits for the users logged in via PAM, +#more specifically, users logged in on via SSH or tty (console). +#Limits related to terminals in Wayland/Xorg sessions depend on a +#change to /etc/systemd/user.conf. +#This does not affect resource limits of the system services. +#This file overrides defaults set in /etc/security/limits.conf + +* soft nofile 4096 +root soft nofile 4096 diff --git a/ublue/brew/src/systemd/01-homebrew.preset b/ublue/brew/src/systemd/01-homebrew.preset new file mode 100644 index 0000000..5cf3a99 --- /dev/null +++ b/ublue/brew/src/systemd/01-homebrew.preset @@ -0,0 +1 @@ +enable brew-setup.service diff --git a/ublue/brew/src/systemd/brew-setup.service b/ublue/brew/src/systemd/brew-setup.service new file mode 100644 index 0000000..98fa5d6 --- /dev/null +++ b/ublue/brew/src/systemd/brew-setup.service @@ -0,0 +1,18 @@ +[Unit] +Description=Setup Brew +Wants=network-online.target +After=network-online.target +ConditionPathExists=!/etc/.linuxbrew +ConditionPathExists=!/var/home/linuxbrew/.linuxbrew + +[Service] +Type=oneshot +ExecStart=/usr/bin/mkdir -p /tmp/homebrew +ExecStart=/usr/bin/tar --zstd -xvf /usr/share/homebrew.tar.zst -C /tmp/homebrew +ExecStart=/usr/bin/cp -R -n /tmp/homebrew/home/linuxbrew/.linuxbrew /var/home/linuxbrew +ExecStart=/usr/bin/chown -R 1000:1000 /var/home/linuxbrew +ExecStart=/usr/bin/rm -rf /tmp/homebrew +ExecStart=/usr/bin/touch /etc/.linuxbrew + +[Install] +WantedBy=default.target multi-user.target diff --git a/ublue/brew/src/tmpfiles.d/homebrew.conf b/ublue/brew/src/tmpfiles.d/homebrew.conf new file mode 100644 index 0000000..92cd2fd --- /dev/null +++ b/ublue/brew/src/tmpfiles.d/homebrew.conf @@ -0,0 +1,3 @@ +d /var/lib/homebrew 0755 1000 1000 - - +d /var/cache/homebrew 0755 1000 1000 - - +d /var/home/linuxbrew 0755 1000 1000 - - diff --git a/ublue/brew/src/vendor.fish b/ublue/brew/src/vendor.fish new file mode 100644 index 0000000..bb6d10d --- /dev/null +++ b/ublue/brew/src/vendor.fish @@ -0,0 +1,13 @@ +#!/usr/bin/fish +#shellcheck disable=all +if status --is-interactive + if [ -d /home/linuxbrew/.linuxbrew ] + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + if test -d (brew --prefix)/share/fish/completions + set -p fish_complete_path (brew --prefix)/share/fish/completions + end + if test -d (brew --prefix)/share/fish/vendor_completions.d + set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d + end + end +end diff --git a/ublue/brew/ublue-brew.spec b/ublue/brew/ublue-brew.spec new file mode 100644 index 0000000..0aab5fd --- /dev/null +++ b/ublue/brew/ublue-brew.spec @@ -0,0 +1,45 @@ +%global debug_package %{nil} + +Name: ublue-brew +Version: 0.1.0 +Release: 1%{?dist} +Summary: Homebrew integration for Universal Blue systems + +License: Apache-2.0 +URL: https://github.com/ublue-os/packages +VCS: {{{ git_dir_vcs }}} +Source: {{{ git_dir_pack }}} + +BuildRequires: systemd-rpm-macros + +%description +Homebrew integration for Universal Blue systems + +%prep +{{{ git_dir_setup_macro }}} + +%install +mkdir -p %{buildroot}{%{_unitdir},%{_prefix}/lib/systemd/system-preset,%{_sysconfdir}} +install -Dpm0755 src/systemd/*.service %{buildroot}%{_unitdir} +install -Dpm0755 src/systemd/*.preset %{buildroot}%{_prefix}/lib/systemd/system-preset +install -Dm0755 ./src/vendor.fish %{buildroot}%{_datadir}/fish/vendor_conf.d/%{name}.fish +cp -rp src/security %{buildroot}%{_sysconfdir} +cp -rp src/profile.d %{buildroot}%{_sysconfdir} +cp -rp src/tmpfiles.d %{buildroot}%{_prefix}/lib + +%post +%systemd_post brew-setup.service + +%preun +%systemd_preun brew-setup.service + +%files +%{_sysconfdir}/profile.d/brew* +%{_datadir}/fish/vendor_conf.d/%{name}.fish +%{_sysconfdir}/security/limits.d/*brew*.conf +%{_unitdir}/brew-setup.service +%{_prefix}/lib/systemd/system-preset/01-homebrew.preset +%{_prefix}/lib/tmpfiles.d/*brew.conf + +%changelog +%autochangelog