Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,153 @@ widthspec.bin
/xfs_test
/xzcompress_test
/zfs_test
=======
# things ./autogen.sh will create
/Makefile.utilgcry.def
/ABOUT-NLS
/aclocal.m4
/autom4te.cache
/build-aux
/configure
/gnulib
/grub-core/lib/gnulib/
/Makefile

# things very common editors create that we never want
*~
.*.sw?
*.patch

# stuff you're likely to make while building test trees
grub.cfg
/build*/

# built objects across the whole tree
Makefile.in
*.a
*.am
*.efi
*.exec
*.image
*.img
*.info
*.lst
*.marker
/m4
*.mod
*.module
*.o
*.pf2
*.yy.[ch]
.deps/
.deps-core/
.deps-util/
.dirstamp

# next are things you get if you do ./configure in the topdir (for e.g.
# "make dist" invocation.
/config-util.h
/config.h
/include/grub/cpu
/include/grub/machine
/INSTALL
/INSTALL.grub
/po/Makefile.in.in
/po/Makevars
/po/Makevars.template
/po/POTFILES
/po/Rules-quot
/stamp-h
/stamp-h1
bootstrap.log
config.log
config.status

# stuff "make dist" creates
ChangeLog
grub-*.tar
grub-*.tar.*

# stuff "make" creates
/[[:digit:]][[:digit:]]_?*
/ascii.h
/build-grub-gen-asciih
/build-grub-gen-widthspec
/build-grub-mkfont
/config-util.h.in
/garbage-gen
/grub*-bios-setup
/grub*-bios-setup.8
/grub*-editenv
/grub*-editenv.1
/grub*-file
/grub*-file.1
/grub*-fs-tester
/grub*-fstest
/grub*-fstest.1
/grub*-get-kernel-settings
/grub*-get-kernel-settings.3
/grub*-glue-efi
/grub*-glue-efi.1
/grub*-install
/grub*-install.8
/grub*-kbdcomp
/grub*-kbdcomp.1
/grub*-macbless
/grub*-macbless.8
/grub*-menulst2cfg
/grub*-menulst2cfg.1
/grub*-mount
/grub*-mount.1
/grub*-mkconfig
/grub*-mkconfig.8
/grub*-mkconfig_lib
/grub*-mkfont
/grub*-mkfont.1
/grub*-mkimage
/grub*-mkimage.1
/grub*-mklayout
/grub*-mklayout.1
/grub*-mknetdir
/grub*-mknetdir.1
/grub*-mkpasswd-pbkdf2
/grub*-mkpasswd-pbkdf2.1
/grub*-mkrelpath
/grub*-mkrelpath.1
/grub*-mkrescue
/grub*-mkrescue.1
/grub*-mkstandalone
/grub*-mkstandalone.1
/grub*-ofpathname
/grub*-ofpathname.8
/grub*-probe
/grub*-probe.8
/grub*-reboot
/grub*-reboot.8
/grub*-render-label
/grub*-render-label.1
/grub*-script-check
/grub*-script-check.1
/grub*-set-bootflag
/grub*-set-bootflag.1
/grub*-set-default
/grub*-set-default.8
/grub*-set-password
/grub*-set-password.8
/grub*-shell
/grub*-shell-tester
/grub*-sparc64-setup
/grub*-sparc64-setup.8
/grub*-syslinux2cfg
/grub*-syslinux2cfg.1
/grub*-switch-to-blscfg
/grub*-switch-to-blscfg.8
/grub_fstest.pp
/grub_fstest_init.c
/grub_fstest_init.lst
/grub_script.tab.[ch]
/libgrub.pp
/libgrub_a_init.c
/libgrub_a_init.lst
/stamp-h.in
/widthspec.h
167 changes: 167 additions & 0 deletions 20-grub.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/bin/bash

if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
exit 0
fi

[[ -f /etc/default/grub ]] && . /etc/default/grub
[[ -f /etc/os-release ]] && . /etc/os-release

COMMAND="$1"
KERNEL_VERSION="$2"
BOOT_DIR_ABS="$3"
KERNEL_IMAGE="$4"

KERNEL_DIR="${KERNEL_IMAGE%/*}"

MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID

# If ${BOOT_DIR_ABS} exists, some other boot loader is active.
[[ -d "${BOOT_DIR_ABS}" ]] && exit 0

BLS_DIR="/boot/loader/entries"

mkbls() {
local kernelver=$1 && shift
local datetime=$1 && shift

local debugname=""
local debugid=""
local flavor=""

if [[ "$kernelver" == *\+* ]] ; then
local flavor=-"${kernelver##*+}"
if [[ "${flavor}" == "-debug" ]]; then
local debugname=" with debugging"
local debugid="-debug"
fi
fi

cat <<EOF
title ${NAME} (${kernelver}) ${VERSION}${debugname}
version ${kernelver}${debugid}
linux /vmlinuz-${kernelver}
initrd /initramfs-${kernelver}.img
options \$kernelopts
id ${ID}-${datetime}-${kernelver}
grub_users \$grub_users
grub_arg --unrestricted
grub_class kernel${flavor}
EOF
}

[[ "$KERNEL_VERSION" == *\+* ]] && flavor=-"${KERNEL_VERSION##*+}"
case "$COMMAND" in
add)
if [[ "${KERNEL_DIR}" != "/boot" ]]; then
for i in \
"$KERNEL_IMAGE" \
"$KERNEL_DIR"/System.map \
"$KERNEL_DIR"/config \
"$KERNEL_DIR"/zImage.stub \
"$KERNEL_DIR"/dtb
do
[[ -e "$i" ]] || continue
rm -f "/boot/${i##*/}-${KERNEL_VERSION}"
cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
command -v restorecon &>/dev/null && \
restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"
done
# hmac is .vmlinuz-<version>.hmac so needs a special treatment
i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
if [[ -e "$i" ]]; then
rm -f "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
command -v restorecon &>/dev/null && \
restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
fi
fi

