Skip to content

Commit

Permalink
app-metrics/sql_exporter: rework ebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurp committed Apr 11, 2024
1 parent 626a3b5 commit b5857ab
Showing 1 changed file with 29 additions and 34 deletions.
63 changes: 29 additions & 34 deletions app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,43 @@ SLOT="0"
KEYWORDS="~amd64"
IUSE="doc"

DEPEND="dev-lang/go
acct-group/sql_exporter
acct-user/sql_exporter"
RDEPEND="acct-group/sql_exporter
acct-user/sql_exporter"
DEPEND="
dev-lang/go
acct-group/sql_exporter
acct-user/sql_exporter"

RDEPEND="
${DEPEND}"

EGO_PN="github.com/justwatchcom/sql_exporter"

src_prepare() {
default
cd "${S}" || die
export GO111MODULE=auto
default
cd "${S}" || die
export GO111MODULE=auto
}

src_compile() {
export GOPATH="${S}"
cd "${S}/src/${EGO_PN}" || die
echo "compiling from $(pwd)" || die
go build -o "${S}/bin/sql_exporter" || die "Failed to build sql_exporter"
export GOPATH="${S}"
cd "${S}/src/${EGO_PN}" || die
echo "compiling from $(pwd)" || die
go build -o "${S}/bin/sql_exporter" || die "Failed to build sql_exporter"
}

src_install() {
# Create user and group
enewgroup sql_exporter
enewuser sql_exporter -1 -1 /var/log/sql_exporter sql_exporter

dobin "${S}/bin/sql_exporter" || die
newinitd "${FILESDIR}/sql_exporter.init.d" sql_exporter || die
exeinto /etc/init.d
newexe "${FILESDIR}/sql_exporter.init.d" sql_exporter || die
dosym /etc/init.d/sql_exporter /etc/runlevels/default/sql_exporter || die

insinto /etc/sql_exporter
doins "${FILESDIR}/sql_exporter.yml"

# Create log directory and file
if ! dodir /var/log/sql_exporter; then
die "Failed to create log directory"
fi
newins /dev/null sql_exporter.log || die "Failed to create log file"
src_test() {
cd "${S}/src/${EGO_PN}" || die
go test -v ./... || die "Tests failed"
}

src_test() {
cd "${S}/src/${EGO_PN}" || die
go test -v ./... || die "Tests failed"
src_install() {
dobin "${S}/bin/sql_exporter"
newinitd "${FILESDIR}/sql_exporter.init.d" sql_exporter
dosym /etc/init.d/sql_exporter /etc/runlevels/default/sql_exporter || die

insinto /etc/sql_exporter
doins "${FILESDIR}/sql_exporter.yml"

# Create log directory and file
dodir /var/log/sql_exporter
touch "${ED}"/var/log/sql_exporter/sql_exporter.log || die "failed to create log file"
}

0 comments on commit b5857ab

Please sign in to comment.