From 3704f302d32f6a09b7483fb22d9273870df7204d Mon Sep 17 00:00:00 2001 From: EnumDev Date: Mon, 7 Jul 2025 21:57:46 +0300 Subject: [PATCH] Update package version to 107 and add cleanup-initramfs script --- check-version.sh | 12 ++++++++++++ pkg.info | 3 +-- source-files/10-dracut.bpmhook | 2 +- source-files/cleanup-initramfs | 11 +++++++++++ source.sh | 4 ++-- 5 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 check-version.sh create mode 100644 source-files/cleanup-initramfs diff --git a/check-version.sh b/check-version.sh new file mode 100644 index 0000000..b574818 --- /dev/null +++ b/check-version.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Github repository +REPO="dracut-ng/dracut-ng" + +# Get tag name using Github Rest API +TAG_NAME=$(curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/"$REPO"/releases/latest | jq -r '.tag_name') + +# Get version number from tag name +VERSION=$(echo "$TAG_NAME" | rev | cut -d'-' -f1 | rev) + +echo "$VERSION" diff --git a/pkg.info b/pkg.info index 419f71d..d9a969e 100644 --- a/pkg.info +++ b/pkg.info @@ -1,7 +1,6 @@ name: dracut description: Event driven initramfs infrastructure -version: 106 -revision: 3 +version: 107 url: https://github.com/dracut-ng/dracut-ng license: GPL2-or-later architecture: any diff --git a/source-files/10-dracut.bpmhook b/source-files/10-dracut.bpmhook index 7922887..e7066db 100644 --- a/source-files/10-dracut.bpmhook +++ b/source-files/10-dracut.bpmhook @@ -2,4 +2,4 @@ trigger_operations: ["install", "upgrade", "remove"] target_type: "path" targets: ["boot/vmlinu*"] depends: ["dracut"] -run: "/usr/bin/generate-initramfs" +run: "/usr/sbin/generate-initramfs" diff --git a/source-files/cleanup-initramfs b/source-files/cleanup-initramfs new file mode 100644 index 0000000..94f2c83 --- /dev/null +++ b/source-files/cleanup-initramfs @@ -0,0 +1,11 @@ +#!/bin/sh + +for file in $(find /boot/ -name 'initramfs-*'); do + kver=$(echo "$file" | sed 's/.img//' | cut -d'-' -f'2-') + + # Continue if kernel version is installed + [ -d /usr/lib/modules/"$kver" ] && continue + + echo "Removed $file" + rm $file +done diff --git a/source.sh b/source.sh index aa286e4..151d4b7 100644 --- a/source.sh +++ b/source.sh @@ -24,8 +24,8 @@ build() { package() { make DESTDIR="$BPM_OUTPUT" install - # Install generate-initramfs script - install -Dm755 "$BPM_WORKDIR"/generate-initramfs "$BPM_OUTPUT"/usr/bin/generate-initramfs + # Install generate-initramfs and cleanup-initramfs scripts + install -Dm755 "$BPM_WORKDIR"/{generate,cleanup}-initramfs -t "$BPM_OUTPUT"/usr/sbin/ # Install BPM hook install -Dm644 "$BPM_WORKDIR"/10-dracut.bpmhook "$BPM_OUTPUT"/var/lib/bpm/hooks/10-dracut.bpmhook