summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch-linux-rolling/.gitignore5
-rw-r--r--arch-linux-rolling/91-extramodules-version.hook11
-rw-r--r--arch-linux-rolling/91-grub.hook11
-rw-r--r--arch-linux-rolling/PKGBUILD95
-rw-r--r--arch-linux-rolling/README.md18
-rwxr-xr-xarch-linux-rolling/clean-old-kernels35
-rw-r--r--arch-linux-rolling/linux-transitional.install27
-rw-r--r--arch-linux-rolling/misc/yaourt.fish32
-rwxr-xr-xarch-linux-rolling/relink-extramodules-version46
-rw-r--r--arch-linux-rolling/rolling.conf8
-rwxr-xr-xarch-linux-rolling/update-grub24
11 files changed, 312 insertions, 0 deletions
diff --git a/arch-linux-rolling/.gitignore b/arch-linux-rolling/.gitignore
new file mode 100644
index 000000000..f3ca38577
--- /dev/null
+++ b/arch-linux-rolling/.gitignore
@@ -0,0 +1,5 @@
+*.tar*
+*.swp
+pkg
+src
+linux.install.pkg
diff --git a/arch-linux-rolling/91-extramodules-version.hook b/arch-linux-rolling/91-extramodules-version.hook
new file mode 100644
index 000000000..b19904dcc
--- /dev/null
+++ b/arch-linux-rolling/91-extramodules-version.hook
@@ -0,0 +1,11 @@
+[Trigger]
+Type = File
+Operation = Remove
+Target = usr/lib/modules/extramodules-*-ARCH/version*
+
+[Action]
+Description = Symlink rolling kernel version to extramodules
+When = PostTransaction
+Depends = bash
+Exec = /usr/lib/linux-rolling/relink-extramodules-version
+NeedsTargets
diff --git a/arch-linux-rolling/91-grub.hook b/arch-linux-rolling/91-grub.hook
new file mode 100644
index 000000000..896065876
--- /dev/null
+++ b/arch-linux-rolling/91-grub.hook
@@ -0,0 +1,11 @@
+[Trigger]
+Type = File
+Operation = Install
+Operation = Remove
+Operation = Upgrade
+Target = boot/vmlinuz-linux*
+
+[Action]
+Description = Updating grub config
+When = PostTransaction
+Exec = /usr/lib/linux-rolling/update-grub
diff --git a/arch-linux-rolling/PKGBUILD b/arch-linux-rolling/PKGBUILD
new file mode 100644
index 000000000..e365a1503
--- /dev/null
+++ b/arch-linux-rolling/PKGBUILD
@@ -0,0 +1,95 @@
+# Maintainer: Versus Void <chaoskeeper@mail.ru>
+
+_source_package=$(curl -s https://www.archlinux.org/packages/core/$CARCH/linux/download/ --write-out '%{redirect_url}')
+if [ ! "$_source_package" ]; then
+ echo "Can't find current kernel package"
+ return 1
+fi
+
+_full_version=${_source_package##*linux-}
+_full_version=${_full_version%%-$CARCH.pkg.tar*}
+pkgver=${_full_version%-*}
+pkgrel=${_full_version##*-}
+_kernel_version=${pkgver%.*}
+
+pkgname=('linux-rolling' "linux-rolling_${_full_version//[.-]/_}")
+pkgdesc="Arch's kernel how it meant to be"
+arch=('i686' 'x86_64')
+url="https://bugs.archlinux.org/task/16702"
+license=('GPL2')
+replaces=()
+options=('!strip')
+source=(
+ $_source_package{,.sig}
+ "rolling.conf"
+ "clean-old-kernels"
+ "91-extramodules-version.hook"
+ "relink-extramodules-version"
+ "91-grub.hook"
+ "update-grub"
+)
+sha256sums=(
+ "SKIP" "SKIP"
+ "fa56a9d520046462a29ff5c52af2f40026a9c6537cf212b8bb2f1f41ee0838fd"
+ "eb087e424d1309edeb0ca9e367d7220dbc309f768aac9d2e3de495a3ad04fb6c"
+ "7f11c0e3a11c0088789676c0398d15c6a71dc7094c78e4093bd72e8421fbcb84"
+ "dc9912bce065140f5a955795e10490c15b42a95dcf92b5c208fe76f7ac488a0e"
+ "bb519b71092079a66498f22ef89feb6d41393d61688896ebe0226f979ed6655e"
+ "6a4f3779e07cfbba36fd25fb4853292e4559ca96a750121836c8bedb7e1132bc"
+)
+validpgpkeys=('5B7E3FB71B7F10329A1C03AB771DF6627EDF681F') # Tobias Powalowski <tobias.powalowski@googlemail.com>
+
+package_linux-rolling() {
+ arch=('any')
+ depends=("linux-rolling_${_full_version//[.-]/_}=$_full_version" "bash")
+ install=linux-transitional.install
+
+ install -Dm644 91-grub.hook "$pkgdir/usr/share/libalpm/hooks/91-grub.hook"
+ install -Dm644 91-extramodules-version.hook "$pkgdir/usr/share/libalpm/hooks/91-extramodules-version.hook"
+ install -Dm644 rolling.conf "$pkgdir/etc/rolling.conf"
+ install -Dm755 clean-old-kernels "$pkgdir/usr/bin/clean-old-kernels"
+ install -Dm755 relink-extramodules-version "$pkgdir/usr/lib/linux-rolling/relink-extramodules-version"
+ install -Dm755 update-grub "$pkgdir/usr/lib/linux-rolling/update-grub"
+}
+
+_package_linux-rolling() {
+ pkgdesc="The Linux kernel and modules"
+ backup=("etc/mkinitcpio.d/linux-$pkgver-$pkgrel.preset")
+ depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
+ optdepends=('crda: to set the correct wireless channels of your country')
+ provides=("linux=$pkgver-$pkgrel")
+ conflicts=("linux=$pkgver-$pkgrel")
+ sed "{
+ s#boot/initramfs-linux.img#boot/initramfs-linux-$pkgver-$pkgrel.img#g;
+ s#boot/initramfs-linux-fallback.img#boot/initramfs-linux-$pkgver-$pkgrel-fallback.img#g;
+ }" .INSTALL > ${startdir}/linux.install.pkg
+ true && install=linux.install.pkg
+
+ mkdir -p "$pkgdir/boot"
+ mv boot/vmlinuz-linux "$pkgdir/boot/vmlinuz-linux-$pkgver-$pkgrel"
+
+ sed -i "{
+ s#/boot/vmlinuz-linux#/boot/vmlinuz-linux-$pkgver-$pkgrel#g;
+ s#/boot/initramfs-linux.img#/boot/initramfs-linux-$pkgver-$pkgrel.img#g;
+ s#/boot/initramfs-linux-fallback.img#/boot/initramfs-linux-$pkgver-$pkgrel-fallback.img#g;
+ }" etc/mkinitcpio.d/linux.preset
+ mkdir -p "$pkgdir/etc/mkinitcpio.d"
+ mv etc/mkinitcpio.d/linux.preset "$pkgdir/etc/mkinitcpio.d/linux-$pkgver-$pkgrel.preset"
+
+ sed -i "{
+ s#boot/vmlinuz-linux#boot/vmlinuz-linux-$pkgver-$pkgrel#g;
+ s#mkinitcpio -p linux#mkinitcpio -p linux-$pkgver-$pkgrel#g;
+ }" usr/share/libalpm/hooks/90-linux.hook
+ mkdir -p "$pkgdir/usr/share/libalpm/hooks"
+ mv usr/share/libalpm/hooks/90-linux.hook "$pkgdir/usr/share/libalpm/hooks/90-linux-$pkgver-$pkgrel.hook"
+
+ mv usr/lib "$pkgdir/usr/"
+
+ mv "$pkgdir/usr/lib/modules/extramodules-$_kernel_version-ARCH/version" \
+ "$pkgdir/usr/lib/modules/extramodules-$_kernel_version-ARCH/version-$pkgver-$pkgrel"
+}
+
+eval "package_${pkgname[1]}() {
+ $(declare -f _package_linux-rolling)
+ _package_linux-rolling
+}"
diff --git a/arch-linux-rolling/README.md b/arch-linux-rolling/README.md
new file mode 100644
index 000000000..c4671c6bd
--- /dev/null
+++ b/arch-linux-rolling/README.md
@@ -0,0 +1,18 @@
+arch-linux-rolling
+=
+
+Kernel for archlinux the way it meant to be.
+
+With the expense of additional packaging and unpackaging and without [infamous bug](https://bugs.archlinux.org/task/16702).
+
+## installation
+
+Note, if you installed `linux-rolling` after `linux-rolling_*`, you should manually regenerate `grub.cfg`.
+
+## Boot loader configuration
+
+`91-grub.hook` will update default grub install (in `/boot` directory with config at `/boot/grub/grub.cfg`)
+automatically.
+
+`systemd-boot` and `syslinux` both use manual configuration, so there is no easy universal update
+mechanism.
diff --git a/arch-linux-rolling/clean-old-kernels b/arch-linux-rolling/clean-old-kernels
new file mode 100755
index 000000000..2fb2ca7f2
--- /dev/null
+++ b/arch-linux-rolling/clean-old-kernels
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+set -e
+
+if [ $# -gt 0 ]; then
+ if [[ $# != 1 || ! "$1" =~ ^[0-9]+$ ]]; then
+ echo "Expect exactly one argument: number of additional kernels to keep"
+ exit 1
+ fi
+ NUM_KERNELS_TO_KEEP=$1
+else
+ eval $(egrep '^[A-Z_]+=[0-9A-Z]+\s*$' /etc/rolling.conf -s)
+fi
+
+kernel_packages=()
+skip=$NUM_KERNELS_TO_KEEP
+current_kernel=linux-rolling_$(uname -r | sed 's/-ARCH//g; s/[.-]/_/g;')
+for p in $(pacman -Qtq | egrep 'linux-rolling_[1-9]' | pacsort); do
+ if [ "$p" = "$current_kernel" ]; then
+ if [ $skip -gt 0 ]; then
+ skip=$(($skip - 1))
+ fi
+ continue
+ fi
+ kernel_packages[${#kernel_packages[@]}]=$p
+done
+
+num_packages_to_remove=$((${#kernel_packages[@]} - $skip))
+if [ $num_packages_to_remove -lt 1 ]; then
+ exit 0
+fi
+
+to_remove_kernel_packages=${kernel_packages[@]:0:$num_packages_to_remove}
+SUDO=$(command -v sudo)
+$SUDO pacman -R $to_remove_kernel_packages
diff --git a/arch-linux-rolling/linux-transitional.install b/arch-linux-rolling/linux-transitional.install
new file mode 100644
index 000000000..b9c72ea89
--- /dev/null
+++ b/arch-linux-rolling/linux-transitional.install
@@ -0,0 +1,27 @@
+post_install () {
+ local kernel_version=${1%.*}
+ if [ ! -e /usr/lib/modules/extramodules-$kernel_version-ARCH/version ]; then
+ ln -sf /usr/lib/modules/extramodules-$kernel_version-ARCH/version-$1 \
+ /usr/lib/modules/extramodules-$kernel_version-ARCH/version
+ fi
+}
+
+post_upgrade() {
+ local new_kernel_version=${1%.*} old_kernel_version=${2%.*}
+ local f=/usr/lib/modules/extramodules-$old_kernel_version-ARCH/version
+ if [ $new_kernel_version != $old_kernel_version ]; then
+ post_remove $2
+ post_install $1
+ elif [ ! -L $f -a ! -e $f -o "$(readlink $f)" = "$f-$2" ]; then
+ # `version` does not exists in any form or is a link to previous kernel
+ ln -sf $f-$1 $f
+ fi
+}
+
+post_remove() {
+ local kernel_version=${1%.*}
+ if [ "$(readlink /usr/lib/modules/extramodules-$kernel_version-ARCH/version)" = \
+ /usr/lib/modules/extramodules-$kernel_version-ARCH/version-$1 ]; then
+ rm /usr/lib/modules/extramodules-$kernel_version-ARCH/version
+ fi
+}
diff --git a/arch-linux-rolling/misc/yaourt.fish b/arch-linux-rolling/misc/yaourt.fish
new file mode 100644
index 000000000..7cdfa8f56
--- /dev/null
+++ b/arch-linux-rolling/misc/yaourt.fish
@@ -0,0 +1,32 @@
+# Example wrapper for yaourt, with automaized kernel update and cleanup
+function yaourt
+ set -l linux_version_before (gunzip -c /var/lib/pacman/sync/core.db ^/dev/null | egrep -ao '^linux-[0-9][0-9.-]*[0-9]' | egrep -o '[0-9].*')
+ set -l linux_rolling_version_before (pacman -Q linux-rolling ^/dev/null | egrep -o '[0-9].*')
+
+ /usr/bin/yaourt $argv
+
+ set -l linux_version_after (gunzip -c /var/lib/pacman/sync/core.db ^/dev/null | egrep -ao '^linux-[0-9][0-9.-]*[0-9]' | egrep -o '[0-9].*')
+ set -l linux_rolling_version_after (pacman -Q linux-rolling ^/dev/null | egrep -o '[0-9].*')
+ if test "$linux_version_before" != "$linux_version_after" \
+ -a "$linux_version_after" != "$linux_rolling_version_after" \
+ -a "$linux_rolling_version_after"
+ echo Building new linux-rolling
+ set -l d (mktemp --tmpdir -d linux-rolling-$linux_version_after.XXX)
+ test -d $d; or return $status
+ pushd $d
+ git clone --depth=1 https://github.com/versusvoid/arch-linux-rolling $d; or return $status
+ makepkg; or return $status
+ set -l p1 linux-rolling_(echo $linux_version_after | sed 's/[.-]/_/g')-$linux_version_after-(uname -m).pkg.tar
+ /usr/bin/yaourt -U --asdeps $p1*; or return $status
+ set -l p2 linux-rolling-$linux_version_after-any.pkg.tar
+ /usr/bin/yaourt -U $p2*; or return $status
+ set linux_rolling_version_after $linux_version_after
+ rm $p1* $p2* linux-$linux_version_after-(uname -m).pkg.tar.xz{,.sig}; or return $status
+ popd
+ rm -rf $d
+ end
+
+ if test "$linux_rolling_version_before" != "$linux_rolling_version_after" -a -e /usr/bin/clean-old-kernels
+ clean-old-kernels
+ end
+end
diff --git a/arch-linux-rolling/relink-extramodules-version b/arch-linux-rolling/relink-extramodules-version
new file mode 100755
index 000000000..27fde6d38
--- /dev/null
+++ b/arch-linux-rolling/relink-extramodules-version
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+kernel-version() {
+ local kernel_version=${1%-ARCH/version*}
+ echo ${kernel_version##*-}
+}
+
+relink-version() {
+ local installed=$(pacman -Qqs linux-rolling_${1//./_} | pacsort | head -n 1)
+ if [ ! "$installed" ]; then
+ return 1
+ fi
+
+ local package_version=${installed##linux-rolling_}
+ local package_release=${package_version##*_}
+ package_version=${package_version%_*}
+ package_version=${package_version//_/.}
+ local f="/usr/lib/modules/extramodules-$1-ARCH/version-$package_version-$package_release"
+ if [ ! -e "$f" ]; then
+ echo "Can't find $f. It must belong to $installed"
+ return 2
+ fi
+
+ ln -sf "$f" /usr/lib/modules/extramodules-$1-ARCH/version
+}
+
+linux-version-removed() {
+ local kernel_version=$(kernel-version "$1")
+ relink-version $kernel_version
+}
+
+linux-rolling-version-removed() {
+ local kernel_version=$(kernel-version "$1")
+ if [ "$(readlink "/usr/lib/modules/extramodules-$kernel_version-ARCH/version")" != "$1" ]; then
+ return 0
+ fi
+ relink-version $kernel_version
+}
+
+while read -r line; do
+ if [[ "$line" == *version ]]; then
+ linux-version-removed "/$line"
+ else
+ linux-rolling-version-removed "/$line"
+ fi
+done
diff --git a/arch-linux-rolling/rolling.conf b/arch-linux-rolling/rolling.conf
new file mode 100644
index 000000000..21d8ed92c
--- /dev/null
+++ b/arch-linux-rolling/rolling.conf
@@ -0,0 +1,8 @@
+
+# Number of kernels to keep
+# zero means keep latest and currently running
+NUM_KERNELS_TO_KEEP=0
+
+# If set to anything other than "0", there would
+# be no attempt to reconfigure grub even if possible
+DISABLE_GRUB_RECONFIGURATION=0
diff --git a/arch-linux-rolling/update-grub b/arch-linux-rolling/update-grub
new file mode 100755
index 000000000..50d5137a1
--- /dev/null
+++ b/arch-linux-rolling/update-grub
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if ! command -v grub-mkconfig > /dev/null; then
+ exit
+fi
+
+eval $(egrep '^[A-Z_]+=[0-9A-Z]+\s*$' /etc/rolling.conf -s)
+if [ "$DISABLE_GRUB_RECONFIGURATION" -a "$DISABLE_GRUB_RECONFIGURATION" != 0 ]; then
+ exit
+fi
+
+if findmnt --fstab -uno SOURCE /boot &>/dev/null && ! mountpoint -q /boot; then
+ echo "WARNING: /boot appears to be a separate partition but is not mounted."
+ echo "Grub would not be reconfigured and you may not be able to boot"
+ exit
+fi
+
+if [ ! -e /boot/grub/grub.cfg ]; then
+ echo "WARNING: /boot/grub/grub.cfg not found"
+ echo "Grub would not be reconfigured and you may not be able to boot"
+ exit
+fi
+
+grub-mkconfig -o /boot/grub/grub.cfg