From: Junchun Guan Date: Fri, 14 Nov 2014 03:22:35 +0000 (+0800) Subject: Create jenkins user in preinstall step X-Git-Tag: 0.23.2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54b9076ffa0fafe0c1ec21f4b1763ac13ab0fe3b;p=tools%2Fgbs.git Create jenkins user in preinstall step Change-Id: Ief1d33a7c773eb6fb4367cd49542d03bfd72d385 Signed-off-by: Junchun Guan --- diff --git a/debian/control b/debian/control index 9bff4e4..8839b25 100644 --- a/debian/control +++ b/debian/control @@ -62,7 +62,6 @@ Description: GBS remotebuild API Package: gbs-jenkins-jobs Architecture: all Depends: ${misc:Depends}, - jenkins Description: GBS local full build jenkins jobs configurations. These jenkins jobs are used to build tizen source from scratch or only a part of packages, and create images finally. @@ -71,6 +70,5 @@ Architecture: all Depends: ${misc:Depends}, gbs, mic, - jenkins 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/.extra-repos b/packaging/.extra-repos deleted file mode 100644 index 8179835..0000000 --- a/packaging/.extra-repos +++ /dev/null @@ -1,10 +0,0 @@ -openSUSE-12.3:http://linux-ftp.fi.intel.com/repo/jenkins/opensuse-stable -openSUSE-13.1:http://linux-ftp.fi.intel.com/repo/jenkins/opensuse-stable -Fedora-19:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable -Fedora-20:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable -CentOS-6.6:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable -CentOS-7:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable -Debian-7.8:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable / -Ubuntu-12.04:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable / -Ubuntu-14.04:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable / -Ubuntu-14.10:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable / diff --git a/packaging/gbs.spec b/packaging/gbs.spec index f5f359f..14597d6 100644 --- a/packaging/gbs.spec +++ b/packaging/gbs.spec @@ -79,7 +79,7 @@ external software. %package jenkins-jobs Summary: GBS local full build jenkins jobs configurations. -Requires: jenkins +PreReq: /usr/sbin/groupadd /usr/sbin/useradd %description jenkins-jobs These jenkins jobs are used to build tizen source from scratch or @@ -87,9 +87,9 @@ 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 -Requires: jenkins %description jenkins-scripts These scripts are used by GBS local full build jenkins jobs. These @@ -103,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}