Skip to content

Commit

Permalink
99-write-log: also write state file
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed Aug 3, 2024
1 parent b9f7ab5 commit f59ff60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
18 changes: 11 additions & 7 deletions hooks/99-write-log.install
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ main() {
[[ ! -f ${initrd} ]] && initrd=unknown
[[ ! -f ${kernel} ]] && kernel=unknown

local log=/var/log/installkernel.log

einfo "Appending installed kernel to ${log}..."

INSTALLKERNEL_PLUGINS="${INSTALLKERNEL_PREINST_PLUGINS:+${INSTALLKERNEL_PREINST_PLUGINS} }${INSTALLKERNEL_POSTINST_PLUGINS}"

if [[ -z ${INSTALLKERNEL_CONF_ROOT} ]]; then
Expand All @@ -82,7 +78,13 @@ main() {
fi
fi

echo -e \
local state=/var/lib/installkernel
local log=/var/log/installkernel.log

einfo "Appending installed kernel to ${log}..."


local logline=\
"$(LC_ALL=C date)\t"\
"gentoo\t"\
"${ver:-notset}\t"\
Expand All @@ -93,8 +95,10 @@ main() {
"${install_dir:-notset}\t"\
"${kernel#"${install_dir}/"}\t"\
"${initrd#"${install_dir}/"}\t"\
"${INSTALLKERNEL_PLUGINS:-notset}\t"\
>> "${log}" || exit 1
"${INSTALLKERNEL_PLUGINS:-notset}"

echo -e "${logline}" > "${state}" || exit 1
echo -e "${logline}" >> "${log}" || exit 1
}

main
17 changes: 9 additions & 8 deletions hooks/systemd/99-write-log.install
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ fi
[[ ! -f ${INITRD} ]] && INITRD=unknown
[[ ! -f ${KERNEL} ]] && KERNEL=unknown

LOG=/var/log/installkernel.log

[[ ${KERNEL_INSTALL_VERBOSE} == 1 ]] && echo "Appending installed kernel to ${LOG}..."

if [[ -z ${KERNEL_INSTALL_CONF_ROOT} ]]; then
if [[ -f /etc/kernel/install.conf ]]; then
KERNEL_INSTALL_CONF_ROOT=/etc/kernel
Expand All @@ -68,7 +64,12 @@ if [[ -z ${KERNEL_INSTALL_CONF_ROOT} ]]; then
fi
fi

echo -e \
STATE=/var/lib/installkernel
LOG=/var/log/installkernel.log

[[ ${KERNEL_INSTALL_VERBOSE} == 1 ]] && echo "Appending installed kernel to ${LOG}..."

LOGLINE=\
"$(LC_ALL=C date)\t"\
"systemd\t"\
"${KERNEL_VERSION:-notset}\t"\
Expand All @@ -79,7 +80,7 @@ echo -e \
"${KERNEL_INSTALL_BOOT_ROOT:-notset}\t"\
"${KERNEL#"${KERNEL_INSTALL_BOOT_ROOT}/"}\t"\
"${INITRD#"${KERNEL_INSTALL_BOOT_ROOT}/"}\t"\
"${KERNEL_INSTALL_PLUGINS:-notset}\t"\
>> "${LOG}" || exit 1

"${KERNEL_INSTALL_PLUGINS:-notset}"

echo -e "${LOGLINE}" > "${STATE}" || exit 1
echo -e "${LOGLINE}" >> "${LOG}" || exit 1

0 comments on commit f59ff60

Please sign in to comment.