summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO15
-rw-r--r--Makefile2
-rw-r--r--PKGBUILD19
-rwxr-xr-xrebuild-detector46
-rwxr-xr-xrebuild-detector-cleanup24
-rw-r--r--rebuild-detector-cleanup.hook10
-rw-r--r--rebuild-detector-cleanup.hook.sigbin566 -> 0 bytes
-rw-r--r--rebuild-detector-cleanup.sigbin566 -> 0 bytes
-rw-r--r--rebuild-detector.hook5
-rw-r--r--rebuild-detector.hook.sigbin566 -> 566 bytes
-rw-r--r--rebuild-detector.install8
-rw-r--r--rebuild-detector.sigbin566 -> 566 bytes
12 files changed, 32 insertions, 97 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 33c8de8e0b02..4e7e6ffcee6c 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,26 +1,17 @@
pkgbase = rebuild-detector
pkgdesc = Pacman hook to automatically detect which packages need to be rebuilt
- pkgver = 1.0.0
+ pkgver = 1.1.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
- source = rebuild-detector-cleanup
- source = rebuild-detector-cleanup.sig
- source = rebuild-detector-cleanup.hook
- source = rebuild-detector-cleanup.hook.sig
validpgpkeys = EB4F9E5A60D32232BB52150C12C87A28FEAC6B20
- sha256sums = c77f55f6d84a9754e744a547fd64ee1b15906fb45afd127613dddc41a9760547
+ sha256sums = 283874f80ef3ee9c93751df25362864e4fefa626ed22bd69be38d2c5fa044342
sha256sums = SKIP
- sha256sums = 85117be08f7c904805de0b58722532caa55dfc2cb31f118d509871f3d40b96ec
- sha256sums = SKIP
- sha256sums = 9d5be08cd837a4e6445b1880119896f82596be2bd53cf24b525abab3b90079d0
- sha256sums = SKIP
- sha256sums = 5609c9c0812412cee629964eec692e989524d476f69c5125fa1cb846ff5be7e2
+ sha256sums = f40d3fbc90c62a7d38795ce1a6600edac3acf2041ea4a4fc987842b6fde5555a
sha256sums = SKIP
pkgname = rebuild-detector
diff --git a/Makefile b/Makefile
index f06b907bcc71..fafe397b76b8 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,5 @@
prepare:
gpg --detach-sign --yes rebuild-detector
gpg --detach-sign --yes rebuild-detector.hook
- gpg --detach-sign --yes rebuild-detector-cleanup
- gpg --detach-sign --yes rebuild-detector-cleanup.hook
updpkgsums
makepkg --printsrcinfo > .SRCINFO
diff --git a/PKGBUILD b/PKGBUILD
index bc828e3d9de8..ff09108ceb9d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,35 +1,24 @@
# Maintainer: Maxim Baz <$pkgname at maximbaz dot com>
pkgname=rebuild-detector
-pkgver=1.0.0
+pkgver=1.1.0
pkgrel=1
pkgdesc="Pacman hook to automatically detect 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"
- "rebuild-detector-cleanup"
- "rebuild-detector-cleanup.sig"
- "rebuild-detector-cleanup.hook"
- "rebuild-detector-cleanup.hook.sig")
-sha256sums=('c77f55f6d84a9754e744a547fd64ee1b15906fb45afd127613dddc41a9760547'
+ "rebuild-detector.hook.sig")
+sha256sums=('283874f80ef3ee9c93751df25362864e4fefa626ed22bd69be38d2c5fa044342'
'SKIP'
- '85117be08f7c904805de0b58722532caa55dfc2cb31f118d509871f3d40b96ec'
- 'SKIP'
- '9d5be08cd837a4e6445b1880119896f82596be2bd53cf24b525abab3b90079d0'
- 'SKIP'
- '5609c9c0812412cee629964eec692e989524d476f69c5125fa1cb846ff5be7e2'
+ 'f40d3fbc90c62a7d38795ce1a6600edac3acf2041ea4a4fc987842b6fde5555a'
'SKIP')
validpgpkeys=("EB4F9E5A60D32232BB52150C12C87A28FEAC6B20")
package() {
install -Dm755 rebuild-detector -t "$pkgdir/usr/share/libalpm/scripts/"
- install -Dm755 rebuild-detector-cleanup -t "$pkgdir/usr/share/libalpm/scripts/"
install -Dm644 rebuild-detector.hook -t "$pkgdir/usr/share/libalpm/hooks/"
- install -Dm644 rebuild-detector-cleanup.hook -t "$pkgdir/usr/share/libalpm/hooks/"
}
# vim:set ts=4 sw=4 et:
diff --git a/rebuild-detector b/rebuild-detector
index 31ddd19fb654..2bc2dc225b36 100755
--- a/rebuild-detector
+++ b/rebuild-detector
@@ -1,49 +1,47 @@
#!/bin/bash
#
-# For each of the upgraded packages, detect packages that depend on it
-# and add those to the list of packages to rebuild grouped by repo.
-#
-# Cleanup the upgraded packages themselves from the rebuild-pending list.
-#
-# All repositories are watched by default.
-# Set $REBUILD_DETECTOR_REPOS to a space-separated list to override.
+# Run `ldd` on each binary in /usr/bin and save the broken ones grouped by repo.
+
+shopt -s nullglob
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 $REBUILD_DETECTOR_REPOS | awk -v i="$installed" '$NF == i { print $1,$2 }'
+ 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() {
+ parallel --will-cite 'ldd "{}" 2>/dev/null | grep "not found" >/dev/null && pacman -Qo "{}" | cut -d" " -f5'
}
-detect_depending_pkgs() {
- parallel --plus --will-cite "pactree -u {#.* } | tail -n +2 | grep '^$1$' >/dev/null && echo {}"
+get_pkg_repo() {
+ grep " $1" installed | cut -d' ' -f1
}
-tmp=$(mktemp -dt "rebuild-detector-upgrade-hook.XXXXXXXX") || exit
+tmp=$(mktemp -dt "rebuild-detector.XXXXXXXX") || exit
trap 'rm -rf $tmp' EXIT
cd "$tmp" || exit
-mapfile -t upgraded
get_installed_pkgs >installed
+get_binaries | get_broken_pkgs >broken
-for pkg in "${upgraded[@]}"; do
- detect_depending_pkgs "$pkg" <installed >depending
+rm -f "$REBUILD_DETECTOR_CACHE_DIR/"*.list
- while read -r repo package; do
- echo "$package" >>"$REBUILD_DETECTOR_CACHE_DIR/$repo.list"
- done <depending
-done
+while read -r pkg; do
+ repo="$(get_pkg_repo "$pkg")"
+ echo "$pkg" >>"$REBUILD_DETECTOR_CACHE_DIR/$repo.list"
+done <broken
-shopt -s nullglob
for list in "$REBUILD_DETECTOR_CACHE_DIR/"*.list; do
sort -u "$list" -o "$list"
done
-current_dir="$(cd "$(dirname "$0")"; pwd)"
-for pkg in "${upgraded[@]}"; do
- echo "$pkg"
-done | "$current_dir/rebuild-detector-cleanup"
-
exit 0
diff --git a/rebuild-detector-cleanup b/rebuild-detector-cleanup
deleted file mode 100755
index 38c27ce710e8..000000000000
--- a/rebuild-detector-cleanup
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-#
-# Remove packages from the rebuild-pending list.
-
-readonly REBUILD_DETECTOR_CACHE_DIR="/var/cache/rebuild-detector"
-
-get_pkg_info() {
- pacman -Sl | awk '{ print $1,$2 }'
-}
-
-
-tmp=$(mktemp -dt "rebuild-detector-cleanup-hook.XXXXXXXX") || exit
-trap 'rm -rf $tmp' EXIT
-cd "$tmp" || exit
-
-get_pkg_info >pkg_info
-
-while read -r pkg; do
- repo=$(grep " $pkg" pkg_info | cut -d' ' -f1)
- file="$REBUILD_DETECTOR_CACHE_DIR/$repo.list"
- [ -f "$file" ] && sed -i "/^$pkg$/d" "$file"
-done
-
-exit 0
diff --git a/rebuild-detector-cleanup.hook b/rebuild-detector-cleanup.hook
deleted file mode 100644
index 2a0ca4663896..000000000000
--- a/rebuild-detector-cleanup.hook
+++ /dev/null
@@ -1,10 +0,0 @@
-[Trigger]
-Type = Package
-Operation = Remove
-Target = *
-
-[Action]
-Description = Ensure the removed packages are not present in the rebuild-pending list
-When = PostTransaction
-Exec = /usr/share/libalpm/scripts/rebuild-detector-cleanup
-NeedsTargets
diff --git a/rebuild-detector-cleanup.hook.sig b/rebuild-detector-cleanup.hook.sig
deleted file mode 100644
index 59fb89b433e1..000000000000
--- a/rebuild-detector-cleanup.hook.sig
+++ /dev/null
Binary files differ
diff --git a/rebuild-detector-cleanup.sig b/rebuild-detector-cleanup.sig
deleted file mode 100644
index 33aff0603f9a..000000000000
--- a/rebuild-detector-cleanup.sig
+++ /dev/null
Binary files differ
diff --git a/rebuild-detector.hook b/rebuild-detector.hook
index 6c553b0e0348..73ce4d4129eb 100644
--- a/rebuild-detector.hook
+++ b/rebuild-detector.hook
@@ -1,10 +1,11 @@
[Trigger]
Type = Package
+Operation = Install
Operation = Upgrade
+Operation = Remove
Target = *
[Action]
-Description = Detect packages that require a rebuild
+Description = Detecting packages that require a rebuild
When = PostTransaction
Exec = /usr/share/libalpm/scripts/rebuild-detector
-NeedsTargets
diff --git a/rebuild-detector.hook.sig b/rebuild-detector.hook.sig
index ca2637db6d1a..2bdc315a80f3 100644
--- a/rebuild-detector.hook.sig
+++ b/rebuild-detector.hook.sig
Binary files differ
diff --git a/rebuild-detector.install b/rebuild-detector.install
deleted file mode 100644
index 4c05739d26bd..000000000000
--- a/rebuild-detector.install
+++ /dev/null
@@ -1,8 +0,0 @@
-post_install() {
- echo ">> Make sure to select which repos to monitor, it will greately speedup the hook."
- echo ">> export REBUILD_DETECTOR_REPOS='my-aur-repo'"
-}
-
-post_upgrade() {
- post_install
-}
diff --git a/rebuild-detector.sig b/rebuild-detector.sig
index 6abe6ea88b08..6f8d90e58543 100644
--- a/rebuild-detector.sig
+++ b/rebuild-detector.sig
Binary files differ