From cd87ea4c4663212d7fc54dd4bbb17816ab99811d Mon Sep 17 00:00:00 2001 From: Junchun Guan Date: Fri, 14 Nov 2014 11:22:35 +0800 Subject: [PATCH] Create jenkins user in preinstall step Change-Id: Ief1d33a7c773eb6fb4367cd49542d03bfd72d385 Signed-off-by: Junchun Guan Conflicts: debian/control packaging/gbs.spec --- debian/control | 1 + debian/gbs-jenkins-jobs.preinst | 15 +++++++++++++++ debian/gbs-jenkins-scripts.preinst | 15 +++++++++++++++ packaging/gbs.spec | 7 +++++++ 4 files changed, 38 insertions(+) create mode 100644 debian/gbs-jenkins-jobs.preinst create mode 100644 debian/gbs-jenkins-scripts.preinst diff --git a/debian/control b/debian/control index 0615d64..4de2edf 100644 --- a/debian/control +++ b/debian/control @@ -70,5 +70,6 @@ Architecture: all Depends: ${misc:Depends}, gbs, mic + mic, Description: Jenkins scripts used by gbs-jenkins-job These scripts are used by GBS local full build jenkins jobs. These scripts should be installed on Jenkins slave nodes. diff --git a/debian/gbs-jenkins-jobs.preinst b/debian/gbs-jenkins-jobs.preinst new file mode 100644 index 0000000..e4928b1 --- /dev/null +++ b/debian/gbs-jenkins-jobs.preinst @@ -0,0 +1,15 @@ +: ${JENKINS_USER:=jenkins} +: ${JENKINS_GROUP:=jenkins} + +# Create jenkins group and user if they don't exist. +# sometimes tools that users want Jenkins to run need a shell, +# so use /bin/bash. See JENKINS-4830 +if ! getent group "$JENKINS_GROUP" > /dev/null; then + addgroup --system --quiet "$JENKINS_GROUP" +fi +if ! id "$JENKINS_USER" >/dev/null 2>&1 ; then + adduser --system --quiet --home /var/lib/jenkins --no-create-home \ + --ingroup "$JENKINS_GROUP" --disabled-password --shell /bin/bash \ + --gecos 'Jenkins' \ + "$JENKINS_USER" +fi diff --git a/debian/gbs-jenkins-scripts.preinst b/debian/gbs-jenkins-scripts.preinst new file mode 100644 index 0000000..e4928b1 --- /dev/null +++ b/debian/gbs-jenkins-scripts.preinst @@ -0,0 +1,15 @@ +: ${JENKINS_USER:=jenkins} +: ${JENKINS_GROUP:=jenkins} + +# Create jenkins group and user if they don't exist. +# sometimes tools that users want Jenkins to run need a shell, +# so use /bin/bash. See JENKINS-4830 +if ! getent group "$JENKINS_GROUP" > /dev/null; then + addgroup --system --quiet "$JENKINS_GROUP" +fi +if ! id "$JENKINS_USER" >/dev/null 2>&1 ; then + adduser --system --quiet --home /var/lib/jenkins --no-create-home \ + --ingroup "$JENKINS_GROUP" --disabled-password --shell /bin/bash \ + --gecos 'Jenkins' \ + "$JENKINS_USER" +fi diff --git a/packaging/gbs.spec b/packaging/gbs.spec index 7612f81..0814e50 100644 --- a/packaging/gbs.spec +++ b/packaging/gbs.spec @@ -79,6 +79,7 @@ external software. %package jenkins-jobs Summary: GBS local full build jenkins jobs configurations. +PreReq: /usr/sbin/groupadd /usr/sbin/useradd %description jenkins-jobs These jenkins jobs are used to build tizen source from scratch or @@ -86,6 +87,7 @@ only a part of packages, and create images finally. %package jenkins-scripts Summary: Jenkins scripts used by gbs-jenkins-job +PreReq: /usr/sbin/groupadd /usr/sbin/useradd Requires: gbs Requires: mic @@ -101,6 +103,11 @@ scripts should be installed on Jenkins slave nodes. %{__python} setup.py build make man +%pre +/usr/bin/getent group jenkins >/dev/null || /usr/sbin/groupadd -r jenkins &>/dev/null || : +/usr/bin/getent passwd jenkins >/dev/null || /usr/sbin/useradd -g jenkins -s /bin/bash -r -c "Jenkins Continuous Build server" \ + -d "%{workdir}" jenkins &>/dev/null || : + %install %{__python} setup.py install --prefix=%{_prefix} --root=%{buildroot} -- 2.7.4