You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by el...@apache.org on 2017/01/11 21:34:26 UTC

[2/8] incubator-trafficcontrol git commit: get RPM to build correctly

get RPM to build correctly

(cherry picked from commit 0ee3772e930cf3b9ef0147c5de8c8852ae15406e)


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c5447794
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c5447794
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c5447794

Branch: refs/heads/master
Commit: c5447794c9e166b3a7e4b116aa040a6d9afe17aa
Parents: d40cf4b
Author: David Neuman <da...@gmail.com>
Authored: Mon Jan 9 19:46:56 2017 +0000
Committer: David Neuman <da...@gmail.com>
Committed: Wed Jan 11 16:01:30 2017 +0000

----------------------------------------------------------------------
 build/build.sh                                  |   5 +-
 traffic_monitor/experimental/build/build_rpm.sh |  13 +-
 traffic_monitor/experimental/build/tm2.spec     | 139 ------------------
 .../experimental/build/traffic_monitor.init     |   2 +-
 .../experimental/build/traffic_monitor.spec     | 143 +++++++++++++++++++
 5 files changed, 154 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c5447794/build/build.sh
----------------------------------------------------------------------
diff --git a/build/build.sh b/build/build.sh
index 32d47d4..f182f0c 100755
--- a/build/build.sh
+++ b/build/build.sh
@@ -21,6 +21,7 @@
 # make sure we start out in traffic_control dir
 topscript=$(readlink -f $0)
 export TC_DIR=$(dirname $(dirname "$topscript"))
+echo $TC_DIR
 [[ -n $TC_DIR ]] && cd "$TC_DIR" || { echo "Could not cd $TC_DIR"; exit 1; }
 
 . build/functions.sh
@@ -46,8 +47,8 @@ fi
 declare -a badproj
 declare -a goodproj
 for p in "${projects[@]}"; do
