kernel-install: do not add kernel entry if already present

The entry may be already present for example when reinstalling package,
or calling the script multiple times (which apparently is the case
during system installation).

(cherry picked from commit 4d4e7cc5e9)
release3.1
Marek Marczykowski-Górecki 8 years ago
parent c3cfafd265
commit 7c8f2c3d6d
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

@ -15,48 +15,50 @@ fi
case "$COMMAND" in case "$COMMAND" in
add) add)
# take the default section and use it as a template for the new entry if ! fgrep -q "[${KVER}]" $EFI_DIR/xen.cfg; then
awk -F = --assign "kver=${KVER}" ' # take the default section and use it as a template for the new entry
/^\[/ { awk -F = --assign "kver=${KVER}" '
# section header - previous section (if any) ended /^\[/ {
# section header - previous section (if any) ended
# if default section already processed, that is all # if default section already processed, that is all
if (in_default) exit; if (in_default) exit;
in_global=0; in_global=0;
in_default=0; in_default=0;
} }
/\[global\]/ { /\[global\]/ {
in_global=1; in_global=1;
}
/^\[/ {
if ("[" default_name "]" == $0) {
in_default=1;
print "[" kver "]";
next;
} }
} /^\[/ {
/^default=/ { if ("[" default_name "]" == $0) {
if (in_global) in_default=1;
default_name=$2; print "[" kver "]";
} next;
/^kernel=/ { }
if (in_default) {
sub("=[^ ]*", "=vmlinuz-" kver);
} }
} /^default=/ {
/^ramdisk=/ { if (in_global)
if (in_default) { default_name=$2;
sub("=[^ ]*", "=initramfs-" kver ".img");
} }
} /^kernel=/ {
{ if (in_default) {
if (in_default) { sub("=[^ ]*", "=vmlinuz-" kver);
print; }
} }
}' $EFI_DIR/xen.cfg >> $EFI_DIR/xen.cfg /^ramdisk=/ {
if (in_default) {
# then change the default sub("=[^ ]*", "=initramfs-" kver ".img");
sed -e "s/default=.*/default=$KVER/" -i $EFI_DIR/xen.cfg }
}
{
if (in_default) {
print;
}
}' $EFI_DIR/xen.cfg >> $EFI_DIR/xen.cfg
# then change the default
sed -e "s/default=.*/default=$KVER/" -i $EFI_DIR/xen.cfg
fi
cp "/boot/vmlinuz-$KVER" "$EFI_DIR/" cp "/boot/vmlinuz-$KVER" "$EFI_DIR/"
dracut -f "$EFI_DIR/initramfs-${KVER}.img" "$KVER" dracut -f "$EFI_DIR/initramfs-${KVER}.img" "$KVER"

Loading…
Cancel
Save