Subject: [PATCH] gnupg-scdaemon: fix pre-install group add

From: Hunter Blanks <[email-masked]>
Date: Sat, 25 Jul 2020 09:29:55 -0700

gnupg-scdaemon fails if /etc/group already contains the group
gnupg. Fix this by checking first if the group exists before
trying to add it.

Example of the bug follows:
  # apk add gnupg-scdaemon
  ...
  Executing gnupg-scdaemon-2.2.20-r0.pre-install
  OK: 26 MiB in 44 packages
  # grep gnupg /etc/group
  gnupg:x:101:
  # apk del gnupg-scdaemon
  ...
  # apk add gnupg-scdaemon
  ...
  Executing gnupg-scdaemon-2.2.20-r0.pre-install
  ERROR: gnupg-scdaemon-2.2.20-r0.pre-install: script exited with error 1
  1 error; 26 MiB in 44 packages
  # addgroup -S gnupg
  addgroup: group 'gnupg' in use
---
 main/gnupg/gnupg-scdaemon.pre-install | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/main/gnupg/gnupg-scdaemon.pre-install b/main/gnupg/gnupg-scdaemon.pre-install
index 8d8262ceea..9e6e5ed01d 100644
--- a/main/gnupg/gnupg-scdaemon.pre-install
+++ b/main/gnupg/gnupg-scdaemon.pre-install
@@ -1,2 +1,5 @@
 #!/bin/sh
-addgroup -S gnupg 2> /dev/null
+if ! grep -q -E '^gnupg:' /etc/group
+then
+    addgroup -S gnupg 2> /dev/null
+fi
-- 
2.25.1