summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-08-26 16:23:41 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-08-26 16:27:43 -0400
commite7edcfde77b0752480db7b4ede5f1a541ee97a88 (patch)
treee8334af8fc5ee4a2c73a792c4311ff05fe2b1374
parent3d380700d49dd6faeb793834079724b5c0b93e92 (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
-rw-r--r--po/es/libretools.po30
-rw-r--r--src/librefetch/.gitignore3
-rw-r--r--src/librefetch/Makefile11
-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
5 files changed, 21 insertions, 62 deletions
diff --git a/po/es/libretools.po b/po/es/libretools.po
index cc36588..b0ee284 100644
--- a/po/es/libretools.po
+++ b/po/es/libretools.po
@@ -1508,35 +1508,23 @@ msgstr "%: se encontraron argumentos no-opciones extras: %s"
msgid "%s: %d non-flag arguments found, expected 1 or 2: %s"
msgstr "%s: %d argumentos no-opciones encontrados, esperado 1 o 2: %s"
-#: src/librefetch/librefetch-install:58
-msgid ":: %s: librefetch is already in %q"
-msgstr ":: %s: librefetch ya está en %q"
-
-#: src/librefetch/librefetch-install:62
-msgid ":: %s: ... but it's an old version"
-msgstr ":: %s: ... pero es una versión antigua"
-
-#: src/librefetch/librefetch-install:69
-msgid ":: %s: adding librefetch to %q"
-msgstr ":: %s: agregando librefetch a %q"
-
-#: src/librefetch/librefetch-install:77
+#: src/librefetch/librefetch-install:49
msgid ":: %s: removing librefetch from %q"
msgstr ":: %s: quitando librefetch de %q"
-#: src/librefetch/librefetch-install:91
-msgid "Usage: %s [install|remove] MAKEPKG_CONF_FILE"
-msgstr "Uso: %s [install|remove] ARCHIVO_CONF_DE_MAKEPKG"
+#: src/librefetch/librefetch-install:59
+msgid "Usage: %s remove MAKEPKG_CONF_FILE"
+msgstr "Uso: %s remove ARCHIVO_CONF_DE_MAKEPKG"
-#: src/librefetch/librefetch-install:92
-msgid "Adds or removes librefetch to/from makepkg.conf:DLAGENTS"
-msgstr "Agrega o quita librefetch a/de makepkg.conf:DLAGENTS"
+#: src/librefetch/librefetch-install:60
+msgid "Removes librefetch to/from makepkg.conf:DLAGENTS"
+msgstr "Quita librefetch a/de makepkg.conf:DLAGENTS"
-#: src/librefetch/librefetch-install:102
+#: src/librefetch/librefetch-install:70
msgid "%s: does not exist: %q"
msgstr "%s: no existe: %q"
-#: src/librefetch/librefetch-install:105
+#: src/librefetch/librefetch-install:73
msgid "%s: cannot write to file: %q"
msgstr "%s: no se puede escribir al archivo: %q"
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