Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to keep track if archzfs and upstream kernel are in sync to know when to update #393

Open
markusressel opened this issue Apr 15, 2021 · 7 comments

Comments

@markusressel
Copy link

Hey there, really awesome project!

Like probably every single user that uses this repo with the zfs-linux packe I tend to run into the "upstream kernel is newer than the archzfs package" situation. This not so much of an issue, I can live with that. However, sometimes I even run into this issue multiple times in a row, with newer versions, because of sheer (un)luck, and I have to wait again 😆

Is there an easy way to look up whether the current archzfs package is in sync with the latest upstream kernel version?

Maybe by comparing official arch repo website with the CI server website for this repo?
Maybe in a way that is possible via some minimal script using pacman?

I would really like to add a simple, automated "upgrade nao!" indicator to my taskbar, so I don't have start a system upgrade to see if it would work.

Thx!

@markusressel
Copy link
Author

markusressel commented May 12, 2021

Ok so I have played around a bit and came up with a little script that compares the official arch website with the archzfs repo. Since release packages not only contain the zfs version, but also the kernel version they are built for, this should work reasonably well.

However, when using this, keep in mind that executing this script too often can ddos the repositories, so please only use with a reasonable, random delay like 12 hours + <random of 0-120 minutes>.

#!/bin/bash

arch=x86_64
package_name=zfs-linux

# check latest kernel version in official arch repos
arch_repo_version=$(curl -s https://archlinux.org/packages/core/$arch/linux/ | grep "<h2>" | grep -oiE "[[:digit:]\.]+arch[[:digit:]-]+" | tr - .)
[ $? -ne 0 ] && echo "no" && exit 1

# check latest supported kernel version by archzfs package
archzfs_version=$(curl -s https://archzfs.com/archzfs/$arch/ | grep -oiE "$package_name-[[:digit:]][0-9\.\_arch]+-" | head -1 | grep -oP "(?<=_)[0-9\.\-arch]+(?=\-)")
[ $? -ne 0 ] && echo "no" && exit 1

# compare versions and print result
if [ "$arch_repo_version" = "$archzfs_version" ]; then
    echo "yes"
else
    echo "no"
fi

@fryfrog
Copy link

fryfrog commented Jul 2, 2021

My "trick" is to just put the following in /etc/pacman.conf and use zfs-dkms. That way, when a zfs update or a kernel update come down the pipes, I can just decide when it is time to do it.

IgnorePkg   = linux linux-docs linux-headers linux-lts linux-lts-docs linux-lts-headers zfs-dkms zfs-utils

@yoo
Copy link

yoo commented May 29, 2022

Here is another solution. This script grabs the version of the linux kernel from the zfs-linux package and downloads the matching version from the Arch Linux Archive.

Add IgnorePkg = linux linux-headers to /etc/pacman.conf.

#!/bin/bash
set -eo pipefail

PKG_CACHE="/var/cache/pacman/pkg/"

pacman --sync --refresh

# grep the kenrel version from the zfs-linux dependencies
KERNEL_VERSION="$(expac -S '%D' zfs-linux | grep -oP 'linux=\K.+')"

KERNEL_PKG="linux-${KERNEL_VERSION}-x86_64.pkg.tar.zst"
KERNEL_HEADERS_PKG="linux-headers-${KERNEL_VERSION}-x86_64.pkg.tar.zst"

KERNEL_PKG_FILE="${PKG_CACHE}/${KERNEL_PKG}"
KERNEL_HEADERS_PKG_FILE="${PKG_CACHE}/${KERNEL_HEADERS_PKG}"

KERNEL_URL="https://archive.archlinux.org/packages/l/linux/${KERNEL_PKG}"
KERNEL_HEADERS_URL="https://archive.archlinux.org/packages/l/linux-headers/${KERNEL_HEADERS_PKG}"


[[ -f "${KERNEL_PKG_FILE}" ]] || {
    curl --output "$KERNEL_PKG_FILE" "${KERNEL_URL}"
}

[[ -f "${KERNEL_HEADERS_PKG_FILE}" ]] || {
    curl --output "${KERNEL_HEADERS_PKG_FILE}" "${KERNEL_HEADERS_URL}"
}

pacman --needed --noconfirm --upgrade "${KERNEL_PKG_FILE}" "${KERNEL_HEADERS_PKG_FILE}"
pacman --sync --noconfirm --needed zfs-linux

@Soulsuke
Copy link

Soulsuke commented Jun 5, 2022

If it can help anyhow, I've ended up building a script to check which kernel package is needed by the latest zfs package and download/serve it via a custom repository: https://github.com/Soulsuke/zfs-kernels

You can either use it to serve a local repository or put it on a vm with a cronjob (although it shouldn't be run too often).

@hikkidev
Copy link

hikkidev commented Apr 4, 2023

Requires: checkupdates

Preparation

/etc/pacman.conf

  • Add all packages directly related to the kernel version to IgnorePkg (On my system there are not many. P.S., dependencies chain can be found through pacman -Qi linux-zen -> Required By:)
  • Set the archzfs repo first in the order
IgnorePkg   = linux-zen linux-zen-headers zfs-linux-zen zfs-utils

...
# REPOSITORIES
#   - can be defined here or included from another file
#   - pacman will search repositories in the order defined here

[archzfs]
Include = /etc/pacman.d/mirrorlist-archzfs

Simple update script
~/.local/bin/upgrade.sh

#!/bin/sh

if [ $(id -u) != 0 ]; then
   exec sudo "$0" "$@"
fi

echo 'A system upgrade starts.'
echo 'Check for pending updates...'
echo ''

if [ "$1" == "skip-kernel" ]; then
   eval 'sed -ie "s/^#IgnorePkg/IgnorePkg/g" /etc/pacman.conf'
else
   eval 'sed -ie "s/^IgnorePkg/#IgnorePkg/g" /etc/pacman.conf'
fi

upd_res=$(checkupdates)
rv=$?
case $rv in
   0) echo "$upd_res" ;;
   1) echo "Unknown cause of failure."; exit ;;
   2) echo "No updates are available."; exit ;;
