Skip to content

Commit

Permalink
kernels: Fix to update the (/boot/photon.cfg) symlink to available ke…
Browse files Browse the repository at this point in the history
…rnel if current kernel is removed.

Linux generic kernel is the default kernel provided to all the appliances
from photon. Studio provides an option for the applicances to include
its own specific set of packages to be installed apart from this default
list. Installer combines the default packages list provided by photon and the
appliance specific package list provided from studio.

Some appliances want linux-esx kernel instead of generic kernel.
In those cases, appliances add linux-esx in their packages list and remove
linux generic kernel as part of studio post install script. so the combined
list contains both linux and linux-esx and the order in which this gets installed
is derived by tdnf using the dependenices.

Based on this dependency list, Linux-esx is installed before linux and when studio
post install script removes linux, the symbolic link (/boot/photon.cfg) is removed
since linux was installed later.

Fix is to parse the /boot folder to find the installed kernels and update the symlink
(/boot/photon.cfg) to any other installed kernel if the current running kernel is removed.
Postun section parses the /boot folder and find the linux-*.cfg files and update the
symlink to this config.

Testing: Installed multiple linux versions and flavors one after the other and uninstalled

Change-Id: I9887402c19654070d625cf45d9359d02bc6b923a
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/7094
Tested-by: gerrit-photon <[email protected]>
Reviewed-by: Alexey Makhalov <[email protected]>
Reviewed-by: Srivatsa S. Bhat <[email protected]>
(cherry picked from commit ddba1e0)
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/7251
  • Loading branch information
keerthanakalyan authored and Srivatsa S. Bhat committed May 28, 2019
1 parent 992fed7 commit 8687026
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
8 changes: 7 additions & 1 deletion SPECS/linux/linux-aws.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Summary: Kernel
Name: linux-aws
Version: 4.19.40
Release: 1%{?kat_build:.%kat_build}%{?dist}
Release: 2%{?kat_build:.%kat_build}%{?dist}
License: GPLv2
URL: http://www.kernel.org/
Group: System Environment/Kernel
Expand All @@ -12,6 +12,7 @@ Source0: http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar
%define sha1 linux=c04181c3736e5b85d349f9b58d406d4c18ad4958
Source1: config-aws
Source2: initramfs.trigger
Source3: update_photon_cfg.postun
# common
Patch0: linux-4.14-Log-kmsg-dump-on-panic.patch
Patch1: double-tcp_mem-limits.patch
Expand Down Expand Up @@ -83,6 +84,7 @@ BuildRequires: procps-ng-devel
BuildRequires: audit-devel
Requires: filesystem kmod
Requires(post):(coreutils or toybox)
Requires(postun):(coreutils or toybox)
%define uname_r %{version}-%{release}-aws

%description
Expand Down Expand Up @@ -286,6 +288,7 @@ find %{buildroot}/lib/modules -name '*.ko' -print0 | xargs -0 chmod u+x
make -C tools JOBS=1 DESTDIR=%{buildroot} prefix=%{_prefix} perf_install

%include %{SOURCE2}
%include %{SOURCE3}

