Switch to my new Ublue CLI tool
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Tell this script to exit if there are any errors.
|
||||
set -oue pipefail
|
||||
|
||||
#
|
||||
# AUTORUN:
|
||||
#
|
||||
# This script simplifies your "recipe.yml" management whenever you simply want
|
||||
# to "run everything automatically" based on whatever script files exist on disk.
|
||||
#
|
||||
|
||||
# Helper functions.
|
||||
yell() { echo "${0}: ${*}"; }
|
||||
abort() { yell "${*}"; exit 0; }
|
||||
die() { yell "${*}"; exit 1; }
|
||||
|
||||
# Determine which directory and script category we're executing under.
|
||||
SCRIPT_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
SCRIPT_MODE="${1:-}"
|
||||
if [[ -z "${SCRIPT_MODE}" ]]; then
|
||||
die "Missing script mode argument."
|
||||
fi
|
||||
|
||||
# Ensure that a "scripts/" sub-directory exists for the "script category".
|
||||
# Note that symlinks to other directories will be accepted by the `-d` check.
|
||||
RUN_DIR="${SCRIPT_DIR}/${SCRIPT_MODE}"
|
||||
if [[ ! -d "${RUN_DIR}" ]]; then
|
||||
abort "Nothing to do, since \"${RUN_DIR}\" doesn't exist."
|
||||
fi
|
||||
|
||||
# Generate a numerically sorted array of all scripts (or symlinks to scripts),
|
||||
# without traversing into deeper subdirectories (to allow the user to store
|
||||
# helper libraries in subfolders without accidental execution). Sorting is
|
||||
# necessary for manually controlling the execution order via numeric prefixes.
|
||||
mapfile -t buildscripts < <(find -L "${RUN_DIR}" -maxdepth 1 -type f -name "*.sh" | sort -n)
|
||||
|
||||
# Exit if there aren't any scripts in the directory.
|
||||
if [[ ${#buildscripts[@]} -eq 0 ]]; then
|
||||
abort "Nothing to do, since \"${RUN_DIR}\" doesn't contain any scripts in its top-level directory."
|
||||
fi
|
||||
|
||||
# Now simply execute all of the discovered scripts, and provide the name of the
|
||||
# current "script category" as an argument, to match the behavior of "build.sh".
|
||||
for script in "${buildscripts[@]}"; do
|
||||
echo "[autorun.sh] Running [${SCRIPT_MODE}]: ${script}"
|
||||
"$script" "${SCRIPT_MODE}"
|
||||
done
|
||||
109
scripts/build.sh
109
scripts/build.sh
@@ -1,109 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Tell build process to exit if there are any errors.
|
||||
set -oue pipefail
|
||||
|
||||
# Helper functions.
|
||||
RECIPE_FILE="/usr/share/ublue-os/recipe.yml"
|
||||
get_yaml_array() {
|
||||
mapfile -t "${1}" < <(yq -- "${2}" "${RECIPE_FILE}")
|
||||
}
|
||||
get_yaml_string() {
|
||||
yq -- "${1}" "${RECIPE_FILE}"
|
||||
}
|
||||
|
||||
# Automatically determine which Fedora version we're building.
|
||||
FEDORA_VERSION="$(cat /usr/lib/os-release | grep -Po '(?<=VERSION_ID=)\d+')"
|
||||
|
||||
# Read configuration variables.
|
||||
BASE_IMAGE="$(get_yaml_string '.base-image')"
|
||||
YAFTI_ENABLED="$(get_yaml_string '.firstboot.yafti')"
|
||||
|
||||
# Welcome.
|
||||
echo "Building custom Fedora ${FEDORA_VERSION} from image: \"${BASE_IMAGE}\"."
|
||||
|
||||
# Add custom repos.
|
||||
get_yaml_array repos '.rpm.repos[]'
|
||||
if [[ ${#repos[@]} -gt 0 ]]; then
|
||||
echo "-- Adding repos defined in recipe.yml --"
|
||||
for repo in "${repos[@]}"; do
|
||||
repo="${repo//%FEDORA_VERSION%/${FEDORA_VERSION}}"
|
||||
wget "${repo}" -P "/etc/yum.repos.d/"
|
||||
done
|
||||
echo "---"
|
||||
fi
|
||||
|
||||
# Ensure that all script files are executable.
|
||||
find /tmp/scripts -type f -exec chmod +x {} \;
|
||||
|
||||
# Run "pre" scripts.
|
||||
run_scripts() {
|
||||
script_mode="$1"
|
||||
get_yaml_array buildscripts ".scripts.${script_mode}[]"
|
||||
if [[ ${#buildscripts[@]} -gt 0 ]]; then
|
||||
echo "-- Running [${script_mode}] scripts defined in recipe.yml --"
|
||||
for script in "${buildscripts[@]}"; do
|
||||
echo "Running [${script_mode}]: ${script}"
|
||||
"/tmp/scripts/${script}" "${script_mode}"
|
||||
done
|
||||
echo "---"
|
||||
fi
|
||||
}
|
||||
run_scripts "pre"
|
||||
|
||||
# Install RPMs.
|
||||
get_yaml_array install_rpms '.rpm.install[]'
|
||||
if [[ ${#install_rpms[@]} -gt 0 ]]; then
|
||||
echo "-- Installing RPMs defined in recipe.yml --"
|
||||
echo "Installing: ${install_rpms[@]}"
|
||||
rpm-ostree install "${install_rpms[@]}"
|
||||
echo "---"
|
||||
fi
|
||||
|
||||
# Remove RPMs.
|
||||
get_yaml_array remove_rpms '.rpm.remove[]'
|
||||
if [[ ${#remove_rpms[@]} -gt 0 ]]; then
|
||||
echo "-- Removing RPMs defined in recipe.yml --"
|
||||
echo "Removing: ${remove_rpms[@]}"
|
||||
rpm-ostree override remove "${remove_rpms[@]}"
|
||||
echo "---"
|
||||
fi
|
||||
|
||||
# Toggle yafti, which provides the "first boot" experience, https://github.com/ublue-os/yafti.
|
||||
FIRSTBOOT_DATA="/usr/share/ublue-os/firstboot"
|
||||
FIRSTBOOT_LINK="/usr/etc/profile.d/ublue-firstboot.sh"
|
||||
if [[ "${YAFTI_ENABLED}" == "true" ]]; then
|
||||
echo "-- firstboot: Installing and enabling \"yafti\" --"
|
||||
pip install --prefix=/usr yafti
|
||||
# Create symlink to our profile script, which creates the per-user "autorun yafti" links.
|
||||
mkdir -p "$(dirname "${FIRSTBOOT_LINK}")"
|
||||
ln -s "${FIRSTBOOT_DATA}/launcher/login-profile.sh" "${FIRSTBOOT_LINK}"
|
||||
else
|
||||
echo "-- firstboot: Removing all \"firstboot\" components --"
|
||||
# Removes the script symlink that creates the per-user autostart symlinks.
|
||||
# We must forcibly remove this here, in case it was added by an upstream image.
|
||||
rm -f "${FIRSTBOOT_LINK}"
|
||||
# Remove all of the launcher-scripts and yafti config, to de-clutter image and
|
||||
# ensure it can't run by accident due to lingering symlinks or upstream image.
|
||||
rm -rf "${FIRSTBOOT_DATA}"
|
||||
fi
|
||||
|
||||
# Add a new yafti "package group" called Custom, for the packages defined in recipe.yml.
|
||||
# Only adds the package group if yafti is enabled and Flatpaks are defined in the recipe.
|
||||
if [[ "${YAFTI_ENABLED}" == "true" ]]; then
|
||||
YAFTI_FILE="${FIRSTBOOT_DATA}/yafti.yml"
|
||||
get_yaml_array flatpaks '.firstboot.flatpaks[]'
|
||||
if [[ ${#flatpaks[@]} -gt 0 ]]; then
|
||||
echo "-- yafti: Adding Flatpaks defined in recipe.yml --"
|
||||
yq -i '.screens.applications.values.groups.Custom.description = "Flatpaks suggested by the image maintainer."' "${YAFTI_FILE}"
|
||||
yq -i '.screens.applications.values.groups.Custom.default = true' "${YAFTI_FILE}"
|
||||
for pkg in "${flatpaks[@]}"; do
|
||||
echo "Adding to yafti: ${pkg}"
|
||||
yq -i ".screens.applications.values.groups.Custom.packages += [{\"${pkg}\": \"${pkg}\"}]" "${YAFTI_FILE}"
|
||||
done
|
||||
echo "---"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run "post" scripts.
|
||||
run_scripts "post"
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "# This file was added by the program 'hda-jack-retask'.
|
||||
# If you want to revert the changes made by this program, you can simply erase this file and reboot your computer.
|
||||
options snd-hda-intel patch=hda-jack-retask.fw,hda-jack-retask.fw,hda-jack-retask.fw,hda-jack-retask.fw" > /etc/modprobe.d/hda-jack-retask.conf
|
||||
|
||||
echo "[codec]
|
||||
0x10ec0b00 0x10438797 0
|
||||
|
||||
[pincfg]
|
||||
0x11 0x411111f0
|
||||
0x14 0x01014010
|
||||
0x15 0x01011012
|
||||
0x16 0x01016011
|
||||
0x17 0x40170000
|
||||
0x18 0x01a19050
|
||||
0x19 0x02a19060
|
||||
0x1a 0x0181305f
|
||||
0x1b 0x01014010
|
||||
0x1e 0x01456140" > /lib/firmware/hda-jack-retask.fw
|
||||
@@ -1,198 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
echo "Installing fprintd service"
|
||||
|
||||
mkdir -p /usr/etc/systemd/system/
|
||||
|
||||
cat <<EOL >/usr/etc/systemd/system/fprintd.service
|
||||
[Unit]
|
||||
Description=Fingerprint Authentication Daemon
|
||||
Documentation=man:fprintd(1)
|
||||
|
||||
[Service]
|
||||
Type=dbus
|
||||
BusName=net.reactivated.Fprint
|
||||
ExecStart=/usr/libexec/fprintd
|
||||
|
||||
# Filesystem lockdown
|
||||
ProtectSystem=strict
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelLogs=true
|
||||
ProtectControlGroups=true
|
||||
# This always corresponds to /var/lib/fprint
|
||||
StateDirectory=fprint
|
||||
StateDirectoryMode=0700
|
||||
ProtectHome=true
|
||||
PrivateTmp=true
|
||||
|
||||
SystemCallFilter=@system-service
|
||||
|
||||
# Network
|
||||
RestrictAddressFamilies=AF_UNIX AF_LOCAL AF_NETLINK
|
||||
|
||||
# Execute Mappings
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
# Modules
|
||||
ProtectKernelModules=true
|
||||
|
||||
# Real-time
|
||||
RestrictRealtime=true
|
||||
|
||||
# Privilege escalation
|
||||
NoNewPrivileges=true
|
||||
|
||||
# Protect clock, allow USB and SPI device access
|
||||
ProtectClock=yes
|
||||
DeviceAllow=char-usb_device rw
|
||||
DeviceAllow=char-spi rw
|
||||
DeviceAllow=char-hidraw rw
|
||||
|
||||
# Allow tuning USB parameters (wakeup and persist)
|
||||
ReadWritePaths=/sys/devices
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Installing tlp config"
|
||||
|
||||
mkdir -p /usr/etc/tlp.d/
|
||||
|
||||
cat <<EOL >/usr/etc/tlp.d/50-framework.conf
|
||||
# ------------------------------------------------------------------------------
|
||||
# /etc/tlp.conf - TLP user configuration (version 1.4)
|
||||
# See full explanation: https://linrunner.de/tlp/settings
|
||||
#
|
||||
# Settings are read in the following order:
|
||||
#
|
||||
# 1. Intrinsic defaults
|
||||
# 2. /etc/tlp.d/*.conf - Drop-in customization snippets
|
||||
# 3. /etc/tlp.conf - User configuration (this file)
|
||||
#
|
||||
# Notes:
|
||||
# - In case of identical parameters, the last occurence has precedence
|
||||
# - This also means, parameters enabled here will override anything else
|
||||
# - However you may append values to a parameter already defined as intrinsic
|
||||
# default or in a previously read file: use PARAMETER+="add values"
|
||||
# - IMPORTANT: all parameters here are disabled; remove the leading '#' if you
|
||||
# like to enable a feature without default or have a value different from the
|
||||
# default
|
||||
# - Default *: intrinsic default that is effective when the parameter is missing
|
||||
# or disabled by a leading '#'; use PARAM="" to disable an intrinsic default
|
||||
# - Default <none>: do nothing or use kernel/hardware defaults
|
||||
# -
|
||||
# ------------------------------------------------------------------------------
|
||||
# tlp - Parameters for power saving
|
||||
#
|
||||
# Settings based on Framework's guidance: https://knowledgebase.frame.work/en_us/optimizing-fedora-battery-life-r1baXZh
|
||||
|
||||
# Select a CPU frequency scaling governor.
|
||||
# Intel processor with intel_pstate driver:
|
||||
# performance, powersave(*).
|
||||
# Intel processor with intel_cpufreq driver (aka intel_pstate passive mode):
|
||||
# conservative, ondemand, userspace, powersave, performance, schedutil(*).
|
||||
# Intel and other processor brands with acpi-cpufreq driver:
|
||||
# conservative, ondemand(*), userspace, powersave, performance, schedutil(*).
|
||||
# Use tlp-stat -p to show the active driver and available governors.
|
||||
# Important:
|
||||
# Governors marked (*) above are power efficient for *almost all* workloads
|
||||
# and therefore kernel and most distributions have chosen them as defaults.
|
||||
# You should have done your research about advantages/disadvantages *before*
|
||||
# changing the governor.
|
||||
# Default: <none>
|
||||
|
||||
CPU_SCALING_GOVERNOR_ON_AC=performance
|
||||
CPU_SCALING_GOVERNOR_ON_BAT=powersave
|
||||
|
||||
# Set Intel CPU energy/performance policies HWP.EPP and EPB:
|
||||
# performance, balance_performance, default, balance_power, power.
|
||||
# Values are given in order of increasing power saving.
|
||||
# Notes:
|
||||
# - HWP.EPP: requires kernel 4.10, intel_pstate scaling driver and Intel Core i
|
||||
# 6th gen. or newer CPU
|
||||
# - EPB: requires kernel 5.2 or module msr and x86_energy_perf_policy from
|
||||
# linux-tools, intel_pstate or intel_cpufreq scaling driver and Intel Core i
|
||||
# 2nd gen. or newer CPU
|
||||
# - When HWP.EPP is available, EPB is not set
|
||||
# Default: balance_performance (AC), balance_power (BAT)
|
||||
|
||||
CPU_ENERGY_PERF_POLICY_ON_AC=performance
|
||||
CPU_ENERGY_PERF_POLICY_ON_BAT=power
|
||||
|
||||
# Set Intel CPU P-state performance: 0..100 (%).
|
||||
# Limit the max/min P-state to control the power dissipation of the CPU.
|
||||
# Values are stated as a percentage of the available performance.
|
||||
# Requires intel_pstate or intel_cpufreq driver and Intel Core i 2nd gen. or
|
||||
# newer CPU.
|
||||
# Default: <none>
|
||||
|
||||
CPU_MIN_PERF_ON_AC=0
|
||||
CPU_MAX_PERF_ON_AC=100
|
||||
CPU_MIN_PERF_ON_BAT=0
|
||||
CPU_MAX_PERF_ON_BAT=30
|
||||
|
||||
# Set the CPU "turbo boost" (Intel) or "turbo core" (AMD) feature:
|
||||
# 0=disable, 1=allow.
|
||||
# Note: a value of 1 does *not* activate boosting, it just allows it.
|
||||
# Default: <none>
|
||||
|
||||
CPU_BOOST_ON_AC=1
|
||||
CPU_BOOST_ON_BAT=0
|
||||
|
||||
# Set the Intel CPU HWP dynamic boost feature:
|
||||
# 0=disable, 1=enable.
|
||||
# Requires intel_pstate scaling driver in 'active' mode and Intel Core i
|
||||
# 6th gen. or newer CPU.
|
||||
# Default: <none>
|
||||
|
||||
CPU_HWP_DYN_BOOST_ON_AC=1
|
||||
CPU_HWP_DYN_BOOST_ON_BAT=0
|
||||
|
||||
# Select platform profile:
|
||||
# performance, balanced, low-power.
|
||||
# Controls system operating characteristics around power/performance levels,
|
||||
# thermal and fan speed. Values are given in order of increasing power saving.
|
||||
# Note: check the output of tlp-stat -p to determine availability on your
|
||||
# hardware and additional profiles such as: balanced-performance, quiet, cool.
|
||||
# Default: <none>
|
||||
|
||||
PLATFORM_PROFILE_ON_AC=performance
|
||||
PLATFORM_PROFILE_ON_BAT=low-power
|
||||
|
||||
# Set the min/max/turbo frequency for the Intel GPU.
|
||||
# Possible values depend on your hardware. For available frequencies see
|
||||
# the output of tlp-stat -g.
|
||||
# Default: <none>
|
||||
|
||||
INTEL_GPU_MIN_FREQ_ON_AC=100
|
||||
INTEL_GPU_MIN_FREQ_ON_BAT=100
|
||||
INTEL_GPU_MAX_FREQ_ON_AC=1300
|
||||
INTEL_GPU_MAX_FREQ_ON_BAT=800
|
||||
INTEL_GPU_BOOST_FREQ_ON_AC=1300
|
||||
INTEL_GPU_BOOST_FREQ_ON_BAT=1100
|
||||
|
||||
# Wi-Fi power saving mode: on=enable, off=disable.
|
||||
# Default: off (AC), on (BAT)
|
||||
|
||||
#WIFI_PWR_ON_AC=off
|
||||
WIFI_PWR_ON_BAT=off
|
||||
|
||||
# PCIe Active State Power Management (ASPM):
|
||||
# default(*), performance, powersave, powersupersave.
|
||||
# (*) keeps BIOS ASPM defaults (recommended)
|
||||
# Default: <none>
|
||||
|
||||
#PCIE_ASPM_ON_AC=default
|
||||
PCIE_ASPM_ON_BAT=powersupersave
|
||||
|
||||
# Exclude PCIe devices assigned to the listed drivers from Runtime PM.
|
||||
# Note: this preserves the kernel driver default, to force a certain state
|
||||
# use RUNTIME_PM_ENABLE/DISABLE instead.
|
||||
# Separate multiple drivers with spaces.
|
||||
# Default: "mei_me nouveau radeon", use "" to disable completely.
|
||||
|
||||
RUNTIME_PM_DRIVER_DENYLIST=""
|
||||
EOL
|
||||
Reference in New Issue
Block a user