File: create-rpm-package.sh

package info (click to toggle)
lizardfs 3.12.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,064 kB
  • sloc: cpp: 91,899; sh: 9,341; python: 3,878; ansic: 3,109; pascal: 128; makefile: 57
file content (35 lines) | stat: -rwxr-xr-x 1,182 bytes parent folder | download
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
#!/usr/bin/env bash
set -eux

os_release="$(cat /etc/redhat-release | tr -dc '0-9' | cut -b 1-2)"
case "$os_release" in
  6*) distro=el6 ;;
  7*) distro=el7 ;;
  24*) distro=fc24 ;;
esac
echo "Building packages for '$distro'"

# Directories used by this script
output_dir=$(pwd)
source_dir=$(dirname "$0")
working_dir=/tmp/lizardfs_rpm_working_directory

# Create an empty working directory for rpmbuild
rm -rf "$working_dir"
mkdir -p "$working_dir"/{BUILD,SOURCES,SPECS,RPMS,SRPMS}

# Create a source tarball (the same as those available on Github) using git-archive to make
# sure there are no additional files included in the source package
cd "$source_dir"
version=$(git show HEAD:rpm/lizardfs.spec | awk '/^Version:/ {print $2}')
release="lizardfs-$version"
git archive --prefix="$release"/ --format=tar HEAD | gzip > "$working_dir/SOURCES/$release.tar.gz"
git show HEAD:rpm/lizardfs.spec | sed -e "s/@DISTRO@/$distro/" > "$working_dir/SPECS/lizardfs.spec"

# Build packages
cd "$working_dir/SPECS"
rpmbuild --define "_topdir $working_dir" -ba lizardfs.spec

# Copy all the created files and clean up
cp "$working_dir"/{RPMS/x86_64,SRPMS}/* "$output_dir"
rm -rf "$working_dir"