From 4ff7aa0d8a8c88a6d1d02fa8462fa59c24a97422 Mon Sep 17 00:00:00 2001
From: Celeste Liu <CoelacanthusHex@gmail.com>
Date: Wed, 11 Jan 2023 16:27:11 +0800
Subject: archbuild: add doc for bind mount config

Signed-off-by: Celeste Liu <CoelacanthusHex@gmail.com>
---
 doc/man/archbuild.1.asciidoc | 1 +
 1 file changed, 1 insertion(+)

(limited to 'doc/man/archbuild.1.asciidoc')

diff --git a/doc/man/archbuild.1.asciidoc b/doc/man/archbuild.1.asciidoc
index 6b00572..777e3f2 100644
--- a/doc/man/archbuild.1.asciidoc
+++ b/doc/man/archbuild.1.asciidoc
@@ -25,6 +25,7 @@ Description
 
 The symlink used to run it will be inspected by archbuild, to determine which target you want it to use. It will load the available pacman configuration from 'pacman-reponame-arch.conf' with a fallback to 'pacman-reponame.conf' from {pkgdatadir}. The makepkg configuration is loaded from 'makepkg-repo-arch.conf' with a fallback to 'makepkg-reponame.conf' from {pkgdatadir}.
 
+It will also load the bind mount configuration from 'mount.d/arch' in {pkgdatadir}. The file format is that each line starting with ro and rw will be used, other lines will be ignored, and the rest of the used line is out/path:in/path preceded by a space as a separator. ro means it is a read-only mount, rw means a read-write mount.
 
 Options
 -------
-- 
cgit v1.2.3-70-g09d2


From e0307c7925168f58c3ec5077ea9915db81d4f62a Mon Sep 17 00:00:00 2001
From: Levente Polyak <anthraxx@archlinux.org>
Date: Fri, 30 Dec 2022 16:49:58 +0100
Subject: conf: move makepkg and pacman config into separate conf.d dirs

We have used the datadir like a kitchen sink, lets clean up a bit by
having a better and well structured layout. Put makepkg and pacman
configs in separate directories: makepkg.conf.d and pacman.conf.d.
---
 Makefile                     | 21 +++++++++++++++------
 doc/man/archbuild.1.asciidoc |  2 +-
 src/archbuild.in             | 12 ++++++------
 src/makerepropkg.in          |  6 ++++--
 src/offload-build.in         |  6 +++---
 5 files changed, 29 insertions(+), 18 deletions(-)

(limited to 'doc/man/archbuild.1.asciidoc')

