]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Fixed adding vagrant user to abuild group on Alpine
authormanu <manu@isc.org>
Tue, 20 Oct 2020 12:58:03 +0000 (14:58 +0200)
committerEmanuel Petr <manu@isc.org>
Tue, 20 Oct 2020 14:12:34 +0000 (14:12 +0000)
hammer.py

index 5671437212121ed9753520d314dc0432d8a14aa9..8db46b7d0d595b9e9c39451bca67aeeade8b9b8d 100755 (executable)
--- a/hammer.py
+++ b/hammer.py
@@ -23,6 +23,8 @@ import textwrap
 import functools
 import subprocess
 import multiprocessing
+import grp
+import pwd
 try:
     import urllib.request
 except:
@@ -1400,8 +1402,6 @@ def prepare_system_local(features, check_times):
     # prepare alpine
     elif system == 'alpine':
 
-        execute('sudo adduser vagrant abuild')
-
         packages = ['gcc', 'g++', 'make', 'autoconf', 'automake', 'libtool', 'openssl-dev',
                     'boost-libs', 'boost-dev']
 
@@ -1434,6 +1434,15 @@ def prepare_system_local(features, check_times):
         execute('sudo apk add log4cplus log4cplus-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted',
                 env=env, timeout=60, check_times=check_times)
 
+        # check for existence of 'vagrant' user and 'abuild' group before adding him to the group
+        try:
+            pwd.getpwnam('vagrant')
+            grp.getgrnam('abuild')
+        except KeyError:
+            log.info("Can't add 'vagrant' user to 'abuild' group. Vagrant or abuild does not exist.")
+        else:
+            execute('sudo adduser vagrant abuild')
+
     else:
         raise NotImplementedError('no implementation for %s' % system)