better ebuild

This commit is contained in:
Micha Glave 2011-05-30 11:44:15 +02:00
parent b0b2e3d8a8
commit 84293449c3
3 changed files with 111 additions and 68 deletions

View File

@ -1,59 +1,90 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=3
EAPI=2
JAVA_PKG_IUSE="doc source"
inherit java-pkg-2 java-ant-2 eutils
inherit eutils
DESCRIPTION="Artifactory Maven Artifact Server"
HOMEPAGE="http://www.jfrog.org/products.php"
SRC_URI="mirror://sourceforge/artifactory/${P}.zip"
SLOT="0"
SRC_URI="mirror://sourceforge/${PN}/${P}.zip"
KEYWORDS="~amd64 ~x86"
LICENSE="LGPL-3"
SLOT="0"
KEYWORDS="~amd64"
IUSE="mysql derby postgres"
IUSE=""
RDEPEND=">=virtual/jre-1.5"
DEPEND=">=virtual/jdk-1.5"
COMMON_DEP=""
RDEPEND=">=virtual/jre-1.5
${COMMON_DEP}"
DEPEND=">=virtual/jdk-1.5
app-arch/unzip
${COMMON_DEP}"
EANT_BUILD_TARGET=""
EANT_DOC_TARGET=""
INSTALL_DIR="/opt/artifactory"
WEBAPP_DIR="${INSTALL_DIR}/webapp"
IDIR=${D}$INSTALL_DIR
ARTIFACTORY_HOME=/var/lib/${PN}
ARTIFACTORY_INSTALL=/usr/share/${PN}
ARTIFACTORY_USER=artifact
pkg_setup() {
#enewgroup <name> [gid]
enewgroup artifact
#enewuser <user> [uid] [shell] [homedir] [groups] [params]
enewuser artifact -1 /bin/bash /opt/artifactory artifact
}
src_unpack() {
unpack ${A}
cd "${S}"
# epatch "${FILESDIR}/${P}.patch"
enewuser ${ARTIFACTORY_USER} -1 /bin/sh -1 artifact
}
src_install() {
use doc && java-pkg_dojavadoc build/javadoc
use source && java-pkg_dosrc src
dodir ${INSTALL_DIR}
cp -r ${PN}.jar bin clilib lib misc webapps ${D}/${INSTALL_DIR}
insinto /etc/${PN}
doins etc/*
newinitd ${FILESDIR}/artifactory.initd ${PN}
}
cd "${S}/bin"
ls | grep -E "\.(bat|exe)" | xargs rm || die "remove failed"
dodir ${ARTIFACTORY_HOME}
dodir ${ARTIFACTORY_INSTALL}
diropts -m775 -o ${ARTIFACTORY_USER} -g artifact
keepdir /etc/artifactory
keepdir /etc/artifactory/plugins/
keepdir ${ARTIFACTORY_HOME}/
keepdir ${ARTIFACTORY_HOME}/data/
keepdir ${ARTIFACTORY_HOME}/work/
keepdir ${ARTIFACTORY_HOME}/backup/
keepdir /var/log/artifactory/
keepdir /var/run/artifactory/
keepdir /var/tmp/artifactory/
dosym /var/log/artifactory ${ARTIFACTORY_HOME}/logs
dosym /etc/artifactory ${ARTIFACTORY_HOME}/etc
CONFIG=${D}/etc/artifactory/default
echo "#!/bin/bash" >> ${CONFIG}
echo "#export ARTIFACTORY_CONSOLE=/var/logs/artifactoy/consoleout.log" >> ${CONFIG}
echo "#export JAVA_HOME=$(java-config --jre-home)" >> ${CONFIG}
echo "export ARTIFACTORY_HOME=${ARTIFACTORY_HOME}" >> ${CONFIG}
echo "export ARTIFACTORY_USER=${ARTIFACTORY_USER}" >> ${CONFIG}
# remove unneeded configs
rm -r ${S}/etc/repo/*mssql
rm -r ${S}/etc/repo/oracle10
if ! use derby; then
rm -r ${S}/etc/repo/*derby
fi
if ! use mysql; then
rm -r ${S}/etc/repo/*mysql
fi
if ! use postgres; then
rm -r ${S}/etc/repo/*postgresql
fi
# remove windows-wrapper
rm ${S}/lib/wrapper*
sed -i -e "s:<SystemProperty name=\"artifactory.home\" default=\"..\"/>/webapps:${ARTIFACTORY_INSTALL}/webapps:" "${S}"/etc/jetty.xml
sed -i -e "s:<SystemProperty name=\"artifactory.home\" default=\"..\"/>/logs:/var/log/artifactory:" "${S}"/etc/jetty.xml
cd "${S}"
cp -pPR clilib lib webapps ${PN}.jar "${D}${ARTIFACTORY_INSTALL}" || die "failed to copy libs"
cp -pPR etc/* "${D}/etc/artifactory" || die "failed to copy conf"
sed -i -e "s:CLI_DIR=\`dirname \$0\`:CLI_DIR=${ARTIFACTORY_INSTALL}/clilib:" "${S}"/bin/artadmin
sed -i -e "s:\`dirname \"\$0\"\`\/\.\.:${ARTIFACTORY_INSTALL}:" "${S}"/bin/artifactory.sh
exeinto /usr/bin
doexe bin/artadmin
# doexe bin/artifactory.sh
newinitd "${FILESDIR}"/artifactory.initd artifactory
newconfd "${FILESDIR}"/artifactory.confd artifactory
elog "Artifact storage is /var/lib/artifact. Ensure that there is enough space."
elog "The default password for user 'admin' is 'password'."
}

View File

@ -0,0 +1,16 @@
# Port for jetty
ARTIFACTORY_PORT="8081"
# Home dir of artifactory
ARTIFACTORY_HOME="/var/lib/artifactory"
ARTIFACTORY_INSTALL="/usr/share/artifactory"
# Options for artifacory
ARTIFACTORY_OPTS=""
# User and group as which to run artifactory
#ARTIFACTORY_USER="artifact"
#ARTIFACTORY_GROUP="artifact"
JAVA_OPTIONS="-server -Xms1g -Xmx1g -Xss256k -XX:PermSize=128m -XX:MaxPermSize=128m -XX:NewSize=384m -XX:MaxNewSize=384m -Djava.awt.headless=true"

View File

@ -1,37 +1,33 @@
#!/sbin/runscript
# Installed in /etc/init.d/artifactory
export JAVA_HOME=/etc/java-config-2/current-system-vm
export PATH=$JAVA_HOME/bin:$PATH
DESC="Artifactory Maven Artifact Server"
NAME=artifactory
PIDFILE=/var/run/$NAME.pid
RUN_AS=artifact
ARTIFACTORY_HOME=/opt/artifact/artifactory
COMMAND=$ARTIFACTORY_HOME/bin/artifactory.init
ARGS="$ARTIFACTORY_HOME/etc/jetty.xml"
LOGFILE="$ARTIFACTORY_HOME/logs/consoleout.log"
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: $
depend() {
use net
after logger
need net
}
start() {
ebegin "Starting $DESC"
start-stop-daemon --start --verbose --background --make-pidfile --pidfile $PIDFILE\
--chdir $ARTIFACTORY_HOME --chuid $RUN_AS --exec $COMMAND -- $ARGS > $LOGFILE 2>&1
ebegin "Starting artifactory"
JAVACMD=$(java-config-2 -J)
JAVA_OPTIONS="$JAVA_OPTIONS -server -Djetty.home=$ARTIFACTORY_HOME -Dartifactory.home=$ARTIFACTORY_HOME -Dfile.encoding=UTF8"
LIB_DIR=$ARTIFACTORY_INSTALL/lib
CLASSPATH=$ARTIFACTORY_INSTALL/artifactory.jar
# Add all jars under the lib dir to the classpath
for i in $(ls $LIB_DIR/*.jar)
do
CLASSPATH="$CLASSPATH:$i"
done
start-stop-daemon --start --chuid ${ARTIFACTORY_USER:-artifact}:${ARTIFACTORY_GROUP:-artifact} \
-t --chdir "/var/lib/artifactory" \
--pidfile /var/run/artifactory.pid --make-pidfile --background \
--exec "$JAVACMD" -- $JAVA_OPTIONS -cp "$CLASSPATH" org.artifactory.standalone.main.Main
eend $?
}
stop() {
ebegin "Stopping $DESC"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
if [ -e $PIDFILE ]
then
rm $PIDFILE
fi
ebegin "Stopping artifactory"
start-stop-daemon --stop --quiet --pidfile /var/run/artifactory.pid
eend $?
}