From e77ad90fb6289a39d644ca4699976285922ff49d Mon Sep 17 00:00:00 2001 From: John Cater Date: Fri, 3 Feb 2017 16:31:32 +0000 Subject: Add pkg_rpm build rule to help generating RPM packages. RELNOTES: Adds pkg_rpm rule for generating RPM packages. -- Change-Id: I2e83161e29218700bbe7e62186b0b1667e555a7c Reviewed-on: https://cr.bazel.build/8590 PiperOrigin-RevId: 146477490 MOS_MIGRATED_REVID=146477490 --- scripts/packages/fedora/BUILD | 30 +++++++------------ scripts/packages/fedora/bazel.spec | 6 ++-- scripts/packages/fedora/build_rpm.sh | 56 ------------------------------------ 3 files changed, 15 insertions(+), 77 deletions(-) delete mode 100755 scripts/packages/fedora/build_rpm.sh (limited to 'scripts/packages') diff --git a/scripts/packages/fedora/BUILD b/scripts/packages/fedora/BUILD index 36d8690ebf..2ee91d01ab 100644 --- a/scripts/packages/fedora/BUILD +++ b/scripts/packages/fedora/BUILD @@ -5,26 +5,18 @@ filegroup( srcs = glob(["**"]), ) -genrule( - name = "bazel-fedora", - srcs = [ - "bazel.spec", +load("//tools/build_defs/pkg:rpm.bzl", "pkg_rpm") + +pkg_rpm( + name = "bazel", + architecture = "x86_64", + changelog = "//:changelog-file", + data = [ + "//scripts:bash_completion", "//scripts/packages:bazel", + "//scripts/packages:bazel.bazelrc", "//scripts/packages:bazel-real", - "//scripts/packages:debian/bazel.bazelrc", - "//scripts:bash_completion", - ], - outs = [ - "bazel-fedora.rpm", ], - cmd = """ - $(location :build_rpm.sh) \ - $(location :bazel.spec) \ - $(location bazel-fedora.rpm) \ - $(location //scripts/packages:bazel) \ - $(location //scripts/packages:bazel-real) \ - $(location //scripts/packages:debian/bazel.bazelrc) \ - $(location //scripts:bash_completion) - """, - tools = ["build_rpm.sh"], + spec_file = "bazel.spec", + version_file = "//scripts/packages:version.txt", ) diff --git a/scripts/packages/fedora/bazel.spec b/scripts/packages/fedora/bazel.spec index 0d69e61e5d..14cabfc5c1 100644 --- a/scripts/packages/fedora/bazel.spec +++ b/scripts/packages/fedora/bazel.spec @@ -30,7 +30,7 @@ install -m 755 bazel %{buildroot}%{_bindir}/bazel install -m 755 bazel-real %{buildroot}%{_bindir}/bazel-real mkdir -p %{buildroot}%{_sysconfdir}/ install -m 644 bazel.bazelrc %{buildroot}%{_sysconfdir}/bazel.bazelrc -mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d +mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d/ install -m 644 bazel-complete.bash %{buildroot}%{_sysconfdir}/bash_completion.d/bazel %files @@ -40,4 +40,6 @@ install -m 644 bazel-complete.bash %{buildroot}%{_sysconfdir}/bash_completion.d/ %{_sysconfdir}/bash_completion.d/bazel %changelog -# TODO: Include changelog. +* Fri Jan 27 2017 jcater@google.com - devel-1 +- Initial package version released. + diff --git a/scripts/packages/fedora/build_rpm.sh b/scripts/packages/fedora/build_rpm.sh deleted file mode 100755 index 525c858b13..0000000000 --- a/scripts/packages/fedora/build_rpm.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -# Copyright 2016 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eu - -# Build a RPM archive from the Bazel sources. - -# Usage: build_rpm.sh spec_file dest_file [other files] - -spec_file=$1 -shift -dest_file=$1 -shift - -echo "Building ${dest_file} from ${spec_file}." -WORK_DIR="${PWD}/bazel-fedora" - -# Copy needed sources. -rm -rf ${WORK_DIR} -mkdir -p ${WORK_DIR}/SOURCES -mkdir -p ${WORK_DIR}/BUILD -cp $spec_file ${WORK_DIR} -for i in "$@"; do - cp $i $WORK_DIR/BUILD -done - -# Build the RPM. -rpmbuild \ - --define "_topdir ${WORK_DIR}" \ - --define "_tmppath /tmp" \ - -bb ${spec_file} > rpmbuild.log 2>&1 -if [ $? -ne 0 ]; then - err=$? - echo "Error in rpmbuild:" - cat rpmbuild.log - exit $err -fi -out_file=$(grep '^Wrote:' rpmbuild.log | cut -d ' ' -f 2) - -# Copy output back to the destination. -cp $out_file $dest_file -echo "Created $dest_file" - -- cgit v1.2.3