Created
February 4, 2021 13:27
-
-
Save corrupt/13a5a4e36b428c3c9cf2ac33110ece33 to your computer and use it in GitHub Desktop.
Revisions
-
corrupt created this gist
Feb 4, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ #!/bin/bash ## # # update-zfs.sh # # simple ZFS update script for arch linux # # will update zfs-linux and zfs-utils to their latest versions in the arch-zfs repo # will retrieve mathching kernel packages from the arch linux package archive, even # if newer are avaiable, if packages in arch-zfs haven't been updated yet # # author: corrupt # license: as-is # date: 2021-02-04 # version: 0.1 # ## #set -x # dependencies PACMAN="/usr/bin/pacman" GREP="/usr/bin/grep" CUT="/usr/bin/cut" DATE="/usr/bin/date" XARGS="/usr/bin/xargs" WGET="/usr/bin/wget" # dependency check DEPS=( $PACMAN $GREP $CUT $DATE $XARGS $WGET ) for dep in ${DEPS[@]}; do if [ ! -f ${dep} ]; then echo "This script depens on ${dep}. Either install it, or adapt its path in ${0} before continuing" exit 1 fi done # variable construction PKG_SUFX="-x86_64.pkg.tar.zst" PKG_DIR="/var/cache/pacman/pkg/" ZFS_DATE=$(${PACMAN} -Si zfs-linux | ${GREP} "Build Date" | ${CUT} -d: -f2) URL_DATE=$(${DATE} --date="${ZFS_DATE}" +%Y/%m/%d) URL_PREF="https://archive.archlinux.org/repos/${URL_DATE}/core/os/x86_64/" # version extraction ZFS_VER=$(${PACMAN} -Si zfs-linux | ${GREP} "Version" | ${CUT} -d: -f2 | ${XARGS}) ZUT_VER=$(${PACMAN} -Si zfs-utils | ${GREP} "Version" | ${CUT} -d: -f2 | ${XARGS}) ZFS_KVER=$(${PACMAN} -Si zfs-linux | ${GREP} "Depends On" | ${GREP} -o "linux=\S*" | ${CUT} -d= -f2 | ${XARGS}) # package name construction KERNEL_PKG="linux-${ZFS_KVER}${PKG_SUFX}" HEADER_PKG="linux-headers-${ZFS_KVER}${PKG_SUFX}" ZFS_PKG="zfs-linux-${ZFS_VER}${PKG_SUFX}" ZUT_PKG="zfs-utils-${ZUT_VER}${PKG_SUFX}" # retrieve matching kernel packages ${WGET} -cP ${PKG_DIR} ${URL_PREF}${KERNEL_PKG} ${WGET} -cP ${PKG_DIR} ${URL_PREF}${KERNEL_PKG}.sig ${WGET} -cP ${PKG_DIR} ${URL_PREF}${HEADER_PKG} ${WGET} -cP ${PKG_DIR} ${URL_PREF}${HEADER_PKG}.sig # retrieve zfs and zfs-utils from repo ${PACMAN} --noconfirm -Sdw zfs-linux zfs-utils # install all packages with regular user interaction (pacman -U checks signatures) ${PACMAN} -U ${PKG_DIR}${KERNEL_PKG} ${PKG_DIR}${HEADER_PKG} ${PKG_DIR}${ZFS_PKG} ${PKG_DIR}${ZUT_PKG} #vim: ft=bash