diff options
author | Andrew Cady <d@jerkface.net> | 2019-06-18 18:43:33 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2019-06-18 18:43:33 -0400 |
commit | 35d9a3d16fadcc96cf328ac2df0b2587c898dc14 (patch) | |
tree | c91b32a29bc8d90936e14c9b429e0a32230341e5 | |
parent | d170553513c12d75b15de7e560ed6b58e06517f7 (diff) |
initrd.sh: improve kernel package selection logic
-rwxr-xr-x | src/initrd.sh | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/initrd.sh b/src/initrd.sh index b6939b1..802e4ac 100755 --- a/src/initrd.sh +++ b/src/initrd.sh | |||
@@ -4,18 +4,17 @@ | |||
4 | 4 | ||
5 | initrd=${samizdat_linux_dir}/initrd.img | 5 | initrd=${samizdat_linux_dir}/initrd.img |
6 | vmlinuz=${samizdat_linux_dir}/vmlinuz | 6 | vmlinuz=${samizdat_linux_dir}/vmlinuz |
7 | |||
8 | # version=4.9.0-6-amd64 | ||
9 | # version=$(apt-cache policy linux-image-amd64 | sed -ne 's/ Candidate: //p' || uname -r) | ||
10 | kernel_package=linux-image-rt-amd64 | ||
11 | kernel_package_version=$(apt-cache policy $kernel_package | sed -ne 's/ *Installed: //p') | ||
12 | real_kernel_package=$(apt-cache show $kernel_package=$kernel_package_version | sed -n 's/^Depends: //p') | ||
13 | version=${real_kernel_package#linux-image-} | ||
14 | |||
15 | conf_dir=$samizdat_initramfs_conf_dir | 7 | conf_dir=$samizdat_initramfs_conf_dir |
16 | |||
17 | apt_dependencies=$samizdat_initrd_files_dir/initrd-dependencies.txt | 8 | apt_dependencies=$samizdat_initrd_files_dir/initrd-dependencies.txt |
18 | 9 | ||
10 | for kernel_package in linux-image-rt-amd64 linux-image-amd64 | ||
11 | do | ||
12 | kernel_package_version=$(apt-cache policy $kernel_package | sed -ne 's/ *Installed: //p') | ||
13 | real_kernel_package=$(apt-cache show $kernel_package=$kernel_package_version | sed -n 's/^Depends: //p') | ||
14 | version=${real_kernel_package#linux-image-} | ||
15 | [ -e "/boot/vmlinuz-${version}" ] && break | ||
16 | done | ||
17 | |||
19 | find_source_dirs() { | 18 | find_source_dirs() { |
20 | find "$conf_dir" "$samizdat_initrd_files_dir" "$@" | 19 | find "$conf_dir" "$samizdat_initrd_files_dir" "$@" |
21 | } | 20 | } |
@@ -31,8 +30,8 @@ rebuild() | |||
31 | [ ! -f "$apt_dependencies" ] || sudo apt-get install -q=10 --no-upgrade -y $(cat "$apt_dependencies") | 30 | [ ! -f "$apt_dependencies" ] || sudo apt-get install -q=10 --no-upgrade -y $(cat "$apt_dependencies") |
32 | 31 | ||
33 | set -ex | 32 | set -ex |
34 | cp -f /boot/vmlinuz-${version} "$vmlinuz" | 33 | cp -f /boot/vmlinuz-"${version}" "$vmlinuz" |
35 | /usr/sbin/mkinitramfs -d "$conf_dir" -o "$initrd" ${version} || force_rebuild | 34 | /usr/sbin/mkinitramfs -d "$conf_dir" -o "$initrd" "${version}" || force_rebuild |
36 | } | 35 | } |
37 | 36 | ||
38 | if [ ! -e "$initrd" -o ! -e "$vmlinuz" ]; then | 37 | if [ ! -e "$initrd" -o ! -e "$vmlinuz" ]; then |