diff --git a/Makefile b/Makefile
index 89251f4..96a76f5 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,7 @@ ARCHBUILD_LINKS = \
 COMPLETIONS = $(addprefix $(BUILDDIR)/,$(patsubst %.in,%,$(wildcard contrib/completion/*/*)))
 
 
-all: binprogs library completion man
+all: binprogs library conf completion man
 binprogs: $(BINPROGS)
 library: $(LIBRARY)
 completion: $(COMPLETIONS)
@@ -90,17 +90,24 @@ $(BUILDDIR)/doc/man/%: doc/man/%.asciidoc doc/asciidoc.conf doc/man/include/foot
 	@mkdir -p $(BUILDDIR)/doc/man
 	@a2x --no-xmllint --asciidoc-opts="-f doc/asciidoc.conf" -d manpage -f manpage --destination-dir=$(BUILDDIR)/doc/man -a pkgdatadir=$(DATADIR) $<
 
+conf:
+	@install -d $(BUILDDIR)/makepkg.conf.d $(BUILDDIR)/pacman.conf.d
+	@cp -a $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d
+	@cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d
+
 clean:
 	rm -rf $(BUILDDIR)
 
 install: all
 	install -dm0755 $(DESTDIR)$(PREFIX)/bin
 	install -dm0755 $(DESTDIR)$(DATADIR)/setarch-aliases.d
+	install -dm0755 $(DESTDIR)$(DATADIR)/makepkg.conf.d
+	install -dm0755 $(DESTDIR)$(DATADIR)/pacman.conf.d
 	install -m0755 ${BINPROGS} $(DESTDIR)$(PREFIX)/bin
 	install -dm0755 $(DESTDIR)$(DATADIR)/lib
 	cp -ra $(BUILDDIR)/lib/* $(DESTDIR)$(DATADIR)/lib
-	for conf in ${MAKEPKG_CONFIGS}; do install -Dm0644 $$conf $(DESTDIR)$(DATADIR)/makepkg-$${conf##*/}; done
-	for conf in ${PACMAN_CONFIGS}; do install -Dm0644 $$conf $(DESTDIR)$(DATADIR)/pacman-$${conf##*/}; done
+	for conf in $(notdir $(MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
+	for conf in $(notdir $(PACMAN_CONFIGS)); do install -Dm0644 $(BUILDDIR)/pacman.conf.d/$$conf $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
 	for a in ${SETARCH_ALIASES}; do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done
 	for l in ${COMMITPKG_LINKS}; do ln -sf commitpkg $(DESTDIR)$(PREFIX)/bin/$$l; done
 	for l in ${ARCHBUILD_LINKS}; do ln -sf archbuild $(DESTDIR)$(PREFIX)/bin/$$l; done
@@ -116,8 +123,8 @@ uninstall:
 	for f in $(notdir $(BINPROGS)); do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
 	for f in $(notdir $(LIBRARY)); do rm -f $(DESTDIR)$(DATADIR)/lib/$$f; done
 	rm -rf $(DESTDIR)$(DATADIR)/lib
-	for conf in ${MAKEPKG_CONFIGS}; do rm -f $(DESTDIR)$(DATADIR)/makepkg-$${conf##*/}; done
-	for conf in ${PACMAN_CONFIGS}; do rm -f $(DESTDIR)$(DATADIR)/pacman-$${conf##*/}; done
+	for conf in $(notdir $(MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
+	for conf in $(notdir $(PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
 	for f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done
 	for l in ${COMMITPKG_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
 	for l in ${ARCHBUILD_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
@@ -128,6 +135,8 @@ uninstall:
 	for manfile in $(notdir $(MANS)); do rm -f $(DESTDIR)$(MANDIR)/man$${manfile##*.}/$${manfile}; done;
 	rmdir --ignore-fail-on-non-empty \
 		$(DESTDIR)$(DATADIR)/setarch-aliases.d \
+		$(DESTDIR)$(DATADIR)/makepkg.conf.d \
+		$(DESTDIR)$(DATADIR)/pacman.conf.d \
 		$(DESTDIR)$(DATADIR)
 
 TODAY=$(shell date +"%Y%m%d")
@@ -146,5 +155,5 @@ upload:
 check: $(BINPROGS_SRC) $(LIBRARY_SRC) contrib/completion/bash/devtools.in config/makepkg/x86_64.conf contrib/makepkg/PKGBUILD.proto
 	shellcheck $^
 
-.PHONY: all binprogs library completion man clean install uninstall tag dist upload check
+.PHONY: all binprogs library completion conf man clean install uninstall tag dist upload check
 .DELETE_ON_ERROR:
diff --git a/doc/man/archbuild.1.asciidoc b/doc/man/archbuild.1.asciidoc
index 777e3f2..2a2d843 100644
--- a/doc/man/archbuild.1.asciidoc
+++ b/doc/man/archbuild.1.asciidoc
@@ -23,7 +23,7 @@ Description
 * staging-x86_64-build
 * testing-x86_64-build
 
-The symlink used to run it will be inspected by archbuild, to determine which target you want it to use. It will load the available pacman configuration from 'pacman-reponame-arch.conf' with a fallback to 'pacman-reponame.conf' from {pkgdatadir}. The makepkg configuration is loaded from 'makepkg-repo-arch.conf' with a fallback to 'makepkg-reponame.conf' from {pkgdatadir}.
+The symlink used to run it will be inspected by archbuild, to determine which target you want it to use. It will load the available pacman configuration from 'reponame-arch.conf' with a fallback to 'reponame.conf' from {pkgdatadir}/pacman.conf.d. The makepkg configuration is loaded from 'repo-arch.conf' with a fallback to 'reponame.conf' from {pkgdatadir}/makepkg.conf.d.
 
 It will also load the bind mount configuration from 'mount.d/arch' in {pkgdatadir}. The file format is that each line starting with ro and rw will be used, other lines will be ignored, and the rest of the used line is out/path:in/path preceded by a space as a separator. ro means it is a read-only mount, rw means a read-write mount.
 
diff --git a/src/archbuild.in b/src/archbuild.in
index 3367011..a7e4231 100644
--- a/src/archbuild.in
+++ b/src/archbuild.in
@@ -46,13 +46,13 @@ done
 chroots='/var/lib/archbuild'
 clean_first=false
 
-pacman_config="@pkgdatadir@/pacman-${repo}.conf"
-if [[ -f @pkgdatadir@/pacman-${repo}-${arch}.conf ]]; then
-    pacman_config="@pkgdatadir@/pacman-${repo}-${arch}.conf"
+pacman_config="@pkgdatadir@/pacman.conf.d/${repo}.conf"
+if [[ -f @pkgdatadir@/pacman.conf.d/${repo}-${arch}.conf ]]; then
+    pacman_config="@pkgdatadir@/pacman.conf.d/${repo}-${arch}.conf"
 fi
-makepkg_config="@pkgdatadir@/makepkg-${arch}.conf"
-if [[ -f @pkgdatadir@/makepkg-${repo}-${arch}.conf ]]; then
-    makepkg_config="@pkgdatadir@/makepkg-${repo}-${arch}.conf"
+makepkg_config="@pkgdatadir@/makepkg.conf.d/${arch}.conf"
+if [[ -f @pkgdatadir@/makepkg.conf.d/${repo}-${arch}.conf ]]; then
+    makepkg_config="@pkgdatadir@/makepkg.conf.d/${repo}-${arch}.conf"
 fi
 
 usage() {
diff --git a/src/makerepropkg.in b/src/makerepropkg.in
index e0a5b85..f310c69 100644
--- a/src/makerepropkg.in
+++ b/src/makerepropkg.in
@@ -97,7 +97,9 @@ get_makepkg_conf() {
         return 1
     fi
     msg2 "using makepkg.conf from ${fname}"
-    bsdtar xOqf "${buildtool_file/file:\/\//}" "usr/share/devtools/makepkg-${arch}.conf" > "${makepkg_conf}"
+	if ! bsdtar xOqf "${buildtool_file/file:\/\//}" "usr/share/devtools/makepkg.conf.d/${arch}.conf" > "${makepkg_conf}"; then
+		bsdtar xOqf "${buildtool_file/file:\/\//}" "usr/share/devtools/makepkg-${arch}.conf" > "${makepkg_conf}"
+	fi
     return 0
 }
 
@@ -228,7 +230,7 @@ elif [[ "${BUILDTOOL}" = devtools ]] && get_makepkg_conf "${BUILDTOOL}-${BUILDTO
 # fallback to current makepkg.conf
 else
     warning "Unknown buildtool (${BUILDTOOL}-${BUILDTOOLVER}), using fallback"
-    makepkg_conf=@pkgdatadir@/makepkg-${CARCH}.conf
+    makepkg_conf=@pkgdatadir@/makepkg.conf.d/${CARCH}.conf
 fi
 printf '%s\n' "${allpkgfiles[@]}" | mkarchroot -M "${makepkg_conf}" -U "${archroot_args[@]}" "${namespace}/root" - || exit 1
 
diff --git a/src/offload-build.in b/src/offload-build.in
index 9e9d71e..027bad3 100644
--- a/src/offload-build.in
+++ b/src/offload-build.in
@@ -102,9 +102,9 @@ mapfile -t files < <(
                 printf "\t%s\n" "$temp"/*
             } >&2 &&
             makepkg_user_config="${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" &&
-            makepkg_config="/usr/share/devtools/makepkg-'"${arch}"'.conf" &&
-            if [[ -f /usr/share/devtools/makepkg-'"${repo}"'-'"${arch}"'.conf ]]; then
-                makepkg_config="/usr/share/devtools/makepkg-'"${repo}"'-'"${arch}"'.conf"
+            makepkg_config="/usr/share/devtools/makepkg.conf.d/'"${arch}"'.conf" &&
+            if [[ -f /usr/share/devtools/makepkg.conf.d/'"${repo}"'-'"${arch}"'.conf ]]; then
+                makepkg_config="/usr/share/devtools/makepkg.conf.d/'"${repo}"'-'"${arch}"'.conf"
             fi &&
             makepkg --config <(cat "${makepkg_user_config}" "${makepkg_config}" 2>/dev/null) --packagelist &&
             printf "%s\n" "${temp}/PKGBUILD"
-- 
cgit v1.2.3-70-g09d2

