commit 8435cd67fc7caea07ffc5a3bdd5ee534eb722e88 Author: Valeria Fadeeva Date: Sat Nov 4 17:24:55 2023 +0500 Update diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100755 index 0000000..77389e0 --- /dev/null +++ b/.github/FUNDING.yml @@ -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"] diff --git a/etc/grub-dracut.conf b/etc/grub-dracut.conf new file mode 100644 index 0000000..c24022f --- /dev/null +++ b/etc/grub-dracut.conf @@ -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" diff --git a/push.sh b/push.sh new file mode 100755 index 0000000..345883e --- /dev/null +++ b/push.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +git add . && git commit -m "Update" && git push + +echo "Ready" diff --git a/usr/bin/dracut-rebuild b/usr/bin/dracut-rebuild new file mode 100755 index 0000000..77ccffa --- /dev/null +++ b/usr/bin/dracut-rebuild @@ -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" diff --git a/usr/lib/dracut/modules.d/91btrfs-snapshot-overlay/module-setup.sh b/usr/lib/dracut/modules.d/91btrfs-snapshot-overlay/module-setup.sh new file mode 100755 index 0000000..7f04ca6 --- /dev/null +++ b/usr/lib/dracut/modules.d/91btrfs-snapshot-overlay/module-setup.sh @@ -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" +} diff --git a/usr/lib/dracut/modules.d/91btrfs-snapshot-overlay/snapshot-overlay.sh b/usr/lib/dracut/modules.d/91btrfs-snapshot-overlay/snapshot-overlay.sh new file mode 100755 index 0000000..fbab872 --- /dev/null +++ b/usr/lib/dracut/modules.d/91btrfs-snapshot-overlay/snapshot-overlay.sh @@ -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 diff --git a/usr/share/libalpm/hooks/60-dracut-remove.hook b/usr/share/libalpm/hooks/60-dracut-remove.hook new file mode 100644 index 0000000..6dd5722 --- /dev/null +++ b/usr/share/libalpm/hooks/60-dracut-remove.hook @@ -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 diff --git a/usr/share/libalpm/hooks/90-dracut-install.hook b/usr/share/libalpm/hooks/90-dracut-install.hook new file mode 100644 index 0000000..89737c8 --- /dev/null +++ b/usr/share/libalpm/hooks/90-dracut-install.hook @@ -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 diff --git a/usr/share/libalpm/scripts/dracut-install b/usr/share/libalpm/scripts/dracut-install new file mode 100755 index 0000000..1867e7b --- /dev/null +++ b/usr/share/libalpm/scripts/dracut-install @@ -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 diff --git a/usr/share/libalpm/scripts/dracut-remove b/usr/share/libalpm/scripts/dracut-remove new file mode 100755 index 0000000..67a0c37 --- /dev/null +++ b/usr/share/libalpm/scripts/dracut-remove @@ -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