diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-26 16:23:41 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-26 16:27:43 -0400 |
commit | e7edcfde77b0752480db7b4ede5f1a541ee97a88 (patch) | |
tree | e8334af8fc5ee4a2c73a792c4311ff05fe2b1374 /src | |
parent | 3d380700d49dd6faeb793834079724b5c0b93e92 (diff) |
librefetch: Drop a file in /etc/makepkg.d/ rather than editing makepkg.conf
The librefetch-install program will stick around for a while (1 year;
2019-08-26) so that it can be used from a post_upgrade hook to remove the
old edits, in order to seamlessly migrate people.
https://git.parabola.nu/abslibre.git/commit/?id=73982c5ad7057ce2fdec669d962aec6c9caf28c8
Diffstat (limited to 'src')
-rw-r--r-- | src/librefetch/.gitignore | 3 | ||||
-rw-r--r-- | src/librefetch/Makefile | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | src/librefetch/librefetch-install (renamed from src/librefetch/librefetch-install.in) | 39 | ||||
-rw-r--r-- | src/librefetch/makepkg-librefetch.conf.in (renamed from src/librefetch/librefetch-makepkg.conf.in) | 0 |
4 files changed, 12 insertions, 41 deletions
diff --git a/src/librefetch/.gitignore b/src/librefetch/.gitignore index d34a2fc..369c107 100644 --- a/src/librefetch/.gitignore +++ b/src/librefetch/.gitignore @@ -1,2 +1 @@ -librefetch-install -librefetch-makepkg.conf +/makepkg-librefetch.conf diff --git a/src/librefetch/Makefile b/src/librefetch/Makefile index f11f0ed..cee8ca8 100644 --- a/src/librefetch/Makefile +++ b/src/librefetch/Makefile @@ -2,12 +2,17 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk libretools.out.bins = librefetch librefetch-install -libretools.out.confs = $(libretools.src.conf) librefetch-makepkg.conf +libretools.out.confs = $(libretools.src.conf) libretools.out.libexecs = $(filter librefetchdir/%,$(libretools.src.exec)) libretools.out.libs = $(filter-out $(libretools.out.libexecs),$(filter librefetchdir/%,$(libretools.src.git))) libretools.pots = $(libretools.out.bins) +libretools.out = makepkg-librefetch.conf -$(outdir)/librefetch-install: $(var.)pkgconfdir -$(outdir)/librefetch-makepkg.conf: $(var.)bindir +files.sys.all += /etc/makepkg.d/librefetch.conf + +$(outdir)/makepkg-librefetch.conf: $(var.)bindir + +$(DESTDIR)/etc/makepkg.d/librefetch.conf: $(outdir)/makepkg-librefetch.conf + install -T -Dm644 '$<' '$@' include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/librefetch/librefetch-install.in b/src/librefetch/librefetch-install index e4756f4..2cdb014 100644..100755 --- a/src/librefetch/librefetch-install.in +++ b/src/librefetch/librefetch-install @@ -23,9 +23,6 @@ set -ueE . "$(librelib messages)" -# This line should be installed -new_code='. @pkgconfdir@/librefetch-makepkg.conf # This line was added by librefetch-install' - # These lines were installed by previous versions of this script old_code=( '# The following line is added by the libretools post_install script' @@ -33,14 +30,9 @@ old_code=( '[[ ! -x /usr/bin/librefetch ]] || DLAGENTS+=({https,libre}"::/usr/bin/librefetch -p \"\$BUILDFILE\" -- %u %o")' 'DLAGENTS+=({https,libre}"::/usr/bin/librefetch -p $(printf "%q" "$BUILDFILE") -- %u %o")' 'DLAGENTS+=({https,libre}'\''::/usr/bin/librefetch -p "$BUILDFILE" -- %u %o'\'')' + '. /etc/libretools.d/librefetch-makepkg.conf # This line was added by librefetch-install' ) -# has_line $file $line -has_line() { - local file=$1 - local line=$2 - grep -Fxq -- "$line" "$file" -} # del_line $file $line del_line() { local file=$1 @@ -51,45 +43,21 @@ del_line() { fi } -# post_install $file -post_install() { - local file=$1 - if grep -q 'librefetch' "$file"; then - print ":: %s: librefetch is already in %q" "${0##*/}" "$(realpath -s "$file")" - local line - for line in "${old_code[@]}"; do - if has_line "$file" "$line"; then - print ":: %s: ... but it's an old version" "${0##*/}" - pre_remove "$file" - post_install "$file" - return - fi - done - else - print ":: %s: adding librefetch to %q" "${0##*/}" "$(realpath -s "$file")" - printf '%s\n' "$new_code" >> "$file" - fi -} - # pre_remove $file pre_remove() { local file=$1 print ":: %s: removing librefetch from %q" "${0##*/}" "$(realpath -s "$file")" - # Check for the old stuff sed -ri 's/^#(.*) # commented out by the libretools post_install script/\1/' "$file" local line for line in "${old_code[@]}"; do del_line "$file" "$line" done - - # Check for the current stuff - del_line "$file" "$new_code" } usage() { - print "Usage: %s [install|remove] MAKEPKG_CONF_FILE" "${0##*/}" - print "Adds or removes librefetch to/from makepkg.conf:DLAGENTS" + print "Usage: %s remove MAKEPKG_CONF_FILE" "${0##*/}" + print "Removes librefetch to/from makepkg.conf:DLAGENTS" } main() { @@ -105,7 +73,6 @@ main() { error "%s: cannot write to file: %q" "${0##*/}" "$(realpath -s "$file")" fi case "$1" in - install) post_install "$file";; remove) pre_remove "$file";; *) usage >&2; return 1;; esac diff --git a/src/librefetch/librefetch-makepkg.conf.in b/src/librefetch/makepkg-librefetch.conf.in index 723bc15..723bc15 100644 --- a/src/librefetch/librefetch-makepkg.conf.in +++ b/src/librefetch/makepkg-librefetch.conf.in |