Skip to content

Instantly share code, notes, and snippets.

@Vincinator
Created February 19, 2025 10:50
Show Gist options
  • Save Vincinator/af8095c455dc504c20f48408c3fc18df to your computer and use it in GitHub Desktop.
Save Vincinator/af8095c455dc504c20f48408c3fc18df to your computer and use it in GitHub Desktop.
Extract download URL of kernel package for a given Garden Linux version + architecture
#!/bin/bash
arch=
version=
while [[ $# -gt 0 ]]; do
case "$1" in
--arch)
arch="$2"
shift 2
;;
--version)
version="$2"
shift 2
;;
*)
echo "Usage: $0 --arch <arch> --version <version>"
exit 1
;;
esac
done
if [[ -z "$arch" || -z "$version" ]]; then
echo "Error: Both --arch and --version are required."
echo "Usage: $0 --arch <arch> --version <version>"
exit 1
fi
call_dir=$pwd
tmpdir=$(mktemp -d)
cd $tmpdir
trap 'cd $call_dir && rm -rf "$tmpdir"' EXIT
# Note: silently fails if URl does not exist. gunzip will complain about stdin not in gzip format
curl -s https://packages.gardenlinux.io/gardenlinux/dists/$version/main/binary-$arch/Packages.gz | gunzip > Packages
# Meta Package linux-image-$arch is only there to depend on the respective linux-image-<version>-<arch>, so user can just install linux-image-<arch> and gets the respective kernel version installed.
#
kernel_version=$(cat Packages | sed -n "/^Package: linux-image-${arch}$/,/^$/p" | grep "Depends:" | cut -d : -f 2 | cut -d' ' -f 2)
# Construct download Link of linux-image-<version>-<arch> packages.
pool_url=$(sed -n "/^Package: ${kernel_version}$/,/^$/p" Packages | grep "^Filename:" | cut -d : -f 2 | sed 's/^ *//' | sed 's|^|https://packages.gardenlinux.io/gardenlinux/|' )
echo $pool_url
@Vincinator
Copy link
Author

example:

./get_kernel_download_url.sh --arch arm64 --version 1592.6 

https://packages.gardenlinux.io/gardenlinux/pool/2f1f996fa24923806f9b47725baa4ab780e09530d8c1bfc48e83fd1310dd43ea/linux-image-6.6.78-arm64_6.6.78-0gl0~bp1592_arm64.deb

@Vincinator
Copy link
Author

Vincinator commented Feb 19, 2025

to inspect content you could do stuff like this

 ./get_kernel_download_url.sh --arch arm64 --version 1592.6 | xargs curl  --output kernel.deb

The kernel.deb can be extracted with ar x kernel.deb, and inside you will find a data.tar.xz, which should contain the kernel config for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment