From 17287df339b0f64c1a9fddb0f8ec28b458295915 Mon Sep 17 00:00:00 2001 From: nyyu Date: Sat, 13 Jan 2018 18:09:13 +0100 Subject: [PATCH] sonarqube --- sonarqube/PKGBUILD | 72 ++++++++++++++++++++++++++++++++ sonarqube/sonarqube-tmpfile.conf | 4 ++ sonarqube/sonarqube-user.conf | 1 + sonarqube/sonarqube.install | 22 ++++++++++ sonarqube/sonarqube.service | 20 +++++++++ 5 files changed, 119 insertions(+) create mode 100644 sonarqube/PKGBUILD create mode 100644 sonarqube/sonarqube-tmpfile.conf create mode 100644 sonarqube/sonarqube-user.conf create mode 100644 sonarqube/sonarqube.install create mode 100644 sonarqube/sonarqube.service diff --git a/sonarqube/PKGBUILD b/sonarqube/PKGBUILD new file mode 100644 index 0000000..6ccf56d --- /dev/null +++ b/sonarqube/PKGBUILD @@ -0,0 +1,72 @@ +# Submitter: Atsushi Ichiki +# Maintainer: Max Falk + +_pkgname=sonarqube +pkgname=${_pkgname} +pkgver=6.7.1 +pkgrel=1 +pkgdesc="An open source platform for continuous inspection of code quality" +arch=("i686" "x86_64") +url="http://www.sonarqube.org/" +license=('LGPL3') + +depends=('java-runtime>=8') + +optdepends=('apache: a fully featured webserver' + 'mariadb: Fast SQL database server, drop-in replacement for MySQL' + 'maven: a java project management and project comprehension tool' + 'postgresql: A sophisticated object-relational DBMS') + +backup=("etc/${_pkgname}/sonar.properties" + "etc/${_pkgname}/wrapper.conf") + +conflicts=("${_pkgname}-lts") +provides=("${_pkgname}") +options=('!strip') + +install=${pkgname}.install +source=("https://sonarsource.bintray.com/Distribution/${_pkgname}/${_pkgname}-${pkgver}.zip" + "${_pkgname}.service" + "${_pkgname}-tmpfile.conf" + "${_pkgname}-user.conf") + +sha256sums=('74cc70ef75d83fa260c7be86863416f45e092f77a2582ab51529d84f9a696fc7' + 'acf98543b635778a690c5d1a8796bf67de725eeda1c72856bd63ea148a892223' + '6e024de469ebb1bc4083274412f0a5d68d5fa511c2139ce4cb1d243c51ff9535' + '43ff10bbb495827e952225dce79da79bb800627eaa6f1d933f8f7fb408aafe6d') + +package() { + cd "${srcdir}/${_pkgname}-${pkgver}" + + # Copy everything except bin and conf to /usr/share/sonarqube. + install -dm755 "${pkgdir}/usr/share/${_pkgname}" + cp -dr --no-preserve=ownership {bin,data,extensions,lib,temp,web,elasticsearch} "${pkgdir}/usr/share/${_pkgname}/" + + # Install the license. + install -Dm644 "COPYING" "${pkgdir}/usr/share/doc/${_pkgname}/COPYING" + + # Install the configuration files to /etc/sonarqube. + install -Dm644 "conf/sonar.properties" "${pkgdir}/etc/${_pkgname}/sonar.properties" + install -Dm644 "conf/wrapper.conf" "${pkgdir}/etc/${_pkgname}/wrapper.conf" + + # Install the systemd configuration and service files. + cd "${srcdir}" + install -Dm644 "${_pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${_pkgname}.service" + install -Dm644 "${_pkgname}-user.conf" "${pkgdir}/usr/lib/sysusers.d/${_pkgname}.conf" + install -Dm644 "${_pkgname}-tmpfile.conf" "${pkgdir}/usr/lib/tmpfiles.d/${_pkgname}.conf" + + # Symbolic links because SonarQube expects a specific directory layout. + ln -s "/var/log/${_pkgname}" "${pkgdir}/usr/share/${_pkgname}/logs" + ln -s "/run/${_pkgname}" "${pkgdir}/usr/share/${_pkgname}/run" + ln -s "/etc/${_pkgname}" "${pkgdir}/usr/share/${_pkgname}/conf" + + # Modify the service file in place to adjust the binary path to the CPU architecture. This is necessary because + # SonarQube expects a certain directory layout. The alternative would be to patch SonarQube's config files which is messy. + if [[ "$CARCH" == 'x86_64' ]]; then + sed -i 's/\$ARCH/linux-x86-64/g' "${pkgdir}/usr/lib/systemd/system/${_pkgname}.service" + elif [[ "$CARCH" == 'i686' ]]; then + sed -i 's/\$ARCH/linux-x86-32/g' "${pkgdir}/usr/lib/systemd/system/${_pkgname}.service" + fi +} + + diff --git a/sonarqube/sonarqube-tmpfile.conf b/sonarqube/sonarqube-tmpfile.conf new file mode 100644 index 0000000..fc57670 --- /dev/null +++ b/sonarqube/sonarqube-tmpfile.conf @@ -0,0 +1,4 @@ +d /run/sonarqube 0755 sonarqube sonarqube - +f /run/sonarqube/SonarQube.pid 0644 sonarqube sonarqube - +d /var/log/sonarqube 0755 sonarqube sonarqube - +d /etc/sonarqube 0755 sonarqube sonarqube - diff --git a/sonarqube/sonarqube-user.conf b/sonarqube/sonarqube-user.conf new file mode 100644 index 0000000..800410a --- /dev/null +++ b/sonarqube/sonarqube-user.conf @@ -0,0 +1 @@ +u sonarqube - "SonarQube user" diff --git a/sonarqube/sonarqube.install b/sonarqube/sonarqube.install new file mode 100644 index 0000000..e44ee8b --- /dev/null +++ b/sonarqube/sonarqube.install @@ -0,0 +1,22 @@ +#!/usr/bin/env sh +# vim:set ts=4 sw=4 et: + +username="sonarqube" + +post_install() { + systemd-sysusers "${username}.conf" + systemd-tmpfiles --create "${username}.conf" + chown -R "$username:$username" /etc/$username /run/$username /usr/share/$username /var/log/$username +} + + +post_upgrade(){ + getent passwd "${username}" >/dev/null 2>&1 || systemd-sysusers "${username}.conf" + systemd-tmpfiles --create sonarqube.conf + + if [ "$(vercmp $2 5.6)" -lt 0 ]; then + echo " >> " + echo " >> Major version update from 5.2 to 5.6. Please take a look at http://www.sonarqube.org/downloads/ for more information." + echo " >> " + fi +} diff --git a/sonarqube/sonarqube.service b/sonarqube/sonarqube.service new file mode 100644 index 0000000..556ceaf --- /dev/null +++ b/sonarqube/sonarqube.service @@ -0,0 +1,20 @@ +[Unit] +Description=An open source platform for continuous inspection of code quality +Documentation=http://www.sonarqube.org +Wants=network.target +After=network.target + +[Service] +Type=forking +User=sonarqube +Group=sonarqube +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=sonarqube +RuntimeDirectory=sonarqube +ExecStart=/usr/share/sonarqube/bin/$ARCH/sonar.sh start +ExecStop=/usr/share/sonarqube/bin/$ARCH/sonar.sh stop + +[Install] +WantedBy=multi-user.target +