-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial ublue-recipes package (#120)
* feat: initial ublue-recipes package * fix: add properly formatted recipe header
- Loading branch information
1 parent
157d364
commit 11a8ab4
Showing
6 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# DO NOT INCLUDE THIS ONE | ||
|
||
# Check Just Syntax | ||
[group('Just')] | ||
check: | ||
#!/usr/bin/bash | ||
find . -type f -name "*.just" | while read -r file; do | ||
echo "Checking syntax: $file" | ||
just --unstable --fmt --check -f $file | ||
done | ||
echo "Checking syntax: Justfile" | ||
just --unstable --fmt --check -f Justfile | ||
|
||
# Fix Just Syntax | ||
[group('Just')] | ||
fix: | ||
#!/usr/bin/bash | ||
find . -type f -name "*.just" | while read -r file; do | ||
echo "Checking syntax: $file" | ||
just --unstable --fmt -f $file | ||
done | ||
echo "Checking syntax: Justfile" | ||
just --unstable --fmt -f Justfile || { exit 1; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# vim: set ft=make : | ||
## Standardized verbs | ||
# configure- = configure something that is pre-installed on the image | ||
# install- = install something, no uninstall or configuration provided | ||
# setup- = install something and also provide configuration and/or uninstallation options | ||
# toggle- = turn something on/off, logic can be automatic or manual selection | ||
# fix- = apply fix/patch/workaround for something | ||
# foo = no verb is used for shortcuts or something deemed important enough to use a super memorable name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Install JetBrains Toolbox | https://www.jetbrains.com/toolbox-app/ | ||
[group('Apps')] | ||
install-jetbrains-toolbox: | ||
#!/usr/bin/env bash | ||
pushd "$(mktemp -d)" | ||
echo "Get latest JetBrains Toolbox version" | ||
# Get the json with latest releases | ||
curl -sSfL -o releases.json "https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release" | ||
# Extract information | ||
BUILD_VERSION=$(jq -r '.TBA[0].build' ./releases.json) | ||
DOWNLOAD_LINK=$(jq -r '.TBA[0].downloads.linux.link' ./releases.json) | ||
CHECKSUM_LINK=$(jq -r '.TBA[0].downloads.linux.checksumLink' ./releases.json) | ||
echo "Installing JetBrains Toolbox ${BUILD_VERSION}" | ||
curl -sSfL -O "${DOWNLOAD_LINK}" | ||
curl -sSfL "${CHECKSUM_LINK}" | sha256sum -c | ||
tar zxf jetbrains-toolbox-"${BUILD_VERSION}".tar.gz | ||
echo "Launching JetBrains Toolbox" | ||
./jetbrains-toolbox-"${BUILD_VERSION}"/jetbrains-toolbox | ||
# Set up command-not-found for Homebrew | ||
[group('Apps')] | ||
setup-brew-not-found ACTION="": | ||
#!/usr/bin/env bash | ||
source /usr/lib/ujust/ujust.sh | ||
OPTION={{ ACTION }} | ||
if [ "$OPTION" == "help" ]; then | ||
echo "Usage: ujust setup-brew-not-found <option>" | ||
echo " <option>: Specify the quick option to skip the prompt" | ||
echo " Use 'enable' to select Enable Brew Not Found" | ||
echo " Use 'disable' to select Disable Brew Not Found" | ||
exit 0 | ||
elif [ "$OPTION" == "" ]; then | ||
echo "${bold}Brew command-not-found Setup${normal}" | ||
OPTION=$(Choose "Enable Brew command-not-found" "Disable Brew command-not-found") | ||
fi | ||
|
||
set -euo pipefail | ||
|
||
BREW_BINARY=/home/linuxbrew/.linuxbrew/bin/brew | ||
HOMEBREW_REPOSITORY=${HOMEBREW_REPOSITORY:-$($BREW_BINARY --repository)} | ||
if ! $BREW_BINARY -h > /dev/null; then | ||
echo "Make sure Homebrew is installed first. Check journalctl -e -u brew-setup.service" | ||
exit | ||
fi | ||
|
||
if [[ "${OPTION,,}" =~ ^enable ]]; then | ||
$BREW_BINARY tap homebrew/command-not-found | ||
pkexec tee /etc/profile.d/brew-command-not-found.sh > /dev/null <<EOF | ||
# Check for interactive bash or zsh and that we haven't already been sourced | ||
if [[ -d /home/linuxbrew/.linuxbrew && \$- == *i* && BREW_COMMAND_NOT_FOUND != 1 ]] ; then | ||
HB_CNF_HANDLER="${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-command-not-found/handler.sh" | ||
[ -f "\$HB_CNF_HANDLER" ] && source "\$HB_CNF_HANDLER" | ||
export BREW_COMMAND_NOT_FOUND=1 | ||
fi | ||
EOF | ||
# Necessary for fish since just having a script sourcing it does not work | ||
pkexec ln -sf "${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-command-not-found/handler.fish" /etc/fish/conf.d/brew-cnf-handler.fish | ||
echo "Brew command-not-found has been ${b}${green}enabled${n}" | ||
fi | ||
|
||
if [[ "${OPTION,,}" =~ ^disable ]]; then | ||
$BREW_BINARY untap homebrew/command-not-found | ||
FILES_TO_BE_REMOVED=() | ||
[ -f /etc/profile.d/brew-command-not-found.sh ] && FILES_TO_BE_REMOVED+=("/etc/profile.d/brew-command-not-found.sh") | ||
[ -f /etc/fish/conf.d/brew-command-not-found.fish ] && FILES_TO_BE_REMOVED+=("/etc/fish/conf.d/brew-command-not-found.fish") | ||
pkexec rm -f "${FILES_TO_BE_REMOVED[@]}" | ||
echo "Brew command-not-found has been ${b}${red}disabled${n}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Run a one minute system benchmark | ||
[group('System')] | ||
benchmark: | ||
#!/usr/bin/env bash | ||
echo 'Running a 1 minute benchmark ...' | ||
trap popd EXIT | ||
pushd $(mktemp -d) | ||
stress-ng --matrix 0 -t 1m --times |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# alias for configure-vfio | ||
[group('System')] | ||
setup-vfio: | ||
@ujust configure-vfio | ||
|
||
# Configure system to use vfio and kvmfr | ||
[group('System')] | ||
configure-vfio ACTION="": | ||
#!/usr/bin/bash | ||
source /usr/lib/ujust/ujust.sh | ||
CURRENT_IMAGE=$(rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"') | ||
if grep -q "dx" <<< $CURRENT_IMAGE ; then | ||
DEVMODE="enabled" | ||
else | ||
DEVMODE="disabled" | ||
fi | ||
if [ "$DEVMODE" == "disabled" ]; then | ||
echo "Please run "ujust devmode" first" | ||
exit 0 | ||
fi | ||
OPTION={{ ACTION }} | ||
if [ "$OPTION" == "help" ]; then | ||
cat <<EOF | ||
Usage: ujust configure-vfio <option> | ||
<option>: Specify the quick option to skip the prompt | ||
Use 'vfio-on' to select Enable VFIO drivers | ||
Use 'vfio-off' to select Disable VFIO drivers | ||
Use 'kvmfr' to select Autocreate Looking-Glass shm | ||
EOF | ||
exit 0 | ||
elif [ "$OPTION" == "" ]; then | ||
cat <<EOF | ||
${bold}VFIO and kvmfr Configuration${normal} | ||
This is only used for GPU passthrough of a secondary dGPU. | ||
It will enable vfio and configure kvmfr for use with $(Urllink "https://looking-glass.io" "Looking Glass") | ||
If you do not plan to use any of this then press ESC. | ||
${bold}NOTE:${normal} Since this is a niche use case, support will be ${b}very limited${n} | ||
EOF | ||
OPTION=$(Choose \ | ||
"Enable VFIO drivers" \ | ||
"Disable VFIO drivers" \ | ||
"Enable kvmfr module" \ | ||
) | ||
fi | ||
if [[ "${OPTION,,}" =~ (^enable[[:space:]]vfio|vfio-on) ]]; then | ||
echo "Enabling VFIO..." | ||
CPU_VENDOR=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ print $2 }') | ||
VENDOR_KARG="unset" | ||
echo 'add_drivers+=" vfio vfio_iommu_type1 vfio-pci "' | sudo tee /etc/dracut.conf.d/vfio.conf | ||
rpm-ostree initramfs --enable | ||
if [[ ${CPU_VENDOR} == "AuthenticAMD" ]]; then | ||
VENDOR_KARG="amd_iommu=on" | ||
elif [[ ${CPU_VENDOR} == "GenuineIntel" ]]; then | ||
VENDOR_KARG="intel_iommu=on" | ||
fi | ||
if [[ ${VENDOR_KARG} == "unset" ]]; then | ||
echo "Failed to get CPU vendor, exiting..." | ||
exit 1 | ||
else | ||
rpm-ostree kargs \ | ||
--append-if-missing="${VENDOR_KARG}" \ | ||
--append-if-missing="iommu=pt" \ | ||
--append-if-missing="rd.driver.pre=vfio_pci" \ | ||
--append-if-missing="vfio_pci.disable_vga=1" \ | ||
--append-if-missing="kvm.ignore_msrs=1" \ | ||
--append-if-missing="kvm.report_ignored_msrs=0" | ||
echo "VFIO will be enabled on next boot, make sure you enable IOMMU, VT-d or AMD-v in your BIOS!" | ||
echo "Please understand that since this is such a niche use case, support will be very limited!" | ||
echo "To add your unused/second GPU device ids to the vfio driver by running" | ||
echo 'rpm-ostree kargs --append-if-missing="vfio-pci.ids=xxxx:yyyy,xxxx:yyzz"' | ||
echo "NOTE: Your second GPU will not be usable by the host after you do this!" | ||
fi | ||
elif [[ "${OPTION,,}" =~ (^disable[[:space:]]vfio|vfio-off) ]]; then | ||
echo "" | ||
echo "Make sure you have ${b}disabled autostart of all VMs using VFIO${n} before continuing!" | ||
CONFIRM=$(Choose Cancel Continue) | ||
if [ "$CONFIRM" == "Continue" ]; then | ||
echo "Disabling VFIO..." | ||
VFIO_IDS="$(rpm-ostree kargs | sed -E 's/.+(vfio_pci.ids=.+\s)/\1/' | awk '{ print $1 }' | grep vfio_pci.ids)" | ||
VFIO_IDS_KARG="" | ||
if [ -n "$VFIO_IDS" ]; then | ||
echo "Found VFIO ids in kargs, adding the below line to removal list" | ||
echo "$VFIO_IDS" | ||
VFIO_IDS_KARG="--delete-if-present=\"$VFIO_IDS\"" | ||
fi | ||
echo "Removing dracut modules" | ||
sudo rm /etc/dracut.conf.d/vfio.conf | ||
rpm-ostree initramfs --enable | ||
rpm-ostree kargs \ | ||
--delete-if-present="iommu=pt" \ | ||
--delete-if-present="iommu=on" \ | ||
--delete-if-present="amd_iommu=on" \ | ||
--delete-if-present="intel_iommu=on" \ | ||
--delete-if-present="rd.driver.pre=vfio_pci" \ | ||
--delete-if-present="vfio_pci.disable_vga=1" \ | ||
--delete-if-present="vfio_pci.disable_vga=0" \ | ||
$VFIO_IDS_KARG | ||
fi | ||
elif [[ "${OPTION,,}" =~ kvmfr ]]; then | ||
sudo /usr/libexec/bluefin-dx-kvmfr-setup | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
%global debug_package %{nil} | ||
|
||
Name: ublue-recipes | ||
Version: 0.1.0 | ||
Release: 1%{?dist} | ||
Summary: Shared Ujust recipes | ||
|
||
License: Apache-2.0 | ||
URL: https://github.com/ublue-os/packages | ||
VCS: {{{ git_dir_vcs }}} | ||
Source: {{{ git_dir_pack }}} | ||
|
||
Recommends: glow | ||
Recommends: gum | ||
Requires: ublue-os-just | ||
|
||
%description | ||
Shared ujust recipes for Universal Blue systems | ||
|
||
%prep | ||
{{{ git_dir_setup_macro }}} | ||
|
||
%build | ||
for file in src/recipes/*.just ; do | ||
cat <<EOF >> recipes.just | ||
######################## | ||
### $(basename $file) | ||
######################## | ||
EOF | ||
cat $file >> recipes.just | ||
done | ||
|
||
%install | ||
install -Dm0644 -t %{buildroot}/%{_datadir}/ublue-os/recipes recipes.just | ||
|
||
# Breaks the build on te CentOS default chroot on COPR, we need to enable EPEL | ||
# %check | ||
# just --unstable --fmt --check -f recipes.just | ||
|
||
%files | ||
%{_datadir}/ublue-os/recipes/recipes.just | ||
|
||
%changelog | ||
%autochangelog |