Init
This commit is contained in:
parent
1039971aaa
commit
01a53f64d0
|
@ -0,0 +1,23 @@
|
|||
pkgbase = melawy-dracut-initramfs
|
||||
pkgdesc = Integration layer for dracut for Arch Linux
|
||||
pkgver = 0
|
||||
pkgrel = 1
|
||||
url = https://github.com/Valeria-Fadeeva/melawy-dracut-initramfs
|
||||
arch = any
|
||||
license = AGPLv3
|
||||
depends = dracut
|
||||
depends = systemd
|
||||
depends = python
|
||||
depends = util-linux
|
||||
depends = python-pefile
|
||||
provides = dracut-hook
|
||||
source = 10-dracut-initramfs-pre-install.hook
|
||||
source = 60-dracut-initramfs-remove.hook
|
||||
source = 90-dracut-initramfs-install.hook
|
||||
source = dracut-initramfs
|
||||
sha256sums = 4a869624ec1b9078e93ed2a9503f71e86b40c110585332b33262e12f8cd37b03
|
||||
sha256sums = f77d94b6eced20b518c68cdc41a6e575ff82a3a78863c96ea6e7ba40f75dbe8e
|
||||
sha256sums = 6ac56a11338191d4e515426fcd5e332cad44777ff45e6ea58667320343eef998
|
||||
sha256sums = 3b96f5fadd5c4c8b0ec44da63079a29c01a572f359433419f93ecfea923f8117
|
||||
|
||||
pkgname = melawy-dracut-initramfs
|
|
@ -0,0 +1,7 @@
|
|||
*.pkg.tar
|
||||
*.pkg.tar.*
|
||||
*.zst
|
||||
*.zst.*
|
||||
pkg/
|
||||
src/
|
||||
.idea/
|
|
@ -0,0 +1,15 @@
|
|||
[Trigger]
|
||||
Type = Path
|
||||
Operation = Install
|
||||
Operation = Upgrade
|
||||
Target = usr/lib/modules/*/pkgbase
|
||||
Target = usr/lib/dracut/*
|
||||
Target = usr/lib/systemd/systemd
|
||||
Target = usr/share/libalpm/hooks/90-dracut-initramfs-install.hook
|
||||
Target = usr/bin/dracut-initramfs
|
||||
Target = usr/src/*/dkms.conf
|
||||
|
||||
[Action]
|
||||
Description = Ensure ESP is mounted...
|
||||
When = PreTransaction
|
||||
Exec = /usr/bin/dracut-initramfs -x
|
|
@ -0,0 +1,11 @@
|
|||
[Trigger]
|
||||
Type = Path
|
||||
Operation = Remove
|
||||
Target = usr/lib/modules/*/pkgbase
|
||||
Target = usr/src/*/dkms.conf
|
||||
|
||||
[Action]
|
||||
Description = Removing linux images...
|
||||
When = PreTransaction
|
||||
Exec = /usr/bin/dracut-initramfs -y
|
||||
NeedsTargets
|
|
@ -0,0 +1,16 @@
|
|||
[Trigger]
|
||||
Type = Path
|
||||
Operation = Install
|
||||
Operation = Upgrade
|
||||
Target = usr/lib/modules/*/pkgbase
|
||||
Target = usr/lib/dracut/*
|
||||
Target = usr/lib/systemd/systemd
|
||||
Target = usr/share/libalpm/hooks/90-dracut-initramfs-install.hook
|
||||
Target = usr/bin/dracut-initramfs
|
||||
Target = usr/src/*/dkms.conf
|
||||
|
||||
[Action]
|
||||
Description = Updating linux images...
|
||||
When = PostTransaction
|
||||
Exec = /usr/bin/dracut-initramfs -z
|
||||
NeedsTargets
|
|
@ -0,0 +1,30 @@
|
|||
# Author: Valeria Fadeeva <valeria@fadeeva.me>
|
||||
# Maintainer: Valeria Fadeeva <valeria@fadeeva.me>
|
||||
|
||||
pkgname=melawy-dracut-initramfs
|
||||
pkgver=0
|
||||
pkgrel=1
|
||||
pkgdesc="Integration layer for dracut for Arch Linux"
|
||||
url="https://github.com/Valeria-Fadeeva/melawy-dracut-initramfs"
|
||||
arch=(any)
|
||||
license=('AGPLv3')
|
||||
depends=(dracut systemd python util-linux python-pefile)
|
||||
optdepends=()
|
||||
source=('10-dracut-initramfs-pre-install.hook'
|
||||
'60-dracut-initramfs-remove.hook'
|
||||
'90-dracut-initramfs-install.hook'
|
||||
'dracut-initramfs')
|
||||
sha256sums=('4a869624ec1b9078e93ed2a9503f71e86b40c110585332b33262e12f8cd37b03'
|
||||
'f77d94b6eced20b518c68cdc41a6e575ff82a3a78863c96ea6e7ba40f75dbe8e'
|
||||
'6ac56a11338191d4e515426fcd5e332cad44777ff45e6ea58667320343eef998'
|
||||
'3b96f5fadd5c4c8b0ec44da63079a29c01a572f359433419f93ecfea923f8117')
|
||||
backup=()
|
||||
provides=(dracut-hook)
|
||||
conflicts=()
|
||||
|
||||
package() {
|
||||
install -Dm644 "${srcdir}/10-dracut-initramfs-pre-install.hook" "${pkgdir}/usr/share/libalpm/hooks/10-dracut-initramfs-pre-install.hook"
|
||||
install -Dm644 "${srcdir}/60-dracut-initramfs-remove.hook" "${pkgdir}/usr/share/libalpm/hooks/60-dracut-initramfs-remove.hook"
|
||||
install -Dm644 "${srcdir}/90-dracut-initramfs-install.hook" "${pkgdir}/usr/share/libalpm/hooks/90-dracut-initramfs-install.hook"
|
||||
install -Dm755 "${srcdir}/dracut-initramfs" "${pkgdir}/usr/bin/dracut-initramfs"
|
||||
}
|
11
README.md
11
README.md
|
@ -1,2 +1,13 @@
|
|||
# melawy-dracut-initramfs
|
||||
Integration layer for dracut for Arch Linux
|
||||
|
||||
```
|
||||
ls -1 /efi/EFI/Linux
|
||||
```
|
||||
```
|
||||
...
|
||||
initramfs-linux-xanmod-anbox-fallback.img
|
||||
initramfs-linux-xanmod-anbox.img
|
||||
...
|
||||
vmlinuz-linux-xanmod-anbox
|
||||
```
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
function usage {
|
||||
echo "$(basename "$0") [OPTIONS]"
|
||||
echo " -h shows usage"
|
||||
echo " -g <version> generate UKI image for specified kernel version"
|
||||
echo " -a generate UKI images for all available kernels"
|
||||
}
|
||||
|
||||
function check_root {
|
||||
[ $EUID -eq 0 ] && return
|
||||
echo "dracut-ukify requires root privileges to work" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ ${#} -eq 0 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
declare -a ukify_global_args=()
|
||||
|
||||
ESP_PATH=$(bootctl --print-esp-path)
|
||||
BOOT_PATH="${ESP_PATH}/EFI/Linux"
|
||||
|
||||
declare -A kernels
|
||||
update_all=0
|
||||
|
||||
while getopts ":hag:xyz" arg; do
|
||||
case ${arg} in
|
||||
g)
|
||||
found=0
|
||||
for line in $(pacman -Qql "$OPTARG"); do
|
||||
if [[ $line =~ ^/usr/lib/modules/([^/]+)/pkgbase$ ]]; then
|
||||
read -r kernel_name < "/${line}"
|
||||
kernels["${kernel_name}"]="${BASH_REMATCH[1]}"
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if (( ! found )); then
|
||||
echo "Error occurred during '$OPTARG' package traversal" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
a)
|
||||
update_all=1
|
||||
;;
|
||||
x)
|
||||
check_root
|
||||
# Trigger some IO on ESP path to be sure it's mounted by autofs if it's the case
|
||||
# Otherwise upgrading systemd may cause ESP partition not mounted at the time dracut attempt to write new image
|
||||
stat "$ESP_PATH" >/dev/null
|
||||
;;
|
||||
y)
|
||||
check_root
|
||||
while read -r line; do
|
||||
if [[ "$line" == 'usr/lib/modules/'+([^/])'/pkgbase' ]]; then
|
||||
read -r kernel_name < "/${line}"
|
||||
path="$(grep -lE "^${kernel_name}\$" /usr/lib/modules/*/pkgbase)"
|
||||
kernel_version=$(basename "${path%/pkgbase}")
|
||||
|
||||
kernel_image="$BOOT_PATH/vmlinuz-$kernel_name"
|
||||
initrd_image="$BOOT_PATH/initramfs-$kernel_name.img"
|
||||
initrd_image_fallback="$BOOT_PATH/initramfs-$kernel_name-fallback.img"
|
||||
|
||||
declare -a images=()
|
||||
images+=($kernel_image)
|
||||
images+=($initrd_image)
|
||||
images+=($initrd_image_fallback)
|
||||
|
||||
for image in "${images[@]}";
|
||||
do
|
||||
if [ -f ]; then
|
||||
echo "==> Removing $image..."
|
||||
rm -f $image
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
;;
|
||||
z)
|
||||
check_root
|
||||
while read -r line; do
|
||||
if [[ $line =~ ^usr/lib/modules/([^/]+)/pkgbase$ ]]; then
|
||||
read -r kernel_name < "/${line}"
|
||||
kernels["${kernel_name}"]="${BASH_REMATCH[1]}"
|
||||
else
|
||||
update_all=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if (( update_all )); then
|
||||
for kernel_path in /usr/lib/modules/*; do
|
||||
[ -f "$kernel_path/pkgbase" ] || continue
|
||||
|
||||
kernel_version=$(basename $kernel_path)
|
||||
kernel_dir="/usr/lib/modules/$kernel_version"
|
||||
pkgbase="$kernel_dir/pkgbase"
|
||||
kernel_name=$(sed -e 's/^[[:space:]]//g' -e 's/[[:space:]]$//g' "$pkgbase")
|
||||
|
||||
if [ -n "$kernel_name" ]; then
|
||||
kernels["$kernel_name"]="$kernel_version"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
function gen_image() {
|
||||
check_root
|
||||
kernel_name="$1"
|
||||
kernel_version="$2"
|
||||
|
||||
kernel_dir="/usr/lib/modules/$kernel_version"
|
||||
|
||||
if [ -f "/etc/kernel/cmdline" ]; then
|
||||
cmdline=$(sed -e 's/^[[:space:]]//g' -e 's/[[:space:]]$//g' "/etc/kernel/cmdline")
|
||||
else
|
||||
cmdline=$(sed -e 's/^[[:space:]]//g' -e 's/[[:space:]]$//g' -e 's/initrd.*$//g' "/proc/cmdline")
|
||||
fi
|
||||
|
||||
vmlinuz="$kernel_dir/vmlinuz"
|
||||
kernel_image="$BOOT_PATH/vmlinuz-$kernel_name"
|
||||
|
||||
initrd_image="$BOOT_PATH/initramfs-$kernel_name.img"
|
||||
initrd_image_fallback="$BOOT_PATH/initramfs-$kernel_name-fallback.img"
|
||||
|
||||
echo "==> Building initrd image $kernel_name $initrd_image"
|
||||
#dracut --force --hostonly --kver "$kernel_version" --kernel-cmdline="$cmdline" "$BOOT_PATH/initramfs-$kernel_name.img"
|
||||
dracut --force --hostonly --no-hostonly-cmdline --kver "$kernel_version" "$BOOT_PATH/initramfs-$kernel_name.img"
|
||||
|
||||
echo "==> Building initrd image $kernel_name $initrd_image_fallback"
|
||||
#dracut --force --no-hostonly --kver "$kernel_version" --kernel-cmdline="$cmdline" "$BOOT_PATH/initramfs-$kernel_name-fallback.img"
|
||||
dracut --force --kver "$kernel_version" "$BOOT_PATH/initramfs-$kernel_name-fallback.img"
|
||||
|
||||
cp -vrf $vmlinuz $kernel_image
|
||||
}
|
||||
|
||||
for kernel_name in "${!kernels[@]}"; do
|
||||
kernel_version="${kernels[$kernel_name]}"
|
||||
gen_image "$kernel_name" "$kernel_version"
|
||||
done
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo -n > sha256sum.txt
|
||||
|
||||
for i in *;
|
||||
do
|
||||
([ -f $i ] && [ "$i" != "PKGBUILD" ] && [ "$i" != "$(basename $0)" ] && [ "$i" != "sha256sum.txt" ] ) || continue
|
||||
echo $(sha256sum $i) | column -t >> sha256sum.txt
|
||||
done
|
||||
|
||||
makepkg --printsrcinfo > .SRCINFO
|
|
@ -0,0 +1,4 @@
|
|||
4a869624ec1b9078e93ed2a9503f71e86b40c110585332b33262e12f8cd37b03 10-dracut-initramfs-pre-install.hook
|
||||
f77d94b6eced20b518c68cdc41a6e575ff82a3a78863c96ea6e7ba40f75dbe8e 60-dracut-initramfs-remove.hook
|
||||
6ac56a11338191d4e515426fcd5e332cad44777ff45e6ea58667320343eef998 90-dracut-initramfs-install.hook
|
||||
3b96f5fadd5c4c8b0ec44da63079a29c01a572f359433419f93ecfea923f8117 dracut-initramfs
|
Loading…
Reference in New Issue