Refactoring repository...
Some checks are pending
Check Conventional Commit / check-commit-message (push) Waiting to run

This commit is contained in:
CELESTIFYX
2025-01-14 19:02:06 +02:00
parent 876fa0988e
commit 08abac9e7d
33171 changed files with 4677 additions and 761 deletions

View File

@@ -0,0 +1,37 @@
# Maintainer: Eshan Roy <eshan@snigdhaos.org>
pkgname=snigdhaos-updater
pkgdesc="Updater for Snigdha OS"
pkgver=1
pkgrel=1
arch=('any')
license=('GPL')
depends=('coreutils' 'sed' 'gawk' 'pacman' 'wget')
backup=(etc/snigdhaos/snigdhaos-updater/config)
source=("auto-pacman"
"config"
"snigdhaos-updater"
"rotation"
"core-script"
"aux-script")
sha512sums=('SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP')
pkgver() {
# cd "$srcdir/$pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
package() {
install -Dm755 snigdhaos-updater "$pkgdir"/usr/bin/snigdhaos-updater
ln -s /usr/bin/snigdhaos-updater "$pkgdir"/usr/bin/updater
install -Dm755 aux-script "$pkgdir"/usr/lib/snigdhaos/snigdhaos-updater/aux-script
install -Dm755 core-script "$pkgdir"/usr/lib/snigdhaos/snigdhaos-updater/core-script
install -Dm755 auto-pacman "$pkgdir"/usr/lib/snigdhaos/snigdhaos-updater/auto-pacman
install -Dm644 rotation "$pkgdir"/etc/logrotate.d/snigdhaos-updater
install -Dm644 config "$pkgdir"/etc/snigdhaos/snigdhaos-updater/config
}

View File

@@ -0,0 +1,115 @@
#!/usr/bin/expect -f
if {![exp_debug]} {trap {exit 1} {SIGINT SIGTERM}}
variable noconfirm [string equal $::env(AUTOPACMAN_PACMAN_NOCONFIRM) "1"]
variable noconfirm_downloading false
variable conflictsfile_set [expr [info exist ::env(AUTOPACMAN_CONFLICTSFILE)] && [file exist $::env(AUTOPACMAN_CONFLICTSFILE)] ? true : false]
# [package to be replaced]: [package to be replaced with]
array set auto_replace_conflicts {
python-xdg python-pyxdg
vimix-gtk-themes snigdhaos-vimix-dark
bibata-cursor-theme sweet-theme-full-git
kvantum-theme-sweet-git sweet-theme-full-git
sweet-gtk-theme-dark sweet-theme-full-git
plasma5-theme-sweet-git sweet-theme-full-git
xcursor-sweet sweet-theme-full-git
exe-thumbnailer icoextract
pipewire-media-session wireplumber
qemu-base qemu-desktop
libretro-mame-git libretro-meta
jack2 pipewire-jack
networkmanager-fortisslvpn networkmanager-support
ananicy-rules cachyos-ananicy-rules-git
sweet-theme-full-git plasma5-themes-sweet-full-git
sweet-kde-theme-git plasma5-themes-sweet-kde-git
jre-openjdk jdk-openjdk
jre-openjdk-headless {jdk-openjdk jre-openjdk}
}
if { $::conflictsfile_set } {
set conflictsfile [open $::env(AUTOPACMAN_CONFLICTSFILE) r]
array set auto_replace_conflicts [gets $conflictsfile]
close $conflictsfile
}
proc parseConflicts {first second} {
foreach {key value} [array get ::auto_replace_conflicts] {
if { [string equal $second $key] && [lsearch -exact $value $first] != -1 } {
send "y\r"
return
}
}
if { $::noconfirm } {
return
} elseif { $::conflictsfile_set } {
send "n\r"
} else {
expect_user -timeout -1 -re "(.*)\n"
if {[regexp {^[Yy]$} $expect_out(1,string)]} {
set ::auto_replace_conflicts($second) $first
send "y\r"
} else {
send "n\r"
}
}
}
proc doExit {} {
catch wait result
if {[info exist ::env(AUTOPACMAN_CONFLICTSFILE)] && ![file exist $::env(AUTOPACMAN_CONFLICTSFILE)] } {
set conflictsfile [open $::env(AUTOPACMAN_CONFLICTSFILE) [list WRONLY CREAT EXCL] 0600]
puts $conflictsfile [array get ::auto_replace_conflicts]
close $conflictsfile
}
exit [lindex $result 3]
}
spawn {*}$argv
log_user 1
set timeout -1
expect {
"Starting full system upgrade..." { }
eof doExit
}
set timeout 15
expect {
-re {Replace \S+ with \S+ \[Y\/n\]} { send "y\r"; exp_continue }
"resolving dependencies..." { }
timeout { }
eof doExit
}
expect {
"looking for conflicting packages" { exp_continue }
"Enter a number (default=1):" { if { $noconfirm } { send "1\r"; exp_continue; } { interact -o "\r" exp_continue; } }
-re {(\S+) and (\S+) are in conflict( \(\S+\))?\.} { parseConflicts $expect_out(1,string) $expect_out(2,string); exp_continue }
-re {Proceed with installation.*} { if { [info exist ::env(AUTOPACMAN_LOG)] } { log_file $::env(AUTOPACMAN_LOG) }; if { $::noconfirm || $::conflictsfile_set } { send "y\r"; set noconfirm_downloading true } }
timeout { }
eof doExit
}
if { $noconfirm } {
if { $noconfirm_downloading } {
set timeout -1
expect {
-re {Do you want to delete it.*} { send "y\r"; exp_continue }
-re {.*\[Y/n\]} { }
eof doExit
}
}
exp_send_error "\nUnexpected user input required. Try again without --noconfirm"
close
} else {
expect_background {
-re {Do you want to delete it.*} { send "y\r"; exp_continue }
}
catch interact
}
doExit

View File

@@ -0,0 +1,138 @@
#!/bin/bash
set -e
package-exists-fast(){
if compgen -G "/var/lib/pacman/local/$1-*" >/dev/null; then
return 0
else
return 1
fi
}
update_keyrings(){
local packages=("snigdhaos-keyring" "archlinux-keyring" "chaotic-keyring")
if $PACMAN -Qq blackarch-keyring &> /dev/null; then
packages+=("blackarch-keyring")
fi
if [ -n "$(PACMAN -Qu "${packages[@]}" 2>&1)" ]; then
echo -e "Updating Keyrings..."
# shellcheck disable=SC1007
SNAPA_PAC_SKIP=y SKIP_AUTOSNAP= $PACMAN -S --needed --noconfirm "${packages[@]}" || return 0
return 1
fi
return 0
}
install_expect(){
if [ -x /usr/bin/tclsh ] && [ ! -x /usr/bin/expect ]; then
SKIP_AUTOSNAP=1 SNAPA_PAC_SKIP=y $PACMAN -U https://mirror.osbeck.com/archlinux/extra/os/x86_64/expect-5.45.4-4-x86_64.pkg.tar.zst --noconfirm -asdeps
fi
}
pre-update-routines(){
local exit_code=0
update_keyrings || exit_code=2
install_expect
return $exit_code
}
migrate-snigdhaos-repo() {
gawk -i inplace 'BEGIN {
err=1
}
{
if (rm)
{
if ($0 ~ /^ *(Include|Server) *=/)
{
next
}
# Check for empty line
else if ($0 ~ /^ *$/)
{
next
}
else
{
rm=0
}
}
if ($0 == "[options]")
{
print
next
}
else if ($0 == "[snigdhaos-core]")
{
if (set) {
rm=1
next
}
set=1
}
else if ($0 == "[core-testing]")
{
print "[testing]"
err=0
next
}
else if ($0 == "[community-testing]")
{
print "[extra-testing]"
err=0
next
}
else if ($0 == "[community]")
{
rm=1
err=0
next
}
}
/^\[[^ \[\]]+\]/ {
if (!set) {
print "[snigdhaos-core]"
print "Server = https://snigdha-os.github.io/snigdhaos-core/x86_64"
print ""
set=1
err=0
}
}
END {exit err}
1' /etc/pacman.conf
}
verify-core(){
local invalid_nvidia=()
if [ -f "/usr/lib/modprobe.d/nvidia-utils.conf" ] && [ -f "/usr/share/licenses/nvidia-dkms/LICENSE" ]; then
for i in /usr/lib/modules/[0-9]*; do
if pacman -Qo "${i}" &>/dev/null; then
local nvidia
nvidia="$(grep -ohP '^.*/nvidia.ko[^/]*(?=:)' "${i}/modules.dep" 2>/dev/null || true)"
if [ -z "$nvidia" ] || [[ "$(modinfo "${i}/${nvidia}" -F vermagic 2>/dev/null | cut -d' ' -f1)" != "${i##*/}" ]]; then
invalid_nvidia+=("${i##*/}")
fi
fi
done
fi
# Oops, at least one is invalid!
if [ ${#invalid_nvidia[@]} -ne 0 ]; then
dkms_version="$(pacman -Rddp --print-format %v nvidia-dkms 2>/dev/null)"
if [ -n "${dkms_version}" ]; then
echo -e "\n\033[1;33m-->\033[1;34m A problem with the NVIDIA drivers has been detected\033[0m"
fi
for i in "${invalid_nvidia[@]}"; do
if [ -n "${dkms_version}" ]; then
echo -e "\n\033[1;33m--->\033[1;34m Building NVIDIA DKMS module for kernel $i\033[0m"
dkms remove -m nvidia -v "${dkms_version%-*}" -k "$i" || true
dkms install -m nvidia -v "${dkms_version%-*}" -k "$i" && depmod "$i" && echo -e "\033[1;33m--->\033[1;32m NVIDIA DKMS module for kernel $i built successfully\033[0m" || echo -e "\033[1;33m--->\033[1;31m Failed to build NVIDIA DKMS module for kernel $i\033[0m"
elif command -v dkms >/dev/null; then
dkms autoinstall -k "$i" && depmod "$i"
fi
done
fi
}
"$@" exit "$?"

View File

@@ -0,0 +1,11 @@
##
## Garuda Update config
##
# Environment variables can be set in this config to modify the behavior of the garuda-update script.
# For more information, see the wiki page: https://wiki.garudalinux.org/garuda-update
#
# Uncomment the variables you wish to set.
# SKIP_MIRRORLIST=1
# UPDATE_AUR=1
# PACMAN_NOCONFIRM=1

View File

@@ -0,0 +1,217 @@
#!/bin/bash
set -e
init_logging(){
if [ ! -d /var/log/snigdhaos/ ]; then
# shellcheck disable=SC2174
mkdir -p -m 755 /var/log/snigdhaos/
fi
echo -e "\n>-<->-< snigdhaos-updater at $(date +"%Y-%m-%d %R %Z(%:::z)")\n" >>/var/log/snigdhaos/snigdhaos-updater
exec &> >(stdbuf -i0 -o0 -e0 tee >(sed '/\x1b\[[0-9][EF]/d;/\r[^\n]$/d;s,\x1B\[[0-9;]*[a-zA-Z],,g' >>/var/log/snigdhais/snigdhaos-updater))
}
parse_pacman_log(){
sed -i -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" "$AUTOPACMAN_LOG"
local reason
reason="$(tac "$AUTOPACMAN_LOG" | grep -oP -m 1 '(?<=error: failed to commit transaction \().*(?=\))')"
case "$reason" in
"invalid or corrupted package"*)
RETRY="Snigdha OS Updater Found Corrupted Packages😑. Retying..."
CUSTOM_PACMAN_CONFIG="$(mktemp)"
# shellcheck disable=SC2016
sed 's|Include = /etc/pacman.d/chaotic-mirrorlist|Server = https://cdn-mirror.chaotic.cx/$repo/$arch|g' /etc/pacman.conf > "$CUSTOM_PACMAN_CONFIG"
pacman_args+=("--config" "$CUSTOM_PACMAN_CONFIG")
;;
"download library error")
RETRY="Snigdha OS Updater Found Corrupted Packages😑. Retying..."
CUSTOM_PACMAN_CONFIG="$(mktemp)"
sed '/^ParallelDownloads.*/d' /etc/pacman.conf >"$CUSTOM_PACMAN_CONFIG"
pacman_args+=("--config" "$CUSTOM_PACMAN_CONFIG")
;;
"conflicting files")
tac "$AUTOPACMAN_LOG" | gawk 'BEGIN { exitcode=1 }
/error: failed to commit transaction \(conflicting files\)/ { exit exitcode }
/\S+: (.*) exists in filesystem/ { if ($0 ~ /\S+:\/usr\/lib\/python[^\/]+\/site-packages\/[^/]+\/__pycache__\/.+\.pyc exists in filesystem/) { exitcode=0 } else { exit 1 } }
ENDFILE {exit 1}' && pacman_args+=("--overwrite" "/usr/lib/python*/site-packages/*/__pycache__/*.pyc") && RETRY="Overwriting Pycache file conflicts..." || true
;;
esac
}
update_mirrorlist(){
if [[ -v SKIP_MIRRORLIST ]]; then
return
fi
local MIRRORLIST_TEMP MINLINES=0
MIRRORLIST_TEMP="$(mktemp)"
# Rate-Mirrors
if command -v rate-mirrors >/dev/null; then
MINLINES=10
echo -e "\n\033[0;96m=>\033[0;96m [Rate-Mirrors]Refreshing Mirrorlist...🛸\033[0m"
rate-mirrors --allow-root --save="$MIRRORLIST_TEMP" arch --max-delay=21600 >/dev/null || { rm "$MIRRORLIST_TEMP"; }
$INT
# Reflector
elif command -v reflector >/dev/null; then
MINLINES=5
echo -e "\n\033[0;96m=>\033[0;96m [Reflector]Refreshing Mirrorlist...🛸\033[0m"
reflector --latest 10 --age 2 --fastest 10 --protocol https --sort rate --save "$MIRRORLIST_TEMP" || { rm "$MIRRORLIST_TEMP"; }
$INT
else
return
fi
# What if we are not using rate-mirrors and reflector?
if [ ! -f "$MIRRORLIST_TEMP" ]; then
echo -e "\033[0;91mMirrorlist Update Failed!\033[0m"
return
fi
if COUNT="$(grep -Ec "^Server *=" "$MIRRORLIST_TEMP")" && [ "$COUNT" -ge "$MINLINES" ]; then
install -m644 "$MIRRORLIST_TEMP" /etc/pacman.d/mirrorlist
# shellcheck disable=SC2034
DATABASE_UPDATED="force"
else
echo -e "\033[0;31Mirror Count Not Satisfied!\033[0m"
fi
echo
rm "$MIRRORLIST_TEMP"
}
do_update(){
if [ -x /usr/bin/expect ]; then
local AUTOPACMAN_LOG EXIT=0 RETRY=false CUSTOM_PACMAN_CONFIG="" SUCCESS=false
if [ ! -v AUTOPACMAN_CONFLICTSFILE ]; then
local AUTOPACMAN_CONFLICTSFILE
AUTOPACMAN_CONFLICTSFILE="$(mktemp -u)"
fi
AUTOPACMAN_LOG="$(mktemp)"
LANG=C LANGUAGE=C LC_ALL=C AUTOPACMAN_LOG="$AUTOPACMAN_LOG" AUTOPACMAN_PACMAN_NOCONFIRM="$PACMAN_NOCONFIRM" AUTOPACMAN_CONFLICTSFILE="$AUTOPACMAN_CONFLICTSFILE" /usr/lib/snigdhaos/snigdhaos-updater/auto-pacman "$PACMAN" "${pacman_args[@]}" || { EXIT=$?; }
if [ -n "$CUSTOM_PACMAN_CONFIG" ]; then
rm "$CUSTOM_PACMAN_CONFIG"
fi
if [ "$EXIT" == "134" ] || [ "$EXIT" == "0" ]; then
SUCCESS=true
fi
if [ "$SUCCESS" != "true" ] && [ -z "$ALREADY_RETRIED" ]; then
parse_pacman_log
fi
rm "$AUTOPACMAN_LOG"
if [ "$RETRY" != "false" ]; then
echo -e "\n\033[0;96m=>\033[0;96m $RETRY \n\033[0m"
ALREADY_RETRIED=true do_update
return
fi
if [ -v AUTOPACMAN_CONFLICTSFILE ]; then
rm -f "$AUTOPACMAN_CONFLICTSFILE"
unset AUTOPACMAN_CONFLICTSFILE
fi
if [ "$SUCCESS" == "false" ]; then
false
fi
else
$PACMAN "${pacman_args[@]}"
fi
}
show_changelog(){
if [ -e "/var/log/snigdhaos/tmp/update_notices" ]; then
echo -e "\033[0;96mUpdate:\n\033[0;96m$(gawk -F '\t' '{print $2}' /var/lib/snigdhaos/tmp/update_notices)\n\033[0m"
rm /var/lib/snigdhaos/tmp/update_notices
fi
}
if [ -f /etc/snigdhaos/snigdhaos-updater/config ]; then
# shellcheck disable=SC1091
source /etc/snigdhaos/snigdhaos-updater/config
fi
PARAMETERS=("$@")
PARSED_OPTIONS=$(getopt --options="a" --longoptions="aur,skip-mirrorlist,noconfirm" --name "$0" -- "${PARAMETERS[@]}")
if [[ $? -ne 0 ]]; then
echo -e "\033[0;31m\nFailed to parse CLI options\n\033[0m"
fi
eval set -- "$PARSED_OPTIONS"
while true; do
case "$1" in
-a | --aur)
UPDATE_AUR=1
shift
;;
--skip-mirrorlist)
SKIP_MIRRORLIST=1
shift
;;
--noconfirm)
PACMAN_NOCONFIRM=1
shift
;;
--)
shift
if [ "$SNIGDHAOS_UPDATE_SELFUPDATE" == 1 ] && [ "$#" -eq 1 ] && [ -z "$1" ]; then
break
fi
PACMAN_EXTRA_OPTS+=("${@}")
break
;;
*)
echo "Programming error"
exit 3
;;
esac
done
if grep -qE 'subvol=@/.snapshots/[0-9]+/snapshot' /proc/cmdline && [[ ! -v GARUDA_SNAPSHOT_PACMAN ]]; then
echo -e "\033[0;31mError: You are currently booted into a snapshot. Please restore the snapshot via btrfs-assistant or snapper-tools before updating your system.\n\033[0;34mNote: You can ignore this error by setting SNIGDHAOS_SNAPSHOT_PACMAN: SNIGDHAOS_SNAPSHOT_PACMAN=1 snigdhaos-updater\n\033[1;31mAny modifications made to this snapshot will be lost next reboot. ❌\033[0m"
exit 1
fi
init_logging
/usr/lib/snigdhaos/snigdhaos-updater/aux-script migrate-snigdhaos-repo && DATABASE_UPDATED=false || true
update_mirrorlist
self_update "${PARAMETERS[@]}"
/usr/lib/snigdhaos/snigdhaos-updater/aux-scripts pre-update-routines || { if [ "$?" -eq 2 ]; then self_update "${PARAMETERS[@]}"; fi; }
pacman_args=("-Su")
if [ "$DATABASE_UPDATED" == false ]; then pacman_args+=("-y"); elif [ "$DATABASE_UPDATED" == "force" ]; then pacman_args+=("-yy"); fi
while IFS= read -r line; do
pacman_args+=("$line")
done < <(/usr/lib/snigdhaos/snigdhaos-updater/aux-scripts package-replaces)
if [ -v PACMAN_EXTRA_OPTS ]; then
pacman_args+=("${PACMAN_EXTRA_OPTS[@]}")
fi
do_update
if [[ -v UPDATE_AUR ]]; then
if [ -x /usr/bin/paru ] && [[ -n "$SUDO_UID" ]]; then
echo -e "\n\033[1;33m-->\033[0;34m Updating AUR packages with paru..\033[0m"
sudo -u "#$SUDO_UID" paru -Sua || { echo -e "\033[1;31m\nParu exited with error code $?\n\033[0m"; }
elif [ -x /usr/bin/yay ] && [[ -n "$SUDO_UID" ]]; then
echo -e "\n\033[0;33m-->\033[0;34m Updating AUR packages with yay..\033[0m"
sudo -u "#$SUDO_UID" yay -Sua || { echo -e "\033[1;31m\nYay exited with error code $?\n\033[0m"; }
else
echo -e "\n\033[0;33m--> UPDATE_AUR specified but no supported AUR helper found ❌\033[0m"
fi
$INT
fi
if [ -x /usr/bin/locate ]; then
systemctl start updatedb.service --no-block
fi
/usr/lib/snigdhaos/snigdhaos-updater/aux-scripts verify-core
echo -e "\n\033[1;32m[SUCCESS]System updated ! \n\033[0m"
show_changelog

