@dmnks requested changes on this pull request.


> @@ -2,6 +2,41 @@
 #
 AT_BANNER([RPM macros])
 
+AT_SETUP([macro path])
+AT_KEYWORDS([macros])
+RPMDB_INIT
+
+# .rpmmacros exists

I'd suggest that we actually check that `~/.rpmmacros` really exists (or just 
`touch` it like in the other tests below). It's currently basically an 
[implementation 
detail](https://github.com/rpm-software-management/rpm/blob/e16bf1fb3198ef0b4c5a1644b627b91db13da99b/tests/Dockerfile.fedora#L55)
 of the test image that, if ever changes, would cause a weird test failure 
:smile: 

> +}
+#else
+/*
+ * Prefer XDG_CONFIG_HOME/rpmmacros but fall back to ~/.rpmmacros
+ * if it exists and the XDG path doesn't.
+ */
+static char *initMacroPath(const char *confdir)
+{
+    const char *xdgconf = getenv("XDG_CONFIG_HOME");
+    if (!(xdgconf && *xdgconf))
+       xdgconf = "~/.config";
+    char *dotpath = rpmGetPath(xdgconf, "/rpmmacros", NULL);
+
+    if (rpmGlob(dotpath, NULL, NULL)) {
+       const char *oldcfg = "~/.rpmmacros";
+       if (rpmGlob(oldcfg, NULL, NULL) == 0) {

Cosmetic: This second `rpmGlob()` check doesn't really achieve anything; if 
`~/.rpmmacros` is missing, we'll just keep (the also missing) 
`~/.config/rpmmacros` in `dotpath`. When later loading the macro files in 
`rpmInitMacros()`, we'll just skip over missing ones anyway.

Note that if you remove this check, though, you'll need to update the test 
covering the `XDG_CONFIG_HOME` use case (to actually create the 
`~/.zzz/rpmconfig` file).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/2992#pullrequestreview-1957907594
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/2992/review/1957907...@github.com>
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to