aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrumeet <17158086+Trumeet@users.noreply.github.com>2019-11-28 22:36:13 -0800
committerTrumeet <17158086+Trumeet@users.noreply.github.com>2019-11-28 22:36:13 -0800
commit4579074020fb93e7b3bd6d03aa23259d7c924a70 (patch)
tree724cbebd6727e14359a224f85d963b2359c6cbe6
parent284f27ef54eb16890831f64d44dd932f69960ae1 (diff)
downloadefigen-master.tar
efigen-master.tar.gz
efigen-master.tar.bz2
efigen-master.zip
feat: support custom kernels (thanks @haruue)HEADmaster
-rw-r--r--99-efigen.hook8
-rw-r--r--PKGBUILD19
-rw-r--r--README.md24
-rwxr-xr-xefigen42
-rw-r--r--linux.config (renamed from efigen.config)2
5 files changed, 58 insertions, 37 deletions
diff --git a/99-efigen.hook b/99-efigen.hook
index fbecaa0..fd326f9 100644
--- a/99-efigen.hook
+++ b/99-efigen.hook
@@ -1,14 +1,14 @@
[Trigger]
Operation = Install
Operation = Upgrade
-Type = Package
-Target = linux
-Target = systemd
+Type = Path
+Target = usr/lib/modules/*/vmlinuz
+Target = usr/lib/initcpio/*
[Action]
Description = Generating linux.efi
When = PostTransaction
-Exec = /usr/bin/efigen
+Exec = /usr/share/libalpm/scripts/efigen
Depends = binutils
Depends = bash
Depends = systemd
diff --git a/PKGBUILD b/PKGBUILD
index d9b0e02..19f97b1 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -7,22 +7,21 @@ pkgdesc=""
arch=("any")
url="https://github.com/Trumeet/efigen"
license=('GPL2')
-depends=("linux"
- "systemd"
+depends=("systemd"
"binutils")
source=(99-efigen.hook
efigen
- efigen.config)
-md5sums=('d894a704527d7ac407160f8d67837069'
- '36baf021eac6ef4fb40ad1fc3cb292b5'
- '47994b7df6fe434b3c680969189bc171')
-backup=('etc/efigen/efigen.config')
+ linux.config)
+md5sums=('3696655e397201916b0c23fbbc5d3bbd'
+ '13805fb5bf05c729a7a9decf4fcf64b8'
+ '35b7be991eaffb22e67afe597b72596b')
+backup=('etc/efigen/linux.config')
package() {
install -m755 -d "${pkgdir}/usr/share/libalpm/hooks/"
- install -m755 -d "${pkgdir}/usr/bin/"
+ install -m755 -d "${pkgdir}/usr/share/libalpm/scripts/"
install -m755 -d "${pkgdir}/etc/efigen/"
install -m644 "${srcdir}/99-efigen.hook" "${pkgdir}/usr/share/libalpm/hooks/"
- install -m755 "${srcdir}/efigen" "${pkgdir}/usr/bin/"
- install -m644 "${srcdir}/efigen.config" "${pkgdir}/etc/efigen"
+ install -m755 "${srcdir}/efigen" "${pkgdir}/usr/share/libalpm/scripts/"
+ install -m644 "${srcdir}/linux.config" "${pkgdir}/etc/efigen"
}
diff --git a/README.md b/README.md
index 28aa95c..5ae7fc1 100644
--- a/README.md
+++ b/README.md
@@ -10,8 +10,6 @@ This package is designed for Arch Linux users with the following configuration:
* `binutils` installed
-* Kernel: `linux`
-
* EFI partition is mounted at `/boot`
## Install
@@ -24,9 +22,9 @@ $ makepkg -cfi
## Config
-Configuration file (an envfile): `/etc/efigen/efigen.config`
+Considering difference in kernels, we provide a way to adept in kernels. All configuration files (envfiles) are placed in `/etc/efigen/`, ending with `.config`. For example, configuration for kernel `linux` should be `/etc/efigen/linux.config`. Although names do not matter, it is suggested to use the same name as kernel name, because of the default naming method which will be talked later.
-Default values and descriptions are stated in that file. The default config may work for most Arch Linux machines with the following configuration:
+The default configuration is `/etc/efigen/linux.config`. It is supposed to work on the following situation:
* Initrd: `/boot/initramfs-linux.img`, no microcode.
@@ -44,17 +42,29 @@ Default values and descriptions are stated in that file. The default config may
* and requirements of this package.
-If the default configuration does not satisfy your situation, you may need to edit the configuration file yourself.
+If the default configuration does not satisfy your situation, you may need to edit the configuration file yourself. If you are using custom kernels, it is suggested to create a new file.
+
+### Default Naming Method
+
+To simplify your work, we provide a default naming method for initrds and kernels. According to names of configuration files (without `.config` extension), kernel and initrd file names are inferred as the following strategy:
+
+* Kernel: `/boot/vmlinuz-<Config name>`
+
+* Initrd: `/boot/initramfs-<Config name>.img`
+
+* Output file: `/boot/<Config name>.img`
+
+If you are using microcodes, or files are not placed in default locations, you have to define variables yourself.
## How to use
-This includes a `pacman` hook, which will be executed after upgrading `linux` or `systemd` package.
+This includes a `pacman` hook, which will be executed following mkinitcpio install, which occurs when `/usr/lib/modules/*/vmlinuz` or `/usr/lib/initcpio/*` is added or modified.
# Next Step
Reinstall kernel to initiate the first generate: `sudo pacman -S linux`.
-For secure boot users, sign `/boot/linux.efi`.
+For secure boot users, sign `/boot/*.efi`.
Get rid of bootloader: `sudo bootctl remove`.
diff --git a/efigen b/efigen
index a8b769a..fa97c12 100755
--- a/efigen
+++ b/efigen
@@ -1,18 +1,28 @@
#!/bin/bash
set -e
-CMD_LINE_FILE=/etc/efigen/cmdline.txt
-OS_RELEASE_FILE=/usr/lib/os-release
-KERNEL=/boot/vmlinuz-linux
-INITRDS=/boot/initramfs-linux.img
-TEMP_INITRD_IMG=./temp.img
-STUB=/usr/lib/systemd/boot/efi/linuxx64.efi.stub
-OUTPUT=/boot/linux.efi
-source /etc/efigen/efigen.config
-cat $INITRDS > $TEMP_INITRD_IMG
-objcopy \
- --add-section .osrel="$OS_RELEASE_FILE" --change-section-vma .osrel=0x20000 \
- --add-section .cmdline="$CMD_LINE_FILE" --change-section-vma .cmdline=0x30000 \
- --add-section .linux="$KERNEL" --change-section-vma .linux=0x40000 \
- --add-section .initrd="$TEMP_INITRD_IMG" --change-section-vma .initrd=0x3000000 \
- "$STUB" "$OUTPUT"
-rm $TEMP_INITRD_IMG
+SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
+if [ -z "$1" ]
+then
+ find /etc/efigen -maxdepth 1 -type f -name "*.config" -exec $SCRIPTPATH {} \;
+else
+ echo "Generating efi executable using configuration $1"
+ CONFIG_NAME_FULL=$(basename $1)
+ CONFIG_NAME="${CONFIG_NAME_FULL%%.*}"
+
+ CMD_LINE_FILE=/etc/efigen/cmdline.txt
+ OS_RELEASE_FILE=/usr/lib/os-release
+ KERNEL=/boot/vmlinuz-$CONFIG_NAME
+ INITRDS=/boot/initramfs-$CONFIG_NAME.img
+ TEMP_INITRD_IMG=./temp.img
+ STUB=/usr/lib/systemd/boot/efi/linuxx64.efi.stub
+ OUTPUT=/boot/$CONFIG_NAME.efi
+ source $1
+ cat $INITRDS > $TEMP_INITRD_IMG
+ objcopy \
+ --add-section .osrel="$OS_RELEASE_FILE" --change-section-vma .osrel=0x20000 \
+ --add-section .cmdline="$CMD_LINE_FILE" --change-section-vma .cmdline=0x30000 \
+ --add-section .linux="$KERNEL" --change-section-vma .linux=0x40000 \
+ --add-section .initrd="$TEMP_INITRD_IMG" --change-section-vma .initrd=0x3000000 \
+ "$STUB" "$OUTPUT"
+ rm $TEMP_INITRD_IMG
+fi
diff --git a/efigen.config b/linux.config
index df602fa..72ad998 100644
--- a/efigen.config
+++ b/linux.config
@@ -1,3 +1,5 @@
+# Generation configuration for `linux` kernel.
+
# Path to the kernel cmdline txt.
# CMD_LINE_FILE=/etc/efigen/cmdline.txt