[2/2] pactree: Set the gpg directory

Message ID 20200105054724.11590-2-develinthedetail@gmail.com
State Superseded, archived
Delegated to: Johannes Löthberg
Headers show
Series [1/2] pactree: Add --debug | expand

Commit Message

Edward E Jan. 5, 2020, 5:47 a.m. UTC
Addresses https://github.com/msys2/MSYS2-packages/issues/1720

Signed-off-by: Edward E <develinthedetail@gmail.com>
---
gpgdir is hardcoded here. Also 'plagiarized' from pacman.
 src/Makefile.am | 4 +++-
 src/pactree.c   | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Johannes Löthberg Jan. 5, 2020, 1:34 p.m. UTC | #1
Excerpts from Edward E's message of January 5, 2020 6:47:
> Addresses https://github.com/msys2/MSYS2-packages/issues/1720
> 
> Signed-off-by: Edward E <develinthedetail@gmail.com>
> ---
> gpgdir is hardcoded here. Also 'plagiarized' from pacman.
>  src/Makefile.am | 4 +++-
>  src/pactree.c   | 4 ++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 

Good catch, thanks!

Patch

diff --git a/src/Makefile.am b/src/Makefile.am
index 8d33be8..eef0590 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,7 @@  DIST_SUBDIRS = $(SUBDIRS)
 # paths set at make time
 conffile  = ${sysconfdir}/pacman.conf
 dbpath    = ${localstatedir}/lib/pacman/
+gpgdir    = ${sysconfdir}/pacman.d/gnupg/
 
 bin_SCRIPTS = \
 	$(OURSCRIPTS)
@@ -82,7 +83,8 @@  endif
 AM_CPPFLAGS = \
 	-DLOCALEDIR=\"@localedir@\" \
 	-DCONFFILE=\"$(conffile)\" \
-	-DDBPATH=\"$(dbpath)\"
+	-DDBPATH=\"$(dbpath)\" \
+	-DGPGDIR=\"$(gpgdir)\"
 
 AM_CFLAGS = \
 	-pedantic \
diff --git a/src/pactree.c b/src/pactree.c
index 8b77f05..f7c4d39 100644
--- a/src/pactree.c
+++ b/src/pactree.c
@@ -125,6 +125,7 @@  static int searchsyncs = 0;
 static int debug = 0;
 static const char *dbpath = DBPATH;
 static const char *configfile = CONFFILE;
+static const char *gpgdir = GPGDIR;
 
 void cb_log(alpm_loglevel_t level, const char *fmt, va_list args)
 {
@@ -545,6 +546,9 @@  int main(int argc, char *argv[])
 		alpm_option_set_logcb(handle, cb_log);
 	}
 
+	/* no need to fail on error */
+	alpm_option_set_gpgdir(handle, gpgdir);
+
 	if(searchsyncs) {
 		if(register_syncs() != 0) {
 			cleanup(1);