View File

@@ -0,0 +1,118 @@
#!/bin/bash
set -e
task=${1:-'fix'}
keyring=false
reset_pacman=false
internal_update=0
if [ "$task" == "setup" ]; then
update
exit 0
elif [ "$task" == "keyring" ]; then
keyring=true
elif [ "$task" == "fix" ]; then
if [ "$VERSION" != 1 ]; then
echo "[RESET] Pacman Config !"
echo "Are you sure? (y/n)"
read yusure
[ $yusure != "y" ] && exit 1
fi
keyring=true
reset_pacman=true
elif [ "$task" == "fullfix" ]; then
if [ "$VERSION" != 1 ]; then
echo "[RESET] Pacman Config !"
echo -e "\033[0;33m[WARNING] Fullfix mode! Reinstall All Packages !\033[0m"
echo "Are you sure? (y/n)"
read yusure
[ $yusure != "y" ] && exit 1
fi
keyring=true
reset_pacman=true
internal_update=2
elif [ "$task" == "reinstall" ]; then
echo -e "\033[0;33m[WARNING] Fullfix mode! Reinstall All Packages !\033[0m"
echo "Are you sure? (y/n)"
read yusure
[ $yusure != "y" ] && exit 1
internal_update=2
elif [ "$task" == "reset-snapper" ]; then
exec bash -c ". <(wget -qO- https://raw.githubusercontent.com/Snigdha-OS/snigdhaos-pkgbuilds/master/common/snigdhaos-updater/reset-snapper)"
elif [ "$task" == "reset-audio" ]; then
internal_update=0
else
echo -e "\033[1;31m\nUnknown subcommand!\n\033[0m";
exit 1
fi
blackarch=false
if [ "$keyring" = true ] || [ "$reset_pacman" = true ]; then
grep -Fxq "[blackarch]" /etc/pacman.conf && blackarch=true
fi
# Get a usable pacman version if possible
pacman=pacman
if [ "$reset_pacman" = true ]; then
temp_file=$(mktemp)
wget https://pkgbuild.com/~morganamilo/pacman-static/x86_64/bin/pacman-static -O $temp_file && chmod +x $temp_file && pacman="$temp_file" || { echo -e "\033[1;31m\nFailed to download pacman-static\n\033[0m"; }
$pacman --version
wget https://gitlab.com/garuda-linux/tools/garuda-tools/-/raw/master/data/pacman-default.conf -O /etc/pacman.conf || { echo -e "\033[1;31m\nFailed to restore pacman.conf\n\033[0m"; }
# Set global CDN mirrors
wget https://archlinux.org/mirrorlist/all/ -O /etc/pacman.d/mirrorlist || true
cat <<-"EOF" >> /etc/pacman.d/mirrorlist
Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch
Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch
EOF
# Set chaotic mirrors
wget https://aur.chaotic.cx/mirrorlist.txt -O /etc/pacman.d/chaotic-mirrorlist || cat <<-"EOF" > /etc/pacman.d/chaotic-mirrorlist
Server = https://random-mirror.chaotic.cx/$repo/$arch
Server = https://cdn-mirror.chaotic.cx/$repo/$arch
Server = https://geo-mirror.chaotic.cx/$repo/$arch
EOF
fi
if [ "$keyring" = true ]; then
rm -rf /etc/pacman.d/gnupg
rm -rf /var/lib/pacman/sync
pacman-key --init
pacman-key --populate archlinux chaotic || { echo -e "\033[1;31m\nFailed to populate keyrings\n\033[0m"; }
pacman-key --recv-key FBA220DFC880C036 6D42BDD116E0068F --keyserver keyserver.ubuntu.com && pacman-key --lsign-key FBA220DFC880C036 6D42BDD116E0068F || { echo -e "\033[1;31m\nFailed to install some keys\n\033[0m"; }
rm /var/cache/pacman/pkg/* || true
fi
# Re-set-up blackarch
if [ "$blackarch" == "true" ]; then
bash <(wget -qO- https://blackarch.org/strap.sh) && SKIP_AUTOSNAP=1 SNAP_PAC_SKIP=y $pacman -S blackarch-keyring --noconfirm --needed || { echo -e "\033[1;31m\nFailed to fix blackarch\n\033[0m"; } # Too bad
fi
if [ "$keyring" = true ]; then
SKIP_AUTOSNAP=1 SNAP_PAC_SKIP=y $pacman -Sy archlinux-keyring chaotic-keyring --noconfirm
fi
if [ "$internal_update" = "1" ]; then
$pacman -Syu
elif [ "$internal_update" = "2" ]; then
$pacman -Qqn | $pacman -Sy -
else
SKIP_AUTOSNAP=1 SNAP_PAC_SKIP=y $pacman -Sy --noconfirm --overwrite='*' garuda-update
PACMAN_EXE="$pacman" update
fi
if [ "$task" == "reset-audio" ]; then
if [ ! -z "$SUDO_USER" ]; then
pacman -Qq pipewire pipewire-pulse pipewire-media-session jamesdsp wireplumber pluseaudio 2>/dev/null || true
SKIP_AUTOSNAP=1 SNAP_PAC_SKIP=y pacman -S --needed wireplumber pipewire-support
systemctl disable --now pulseaudio pulseaudio.socket pipewire-media-session.service jack --user --machine=$SUDO_USER@.host
systemctl enable -f --now pipewire.socket pipewire-pulse.socket pipewire.service pipewire-pulse.service wireplumber.service --user --machine=$SUDO_USER@.host
else
echo -e "\033[1;31m\nCould not detect sudo user.\n\033[0m";
fi
fi
if [ ! -z "$temp_file" ]; then
rm -f $temp_file
fi

View File

@@ -0,0 +1,43 @@
#!/bin/bash
set -e
get_children_recursive() {
local children="$(echo "$VOLUMES" | awk -v id=$1 '{if (id == $7) {print $2}}')"
if [ ! -z "$children" ]; then
while IFS= read -r line ; do get_children_recursive $line; done <<< "$children"
echo "$children"
fi
}
if [[ "$(findmnt / -o options)" != *"subvol=/@"* ]]; then
echo "You are still booted into a snapshot."
exit
fi
# First, we stop snapperd so we don't screw stuff up. It will auto start when needed anyway.
systemctl stop snapperd
VOLUMES="$(btrfs subvolume list /)"
TO_DELETE=""
OLD_ROOTS="$(echo "$VOLUMES" | awk '/@_backup_[0-9]+\S+$/ {print $2} /restore_backup_\S+_[0-9]+$/ {print $2} /timeshift-btrfs\/snapshots\/[^\/]+\/@$/ {print $2}')"
# Find all children of OLD_ROOTS recursively
OLD_ROOTS_CHILDREN="$(while IFS= read -r line ; do get_children_recursive $line; done <<< "$OLD_ROOTS")"
TO_DELETE="$OLD_ROOTS_CHILDREN $OLD_ROOTS"
SNAPSHOTS_VOL="$(echo "$VOLUMES" | awk '/ .snapshots$/ {print $2; exit}')"
if [ ! -z "$SNAPSHOTS_VOL" ]; then
TO_DELETE+=" $(get_children_recursive $SNAPSHOTS_VOL) $SNAPSHOTS_VOL"
fi
for i in $TO_DELETE
do
btrfs subvolume delete -i $i /
done
# Now we force recreate the snapper configs
rm -f /etc/snapper/configs/*
rm -r /.snapshots/ || true
sed -i /etc/conf.d/snapper -e 's,SNAPPER_CONFIGS=.*,SNAPPER_CONFIGS=\"\",'
snapper create-config --template garuda /

View File

@@ -0,0 +1,8 @@
/var/log/snigdhaos/snigdhaos-updater {
daily
rotate 7
missingok
notifempty
maxsize 2M
noolddir
}

View File

@@ -0,0 +1,67 @@
#!/bin/bash
# shellcheck disable=SC2015
# shellcheck disable=SC1091
set -e
def_pacman_config(){
local TEMP_CONF
TEMP_CONF=$(mktemp)
# Configuring Backup Repo
echo -e "[snigdhaos-core]\nServer = https://snigdhalinux.github.io/snigdhaos-core/x86_64" >"$TEMP_CONF"
echo "$TEMP_CONF"
}
# Credit : Garuda Linux
# URL : https://garudalinux.org/
# Script Source : https://gitlab.com/garuda-linux/pkgbuilds/-/blob/main/garuda-update/garuda-update
self_update(){
local EXTRA_PARAMS=()
if [ "$DATABASE_UPDATED" == "force" ]; then
$PACMAN -Syy && DATABASE_UPDATED=true || true
elif [ "$DATABASE_UPDATED" != "true" ]; then
$PACMAN -Syy && DATABASE_UPDATED=true || true
fi
[ "$DATABASE_UPDATED" != "true" ] && local MIN_PACMAN_CONF && MIN_PACMAN_CONF="$(def_pacman_config)" && $PACMAN --config "$MIN_PACMAN_CONF" -Syy && EXTRA_PARAMS=("--config" "$MIN_PACMAN_CONF") || true
$INT
if $PACMAN "${EXTRA_PARAMS[@]}" -Qu snigdhaos-updater &>/dev/null; then
local success=true
if ! SNAP_PAC_SKIP=y SKIP_AUTOSNAP='' $PACMAN "${EXTRA_PARAMS[@]}" -Sdd snigdhaos-updater --needed --noconfirm; then
$INT
unshare -m bash -c 'mount -t tmpfs tmpfs /usr/share/libalpm/hooks && { [ ! -d /var/cache/pacman/pkg ] mount -t tmpfs tmpfs /var/cache/pacman/pkg; } && eval "$@"' -- SNAP_PAC_SKIP=y SKIP_AUTOSNAP='' "$PACMAN" "${EXTRA_PARAMS[@]}" --hookdir "/usr/share/libalpm/hooks" -Sdd snigdhaos-updater --needed --noconfirm || success=false
fi
$INT
if [ "$success" == "true" ]; then
SNIGDHAOS_UPDATER_SELFUPDATE=2 exec /usr/bin/snigdhaos-updater "$@"
fi
fi
$INT
}
INT=true
trap "INT=false" INT
if [[ $EUID -ne 0 ]]; then
exec sudo --preserve-env="SKIP_MIRRORLIST"
exit 1
fi
if [ "$1" == "remote" ]; then
exec bash -c "VERSION=6 . <(wget -qO- https://raw.githubusercontent.com/Snigdha-OS/snigdhaos-pkgbuilds/master/common/snigdhaos-updater/remote) \"\$@\"" remote "${@:2}"
fi
if [ -n "$PACMAN_EXE" ]; then
PACMAN="$PACMAN_EXE"
else
PACMAN="pacman"
fi
export PACMAN
DATABASE_UPDATED=false
if [ -n "$SNIGDHAOS_UPDATER_SELFUPDATE" ]; then
DATABASE_UPDATED=true
fi
self_update "$@"
source /usr/lib/snigdhaos/snigdhaos-updater/core-script