esac

str_zfs='zfs-linux-zen'
str_zfs_lts='zfs-linux-lts'

if [[ $upd_res == *"$str_kernel"* ]]; then
  echo ' '
  if [[ $upd_res == *"$str_zfs"* ]]; then
    echo "ZEN Kernel and ZFS module update available."
  else
    echo "ZEN Kernel update available, but not the ZFS module."
    eval 'sed -ie "s/^#IgnorePkg/IgnorePkg/g" /etc/pacman.conf'
    exit -1
  fi
fi

while true; do
    read -p "Do you wish to upgrade process? " yn
    case $yn in
        [Yy]* ) break;;
        [Nn]* ) eval 'sed -ie "s/^#IgnorePkg/IgnorePkg/g" /etc/pacman.conf'; exit;;
        * ) echo "Please answer yes or no.";;
    esac
done

snap_name=$(date +%Y%m%d)_$(uname -r)
eval "zfs snapshot -r <SOME_POOL>@${snap_name}_sys-upgrade"
eval 'pacman -Syu && sed -ie "s/^#IgnorePkg/IgnorePkg/g" /etc/pacman.conf'

Someday I'll improve it to parsing issues related to the kernel ))

@stevleibelt
Copy link

I am pretty straight forward. When I do an system update, I give it a try with the default pacman -Syyu and on error, try it again but with ignored packages.
Only the silently failing zfs-dkms build is an issue I have to learn to deal with.

Cheers,
Stev

@aedalzotto
Copy link

The dependencies solution works fine when adding linux (linux-zen in my specific case) to IgnorePkg.
When zfs-linux (or zfs-linux-zen) updates, it automatically syncs the kernel version.

I am having a problem with linux-headers. This package is not automatically updated along with linux or zfs-linux. Maybe a solution is to add linux-headers as a dependency of zfs-linux-headers?
This causes other dkms packages to fail to build and require manual intervention every time zfs-linux updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants