Skip to content

Commit

Permalink
handle .pacnew files automatically on Arch Linux
Browse files Browse the repository at this point in the history
By installing a libalpm hook, as supported by Pacman 5.0+.
  • Loading branch information
majewsky committed May 25, 2016
1 parent f2915ce commit 682396e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ install: default conf/holorc conf/holorc.holo-files src/holo-test util/autocompl
install -D -m 0644 build/man/holo-files.8 "$(DESTDIR)/usr/share/man/man8/holo-files.8"
install -D -m 0644 build/man/holo-test.7 "$(DESTDIR)/usr/share/man/man7/holo-test.7"
install -D -m 0644 build/man/holo-plugin-interface.7 "$(DESTDIR)/usr/share/man/man7/holo-plugin-interface.7"
env DESTDIR=$(DESTDIR) ./src/distribution-integration/install.sh

.PHONY: prepare-build test check install
13 changes: 13 additions & 0 deletions src/distribution-integration/alpm-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

# enumerate files that are managed by holo-files
holo scan --short | grep '^file:' | cut -d: -f2- | sort > /tmp/files-managed-by-holo

# changed files come from stdin (but without leading slash!); find files
# managed by Holo among these
sort | sed 's+^+/+' | comm -12 - /tmp/files-managed-by-holo | sed 's/^/file:/' | xargs holo apply

# cleanup
rm /tmp/files-managed-by-holo
11 changes: 11 additions & 0 deletions src/distribution-integration/alpm.hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Trigger]
Operation = Upgrade
Type = File
Target = *

[Action]
Description = Checking for .pacnew files that can be resolved by Holo...
When = PostTransaction
Depends = holo
Exec = /usr/lib/holo/alpm-hook-resolve-pacnew
NeedsTargets
18 changes: 18 additions & 0 deletions src/distribution-integration/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

CURRENT_DIR="$(dirname $0)"

# check distribution and install appropriate integrations
[ -f /etc/os-release ] && source /etc/os-release || source /usr/lib/os-release
DIST_IDS="$(echo "$ID $ID_LIKE" | tr ' ' ',')"

case ",$DIST_IDS," in
*,arch,*)
set -ex
install -D -m 0644 "${CURRENT_DIR}/alpm.hook" "${DESTDIR}/usr/share/libalpm/hooks/01-holo-resolve-pacnew.hook"
install -D -m 0755 "${CURRENT_DIR}/alpm-hook.sh" "${DESTDIR}/usr/lib/holo/alpm-hook-resolve-pacnew"
;;
*)
echo No specialized integration for this distribution.
;;
esac

0 comments on commit 682396e

Please sign in to comment.