%post
/sbin/depmod -aq %{uname_r}
Expand Down Expand Up @@ -357,6 +360,9 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
%{_libdir}/perf/include/bpf/*

%changelog
* Tue May 14 2019 Keerthana K <[email protected]> 4.19.40-2
- Fix to parse through /boot folder and update symlink (/boot/photon.cfg) if
- mulitple kernels are installed and current linux kernel is removed.
* Tue May 07 2019 Ajay Kaher <[email protected]> 4.19.40-1
- Update to version 4.19.40
* Fri Mar 29 2019 Srivatsa S. Bhat (VMware) <[email protected]> 4.19.32-2
Expand Down
8 changes: 7 additions & 1 deletion SPECS/linux/linux-esx.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Summary: Kernel
Name: linux-esx
Version: 4.19.40
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2
URL: http://www.kernel.org/
Group: System Environment/Kernel
Expand All @@ -12,6 +12,7 @@ Source0: http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar
%define sha1 linux=c04181c3736e5b85d349f9b58d406d4c18ad4958
Source1: config-esx
Source2: initramfs.trigger
Source3: update_photon_cfg.postun
# common
Patch0: linux-4.14-Log-kmsg-dump-on-panic.patch
Patch1: double-tcp_mem-limits.patch
Expand Down Expand Up @@ -55,6 +56,7 @@ BuildRequires: openssl-devel
BuildRequires: procps-ng-devel
Requires: filesystem kmod
Requires(post):(coreutils or toybox)
Requires(postun):(coreutils or toybox)
%define uname_r %{version}-%{release}-esx

%description
Expand Down Expand Up @@ -168,6 +170,7 @@ ln -sf /usr/src/linux-headers-%{uname_r} %{buildroot}/lib/modules/%{uname_r}/bui
find %{buildroot}/lib/modules -name '*.ko' -print0 | xargs -0 chmod u+x

%include %{SOURCE2}
%include %{SOURCE3}

%post
/sbin/depmod -a %{uname_r}
Expand All @@ -194,6 +197,9 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
/usr/src/linux-headers-%{uname_r}

%changelog
* Tue May 14 2019 Keerthana K <[email protected]> 4.19.40-2
- Fix to parse through /boot folder and update symlink (/boot/photon.cfg) if
- mulitple kernels are installed and current linux kernel is removed.
* Tue May 07 2019 Ajay Kaher <[email protected]> 4.19.40-1
- Update to version 4.19.40
* Fri May 03 2019 Ajay Kaher <[email protected]> 4.19.32-3
Expand Down
8 changes: 7 additions & 1 deletion SPECS/linux/linux-secure.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Summary: Kernel
Name: linux-secure
Version: 4.19.40
Release: 1%{?kat_build:.%kat_build}%{?dist}
Release: 2%{?kat_build:.%kat_build}%{?dist}
License: GPLv2
URL: http://www.kernel.org/
Group: System Environment/Kernel
Expand All @@ -12,6 +12,7 @@ Source0: http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{version}.tar
%define sha1 linux=c04181c3736e5b85d349f9b58d406d4c18ad4958
Source1: config-secure
Source2: initramfs.trigger
Source3: update_photon_cfg.postun
# common
Patch0: linux-4.14-Log-kmsg-dump-on-panic.patch
Patch1: double-tcp_mem-limits.patch
Expand Down Expand Up @@ -60,6 +61,7 @@ BuildRequires: openssl-devel
BuildRequires: procps-ng-devel
Requires: filesystem kmod
Requires(post):(coreutils or toybox)
Requires(postun):(coreutils or toybox)
%define uname_r %{version}-%{release}-secure

%description
Expand Down Expand Up @@ -202,6 +204,7 @@ ln -sf /usr/src/linux-headers-%{uname_r} %{buildroot}/lib/modules/%{uname_r}/bui


%include %{SOURCE2}
%include %{SOURCE3}

%post
/sbin/depmod -a %{uname_r}
Expand Down Expand Up @@ -236,6 +239,9 @@ ln -sf linux-%{uname_r}.cfg /boot/photon.cfg
/usr/src/linux-headers-%{uname_r}

%changelog
* Tue May 14 2019 Keerthana K <[email protected]> 4.19.40-2
- Fix to parse through /boot folder and update symlink (/boot/photon.cfg) if
- mulitple kernels are installed and current linux kernel is removed.
* Tue May 07 2019 Ajay Kaher <[email protected]> 4.19.40-1
- Update to version 4.19.40
* Fri Mar 29 2019 Srivatsa S. Bhat (VMware) <[email protected]> 4.19.32-2
Expand Down
8 changes: 7 additions & 1 deletion SPECS/linux/linux.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Summary: Kernel
Name: linux
Version: 4.19.40
Release: 1%{?kat_build:.%kat_build}%{?dist}
Release: 2%{?kat_build:.%kat_build}%{?dist}
License: GPLv2
URL: http://www.kernel.org/
Group: System Environment/Kernel
Expand All @@ -18,6 +18,7 @@ Source3: https://github.com/amzn/amzn-drivers/archive/ena_linux_%{ena_version}.t
Source4: config_aarch64
Source5: xr_usb_serial_common_lnx-3.6-and-newer-pak.tar.xz
%define sha1 xr=74df7143a86dd1519fa0ccf5276ed2225665a9db
Source6: update_photon_cfg.postun
# common
Patch0: linux-4.14-Log-kmsg-dump-on-panic.patch
Patch1: double-tcp_mem-limits.patch
Expand Down Expand Up @@ -89,6 +90,7 @@ BuildRequires: procps-ng-devel
BuildRequires: audit-devel
Requires: filesystem kmod
Requires(post):(coreutils or toybox)
Requires(postun):(coreutils or toybox)
%define uname_r %{version}-%{release}

%description
Expand Down Expand Up @@ -354,6 +356,7 @@ cp arch/arm64/kernel/module.lds %{buildroot}/usr/src/%{name}-headers-%{uname_r}/
make -C tools JOBS=1 DESTDIR=%{buildroot} prefix=%{_prefix} perf_install

%include %{SOURCE2}
%include %{SOURCE6}

%post
/sbin/depmod -a %{uname_r}
Expand Down Expand Up @@ -439,6 +442,9 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
%endif

%changelog
* Tue May 14 2019 Keerthana K <[email protected]> 4.19.40-2
- Fix to parse through /boot folder and update symlink (/boot/photon.cfg) if
- mulitple kernels are installed and current linux kernel is removed.
* Tue May 07 2019 Ajay Kaher <[email protected]> 4.19.40-1
- Update to version 4.19.40
* Thu Apr 11 2019 Srivatsa S. Bhat (VMware) <[email protected]> 4.19.32-3
Expand Down
9 changes: 9 additions & 0 deletions SPECS/linux/update_photon_cfg.postun
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%postun
if [ ! -e /boot/photon.cfg ]
then
if [ `ls /boot/linux-*.cfg 1> /dev/null 2>&1` ]
then
list=`ls -tu /boot/linux-*.cfg | head -n1`
test -n "$list" && ln -sf "$list" /boot/photon.cfg
fi
fi

0 comments on commit 8687026

Please sign in to comment.