-	# strip from first /
-	p=${p%%/*}
+	# strip trailing /
+	p=${p%/}
 	bldscript="$p/build/build_rpm.sh"
 	if [[ ! -x $bldscript ]]; then
 		echo "$bldscript not found"

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c5447794/traffic_monitor/experimental/build/build_rpm.sh
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/build/build_rpm.sh b/traffic_monitor/experimental/build/build_rpm.sh
old mode 100644
new mode 100755
index 9ec72a3..12115a8
--- a/traffic_monitor/experimental/build/build_rpm.sh
+++ b/traffic_monitor/experimental/build/build_rpm.sh
@@ -18,7 +18,8 @@
 function importFunctions() {
 	local script=$(readlink -f "$0")
 	local scriptdir=$(dirname "$script")
-	export TM_DIR=$(dirname "$scriptdir")
+	export goTM_DIR=$(dirname "$scriptdir")
+	export TM_DIR=$(dirname "$goTM_DIR")
 	export TC_DIR=$(dirname "$TM_DIR")
 	functions_sh="$TC_DIR/build/functions.sh"
 	if [[ ! -r $functions_sh ]]; then
@@ -35,17 +36,17 @@ function initBuildArea() {
 
 	# tar/gzip the source
 	local tm_dest=$(createSourceDir traffic_monitor)
-	cd "$TM_DIR" || \
-		 { echo "Could not cd to $TM_DIR: $?"; exit 1; }
+	cd "$goTM_DIR" || \
+		 { echo "Could not cd to $goTM_DIR: $?"; exit 1; }
 	rsync -av ./ "$tm_dest"/ || \
 		 { echo "Could not copy to $tm_dest: $?"; exit 1; }
-	cp "$TM_DIR"/build/*.spec "$RPMBUILD"/SPECS/. || \
+	cp "$goTM_DIR"/build/*.spec "$RPMBUILD"/SPECS/. || \
 		 { echo "Could not copy spec files: $?"; exit 1; }
 
-	cp -r "$TM_DIR"/ "$tm_dest" || { echo "Could not copy $TM_DIR to $tm_dest: $?"; exit 1; }
+	cp -r "$goTM_DIR"/ "$tm_dest" || { echo "Could not copy $goTM_DIR to $tm_dest: $?"; exit 1; }
 
 	tar -czvf "$tm_dest".tgz -C "$RPMBUILD"/SOURCES $(basename $tm_dest) || { echo "Could not create tar archive $tm_dest.tgz: $?"; exit 1; }
-	cp "$TM_DIR"/build/*.spec "$RPMBUILD"/SPECS/. || { echo "Could not copy spec files: $?"; exit 1; }
+	cp "$goTM_DIR"/build/*.spec "$RPMBUILD"/SPECS/. || { echo "Could not copy spec files: $?"; exit 1; }
 
 	echo "The build area has been initialized."
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c5447794/traffic_monitor/experimental/build/tm2.spec
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/build/tm2.spec b/traffic_monitor/experimental/build/tm2.spec
deleted file mode 100644
index 076b9c0..0000000
--- a/traffic_monitor/experimental/build/tm2.spec
+++ /dev/null
@@ -1,139 +0,0 @@
-#
-#
-# 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.
-#
-#
-# RPM spec file for the Go version of Traffic Monitor (tm).
-#
-%define debug_package %{nil}
-Name:		traffic_monitor
-Version:        %{traffic_control_version}
-Release:        %{build_number}
-Summary:	Monitor the caches
-Packager:	david_neuman2 at Cable dot Comcast dot com
-Vendor:		Apache Software Foundation
-Group:		Applications/Communications
-License:	Apache License, Version 2.0
-URL:		https://github.com/apache/incubator-trafficcontrol
-Source:		%{_sourcedir}/traffic_monitor-%{traffic_control_version}.tgz
-
-%description
-Installs traffic_monitor
-
-%prep
-
-%setup
-
-%build
-export GOPATH=$(pwd)
-# Create build area with proper gopath structure
-mkdir -p src pkg bin || { echo "Could not create directories in $(pwd): $!"; exit 1; }
-
-go_get_version() {
-  local src=$1
-  local version=$2
-  (
-   cd $src && \
-   git checkout $version && \
-   go get -v \
-  )
-}
-
-# get traffic_ops client
-godir=src/github.com/apache/incubator-trafficcontrol/traffic_ops/client
-( mkdir -p "$godir" && \
-  cd "$godir" && \
-  cp -r "$TC_DIR"/traffic_ops/client/* . && \
-  go get -v \
-) || { echo "Could not build go program at $(pwd): $!"; exit 1; }
-
-#build traffic_monitor binary
-godir=src/github.com/apache/incubator-trafficcontrol/traffic_monitor/experimental/traffic_monitor
-oldpwd=$(pwd)
-( mkdir -p "$godir" && \
-  cd "$godir" && \
-  cp -r "$TC_DIR"/traffic_monitor/expiremental/* . && \
-  go get -d -v && \
-  go build -ldflags "-X main.GitRevision=`git rev-parse HEAD` -X main.BuildTimestamp=`date +'%Y-%M-%dT%H:%M:%S'`" \
-) || { echo "Could not build go program at $(pwd): $!"; exit 1; }
-
-%install
-mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor
-mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/bin
-mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/conf
-mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/backup
-mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/var/run
-mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/var/log
-mkdir -p "${RPM_BUILD_ROOT}"/etc/init.d
-mkdir -p "${RPM_BUILD_ROOT}"/etc/logrotate.d
-
-src=src/github.com/apache/incubator-trafficcontrol/traffic_monitor/expiremental
-cp -p traffic_monitor/traffic_monitor     "${RPM_BUILD_ROOT}"/opt/traffic_monitor/bin/traffic_monitor
-cp "$src"/conf/traffic_ops.cfg        "${RPM_BUILD_ROOT}"/opt/traffic_monitor/conf/traffic_ops.cfg
-cp "$src"/build/traffic_monitor.init       "${RPM_BUILD_ROOT}"/etc/init.d/traffic_monitor
-cp "$src"/build/traffic_monitor.logrotate  "${RPM_BUILD_ROOT}"/etc/logrotate.d/traffic_monitor
-
-%pre
-/usr/bin/getent group traffic_monitor >/dev/null
-
-if [ $? -ne 0 ]; then
-
-	/usr/sbin/groupadd -g 422 traffic_monitor
-fi
-
-/usr/bin/getent passwd traffic_monitor >/dev/null
-
-if [ $? -ne 0 ]; then
-
-	/usr/sbin/useradd -g traffic_monitor -u 422 -d /opt/traffic_monitor -M traffic_monitor
-
-fi
-
-/usr/bin/passwd -l traffic_monitor >/dev/null
-/usr/bin/chage -E -1 -I -1 -m 0 -M 99999 -W 7 traffic_monitor
-
-if [ -e /etc/init.d/traffic_monitor ]; then
-	/sbin/service traffic_monitor stop
-fi
-
-%post
-
-/sbin/chkconfig --add traffic_monitor
-/sbin/chkconfig traffic_monitor on
-
-%files
-%defattr(644, traffic_monitor, traffic_monitor, 755)
-%config(noreplace) /opt/traffic_monitor/conf/traffic_monitor.cfg
-%config(noreplace) /opt/traffic_monitor/conf/traffic_ops.cfg
-%config(noreplace) /etc/logrotate.d/traffic_monitor
-
-%dir /opt/traffic_monitor
-%dir /opt/traffic_monitor/bin
-%dir /opt/traffic_monitor/conf
-%dir /opt/traffic_monitor/backup
-%dir /opt/traffic_monitor/var
-%dir /opt/traffic_monitor/var/log
-%dir /opt/traffic_monitor/var/run
-
-%attr(600, traffic_monitor, traffic_monitor) /opt/traffic_monitor/conf/*
-%attr(755, traffic_monitor, traffic_monitor) /opt/traffic_monitor/bin/*
-%attr(755, traffic_monitor, traffic_monitor) /etc/init.d/traffic_monitor
-
-%preun
-# args for hooks: http://www.ibm.com/developerworks/library/l-rpm2/
-# if $1 = 0, this is an uninstallation, if $1 = 1, this is an upgrade (don't do anything)
-if [ "$1" = "0" ]; then
-	/sbin/chkconfig traffic_monitor off
-	/etc/init.d/traffic_monitor stop
-	/sbin/chkconfig --del traffic_monitor
-fi

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c5447794/traffic_monitor/experimental/build/traffic_monitor.init
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/build/traffic_monitor.init b/traffic_monitor/experimental/build/traffic_monitor.init
index 76de8ca..9240ead 100644
--- a/traffic_monitor/experimental/build/traffic_monitor.init
+++ b/traffic_monitor/experimental/build/traffic_monitor.init
@@ -46,7 +46,7 @@ runpath=var/run
 name=traffic_monitor
 prog=$basepath/$binpath/$name
 lockfile=$basepath/$runpath/$name
-options="--opsCfg /opt/traffic_monitor/conf/traffic_ops.cfg --config opt/traffic_monitor/conf/traffic_monitor.cfg"
+options="--opsCfg /opt/traffic_monitor/conf/traffic_ops.cfg --config /opt/traffic_monitor/conf/traffic_monitor.cfg"
 
 start() {
         [ "$NETWORKING" = "no" ] && exit 1

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c5447794/traffic_monitor/experimental/build/traffic_monitor.spec
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/build/traffic_monitor.spec b/traffic_monitor/experimental/build/traffic_monitor.spec
new file mode 100644
index 0000000..181394b
--- /dev/null
+++ b/traffic_monitor/experimental/build/traffic_monitor.spec
@@ -0,0 +1,143 @@
+#
+#
+# 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.
+#
+#
+# RPM spec file for the Go version of Traffic Monitor (tm).
+#
+%define debug_package %{nil}
+Name:		traffic_monitor
+Version:        %{traffic_control_version}
+Release:        %{build_number}
+Summary:	Monitor the caches
+Packager:	david_neuman2 at Cable dot Comcast dot com
+Vendor:		Apache Software Foundation
+Group:		Applications/Communications
+License:	Apache License, Version 2.0
+URL:		https://github.com/apache/incubator-trafficcontrol
+Source:		%{_sourcedir}/traffic_monitor-%{traffic_control_version}.tgz
+
+%description
+Installs traffic_monitor
+
+%prep
+
+%setup
+
+%build
+export GOPATH=$(pwd)
+# Create build area with proper gopath structure
+mkdir -p src pkg bin || { echo "Could not create directories in $(pwd): $!"; exit 1; }
+
+go_get_version() {
+  local src=$1
+  local version=$2
+  (
+   cd $src && \
+   git checkout $version && \
+   go get -v \
+  )
+}
+
+# get traffic_ops client
+godir=src/github.com/apache/incubator-trafficcontrol/traffic_ops/client
+( mkdir -p "$godir" && \
+  cd "$godir" && \
+  cp -r "$TC_DIR"/traffic_ops/client/* . && \
+  go get -v \
+) || { echo "Could not build go program at $(pwd): $!"; exit 1; }
+
+#build traffic_monitor binary
+godir=src/github.com/apache/incubator-trafficcontrol/traffic_monitor/experimental
+oldpwd=$(pwd)
+( mkdir -p "$godir" && \
+  cd "$godir" && \
+  cp -r "$TC_DIR"/traffic_monitor/experimental/* . && \
+  cd traffic_monitor && \
+  go get -d -v && \
+  go build -ldflags "-X main.GitRevision=`git rev-parse HEAD` -X main.BuildTimestamp=`date +'%Y-%M-%dT%H:%M:%s'`" \
+) || { echo "Could not build go program at $(pwd): $!"; exit 1; }
+
+%install
+mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor
+mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/bin
+mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/conf
+mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/backup
+mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/var/run
+mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_monitor/var/log
+mkdir -p "${RPM_BUILD_ROOT}"/etc/init.d
+mkdir -p "${RPM_BUILD_ROOT}"/etc/logrotate.d
+
+src=src/github.com/apache/incubator-trafficcontrol/traffic_monitor/experimental
+cp -p "$src"/traffic_monitor/traffic_monitor     "${RPM_BUILD_ROOT}"/opt/traffic_monitor/bin/traffic_monitor
+cp  "$src"/traffic_monitor/index.html     "${RPM_BUILD_ROOT}"/opt/traffic_monitor/bin/index.html
+cp  "$src"/traffic_monitor/sorttable.js     "${RPM_BUILD_ROOT}"/opt/traffic_monitor/bin/sorttable.js
+cp "$src"/conf/traffic_ops.cfg        "${RPM_BUILD_ROOT}"/opt/traffic_monitor/conf/traffic_ops.cfg
+cp "$src"/conf/traffic_monitor.cfg        "${RPM_BUILD_ROOT}"/opt/traffic_monitor/conf/traffic_monitor.cfg
+cp "$src"/build/traffic_monitor.init       "${RPM_BUILD_ROOT}"/etc/init.d/traffic_monitor
+cp "$src"/build/traffic_monitor.logrotate  "${RPM_BUILD_ROOT}"/etc/logrotate.d/traffic_monitor
+
+%pre
+/usr/bin/getent group traffic_monitor >/dev/null
+
+if [ $? -ne 0 ]; then
+
+	/usr/sbin/groupadd -g 423 traffic_monitor
+fi
+
+/usr/bin/getent passwd traffic_monitor >/dev/null
+
+if [ $? -ne 0 ]; then
+
+	/usr/sbin/useradd -g traffic_monitor -u 423 -d /opt/traffic_monitor -M traffic_monitor
+
+fi
+
+/usr/bin/passwd -l traffic_monitor >/dev/null
+/usr/bin/chage -E -1 -I -1 -m 0 -M 99999 -W 7 traffic_monitor
+
+if [ -e /etc/init.d/traffic_monitor ]; then
+	/sbin/service traffic_monitor stop
+fi
+
+%post
+
+/sbin/chkconfig --add traffic_monitor
+/sbin/chkconfig traffic_monitor on
+
+%files
+%defattr(644, traffic_monitor, traffic_monitor, 755)
+%config(noreplace) /opt/traffic_monitor/conf/traffic_monitor.cfg
+%config(noreplace) /opt/traffic_monitor/conf/traffic_ops.cfg
+%config(noreplace) /etc/logrotate.d/traffic_monitor
+
+%dir /opt/traffic_monitor
+%dir /opt/traffic_monitor/bin
+%dir /opt/traffic_monitor/conf
+%dir /opt/traffic_monitor/backup
+%dir /opt/traffic_monitor/var
+%dir /opt/traffic_monitor/var/log
+%dir /opt/traffic_monitor/var/run
+
+%attr(600, traffic_monitor, traffic_monitor) /opt/traffic_monitor/conf/*
+%attr(755, traffic_monitor, traffic_monitor) /opt/traffic_monitor/bin/*
+%attr(755, traffic_monitor, traffic_monitor) /etc/init.d/traffic_monitor
+
+%preun
+# args for hooks: http://www.ibm.com/developerworks/library/l-rpm2/
+# if $1 = 0, this is an uninstallation, if $1 = 1, this is an upgrade (don't do anything)
+if [ "$1" = "0" ]; then
+	/sbin/chkconfig traffic_monitor off
+	/etc/init.d/traffic_monitor stop
+	/sbin/chkconfig --del traffic_monitor
+fi