Skip to content

Commit

Permalink
rpm: break out to own script
Browse files Browse the repository at this point in the history
As for the .deb, remove the sysconfig/defaults file but respect it if
it exists.

Also provides a default config.

Also addresses most of the issues brought up in
#221.
  • Loading branch information
jasonish committed Feb 20, 2023
1 parent ed06fce commit 02f66bd
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 46 deletions.
33 changes: 0 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,39 +72,6 @@ dist: webapp
cp examples/evebox.yaml $(DIST_DIR)/examples/
cd dist && zip -r $(DIST_NAME).zip $(DIST_NAME)

# RPM packaging.
ifneq ($(VERSION_SUFFIX),)
# Setup non-release versioning.
rpm: RPM_ITERATION := 0.$(VERSION_SUFFIX)$(BUILD_DATE)
rpm: OUTPUT := dist/evebox-latest-x86_64.rpm
else
# Setup release versioning.
rpm: RPM_ITERATION := 1
rpm: OUTPUT := dist/
endif
rpm:
fpm --force -s dir \
-t rpm \
-p $(OUTPUT) \
-n evebox \
-v $(VERSION) \
--iteration $(RPM_ITERATION) \
--before-install=./packaging/rpm/before-install.sh \
--after-upgrade=./packaging/rpm/after-upgrade.sh \
--config-files /etc/sysconfig/evebox \
--rpm-attr 0644,root,root:/lib/systemd/system/evebox.service \
--rpm-attr 0644,root,root:/lib/systemd/system/evebox-agent.service \
--rpm-attr 0755,root,root:/usr/bin/evebox \
--rpm-attr 0644,root,root:/etc/evebox/evebox.yaml.example \
--rpm-attr 0644,root,root:/etc/evebox/agent.yaml.example \
--rpm-attr 0644,root,root:/etc/sysconfig/evebox.service \
${EVEBOX_BIN}=/usr/bin/evebox \
examples/evebox.yaml=/etc/evebox/evebox.yaml.example \
examples/agent.yaml=/etc/evebox/agent.yaml.example \
./packaging/rpm/evebox.sysconfig=/etc/sysconfig/evebox \
./packaging/rpm/evebox.service=/lib/systemd/system/evebox.service \
./packaging/rpm/evebox-agent.service=/lib/systemd/system/evebox-agent.service

fmt:
cargo fmt
cd webapp && npm run fmt
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ cross_run() {
}

build_linux() {
#build_cross x86_64-unknown-linux-musl "dist rpm deb"
cross_run x86_64-unknown-linux-musl make dist rpm
cross_run x86_64-unknown-linux-musl make dist
cross_run x86_64-unknown-linux-musl ./packaging/build-deb.sh amd64
cross_run x86_64-unknown-linux-musl ./packaging/build-rpm.sh amd64
}
COMMANDS[linux]=build_linux

Expand Down
5 changes: 3 additions & 2 deletions packaging/build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ fi
if [ "${VERSION_SUFFIX}" ]; then
FILENAME="evebox-latest-${ARCH}.deb"
else
FILENAME="$evebox-${VERSION}-${ARCH}.deb"
FILENAME="evebox-${VERSION}-${ARCH}.deb"
fi

fpm --verbose -t deb -n evebox -s dir --epoch 1 \
-a "${ARCH}" \
-p "dist/${FILENAME}" -v "${VERSION}" \
-p "dist/${FILENAME}" \
-v "${VERSION}" \
--force \
--after-install=./packaging/debian/after-install.sh \
--after-upgrade=./packaging/debian/after-upgrade.sh \
Expand Down
44 changes: 44 additions & 0 deletions packaging/build-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! /bin/sh

set -e
set -x

CARGO_VERSION=$(cat Cargo.toml | awk '/^version/ { gsub(/"/, "", $3); print $3 }')
VERSION=$(echo ${CARGO_VERSION} | sed 's/\(.*\)\-.*/\1/')
VERSION_SUFFIX=$(echo ${CARGO_VERSION} | sed -n 's/.*-\(.*\)/\1/p')
DATE=$(date +%s)

case "${1}" in
"x86_64"|"amd64")
ARCH="x86_64"
BIN="./dist/evebox-latest-linux-x64/evebox"
;;
*)
echo "error: invalid ARCH"
exit 1
esac

if [ "${VERSION_SUFFIX}" ]; then
RPM_ITERATION="0.${VERSION_SUFFIX}${DATE}"
OUTPUT="evebox-latest-${ARCH}.rpm"
else
RPM_ITERATION="1"
OUTPUT=""
fi

fpm --verbose -t rpm -n evebox -s dir --epoch 1 \
-a "${ARCH}" \
-v "${VERSION}" \
-p "./dist/${OUTPUT}" \
--force \
--iteration "${RPM_ITERATION}" \
--before-install=./packaging/rpm/before-install.sh \
--after-upgrade=./packaging/rpm/after-upgrade.sh \
--config-files /etc/evebox/evebox.yaml \
--rpm-attr 0644,root,root:/lib/systemd/system/evebox.service \
--rpm-attr 0644,root,root:/lib/systemd/system/evebox-agent.service \
--rpm-attr 0755,root,root:/usr/bin/evebox \
${BIN}=/usr/bin/evebox \
./packaging/rpm/evebox.service=/lib/systemd/system/evebox.service \
./packaging/rpm/evebox-agent.service=/lib/systemd/system/evebox-agent.service \
./packaging/evebox.yaml=/etc/evebox/evebox.yaml
1 change: 1 addition & 0 deletions packaging/rpm/evebox.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Group=evebox
ExecStart=/usr/bin/evebox server $ELASTICSEARCH_URL $CONFIG $EVEBOX_OPTS
EnvironmentFile=-/etc/sysconfig/evebox
Environment=EVEBOX_DATA_DIRECTORY=/var/lib/evebox
Environment=CONFIG="-c /etc/evebox/evebox.yaml"

[Install]
WantedBy=multi-user.target
9 changes: 0 additions & 9 deletions packaging/rpm/evebox.sysconfig

This file was deleted.

0 comments on commit 02f66bd

Please sign in to comment.