if [[ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]] || [[ ! -f /sbin/new-kernel-pkg ]]; then
eval "$(grub2-get-kernel-settings)" || true
[[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR"
BLS_ID="${MACHINE_ID}-${KERNEL_VERSION}"
BLS_TARGET="${BLS_DIR}/${BLS_ID}.conf"
if [[ -f "${KERNEL_DIR}/bls.conf" ]]; then
cp -aT "${KERNEL_DIR}/bls.conf" "${BLS_TARGET}" || exit $?
else
mkbls "${KERNEL_VERSION}" \
"$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${KERNEL_DIR}")")" \
>"${BLS_TARGET}"
fi

LINUX="$(grep '^linux[ \t]' "${BLS_TARGET}" | sed -e 's,^linux[ \t]*,,')"
INITRD="$(grep '^initrd[ \t]' "${BLS_TARGET}" | sed -e 's,^initrd[ \t]*,,')"
LINUX_RELPATH="$(grub2-mkrelpath /boot${LINUX})"
BOOTPREFIX="$(dirname ${LINUX_RELPATH})"
ROOTPREFIX="$(dirname "/boot${LINUX}")"

if [[ $LINUX != $LINUX_RELPATH ]]; then
sed -i -e "s,^linux.*,linux ${BOOTPREFIX}${LINUX},g" "${BLS_TARGET}"
sed -i -e "s,^initrd.*,initrd ${BOOTPREFIX}${INITRD},g" "${BLS_TARGET}"
fi

if [[ "$KERNEL_VERSION" == *\+* ]] && [ "x$GRUB_DEFAULT_TO_DEBUG" != "xtrue" ]; then
GRUB_UPDATE_DEFAULT_KERNEL=false
fi

if [ "x$GRUB_UPDATE_DEFAULT_KERNEL" = "xtrue" ]; then
NEWDEFAULT="${BLS_ID}"
fi

if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
ARCH="$(uname -m)"
BLS_DEBUG_ID="$(echo ${BLS_ID} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")"
BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")"
cp -aT "${BLS_TARGET}" "${BLS_DEBUG}"
TITLE="$(grep '^title[ \t]' "${BLS_DEBUG}" | sed -e 's/^title[ \t]*//')"
sed -i -e "s/^title.*/title ${TITLE}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${BLS_DEBUG}"
sed -i -e "s/^id.*/id ${BLS_DEBUG_ID}/" "${BLS_DEBUG}"
sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${BLS_DEBUG}"
if [ -n "$NEWDEFAULT" -a "x$GRUB_DEFAULT_TO_DEBUG" = "xtrue" ]; then
NEWDEFAULT="${BLS_DEBUG_ID}"
fi
fi
if [ -n "$NEWDEFAULT" ]; then
grub2-editenv - set "saved_entry=${NEWDEFAULT}"
fi

# this probably isn't the best place to do this, but it will do for now.
if [ -e "${ROOTPREFIX}${INITRD}" -a -e "${ROOTPREFIX}${LINUX}" -a \
"${ROOTPREFIX}${INITRD}" -ot "${ROOTPREFIX}${LINUX}" -a \
-x /usr/lib/kernel/install.d/50-dracut.install ]; then
rm -f "${ROOTPREFIX}${INITRD}"
fi
exit 0
fi

/sbin/new-kernel-pkg --package "kernel${flavor}" --install "$KERNEL_VERSION" || exit $?
/sbin/new-kernel-pkg --package "kernel${flavor}" --mkinitrd --dracut --depmod --update "$KERNEL_VERSION" || exit $?
/sbin/new-kernel-pkg --package "kernel${flavor}" --rpmposttrans "$KERNEL_VERSION" || exit $?
# If grubby is used there's no need to run other installation plugins
exit 77
;;
remove)

if [[ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]] || [[ ! -f /sbin/new-kernel-pkg ]]; then
ARCH="$(uname -m)"
BLS_TARGET="${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf"
BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")"
rm -f "${BLS_TARGET}" "${BLS_DEBUG}"

for i in vmlinuz System.map config zImage.stub dtb; do
rm -rf "/boot/${i}-${KERNEL_VERSION}"
done
# hmac is .vmlinuz-<version>.hmac so needs a special treatment
rm -f "/boot/.vmlinuz-${KERNEL_VERSION}.hmac"

exit 0
fi

/sbin/new-kernel-pkg --package "kernel${flavor+-$flavor}" --rminitrd --rmmoddep --remove "$KERNEL_VERSION" || exit $?
# If grubby is used there's no need to run other installation plugins
exit 77
;;
*)
;;
esac
24 changes: 24 additions & 0 deletions 99-grub-mkconfig.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
exit 0
fi

ARCH=$(uname -m)

# Is only needed for ppc64* since we can't assume a BLS capable bootloader there
if [[ $ARCH != "ppc64" && $ARCH != "ppc64le" ]]; then
exit 0
fi

[[ -f /etc/default/grub ]] && . /etc/default/grub

COMMAND="$1"

case "$COMMAND" in
add|remove)
grub2-mkconfig --no-grubenv-update -o /boot/grub2/grub.cfg >& /dev/null
;;
*)
;;
esac
4 changes: 4 additions & 0 deletions Makefile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RPM_SPEC_FILES.dom0 := grub2.spec
RPM_SPEC_FILES := $(RPM_SPEC_FILES.$(PACKAGE_SET))

NO_ARCHIVE := 1
Loading