[pacman-key] Support for new gpg kbx files in imports.

Message ID 0800a1d9-cfa9-e133-7162-04ec9606afbf@gmail.com
State Under Review
Headers show
Series [pacman-key] Support for new gpg kbx files in imports. | expand

Commit Message

Masato TOYOSHIMA Dec. 2, 2022, 4:21 p.m. UTC
Hello.

Support for new gpg kbx files in imports.
Allow Import for both types pubring.gpg and pubring.kbx.

```
++				ret=1
++			fi
++		fi
+ 		fi
+ 	done
+ 	if (( ret )); then
```

Patch

diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index 913f2c3..5910b47 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -453,14 +453,21 @@  import() {
 	local importdir
 	local ret=0
 	for importdir in "$@"; do
+		if [[ ! -f "${importdir}/pubring.gpg" && ! -f "${importdir}/pubring.kbx" ]]; then
+			error "$(gettext "Both file %s does not exist and could not be imported.")" "${importdir}/pubring.gpg and ${importdir}/pubring.kbx"
+			ret=1
 		if [[ -f "${importdir}/pubring.gpg" ]]; then
 			if ! "${GPG_PACMAN[@]}" --quiet --batch --import "${importdir}/pubring.gpg" ; then
 				error "$(gettext "%s could not be imported.")" "${importdir}/pubring.gpg"
 				ret=1
 			fi
-		else
-			error "$(gettext "File %s does not exist and could not be imported.")" "${importdir}/pubring.gpg"
-			ret=1
+		fi
+		if [[ -f "${importdir}/pubring.kbx" ]]; then
+			if ! "${GPG_PACMAN[@]}" --quiet --batch --homedir "${importdir}" --keyring pubring.kbx --export | "${GPG_PACMAN[@]}" --import - ; then
+				error "$(gettext "%s could not be imported.")" "${importdir}/pubring.kbx"
+				ret=1
+			fi
+		fi
 		fi
 	done
 	if (( ret )); then