commit 3f3e60432ab6e80bf3da840fecc9b44031a58828 Author: Christian Schendel Date: Wed Sep 3 10:01:59 2025 +0200 Initial commit diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 0000000..69b4350 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,24 @@ +pkgbase = needrestart + pkgdesc = Restart daemons after library updates + pkgver = 3.11 + pkgrel = 2 + url = https://github.com/liske/needrestart + arch = any + license = GPL-2.0-or-later + makedepends = git + depends = bash + depends = perl + depends = perl-module-find + depends = perl-term-readkey + depends = perl-proc-processtable + depends = perl-sort-naturally + depends = perl-module-scandeps + depends = perl-libintl-perl + optdepends = iucode-tool: for outdated microcode detection + options = !emptydirs + source = needrestart-3.11::git+https://github.com/liske/needrestart.git#tag=v3.11 + source = needrestart.hook + b2sums = c8556a9ecfa8d822d122364d222082c732c8d0b39ce1da3fb1c4698b86746b56556097848e79b26a9dbdad42b8c52bfbfc4fc771b79f0653129b6121ea667994 + b2sums = f437710081109c2d1dc7fcffebd7e953a31e3be94322f3727eefa8ac2ab6917c9adca90be158a7a1d9df9fa520cd10d633664d427950832b9f76d364b8bfd8d5 + +pkgname = needrestart diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed2cb17 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# Ignore everything +* + +# But not these files... +!.gitignore +!PKGBUILD +!.SRCINFO +!LICENSE +!chroot-build +!.nvchecker.toml +!/keys +!/keys/pgp +!/keys/pgp/*.asc +!/LICENSES +!/LICENSES/*.txt +!REUSE.toml +!*.install +!*.patch +!*.hook diff --git a/.nvchecker.toml b/.nvchecker.toml new file mode 100644 index 0000000..e89a0a1 --- /dev/null +++ b/.nvchecker.toml @@ -0,0 +1,4 @@ +[needrestart] +source = "git" +git = "https://github.com/liske/needrestart.git" +prefix = "v" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b87c5e4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +Copyright Arch Linux Contributors + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE +FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN +AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/LICENSES/0BSD.txt b/LICENSES/0BSD.txt new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/LICENSES/0BSD.txt @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..8b09009 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,61 @@ +# Maintainer: Christian Schendel +# Contributor: Thomas Weißschuh + +pkgname=needrestart +pkgver=3.11 +pkgrel=2 +arch=(any) +pkgdesc="Restart daemons after library updates" +url="https://github.com/liske/needrestart" +license=( + 'GPL-2.0-or-later' +) +depends=( + bash + perl + perl-module-find + perl-term-readkey + perl-proc-processtable + perl-sort-naturally + perl-module-scandeps + perl-libintl-perl +) +makedepends=( + git +) +optdepends=( + 'iucode-tool: for outdated microcode detection' +) +options=( + !emptydirs +) +source=("$pkgname-$pkgver::git+$url.git#tag=v$pkgver" + "needrestart.hook") +b2sums=('c8556a9ecfa8d822d122364d222082c732c8d0b39ce1da3fb1c4698b86746b56556097848e79b26a9dbdad42b8c52bfbfc4fc771b79f0653129b6121ea667994' + 'f437710081109c2d1dc7fcffebd7e953a31e3be94322f3727eefa8ac2ab6917c9adca90be158a7a1d9df9fa520cd10d633664d427950832b9f76d364b8bfd8d5') + +prepare() { + cd "$pkgname-$pkgver" + sed -i -e 's|/usr/sbin|/usr/bin|' Makefile +} + +build() { + cd "$pkgname-$pkgver" + unset PERL5LIB PERL_MM_OPT PERL_LOCAL_LIB_ROOT + export PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps + make +} + +package() { + cd "$pkgname-$pkgver" + unset PERL5LIB PERL_MM_OPT PERL_LOCAL_LIB_ROOT + export PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps + make DESTDIR="${pkgdir}" install + + install -Dm444 "${srcdir}/needrestart.hook" \ + "${pkgdir}/usr/share/libalpm/hooks/needrestart.hook" + + install -Dm0644 -t "$pkgdir/usr/share/doc/$pkgname" NEWS README.* +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 0000000..e45b4ff --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,23 @@ +version = 1 + +[[annotations]] +path = [ + "PKGBUILD", + "README.md", + "keys/**", + ".SRCINFO", + ".nvchecker.toml", + ".gitignore", + "*.install", + "*.sysusers", + "*.tmpfiles", + "*.logrotate", + "*.pam", + "*.service", + "*.socket", + "*.timer", + "*.desktop", + "*.hook", +] +SPDX-FileCopyrightText = "Arch Linux contributors" +SPDX-License-Identifier = "0BSD" diff --git a/chroot-build b/chroot-build new file mode 100755 index 0000000..f69cac8 --- /dev/null +++ b/chroot-build @@ -0,0 +1,65 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: Christian Schendel +# SPDX-License-Identifier: 0BSD + +set -euo pipefail +use_tmpfs=true +CHROOT="/tmp/mkarchroot" + +check_available_ram() { + if [ "$(awk '/^MemAvailable:/ { print $2; }' /proc/meminfo)" -lt 50000 ]; then + use_tmpfs=false + fi +} + +create_chroot_directory() { + if [ $use_tmpfs ]; then + sudo mount --mkdir -t tmpfs -o defaults,size=20G tmpfs $CHROOT + else + sudo mkdir -p "$CHROOT" + fi +} + +create_chroot_environment() { + if [[ ! -d "$CHROOT/root" ]]; then + mkarchroot -M ~/.config/pacman/makepkg.conf "$CHROOT/root" base-devel + fi +} + +build_package(){ + arch-nspawn "$CHROOT/root" pacman -Syu + if makechrootpkg -c -r "$CHROOT" -- -Asf . ; then + makepkg --printsrcinfo >.SRCINFO + else + delete_chroot_environment && echo -e "\n\e[1;31m==> BUILD FAILED: \e[1;37m$CHROOT removed\e[0m " && exit 1 + fi +} + +sign_package(){ + PACKAGE="$(makepkg --packagelist)" + gpg --use-agent --output "$PACKAGE.sig" --detach-sign "$PACKAGE" +} + +delete_chroot_environment() { + if [ "$(stat -f --format=%T "$CHROOT")" == "btrfs" ]; then + { + sudo btrfs subvolume delete "$CHROOT/root/var/lib/portables" + sudo btrfs subvolume delete "$CHROOT/root/var/lib/machines" + sudo btrfs subvolume delete "$CHROOT/root" + sudo rm -Rf $CHROOT + } >>/dev/null 2>&1 + elif [ "$(stat -f --format=%T "$CHROOT")" == "tmpfs" ]; then + sudo umount -f $CHROOT + fi + sudo rm -Rf $CHROOT +} + +check_available_ram +create_chroot_directory +create_chroot_environment +build_package +sign_package +delete_chroot_environment + +# vim: set ts=4 sw=4 et: diff --git a/needrestart.hook b/needrestart.hook new file mode 100644 index 0000000..7d206c7 --- /dev/null +++ b/needrestart.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Upgrade +Type = Package +Target = * + +[Action] +Description = Check if daemons need restart after library/binary upgrades +Exec = /usr/bin/needrestart +When = PostTransaction +Depends = needrestart