forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-rpm.sh
executable file
·47 lines (37 loc) · 1.51 KB
/
package-rpm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# package-rpm.sh
#
# SUMMARY
#
# Packages a .rpm file to be distributed in the YUM package manager.
set -eu
project_root=$(pwd)
archive_name="vector-$TARGET.tar.gz"
archive_path="target/artifacts/$archive_name"
package_version="$($project_root/scripts/version.sh)"
# RPM has a concept of releases, but we do not need this so every
# release is 1.
export RELEASE=1
# The RPM spec does not like a leading `v` or `-` in the version name.
# Therefore we clean the version so that the `rpmbuild` command does
# not fail.
export CLEANED_VERSION=$package_version
CLEANED_VERSION=$(echo $CLEANED_VERSION | sed 's/-/\./g')
# The arch is the first part of the target
# For some architectures, like armv7hl it doesn't match the arch
# from Rust target triple and needs to be specified manually.
ARCH=${ARCH:-$(echo $TARGET | cut -d'-' -f1)}
# Create source dir
rm -rf /root/rpmbuild/SOURCES
mkdir -p /root/rpmbuild/SOURCES
mkdir -p /root/rpmbuild/SOURCES/init.d
mkdir -p /root/rpmbuild/SOURCES/systemd
cp -av distribution/init.d/. /root/rpmbuild/SOURCES/init.d
cp -av distribution/systemd/. /root/rpmbuild/SOURCES/systemd
# Copy the archive into the sources dir
cp -av $archive_path "/root/rpmbuild/SOURCES/vector-$ARCH.tar.gz"
# Perform the build.
rpmbuild --target "$ARCH-redhat-linux" --define "_arch $ARCH" -ba distribution/rpm/vector.spec
# Move the RPM into the artifacts dir
ls "/root/rpmbuild/RPMS/$ARCH"
mv -v "/root/rpmbuild/RPMS/$ARCH/vector-$CLEANED_VERSION-$RELEASE.$ARCH.rpm" "target/artifacts/vector-$ARCH.rpm"