This commit is contained in:
Valeria Fadeeva 2023-11-04 17:24:55 +05:00
commit 8435cd67fc
10 changed files with 144 additions and 0 deletions

15
.github/FUNDING.yml vendored Executable file
View File

@ -0,0 +1,15 @@
# These are supported funding model platforms
#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
#patreon: # Replace with a single Patreon username
#open_collective: # Replace with a single Open Collective username
#ko_fi: # Replace with a single Ko-fi username
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
#liberapay: # Replace with a single Liberapay username
#issuehunt: # Replace with a single IssueHunt username
#otechie: # Replace with a single Otechie username
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
#github: [Valeria-Fadeeva]
custom: ["https://www.tinkoff.ru/rm/fadeeva.valeriya96/9bLRi79066", "https://yoomoney.ru/to/4100115921160758", "https://qiwi.com/n/VALERIAFADEEVA", "valeria.fadeeva.me"]

7
etc/grub-dracut.conf Normal file
View File

@ -0,0 +1,7 @@
# This config file controls the automation provided by eos-dracut
# When DRACUT_QUIET is set to true, dracut will operate with quiet flag set suppressing most output
#DRACUT_QUIET="false"
# When NO_FALLBACK is set to true, no fallback initrd will be generated
#NO_DRACUT_FALLBACK="false"

5
push.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
git add . && git commit -m "Update" && git push
echo "Ready"

8
usr/bin/dracut-rebuild Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
#
# Rebuild the initrds for all kernels found in /usr/lib/modules
#
# Run dracut for all the installed kernels
# This script requires passing a valid file to regenerate all initrds so we pass a file we know will exist
/usr/share/libalpm/scripts/dracut-install < "/usr/bin/dracut-rebuild"

View File

@ -0,0 +1,19 @@
#!/bin/bash
# called by dracut
check() {
dracut_module_included btrfs || return 1
return 0
}
# called by dracut
depends() {
return 0
}
# called by dracut
install() {
inst mktemp
hostonly='' instmods overlay
inst_hook pre-pivot 000 "$moddir/snapshot-overlay.sh"
}

View File

@ -0,0 +1,12 @@
#!/bin/bash
function mount_snapshot_overlay() {
local root_mnt="$NEWROOT"
if [[ "$(findmnt --mountpoint "$root_mnt" -o FSTYPE -n)" = "btrfs" ]] && [[ "$(btrfs property get ${root_mnt} ro)" != "ro=false" ]]; then
local ram_dir=$(mktemp -d -p /)
mount -t tmpfs cowspace ${ram_dir}
mkdir -p ${ram_dir}/{upper,work}
mount -t overlay -o lowerdir=${root_mnt},upperdir=${ram_dir}/upper,workdir=${ram_dir}/work rootfs ${root_mnt}
fi
}
mount_snapshot_overlay

View File

@ -0,0 +1,10 @@
[Trigger]
Type = Path
Operation = Remove
Target = usr/lib/modules/*/pkgbase
[Action]
Description = Removing initramfs...
When = PreTransaction
Exec = /usr/share/libalpm/scripts/dracut-remove
NeedsTargets

View File

@ -0,0 +1,13 @@
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/lib/modules/*/vmlinuz
Target = usr/lib/dracut/*
Target = usr/lib/systemd/systemd
[Action]
Description = Updating initramfs...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/dracut-install
NeedsTargets

View File

@ -0,0 +1,45 @@
#!/bin/bash -e
all=0
lines=()
# Read the optional config file for automation
[[ -f /etc/grub-dracut.conf ]] && source /etc/grub-dracut.conf
while read -r line; do
if [[ "${line}" != */vmlinuz ]]; then
# triggers when it's a change to dracut files
all=1
continue
fi
lines+=("/${line%/vmlinuz}")
pkgbase="$(<"${lines[-1]}/pkgbase")"
install -Dm644 "/${line}" "/boot/vmlinuz-${pkgbase}"
done
if (( all )); then
lines=(/usr/lib/modules/*)
fi
[[ ${DRACUT_QUIET} == "true" ]] && DRACUT_EXTRA_PARAMS=" --quiet"
for line in "${lines[@]}"; do
if ! pacman -Qqo "${line}/pkgbase" &> /dev/null; then
# if pkgbase does not belong to any package then skip this kernel
continue
fi
pkgbase="$(<"${line}/pkgbase")"
kver="${line##*/}"
dracut_restore_img="/usr/lib/modules/${kver}/initrd"
echo ":: Building initramfs for ${pkgbase} (${kver})"
dracut --force --hostonly --no-hostonly-cmdline${DRACUT_EXTRA_PARAMS} ${dracut_restore_img} "${kver}"
install -Dm644 ${dracut_restore_img} "/boot/initramfs-${pkgbase}.img"
if [[ ${NO_DRACUT_FALLBACK} != "true" ]] ; then
echo ":: Building fallback initramfs for ${pkgbase} (${kver})"
dracut --force --no-hostonly${DRACUT_EXTRA_PARAMS} "/boot/initramfs-${pkgbase}-fallback.img" "${kver}"
fi
done

View File

@ -0,0 +1,10 @@
#!/bin/bash -e
while read -r line; do
if [[ "${line}" == */pkgbase ]]; then
pkgbase="$(<"/${line}")"
kver="$(echo ${line} | cut -d/ -f4)"
rm -rf "/usr/lib/modules/${kver}" "/boot/vmlinuz-${pkgbase}" "/boot/initramfs-${pkgbase}.img" "/boot/initramfs-${pkgbase}-fallback.img" 2> /dev/null
fi
done