dewrich closed pull request #2332: Adding grove to standard pkg build.
URL: https://github.com/apache/incubator-trafficcontrol/pull/2332
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/grove/build/build_rpm.sh b/grove/build/build_rpm.sh
index e22e2352a..9363f946d 100755
--- a/grove/build/build_rpm.sh
+++ b/grove/build/build_rpm.sh
@@ -12,23 +12,44 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-BUILDDIR="$HOME/rpmbuild"
+ROOTDIR=$(git rev-parse --show-toplevel)
+[ ! -z "$ROOTDIR" ] || { echo "Cannot find repository root." >&2 ; exit 1; }
 
+cd "$ROOTDIR/grove"
+
+BUILDDIR="$ROOTDIR/grove/rpmbuild"
 VERSION=`cat ./VERSION`.`git rev-list --all --count`
 
 # prep build environment
-rm -rf $BUILDDIR
-mkdir -p $BUILDDIR/{BUILD,RPMS,SOURCES}
-echo "$BUILDDIR" > ~/.rpmmacros
+[ -e $BUILDDIR ] && rm -rf $BUILDDIR
+[ ! -e $BUILDDIR ] || { echo "Failed to clean up rpm build directory 
'$BUILDDIR': $?" >&2; exit 1; }
+mkdir -p $BUILDDIR/{BUILD,RPMS,SOURCES} || { echo "Failed to create build 
directory '$BUILDDIR': $?" >&2; exit 1; }
 
 # build
-go build -v -ldflags "-X main.Version=$VERSION"
+go get -v -d . || { echo "Failed to go get dependencies: $?" >&2; exit 1; }
+go build -v -ldflags "-X main.Version=$VERSION" || { echo "Failed to build 
grove: $?" >&2; exit 1; }
 
 # tar
-tar -cvzf $BUILDDIR/SOURCES/grove-${VERSION}.tgz grove conf/grove.cfg 
build/grove.init build/grove.logrotate
+tar -cvzf $BUILDDIR/SOURCES/grove-${VERSION}.tgz grove conf/grove.cfg 
build/grove.init build/grove.logrotate || { echo "Failed to create archive for 
rpmbuild: $?" >&2; exit 1; }
+
+# Work around bug in rpmbuild. Fixed in rpmbuild 4.13.
+# See: 
https://github.com/rpm-software-management/rpm/commit/916d528b0bfcb33747e81a57021e01586aa82139
+# Takes ownership of the spec file.
+spec=build/grove.spec
+spec_owner=$(stat -c%u $spec)
+spec_group=$(stat -c%g $spec)
+if ! id $spec_owner >/dev/null 2>&1; then
+       chown $(id -u):$(id -g) build/grove.spec
+
+       function give_spec_back {
+               chown ${spec_owner}:${spec_group} build/grove.spec
+       }
+       trap give_spec_back EXIT
+fi
 
 # build RPM
-rpmbuild --define "version ${VERSION}" -ba build/grove.spec
+rpmbuild --define "_topdir $BUILDDIR" --define "version ${VERSION}" -ba 
build/grove.spec || { echo "rpmbuild failed: $?" >&2; exit 1; }
 
 # copy build RPM to .
-cp $BUILDDIR/RPMS/x86_64/grove-${VERSION}-1.x86_64.rpm .
+[ -e ../dist ] || mkdir -p ../dist
+cp $BUILDDIR/RPMS/x86_64/grove-${VERSION}-1.x86_64.rpm ../dist
diff --git a/infrastructure/docker/build/Dockerfile-grove 
b/infrastructure/docker/build/Dockerfile-grove
new file mode 100644
index 000000000..979ebf797
--- /dev/null
+++ b/infrastructure/docker/build/Dockerfile-grove
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+FROM centos:7
+
+MAINTAINER Chris Lemmons
+
+# top level of trafficcontrol directory must be mounted as a volume:
+# docker run --volume /trafficcontrol:$(pwd) ...
+VOLUME /trafficcontrol
+
+### Common for all sub-component builds
+RUN    yum -y install \
+               epel-release && \
+       yum -y clean all
+RUN    yum -y install \
+               git \
+               rpm-build && \
+       yum -y clean all
+
+### grove specific requirements
+RUN    yum -y install \
+               golang && \
+       yum -y clean all
+###
+
+ADD infrastructure/docker/build/clean_build.sh /
+
+ENV GOPATH=/go
+RUN mkdir -p /go/src/github.com/apache && ln -s /tmp/trafficcontrol 
/go/src/github.com/apache/incubator-trafficcontrol
+CMD /clean_build.sh grove
+
+# vi:syntax=Dockerfile
diff --git a/infrastructure/docker/build/docker-compose.yml 
b/infrastructure/docker/build/docker-compose.yml
index 59b4cf1d5..73ba34522 100644
--- a/infrastructure/docker/build/docker-compose.yml
+++ b/infrastructure/docker/build/docker-compose.yml
@@ -78,6 +78,14 @@ services:
     volumes:
       - ../../..:/trafficcontrol:z
 
+  grove_build:
+    image: grove_builder
+    build:
+      dockerfile: infrastructure/docker/build/Dockerfile-grove
+      context: ../../..
+    volumes:
+      - ../../..:/trafficcontrol:z
+
   weasel:
     image: licenseweasel/weasel:0.1
     volumes:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to