summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxim Baz2018-08-15 23:42:11 +0200
committerMaxim Baz2018-08-15 23:42:11 +0200
commit7d30063632c7ee414ab8e6f539e73c76d4b8807e (patch)
treec39f17612942c2ef51d13d01d350099dbef337f9
parentdc01ee8696d9bc878fce300e49c28c570b9d1695 (diff)
downloadaur-7d30063632c7ee414ab8e6f539e73c76d4b8807e.tar.gz
Convert to a normal binary, don't write to disk, check entire PATH
-rw-r--r--.SRCINFO11
-rw-r--r--Makefile1
-rw-r--r--PKGBUILD16
-rwxr-xr-xrebuild-detector57
-rw-r--r--rebuild-detector.hook11
-rw-r--r--rebuild-detector.hook.sigbin566 -> 0 bytes
-rw-r--r--rebuild-detector.install3
-rw-r--r--rebuild-detector.sigbin566 -> 566 bytes
8 files changed, 26 insertions, 73 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 8c30092163e6..bdd8acaba45e 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,18 +1,13 @@
pkgbase = rebuild-detector
- pkgdesc = Pacman hook to automatically detect which packages need to be rebuilt
- pkgver = 1.2.1
+ pkgdesc = Detects which packages need to be rebuilt
+ pkgver = 2.0.0
pkgrel = 1
- install = rebuild-detector.install
arch = any
license = MIT
source = rebuild-detector
source = rebuild-detector.sig
- source = rebuild-detector.hook
- source = rebuild-detector.hook.sig
validpgpkeys = EB4F9E5A60D32232BB52150C12C87A28FEAC6B20
- sha256sums = a4678300a04411c74bf7d37a3d56087f3d5427ee7093c0ac75519ac58914d9ba
- sha256sums = SKIP
- sha256sums = f40d3fbc90c62a7d38795ce1a6600edac3acf2041ea4a4fc987842b6fde5555a
+ sha256sums = 54fe5370f26e463e74c101df9870c9f716db558cf9e30307ab74e9e4ca0cfbe2
sha256sums = SKIP
pkgname = rebuild-detector
diff --git a/Makefile b/Makefile
index fafe397b76b8..7cbb63172efd 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,5 @@
prepare:
gpg --detach-sign --yes rebuild-detector
- gpg --detach-sign --yes rebuild-detector.hook
updpkgsums
makepkg --printsrcinfo > .SRCINFO
diff --git a/PKGBUILD b/PKGBUILD
index df034fbc51df..c5ec38255225 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,25 +1,19 @@
# Maintainer: Maxim Baz <$pkgname at maximbaz dot com>
pkgname=rebuild-detector
-pkgver=1.2.1
+pkgver=2.0.0
pkgrel=1
-pkgdesc="Pacman hook to automatically detect which packages need to be rebuilt"
+pkgdesc="Detects which packages need to be rebuilt"
arch=("any")
license=("MIT")
-install="rebuild-detector.install"
source=("rebuild-detector"
- "rebuild-detector.sig"
- "rebuild-detector.hook"
- "rebuild-detector.hook.sig")
-sha256sums=('a4678300a04411c74bf7d37a3d56087f3d5427ee7093c0ac75519ac58914d9ba'
- 'SKIP'
- 'f40d3fbc90c62a7d38795ce1a6600edac3acf2041ea4a4fc987842b6fde5555a'
+ "rebuild-detector.sig")
+sha256sums=('54fe5370f26e463e74c101df9870c9f716db558cf9e30307ab74e9e4ca0cfbe2'
'SKIP')
validpgpkeys=("EB4F9E5A60D32232BB52150C12C87A28FEAC6B20")
package() {
- install -Dm755 rebuild-detector -t "$pkgdir/usr/share/libalpm/scripts/"
- install -Dm644 rebuild-detector.hook -t "$pkgdir/usr/share/libalpm/hooks/"
+ install -Dm755 rebuild-detector -t "$pkgdir/usr/bin/"
}
# vim:set ts=4 sw=4 et:
diff --git a/rebuild-detector b/rebuild-detector
index 7aec2c7ca4b4..ad5df2664764 100755
--- a/rebuild-detector
+++ b/rebuild-detector
@@ -1,31 +1,19 @@
#!/bin/bash
#
-# Detect broken packages that need to be rebuilt and save them grouped by repo.
+# Detect broken packages that need to be rebuilt
shopt -s nullglob
shopt -s extglob
-readonly REBUILD_DETECTOR_CACHE_DIR="/var/cache/rebuild-detector"
-mkdir -p "$REBUILD_DETECTOR_CACHE_DIR"
-
-
-get_installed_pkgs() {
- printf -v installed '[%s]' "$(gettext installed)"
- pacman -Sl | awk -v i="$installed" '$NF == i { print $1,$2 }'
-}
-
-get_binaries() {
- find -L /usr/bin -type f -print0 | xargs -0 readlink -f
-}
-
-get_broken_pkgs() {
+get_broken_ldd_pkgs() {
+ while IFS= read -rd: dir; do readlink -f "$dir"; done <<<"$PATH" |
+ sort -u |
+ xargs -I{} find -L "{}" -maxdepth 1 -type f -print0 |
+ xargs -0 readlink -f |
+ sort -u |
parallel --will-cite 'ldd "{}" 2>/dev/null | grep "not found" >/dev/null && pacman -Qqo "{}"'
}
-get_pkg_repo() {
- grep " $1" installed | cut -d' ' -f1
-}
-
get_broken_python_pkgs() {
python_version="$(python --version | cut -d'.' -f2)"
pacman -Qqo /usr/lib/python3.!($python_version) 2>/dev/null
@@ -36,27 +24,18 @@ get_broken_perl_pkgs() {
pacman -Qqo /usr/lib/perl*/!($perl_version) 2>/dev/null
}
+get_broken_pkgs() {
+ {
+ get_broken_ldd_pkgs
+ get_broken_python_pkgs
+ get_broken_perl_pkgs
+ } | sort -u
+}
-tmp=$(mktemp -dt "rebuild-detector.XXXXXXXX") || exit
-trap 'rm -rf $tmp' EXIT
-cd "$tmp" || exit
-
-# Detect broken packages
-get_installed_pkgs >installed
-get_binaries | get_broken_pkgs >broken
-get_broken_python_pkgs >>broken
-get_broken_perl_pkgs >>broken
-
-# Save broken packages grouped by repo, overriding previous results
-rm -f "$REBUILD_DETECTOR_CACHE_DIR/"*.list
-while read -r pkg; do
- repo="$(get_pkg_repo "$pkg")"
- echo "$pkg" >>"$REBUILD_DETECTOR_CACHE_DIR/$repo.list"
-done <broken
+get_repo_pkgs() {
+ pacman -Sl | cut -d' ' -f1-2
+}
-# Remove duplicates
-for list in "$REBUILD_DETECTOR_CACHE_DIR/"*.list; do
- sort -u "$list" -o "$list"
-done
+join -12 <(get_repo_pkgs | sort -k2) <(get_broken_pkgs) | awk '{ print $2 "\t" $1 }'
exit 0
diff --git a/rebuild-detector.hook b/rebuild-detector.hook
deleted file mode 100644
index 73ce4d4129eb..000000000000
--- a/rebuild-detector.hook
+++ /dev/null
@@ -1,11 +0,0 @@
-[Trigger]
-Type = Package
-Operation = Install
-Operation = Upgrade
-Operation = Remove
-Target = *
-
-[Action]
-Description = Detecting packages that require a rebuild
-When = PostTransaction
-Exec = /usr/share/libalpm/scripts/rebuild-detector
diff --git a/rebuild-detector.hook.sig b/rebuild-detector.hook.sig
deleted file mode 100644
index 86dfd784ee10..000000000000
--- a/rebuild-detector.hook.sig
+++ /dev/null
Binary files differ
diff --git a/rebuild-detector.install b/rebuild-detector.install
deleted file mode 100644
index 0ea942cd8533..000000000000
--- a/rebuild-detector.install
+++ /dev/null
@@ -1,3 +0,0 @@
-post_install() {
- echo ">> The lists of packages to rebuild will be stored in /var/cache/rebuild-detector/"
-}
diff --git a/rebuild-detector.sig b/rebuild-detector.sig
index 4907692bfb46..308c32d4ea74 100644
--- a/rebuild-detector.sig
+++ b/rebuild-detector.sig
Binary files differ