diff --git a/README.md b/README.md index b18275b..a57895a 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ This repository holds files and scripts to build a Sonatype Nexus .rpm package. # Ingredients -- Nexus OSS 1.9.2.3: from http://nexus.sonatype.com +- Nexus OSS Latest: from http://nexus.sonatype.com # Licenses - Nexus OSS: AGPL, Sonatype -- Scripts and Spec: AGPL, Jens Braeuer +- Scripts and Spec: AGPL, Jens Braeuer , Ilja Bobkevic # How to build - fetch Nexus OSS tar.gz: ./fetch-nexus-oos @@ -18,17 +18,14 @@ Nexus configuration has been customized, so Nexus behaves more like a "real" daemon. - Logfiles: /var/log/nexus -- Pidfile: /var/run/ +- Pidfile: /var/run - Conf: /etc/nexus - Init file: /etc/init.d/nexus # Current state -This has been tested on Scientific Linux 6.1. It should work on CentOS -and RHEL too. Currently Nexus is configured to run as root -user. While this not perfect, it is better than the manual -unzip/install steps . +This has been tested on Scientific Linux 6.1 and CentOS 6.4. +It should work on RHEL too. Have fun! -Jens diff --git a/SOURCES/nexus_initd.patch b/SOURCES/nexus_initd.patch new file mode 100644 index 0000000..b9d8bfc --- /dev/null +++ b/SOURCES/nexus_initd.patch @@ -0,0 +1,35 @@ +--- nexus-2.5.1-01/bin/nexus.orig 2013-06-28 19:26:12.000000000 +0000 ++++ nexus-2.5.1-01/bin/nexus 2013-07-08 13:48:29.951546295 +0000 +@@ -1,4 +1,21 @@ + #! /bin/sh ++# ++# nexu Startup script for Nexus OSS ++# ++# chkconfig: 2345 98 02 ++# description: Nexus OSS daemon ++ ++### BEGIN INIT INFO ++# Provides: nexus ++# Required-Start: $local_fs $network $remote_fs ++# Required-Stop: $local_fs $network $remote_fs ++# Should-Start: $named $time ++# Should-Stop: $named $time ++# Default-Start: 2 3 4 5 ++# Default-Stop: 0 1 6 ++# Short-Description: Startup script for the Nexus OSS ++# Description: Nexus OSS daemon ++### END INIT INFO + + # + # Copyright (c) 1999, 2006 Tanuki Software Inc. +@@ -289,7 +306,9 @@ + + # Still want to change users, recurse. This means that the user will only be + # prompted for a password once. Variables shifted by 1 +- su - $RUN_AS_USER -c "\"$REALPATH\" $2" ++ touch $PIDFILE ++ chown $RUN_AS_USER:$RUN_AS_GROUP $PIDFILE ++ sudo -u $RUN_AS_USER $REALPATH $2 + + # Now that we are the original user again, we may need to clean up the lock file. + if [ "X$LOCKPROP" != "X" ] diff --git a/SPECS/nexus-oss.spec b/SPECS/nexus-oss.spec index 987600d..a4e8330 100644 --- a/SPECS/nexus-oss.spec +++ b/SPECS/nexus-oss.spec @@ -1,14 +1,15 @@ Summary: Nexus manages software “artifacts” required for development, deployment, and provisioning. -Name: nexus-oss -Version: 1.9.2.3 -Release: 1 +Name: nexus +Version: %{version} +Release: %{release} License: AGPL Group: unknown URL: http://nexus.sonatype.org/ -Source0: %{name}-webapp-%{version}-bundle.tar.gz +Source0: %{name}-%{version}-%{release}-bundle.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root -Requires: jdk +BuildArch: noarch AutoReqProv: no +Patch0: nexus_initd.patch %define __os_install_post %{nil} @@ -16,7 +17,8 @@ AutoReqProv: no A package repository %prep -%setup -q -n %{name}-webapp-%{version} +%setup -q -n %{name}-%{version}-%{release} +%patch0 -p1 %build @@ -25,23 +27,20 @@ rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/share/%{name} mv * $RPM_BUILD_ROOT/usr/share/%{name} -arch=$(echo "%{_arch}" | sed -e 's/_/-/') mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ cd $RPM_BUILD_ROOT/etc/rc.d/init.d/ -ln -sf /usr/share/%{name}/bin/jsw/linux-$arch/nexus $RPM_BUILD_ROOT/etc/rc.d/init.d/ +ln -sf /usr/share/%{name}/bin/nexus $RPM_BUILD_ROOT/etc/rc.d/init.d/ mkdir -p $RPM_BUILD_ROOT/etc/ ln -sf /usr/share/%{name}/conf $RPM_BUILD_ROOT/etc/nexus # patch work dir -sed -i -e 's#nexus-work=.*#nexus-work=/var/lib/nexus/#g' $RPM_BUILD_ROOT/usr/share/%{name}/conf/plexus.properties +sed -i -e 's#nexus-work=.*#nexus-work=/var/lib/nexus/#g' $RPM_BUILD_ROOT/usr/share/%{name}/conf/nexus.properties mkdir -p $RPM_BUILD_ROOT/var/lib/nexus -# patch tcp port -sed -i -e 's#application-port=.*#application-port=80#g' $RPM_BUILD_ROOT/usr/share/%{name}/conf/plexus.properties - # patch pid dir -sed -i -e 's#PIDDIR=.*#PIDDIR=/var/run/#' $RPM_BUILD_ROOT/usr/share/%{name}/bin/jsw/linux-$arch/nexus +sed -i -e 's#PIDDIR=.*#PIDDIR=/var/run#' $RPM_BUILD_ROOT/usr/share/%{name}/bin/nexus +sed -i -e 's/#RUN_AS_USER=.*/RUN_AS_USER=nexus/' $RPM_BUILD_ROOT/usr/share/%{name}/bin/nexus # patch logfile mkdir -p $RPM_BUILD_ROOT/var/log/nexus @@ -51,7 +50,7 @@ sed -i -e 's#wrapper.logfile=.*#wrapper.logfile=/var/log/nexus/nexus.log#' $RPM_ rm -rf $RPM_BUILD_ROOT %files -%defattr(-,root,root,-) +%defattr(-,nexus,nexus,-) %doc /usr/share/%{name} /etc/rc.d/init.d/nexus @@ -59,7 +58,25 @@ rm -rf $RPM_BUILD_ROOT /var/lib/nexus /var/log/nexus +%pre +getent group nexus >/dev/null || groupadd -r nexus +getent passwd nexus >/dev/null || \ + useradd -r -g nexus -d /usr/share/%{name} -s /sbin/nologin \ + -c "Nexus OSS" nexus + +%post +service nexus start + +%preun +service nexus stop + %changelog +* Mon Jul 8 2013 Ilja Bobkevic +- Addopt spec for external verison and release definition +- Use nexus credentials for the daemon +- Patch init.d script with proper headers and to use sudo instead su +* Thu Jul 13 2012 Mike Champion - 2.0.6 +- Upgrade to 2.0.6 * Thu Dec 22 2011 Jens Braeuer - 1.9.2.3-1 - Initial packaging. - For now nexus will run as root and listen to port 80 diff --git a/fetch-nexus-oss b/fetch-nexus-oss index d5a81d1..ad050f6 100755 --- a/fetch-nexus-oss +++ b/fetch-nexus-oss @@ -1,10 +1,10 @@ #! /bin/bash readonly BASEDIR="$(dirname $(readlink -f "$0"))" -readonly BASEURL="http://nexus.sonatype.org/downloads" -readonly BINARY="nexus-oss-webapp-1.9.2.3-bundle.tar.gz" +readonly BASEURL="http://www.sonatype.org/downloads" +readonly BINARY="nexus-latest-bundle.tar.gz" set -e -mkdir -p "${BASEDIR}/SOURCES/" cd "${BASEDIR}/SOURCES/" wget "${BASEURL}/${BINARY}" + diff --git a/rpm b/rpm index 07c9a63..d2631c0 100755 --- a/rpm +++ b/rpm @@ -13,8 +13,17 @@ fi readonly SPEC="$(readlink -f "$1")" readonly BASEDIR="$(dirname $(readlink -f "$0"))" +# Get downloaded file name +stringZ=`ls ${BASEDIR}/SOURCES/nexus-*-bundle.tar.gz` +# Parse version code +verrel=`expr match "$stringZ" '.*nexus-\(.*\)-bundle\.tar\.gz'` +# Sepearate version from release digits +IFS='-' read -a verarr <<< "$verrel" + mkdir -p ${BASEDIR}/{BUILD,BUILDROOT,RPMS} rpmbuild --verbose \ --define "_topdir ${BASEDIR}" \ --define "_rpmdir ${BASEDIR}/RPMS" \ + --define "version ${verarr[0]}" \ + --define "release ${verarr[1]}" \ -bb "${SPEC}"