Skip to content

Commit

Permalink
Allow sd-boot manager to source additional config files (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pogogo007 authored Jun 12, 2024
1 parent 3f7b948 commit 2c64364
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions systemd-boot-manager/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pkgbase = systemd-boot-manager
pkgdesc = A simple tool to maintain systemd-boot & systemd-boot entries for CachyOS
pkgver = 9
pkgver = 11
pkgrel = 1
url = https://github.com/CachyOS/CachyOS-PKGBUILDS/tree/master/systemd-boot-manager
arch = any
license = GPL2
license = GPL-2.0-or-later
depends = systemd
depends = findutils
depends = grep
Expand All @@ -16,9 +16,9 @@ pkgbase = systemd-boot-manager
source = https://github.com/CachyOS/CachyOS-PKGBUILDS/tree/master/systemd-boot-manager/sdboot-kernel-remove.hook
source = https://github.com/CachyOS/CachyOS-PKGBUILDS/tree/master/systemd-boot-manager/sdboot-systemd-update.hook
sha512sums = b3f57e275eb472b0b9a1006d601cc62053e9184a7169228d0152b4df88d698f91a523153527136e0a9ad37c97296a92185acb4d2fc1875d9ce935e2fd03c9c4b
sha512sums = dbc7ca7aeb1700bf36bfd63fb0bb6c73cf18d9006493766475c09a4f31f7e88e6155b02295e6f5acdb1c611eca096a8fe2380cfd34483c53a3cf483027ada632
sha512sums = 63439b2a71571d22b0bf231732c9d4e56cb945203737d1cdc9d97f7d9f1bd6d2ef9b49fc46ab5da98f29d05e4c2fbc36183a430062d43b715602bc3e109826b8
sha512sums = 047da99a32b3cf1d9ff52ff347a0a8119f7c02a947d45c913c62d4c960d69aebcc240c1a466780bbcea08903361d8f33096d679e8aaac81d8a1f0c9fdf48f442
sha512sums = 4ff08aa5d4603d699a6d5df96bc19ef15959418b41bab62b4425e97c263f6561f8fcb7cf4b06cb2a1153e0c842cc6fb03dd2f50ff24ab2489b0f129b91febc71
sha512sums = 91fc0f00fd1e6f39d1982994e26c997e51762eeb7bdcca29f6a0d50f6b32a9717acef62f7979e9cdbd170c148579d1c1e48929b0c8153103c01310cbd05abbbc
sha512sums = ebd0c79def6f2d77b9eac63ca41460db5670220dd9ba033bd0c24017abc7f71da2250907f76cac0cc9cf10e219ef518b916aa547fafbba4715be4985cc278c50

pkgname = systemd-boot-manager
5 changes: 4 additions & 1 deletion systemd-boot-manager/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkgname=systemd-boot-manager
pkgver=10
pkgver=11
pkgrel=1
pkgdesc='A simple tool to maintain systemd-boot & systemd-boot entries for CachyOS'
arch=(any)
Expand All @@ -24,10 +24,13 @@ sha512sums=('b3f57e275eb472b0b9a1006d601cc62053e9184a7169228d0152b4df88d698f91a5
'047da99a32b3cf1d9ff52ff347a0a8119f7c02a947d45c913c62d4c960d69aebcc240c1a466780bbcea08903361d8f33096d679e8aaac81d8a1f0c9fdf48f442'
'91fc0f00fd1e6f39d1982994e26c997e51762eeb7bdcca29f6a0d50f6b32a9717acef62f7979e9cdbd170c148579d1c1e48929b0c8153103c01310cbd05abbbc'
'ebd0c79def6f2d77b9eac63ca41460db5670220dd9ba033bd0c24017abc7f71da2250907f76cac0cc9cf10e219ef518b916aa547fafbba4715be4985cc278c50')

package() {
install -D -m755 "sdboot-manage" "${pkgdir}/usr/bin/sdboot-manage"
install -D -m644 "sdboot-manage.conf" "${pkgdir}/etc/sdboot-manage.conf"
install -D -m644 "sdboot-kernel-update.hook" "${pkgdir}/usr/share/libalpm/hooks/sdboot-kernel-update.hook"
install -D -m644 "sdboot-kernel-remove.hook" "${pkgdir}/usr/share/libalpm/hooks/sdboot-kernel-remove.hook"
install -D -m644 "sdboot-systemd-update.hook" "${pkgdir}/usr/share/libalpm/hooks/sdboot-systemd-update.hook"
mkdir -m 644 "${pkgdir}/etc/sdboot-manage.conf.d/"
mkdir -m 644 "${pkgdir}/usr/lib/sdboot-manage.conf.d/"
}
16 changes: 15 additions & 1 deletion systemd-boot-manager/sdboot-manage
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ export LINUX_OPTIONS \
# Load the config file
[[ -f ${config} ]] && . "${config}"

# Sources additional config files
# #APPENDED_LINUX_OPTIONS do not overwrite each other and instead get merged to be added to the end of the kernel cmdline
# Firstly loads from /usr/lib/sdboot-manage.conf.d then /etc/sdboot-manage.conf.d
# File should be loaded alphabetically
ADDITIONAL_LINUX_OPTIONS=""
for file in /usr/lib/sdboot-manage.conf.d/*.conf /etc/sdboot-manage.conf.d/*.conf; do
#Source files if exists
[[ -f "${file}" ]] && . "${file}"
#Check if variable is non empty if so append.
[[ -n "${APPENDED_LINUX_OPTIONS}" ]] && ADDITIONAL_LINUX_OPTIONS+=" ${APPENDED_LINUX_OPTIONS}"
#Delete variable so it gets set by next source
unset APPENDED_LINUX_OPTIONS
done;

get_entry_root() {
echo -n "$ESP/loader/entries/"
}
Expand Down Expand Up @@ -205,7 +219,7 @@ generate_entries() {
# get the kernel location so the initrd can be written to the same location as the kernel
[[ $(dirname ${kernel}) == "/" ]] && kernelpath="" || kernelpath=$(dirname ${kernel})

echo -e "title\t${title}\nlinux\t${kernel}\n${initrd}initrd\t${kernelpath}$initramfs.img\noptions\t${sdoptions} ${LINUX_OPTIONS}" >"$(get_entry_root "$ESP")$entry.conf"
echo -e "title\t${title}\nlinux\t${kernel}\n${initrd}initrd\t${kernelpath}$initramfs.img\noptions\t${sdoptions} ${LINUX_OPTIONS}${ADDITIONAL_LINUX_OPTIONS}" >"$(get_entry_root "$ESP")$entry.conf"

if [[ ${DISABLE_FALLBACK} != "yes" ]]; then
echo -e "title\t${title} (Fallback)\nlinux\t${kernel}\n${initrd}initrd\t${kernelpath}$initramfs-fallback.img\noptions\t${sdoptions} ${LINUX_FALLBACK_OPTIONS}" >"$(get_entry_root "$ESP")$entry-fallback.conf"
Expand Down

0 comments on commit 2c64364

Please sign in to comment.