Skip to content

Commit

Permalink
feat(ublue, brew): add universal blue homebrew integration scripts (#95)
Browse files Browse the repository at this point in the history
* feat(ublue, brew): add universal blue homebrew integration scripts

This should just add all the integrations we need, sadly it still doesnt install homebrew directly.

* feat(ublue, brew): add fish configuration hooks
  • Loading branch information
tulilirockz authored Dec 30, 2024
1 parent dfccad8 commit c4f6307
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ublue/brew/src/profile.d/brew-bash-completion.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions ublue/brew/src/profile.d/brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
[[ -d /home/linuxbrew/.linuxbrew && $- == *i* ]] && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
9 changes: 9 additions & 0 deletions ublue/brew/src/security/limits.d/30-brew-limits.conf
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions ublue/brew/src/systemd/01-homebrew.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable brew-setup.service
18 changes: 18 additions & 0 deletions ublue/brew/src/systemd/brew-setup.service
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions ublue/brew/src/tmpfiles.d/homebrew.conf
Original file line number Diff line number Diff line change
@@ -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 - -
13 changes: 13 additions & 0 deletions ublue/brew/src/vendor.fish
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions ublue/brew/ublue-brew.spec
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c4f6307

Please sign in to comment.