diff options
Diffstat (limited to 'dist')
-rwxr-xr-x | dist/build-rpm.sh | 124 | ||||
-rw-r--r-- | dist/vespa.spec | 9 |
2 files changed, 131 insertions, 2 deletions
diff --git a/dist/build-rpm.sh b/dist/build-rpm.sh new file mode 100755 index 00000000000..e86eebe9380 --- /dev/null +++ b/dist/build-rpm.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +set -e + +Usage() { + cat <<EOF +Usage: ${0##*/} [OPTIONS]...SPECFILE +Run rpmbuild with the given specfile macros, creating TOPDIR if necessary. + +Options: + -b BUILDDIR Overrides %_builddir. + -d DIST The %dist to build for (e.g. .el7 for RHEL 7). Can be specified + multiple time to build multiple RPMs. The default %dist is used + if no -d options have been specified. + -h Print this help text and exit. + -t TOPDIR Overrides %_topdir. + -v VERSION [Required] The version of the RPM. +EOF + + exit 1 +} + +Fail() { + printf "%s\n" "$*" + exit 1 +} + +Run() { + local command="$1" + shift + printf "%q" "$command" + + local arg + for arg in "$@"; do + printf " %q" "$arg" + done + printf "\n" + + "$command" "$@" +} + +Main() { + local -a dists=() + local version= topdir= builddir= + while (( $# > 0 )); do + case "$1" in + -b|--builddir) + builddir="$2" + shift 2 + if ! test -d "$builddir"; then + Fail "BUILDDIR '$builddir' does not exist" + # Make builddir an absolute path + elif ! builddir=$(readlink -e "$builddir"); then + Fail "Failed to resolve BUILDDIR '$builddir'" + fi + ;; + -d|--dist) + local dist="$2" + shift 2 + case "$dist" in + .el6|.el7) : ;; + *) Fail "Bad DIST value '$dist'" ;; + esac + dists+=("$dist") + ;; + -t|--topdir) + topdir="$2" + shift 2 + if ! [[ "$topdir" =~ ^/ ]]; then + Fail "TOPDIR must be an absolute path" + fi + ;; + -v|--version) + version="$2" + shift 2 + if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + Fail "VERSION must be a version of the form X.Y.Z" + fi + ;; + *) break ;; + esac + done + + if (( $# == 0 )); then + Fail "Missing SPECFILE" + elif (( $# > 1 )); then + Fail "Too many arguments" + else + case "$1" in + help|-h|--help) Usage ;; + esac + fi + local specfile="$1" + + local -a defines=() + + if test -n "$builddir"; then + defines+=(--define "_builddir $builddir") + fi + + if test -n "$topdir"; then + if ! mkdir -p "$topdir"; then + Fail "Failed to create TOPDIR directory '$topdir'" + fi + defines+=(--define "_topdir $topdir") + fi + + if test -n "$version"; then + defines+=(--define "version $version") + else + Fail "VERSION is required" + fi + + if (( ${#dists[@]} == 0 )); then + Run rpmbuild -bb "${defines[@]}" "$specfile" + else + local dist + for dist in "${dists[@]}"; do + Run rpmbuild -bb "${defines[@]}" --define "dist $dist" "$specfile" + done + fi +} + +Main "$@" diff --git a/dist/vespa.spec b/dist/vespa.spec index 71fc91ad905..c17454804dc 100644 --- a/dist/vespa.spec +++ b/dist/vespa.spec @@ -197,13 +197,18 @@ exit 0 %postun %systemd_postun_with_restart vespa.service %systemd_postun_with_restart vespa-configserver.service -rm -f /etc/profile.d/vespa.sh -userdel vespa +if [ $1 -eq 0 ]; then # this is an uninstallation + rm -f /etc/profile.d/vespa.sh + userdel vespa +fi %files %defattr(-,vespa,vespa,-) %doc %{_prefix}/* +%config(noreplace) %{_prefix}/conf/logd/logd.cfg +%config(noreplace) %{_prefix}/conf/vespa/default-env.txt +%config(noreplace) %{_prefix}/etc/vespamalloc.conf %attr(644,root,root) /usr/lib/systemd/system/vespa.service %attr(644,root,root) /usr/lib/systemd/system/vespa-configserver.service |