diff --git a/sabayon-buildpackages b/sabayon-buildpackages index 7e14455..76b93c1 100755 --- a/sabayon-buildpackages +++ b/sabayon-buildpackages @@ -2,6 +2,7 @@ set -e ROOT="${ROOT:-$PWD}" DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/builder-amd64}" +. /sbin/sabayondevkit-functions.sh if [ $# -eq 0 ] then @@ -9,8 +10,6 @@ if [ $# -eq 0 ] exit 1 fi -if [ "$(id -u)" != "0" ]; then - echo "!! If you are not running the script as root, your user should be in the docker group to use it. (sudo gpasswd -a $USER docker) !!" -fi +check_docker_requirements docker run --rm -v "$ROOT"/portage_artifacts:/usr/portage/packages -ti $DOCKER_IMAGE $@ diff --git a/sabayon-createrepo b/sabayon-createrepo index 6b2eb21..2dc0371 100755 --- a/sabayon-createrepo +++ b/sabayon-createrepo @@ -1,5 +1,7 @@ #!/bin/bash set -e +. /sbin/sabayondevkit-functions.sh + ROOT="${ROOT:-$PWD}" entropysrv=$(mktemp) createrepo=$(mktemp) @@ -8,9 +10,7 @@ REPOSITORY_DESCRIPTION="${REPOSITORY_DESCRIPTION:-My Sabayon repository}" DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/builder-amd64}" EDITOR=cat -if [ "$(id -u)" != "0" ]; then - echo "!! If you are not running the script as root, your user should be in the docker group to use it. (sudo gpasswd -a $USER docker) !!" -fi +check_docker_requirements echo "Repository: $REPOSITORY_NAME" echo "Repository Description: $REPOSITORY_DESCRIPTION" diff --git a/sabayondevkit-functions.sh b/sabayondevkit-functions.sh index 6cef70d..e7c6be1 100644 --- a/sabayondevkit-functions.sh +++ b/sabayondevkit-functions.sh @@ -1,5 +1,12 @@ #!/bin/bash +check_docker_requirements(){ + if [ "$(id -u)" != "0" ]; then + groups | grep -q docker || echo "--> If you are not running the script as root, your user should be in the docker group to use it. (sudo gpasswd -a $USER docker)" + fi + ps aux | grep -q '[d]ocker' || echo "--> Be sure to have the docker daemon running (sudo systemctl start docker)" +} + build() { local SEARCH=$1 local EMERGE_DEFAULT_ARGS=${2:---accept-properties=-interactive --verbose --oneshot --nospinner --quiet-build=y --quiet-fail --fail-clean=y --complete-graph --buildpkg}