diff options
-rw-r--r-- | dev-util/artifactory-bin/Manifest | 2 | ||||
-rw-r--r-- | dev-util/artifactory-bin/artifactory-bin-5.3.2.ebuild | 110 | ||||
-rw-r--r-- | dev-util/artifactory-bin/artifactory-bin-5.4.4.ebuild | 110 | ||||
-rw-r--r-- | dev-util/artifactory-bin/files/initd-r3 | 165 |
4 files changed, 387 insertions, 0 deletions
diff --git a/dev-util/artifactory-bin/Manifest b/dev-util/artifactory-bin/Manifest index 30cf3df5ccd4..66dd70d677de 100644 --- a/dev-util/artifactory-bin/Manifest +++ b/dev-util/artifactory-bin/Manifest @@ -1 +1,3 @@ DIST artifactory-4.16.0.zip 41455447 SHA256 f5711536cdf0a597799e01c570bbd38e6f5f3ffb6935cde21d38119be6592f16 SHA512 e861b66ed7586ba881267312462584fd9037e2b72021e930a52489ae718ca2449c7997278cb26cb3dead774f16d74cf285c8ce2fca0c085e7edb444f71deaa14 WHIRLPOOL 01a60743fe85909d06f69ef4bda94a2cfb37e847ee481ee025075c0b586df11118566f7f99352a7808147eec51fc1bacb649853baa97a90253ab89d3b92279a5 +DIST artifactory-5.3.2.zip 45729254 SHA256 e086a067ad191859cd0a0c996313cf5c7386e6ee892b55697c27b0f42ae2bc14 SHA512 60fbbed97c9915ed4a7627a3b893fa6c5bcec695932415d3102b9788ba6182c8cef937ad48639d4398a682ab2f517771c3dcda9306842e4202bbd45ab4768f1d WHIRLPOOL bf3b31f7a1989ddb90b03396172eeac37dc5230c4bbcc99b54c66326e5d52e26dbb83003824647c6e89926049c31b9644212aee183fa24db7475831dda0ceaec +DIST artifactory-5.4.4.zip 76841935 SHA256 bf2198a0fefe818fe412579dd008f2a24dc065780da4c9657a923363c70a0a3d SHA512 f949e4c2ecaaf4581bc2e96058403684cab09f10b0bec512eda9b65bb41577a792b08d05f7a16e0e7f1614567dc9b0d1d59bb3c6ad6a4dafeb0c054a3add09a8 WHIRLPOOL c0c27a0ce5b0035d9266b6af4316044cf1aed361dbe0f7aaf66844015a70678e92bb0c6a13330ffd8f5a05903f66a82b48995605c272ba3950a19aa47d1fc85d diff --git a/dev-util/artifactory-bin/artifactory-bin-5.3.2.ebuild b/dev-util/artifactory-bin/artifactory-bin-5.3.2.ebuild new file mode 100644 index 000000000000..242019ded03b --- /dev/null +++ b/dev-util/artifactory-bin/artifactory-bin-5.3.2.ebuild @@ -0,0 +1,110 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# Using a binary ebuild until a source ebuild is doable. +# This was previously blocked by two major bugs upstream: +# A lack of documented build instructions - https://www.jfrog.com/jira/browse/RTFACT-8960 +# A lack of source releases - https://www.jfrog.com/jira/browse/RTFACT-8961 +# Upstream now releases source and instructions (yay!), but most of artifactory's +# dependencies are not in portage yet. + +EAPI=6 + +inherit user + +MY_P="${P/-bin}" +MY_PN="${PN/-bin}" +MY_PV="${PV/-bin}" + +DESCRIPTION="The world's most advanced repository manager for maven" +HOMEPAGE="http://www.jfrog.org/products.php" +SRC_URI="https://bintray.com/artifact/download/jfrog/artifactory/jfrog-artifactory-oss-${MY_PV}.zip -> ${MY_P}.zip" + +LICENSE="AGPL-3+" +SLOT="0" +KEYWORDS="~x86 ~amd64" +IUSE="ssl" + +RDEPEND=">=virtual/jre-1.8" +DEPEND=">=virtual/jdk-1.8 + app-arch/unzip" + +S="${WORKDIR}/${MY_PN}-oss-${MY_PV}" + +pkg_setup() { + enewgroup artifactory + enewuser artifactory -1 /bin/sh -1 artifactory +} + +limitsdfile=40-${MY_PN}.conf + +print_limitsdfile() { + printf "# Start of ${limitsdfile} from ${P}\n\n" + printf "@${MY_PN}\t-\tnofile\t32000\n" + printf "\n# End of ${limitsdfile} from ${P}\n" +} + +src_prepare() { + default + + if use ssl ; then + cp "${FILESDIR}/artifactory.xml" tomcat/conf/Catalina/localhost/artifactory.xml || die + cp "${FILESDIR}/server.xml" tomcat/conf/server.xml || die + fi + + # Reverse https://www.jfrog.com/jira/browse/RTFACT-7123 + sed -i -e "s%artifactory.repo.global.disabled=true%artifactory.repo.global.disabled=false%g;" \ + etc/artifactory.system.properties || die + + # See FIXME in src_install(), this can probably go away, + # but catalina.sh may need to be fixed for that: + sed -i -e "s%/etc/opt/jfrog/artifactory/default%/etc/conf.d/${MY_PN}%g;" \ + misc/service/setenv.sh || die + + einfo "Generating ${limitsdfile}" + print_limitsdfile > "${S}/${limitsdfile}" +} + +src_install() { + local ARTIFACTORY_HOME="/opt/artifactory" + local TOMCAT_HOME="${ARTIFACTORY_HOME}/tomcat" + + insinto ${ARTIFACTORY_HOME} + doins -r etc logs misc tomcat webapps + + dodir /etc/opt/jfrog + dosym ${ARTIFACTORY_HOME}/etc /etc/opt/jfrog/artifactory + + dosym ${ARTIFACTORY_HOME}/logs /var/log/artifactory + + exeinto ${ARTIFACTORY_HOME}/bin + doexe bin/* + + # FIXME: this is called by catalina.sh (it echoes the variables before starting + # artifactory, as well as makes sure log dir, etc. exists). Those directories + # could probably be moved to the ebuild and the script removed from catalina.sh + # without consequence (and quieter starts). Would need to check if CATALINA_* + # variables are actually used anywhere (from reading code don't appear to be + # actually needed) + exeinto ${TOMCAT_HOME}/bin + doexe misc/service/setenv.sh + doexe tomcat/bin/* + + keepdir ${ARTIFACTORY_HOME}/backup + keepdir ${ARTIFACTORY_HOME}/data + keepdir ${ARTIFACTORY_HOME}/run + keepdir ${ARTIFACTORY_HOME}/work + keepdir ${TOMCAT_HOME}/logs/catalina + keepdir ${TOMCAT_HOME}/temp + keepdir ${TOMCAT_HOME}/work + keepdir /var/opt/jfrog/artifactory/run + + newconfd "${FILESDIR}/confd" ${MY_PN} + newinitd "${FILESDIR}/initd-r3" ${MY_PN} + + fowners -R artifactory:artifactory ${ARTIFACTORY_HOME} + fperms -R u+w ${TOMCAT_HOME}/work + + insinto /etc/security/limits.d + doins "${S}/${limitsdfile}" +} diff --git a/dev-util/artifactory-bin/artifactory-bin-5.4.4.ebuild b/dev-util/artifactory-bin/artifactory-bin-5.4.4.ebuild new file mode 100644 index 000000000000..242019ded03b --- /dev/null +++ b/dev-util/artifactory-bin/artifactory-bin-5.4.4.ebuild @@ -0,0 +1,110 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# Using a binary ebuild until a source ebuild is doable. +# This was previously blocked by two major bugs upstream: +# A lack of documented build instructions - https://www.jfrog.com/jira/browse/RTFACT-8960 +# A lack of source releases - https://www.jfrog.com/jira/browse/RTFACT-8961 +# Upstream now releases source and instructions (yay!), but most of artifactory's +# dependencies are not in portage yet. + +EAPI=6 + +inherit user + +MY_P="${P/-bin}" +MY_PN="${PN/-bin}" +MY_PV="${PV/-bin}" + +DESCRIPTION="The world's most advanced repository manager for maven" +HOMEPAGE="http://www.jfrog.org/products.php" +SRC_URI="https://bintray.com/artifact/download/jfrog/artifactory/jfrog-artifactory-oss-${MY_PV}.zip -> ${MY_P}.zip" + +LICENSE="AGPL-3+" +SLOT="0" +KEYWORDS="~x86 ~amd64" +IUSE="ssl" + +RDEPEND=">=virtual/jre-1.8" +DEPEND=">=virtual/jdk-1.8 + app-arch/unzip" + +S="${WORKDIR}/${MY_PN}-oss-${MY_PV}" + +pkg_setup() { + enewgroup artifactory + enewuser artifactory -1 /bin/sh -1 artifactory +} + +limitsdfile=40-${MY_PN}.conf + +print_limitsdfile() { + printf "# Start of ${limitsdfile} from ${P}\n\n" + printf "@${MY_PN}\t-\tnofile\t32000\n" + printf "\n# End of ${limitsdfile} from ${P}\n" +} + +src_prepare() { + default + + if use ssl ; then + cp "${FILESDIR}/artifactory.xml" tomcat/conf/Catalina/localhost/artifactory.xml || die + cp "${FILESDIR}/server.xml" tomcat/conf/server.xml || die + fi + + # Reverse https://www.jfrog.com/jira/browse/RTFACT-7123 + sed -i -e "s%artifactory.repo.global.disabled=true%artifactory.repo.global.disabled=false%g;" \ + etc/artifactory.system.properties || die + + # See FIXME in src_install(), this can probably go away, + # but catalina.sh may need to be fixed for that: + sed -i -e "s%/etc/opt/jfrog/artifactory/default%/etc/conf.d/${MY_PN}%g;" \ + misc/service/setenv.sh || die + + einfo "Generating ${limitsdfile}" + print_limitsdfile > "${S}/${limitsdfile}" +} + +src_install() { + local ARTIFACTORY_HOME="/opt/artifactory" + local TOMCAT_HOME="${ARTIFACTORY_HOME}/tomcat" + + insinto ${ARTIFACTORY_HOME} + doins -r etc logs misc tomcat webapps + + dodir /etc/opt/jfrog + dosym ${ARTIFACTORY_HOME}/etc /etc/opt/jfrog/artifactory + + dosym ${ARTIFACTORY_HOME}/logs /var/log/artifactory + + exeinto ${ARTIFACTORY_HOME}/bin + doexe bin/* + + # FIXME: this is called by catalina.sh (it echoes the variables before starting + # artifactory, as well as makes sure log dir, etc. exists). Those directories + # could probably be moved to the ebuild and the script removed from catalina.sh + # without consequence (and quieter starts). Would need to check if CATALINA_* + # variables are actually used anywhere (from reading code don't appear to be + # actually needed) + exeinto ${TOMCAT_HOME}/bin + doexe misc/service/setenv.sh + doexe tomcat/bin/* + + keepdir ${ARTIFACTORY_HOME}/backup + keepdir ${ARTIFACTORY_HOME}/data + keepdir ${ARTIFACTORY_HOME}/run + keepdir ${ARTIFACTORY_HOME}/work + keepdir ${TOMCAT_HOME}/logs/catalina + keepdir ${TOMCAT_HOME}/temp + keepdir ${TOMCAT_HOME}/work + keepdir /var/opt/jfrog/artifactory/run + + newconfd "${FILESDIR}/confd" ${MY_PN} + newinitd "${FILESDIR}/initd-r3" ${MY_PN} + + fowners -R artifactory:artifactory ${ARTIFACTORY_HOME} + fperms -R u+w ${TOMCAT_HOME}/work + + insinto /etc/security/limits.d + doins "${S}/${limitsdfile}" +} diff --git a/dev-util/artifactory-bin/files/initd-r3 b/dev-util/artifactory-bin/files/initd-r3 new file mode 100644 index 000000000000..5a9a6e214efb --- /dev/null +++ b/dev-util/artifactory-bin/files/initd-r3 @@ -0,0 +1,165 @@ +#!/sbin/openrc-run + +description="Manages the services needed to run Artifactory on a dedicated Tomcat" +command="/opt/artifactory/tomcat/bin/catalina.sh" +pidfile="/opt/artifactory/run/artifactory.pid" +procname="artifactory" +user=${ARTIFACTORY_USER:-artifactory} +group=${group:-artifactory} + +# Artifactory can be very slow to start, and without locking, +# restarting via runscript is very error prone +CATALINA_LOCK_FILE="$(dirname $pidfile)/lock" + +CATALINA_MGMT_PORT=8015 +REQUIRED_JAVA_VERSION="1.8" +START_TIMEOUT=300 + +# Helper functions: +is_mgmt_port_used() { + mgmt_port_used=$(netstat -vatn | grep LISTEN | grep $CATALINA_MGMT_PORT | wc -l) +} + +get_pid_info() { + pidValue="" + javaPs="" + if [ -e "$pidfile" ]; then + pidValue=$(cat $pidfile) + if [ -n "$pidValue" ]; then + javaPs="$(ps -p $pidValue | grep java)" + fi + fi +} + +depend() { + need net nginx + use dns logger netmount +} + +start_pre() { + if [ -z "$ARTIFACTORY_HOME" ] || [ ! -d "$ARTIFACTORY_HOME" ]; then + eerror "Artifactory home folder not defined or does not exists at $ARTIFACTORY_HOME" + return 1 + fi + + if [ -z "$pidfile" ]; then + eerror "Artifactory pid destination pidfile was not set!" + return 1 + fi + + if [ -z "$TOMCAT_HOME" ] || [ ! -d "$TOMCAT_HOME" ]; then + eerror "Tomcat Artifactory folder not defined or does not exists at $TOMCAT_HOME" + return 1 + fi + + if [ -z "$ARTIFACTORY_USER" ]; then + ARTIFACTORY_USER=$user + fi + + current_open_file_limit=$(su -l $ARTIFACTORY_USER -c "ulimit -n") + desired_open_file_limit=32000 + if [ "$current_open_file_limit" != "unlimited" ] && [ $current_open_file_limit -lt $desired_open_file_limit ]; then + eerror "Maximum number of open files ($current_open_file_limit) is too small!" + eerror "You should add:" + eerror "artifactory soft nofile $desired_open_file_limit" + eerror "artifactory hard nofile $desired_open_file_limit" + eerror "to your /etc/security/limits.conf file." + return 1 + fi + + current_max_process_limit=$(su -l $ARTIFACTORY_USER -c "ulimit -u") + desired_max_process_limit=1024 + if [ "$current_max_process_limit" != "unlimited" ] && [ $current_max_process_limit -lt $desired_max_process_limit ]; then + eerror "Number of processes $current_max_process_limit is too small!" + eerror "You should add:" + eerror "artifactory soft nproc $desired_max_process_limit" + eerror "artifactory hard nproc $desired_max_process_limit" + eerror "to your /etc/security/limits.conf file." + return 1 + fi + + if [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then + einfo "Found java executable in $JAVA_HOME" + _java="$JAVA_HOME/bin/java" + elif command -v java > dev/null 2>&1 ; then + _java=java + else + eerror "No Java Runtime Environment (jre) found! At least java-$REQUIRED_JAVA_VERSION is required." + return 1 + fi + if [ "$_java" ]; then + java_version=$($_java -version 2>&1 | grep 'version' | cut -d ' ' -f3 | tr -d \") + java_major=$(echo $java_version | cut -d . -f1-2) + if [ "$java_major" != "$REQUIRED_JAVA_VERSION" ] ; then + eerror "Java version $java_version is too old, java-$REQUIRED_JAVA_VERSION is required." + return 1 + fi + fi +} + +# We have to pass start/stop through to catalina.sh, which doesn't understand restart (and restart can't be overridden in OpenRC): +start() { + get_pid_info + is_mgmt_port_used + if [ $mgmt_port_used -ne 0 ] || [ -n "$javaPs" ]; then + eerror "$RC_SERVICE already started!" + return 1 + else + ebegin "Starting $RC_SERVICE" + start-stop-daemon --exec $command --pidfile $pidfile --user $user:$group --wait $START_TIMEOUT start + RETVAL=$? + eend $RETVAL "start-stop-daemon failed to start $RC_SERVICE" + fi + + + is_mgmt_port_used + seconds=1 + while [ $mgmt_port_used -eq 0 ] && [ $seconds -lt $START_TIMEOUT ]; do + sleep 1 + seconds=$((seconds+1)) + is_mgmt_port_used + done + if [ $mgmt_port_used -eq 0 ]; then + eerror "$RC_SERVICE did not start in $START_TIMEOUT seconds!" + return 1 + elif [ $mgmt_port_used -eq 1 ]; then + einfo "$RC_SERVICE started" + [ $RETVAL=0 ] && touch $CATALINA_LOCK_FILE + else + eerror "Got unexpected result when checking port $CATALINA_MGMT_PORT" + return 1 + fi + return $RETVAL +} + +stop() { + ebegin "Stopping $RC_SERVICE" + start-stop-daemon --stop --pidfile $pidfile --retry $START_TIMEOUT stop + RETVAL=$? + eend $RETVAL "Failed to stop $RC_SERVICE!" + + [ $RETVAL=0 ] && rm -f "$CATALINA_LOCK_FILE" "$pidfile" + return $RETVAL +} + +status() { + is_mgmt_port_used + if [ $mgmt_port_used -eq 0 ]; then + if [ -e "$pidfile" ]; then + eerror "$RC_SERVICE stopped but the pid file $pidfile still exists!" + RETVAL=1 + else + if [ -e "$CATALINA_LOCK_FILE" ]; then + eerror "$RC_SERVICE is stopped but the lock file $CATALINA_LOCK_FILE still exists!" + RETVAL=2 + else + eerror "$RC_SERVICE is stopped" + RETVAL=3 + fi + fi + else + einfo "$RC_SERVICE is running" + RETVAL=0 + fi + return $RETVAL +} |