Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2ddf898
- Bourne Shell shebang
zrhoffman May 24, 2020
a47eb41
Remove non-standard "function" keyword (SC2112)
zrhoffman May 24, 2020
117491d
Declare variables before setting to avoid masking return values
zrhoffman May 24, 2020
4cfc828
Reformat RPM scripts and spec files
zrhoffman May 25, 2020
87e3e47
- Quote variables
zrhoffman May 24, 2020
f72c9b2
Rewrite verify_and_set_go_version to use sed instead of BASH_REMATCH and
zrhoffman May 24, 2020
60c7f48
Eliminate Bash-only brace expansions
zrhoffman May 24, 2020
9da95b3
Use subshells instead of pushd/popd
zrhoffman May 24, 2020
2fe6ff4
Do not use Bash arrays
zrhoffman May 24, 2020
587f1f6
Avoid using non-standard tar options --exclude-cvs and --transform and
zrhoffman May 24, 2020
8c543e6
Group commands to use intended control flow
zrhoffman May 25, 2020
98a1db2
Optionally skip stripping binaries as a rpmbuild option instead of
zrhoffman May 24, 2020
dc44a1d
Compress RPMs with xz level 2 compression
zrhoffman May 24, 2020
d487ccf
Strip the go binaries from `go build` in case RPM does not strip them
zrhoffman May 24, 2020
5e7492f
Statically link go binaries
zrhoffman May 24, 2020
76dbe91
Use a more reliable way to check the OS version and add a default ver…
zrhoffman May 24, 2020
0d2020d
Use sed for pattern replacements, not perl
zrhoffman May 24, 2020
89db273
Unglob files list in RPM spec file
zrhoffman May 24, 2020
83e4213
Rewrite build command to not use 4 nested subshells and 4 file descri…
zrhoffman May 24, 2020
8cd5df7
- Remove gitignored files and dist symlink in case clean_build.sh was…
zrhoffman May 25, 2020
87c25e7
Use realpath instead of readlink -f
zrhoffman May 25, 2020
98e0c8a
Various cross-platform scripting improvements
zrhoffman May 25, 2020
907b2d3
- Fix bug from 4cf95296ed where failing the environment check did not
zrhoffman May 26, 2020
f071e7e
Move the note about specifying the Traffic Ops host to the "Installing
zrhoffman Jun 3, 2020
16963ed
- Add subsection for installing the global NPM packages
zrhoffman Jun 3, 2020
1db3ce4
Add instructions for getting OpenJDK 8 on macOS
zrhoffman Jun 3, 2020
26873a0
Move instructions for building docs to documentation guidelines page
zrhoffman Jun 3, 2020
019d951
- Move clean_build.sh to the main build directory for easy access
zrhoffman May 25, 2020
037fe84
Support native building in CDN-in-a-Box makefile
zrhoffman May 30, 2020
7a22457
Docs touch-ups
zrhoffman Jun 9, 2020
71784b8
Recursively remove untracked files in clean_build.sh, not just the to…
zrhoffman Jun 16, 2020
6596da5
Add native phony make target
zrhoffman Jun 18, 2020
65ae412
Docs building changes
zrhoffman Jun 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ cpanfile.snapshot
rpm/build.number
rpmbuild/
docs/build/*
/grove/grove
/grove/grovetccfg/grovetccfg
local
traffic_ops_extensions/log/*
traffic_ops_extensions/lib/Extensions/InfluxDB/log/*
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Traffic Router: Added support for topology-based delivery services
- Updated /servers/details to use multiple interfaces in API v3
- Added [Edge Traffic Routing](https://traffic-control-cdn.readthedocs.io/en/latest/admin/traffic_router.html#edge-traffic-routing) feature which allows Traffic Router to localize more DNS record types than just the routing name for DNS delivery services
- Added the ability to speedily build development RPMs from any OS without needing Docker
- Astats csv support - astats will now respond to `Accept: text/csv` and return a csv formatted stats list
- Updated /deliveryservices/{{ID}}/servers to use multiple interfaces in API v3
- Updated /deliveryservices/{{ID}}/servers/eligible to use multiple interfaces in API v3
Expand Down
84 changes: 44 additions & 40 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/bash

#
#
#!/usr/bin/env sh
# 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
Expand All @@ -14,91 +11,98 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# shellcheck shell=ash
trap 'exit_code=$?; [ $exit_code -ne 0 ] && echo "Error on line ${LINENO} of ${0}"; exit $exit_code' EXIT;
set -o errexit -o nounset -o pipefail;

# By default all sub-projects are built. Supply a list of projects to build if
# only a subset is wanted.

# make sure we start out in traffic_control dir
topscript=$(readlink -f $0)
export TC_DIR=$(dirname $(dirname "$topscript"))
[[ -n $TC_DIR ]] && cd "$TC_DIR" || { echo "Could not cd $TC_DIR"; exit 1; }

. build/functions.sh

checkEnvironment

# make sure we start out in traffic_control dir
topscript='' TC_DIR=''
topscript="$(realpath "$0")"
TC_DIR="$(dirname "$(dirname "$topscript")")"
export TC_DIR
if [ -z "$TC_DIR" ] || ! cd "$TC_DIR"; then
echo "Could not cd TC_DIR ${TC_DIR}";
exit 1;
fi;

if [[ $# -gt 0 ]]; then
projects=( "$*" )
if [ $# -gt 0 ]; then
projects="$*"
else
# get all subdirs containing build/build_rpm.sh
projects_to_build=( */build/build_rpm.sh )
projects_to_build='*/build/build_rpm.sh'
# Always build tarball when building everything..
projects=(tarball)
for p in "${projects_to_build[@]}"; do
p=${p%%/*}
if [[ $p != "traffic_monitor_golang" ]]; then
projects+=($p)
projects=tarball
for p in ${projects_to_build}; do
p="${p%%/*}"
if [ "$p" != "traffic_monitor_golang" ]; then
projects="${projects} ${p}"
fi
done
fi


declare -a badproj
declare -a goodproj
for p in "${projects[@]}"; do
if [[ $p == tarball ]]; then
badproj=''
goodproj=''
for p in ${projects}; do
if [ "$p" = tarball ]; then
if isInGitTree; then
echo "----- Building tarball ..."
tarball=$(createTarball "$TC_DIR")
ls -l $tarball
checkEnvironment -e rpmbuild
tarball="$(createTarball "$TC_DIR")"
ls -l "$tarball"
else
echo "---- Skipping tarball creation"
fi
continue
fi
if [[ $p == docs ]]; then
if [ "$p" = docs ]; then
if isInGitTree; then
echo "----- Building docs ..."
pushd docs
checkEnvironment -i python3,make, -e rpmbuild
( cd docs
make html
popd
)
tarball=$(createDocsTarball "${TC_DIR}")
ls -l $tarball
ls -l "$tarball"
else
echo "---- Skipping docs creation"
fi
continue
fi
# strip trailing /
p=${p%/}
bldscript="$p/build/build_rpm.sh"
if [[ ! -x $bldscript ]]; then
p="${p%/}"
bldscript="${p}/build/build_rpm.sh"
if [ ! -x "$bldscript" ]; then
echo "$bldscript not found"
badproj+=($p)
badproj="${badproj} ${p}"
continue
fi

echo "----- Building $p ..."
if $bldscript; then
goodproj+=($p)
goodproj="${goodproj} ${p}"
else
echo "$p failed: $!"
badproj+=($p)
echo "${p} failed: ${bldscript}"
badproj="${badproj} ${p}"
fi
done

if [[ ${#goodproj[@]} -ne 0 ]]; then
if [ "$(echo "${goodproj}" | wc -w)" -ne 0 ]; then
echo "The following subdirectories built successfully: "
for p in "${goodproj[@]}"; do
for p in ${goodproj}; do
echo " $p"
done
echo "See $(pwd)/dist for newly built rpms."
fi

if [[ ${#badproj[@]} -ne 0 ]]; then
if [ "$(echo "${badproj}" | wc -w)" -ne 0 ]; then
echo "The following subdirectories had errors: "
for p in "${badproj[@]}"; do
for p in ${badproj}; do
echo " $p"
done
exit 1
Expand Down
71 changes: 71 additions & 0 deletions build/clean_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env sh
# 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.
#
# shellcheck shell=ash
trap 'exit_code=$?; [ $exit_code -ne 0 ] && echo "Error on line ${LINENO} of ${0}"; cleanup; exit $exit_code' EXIT;
set -o errexit -o nounset -o pipefail;


# Fix ownership of output files
# $1 is file or dir with correct ownership
# remaining args are files/dirs to be fixed, recursively
setowner() {
own=$(stat -c%u:%g "$1" 2>/dev/null || stat -f%u:%g "$1")
shift
[ -n "$*" ] && chown -R "${own}" "$@"
}

cleanup() {
setowner "$tc_volume" "${tc_volume}/dist"
}

set -o xtrace;

if ! script_path="$(readlink "$0")"; then
script_path="$0";
fi;
cd "$(dirname "$script_path")";
if ! tc_volume="$(git rev-parse --show-toplevel 2>/dev/null)"; then
tc_volume='/trafficcontrol'; # Default repo location for ATC builder Docker images
fi;

# set owner of dist dir -- cleans up existing dist permissions...
export GOPATH=/tmp/go GOOS="${GOOS:-linux}";
tc_dir=${GOPATH}/src/github.com/apache/trafficcontrol;
if which cygpath 2>/dev/null; then
GOPATH="$(cygpath -w "$GOPATH")" # cygwin compatibility
fi
(mkdir -p "$GOPATH"
cd "$GOPATH"
mkdir -p src pkg bin "$(dirname "$tc_dir")"
)
rsync -a --exclude=dist "${tc_volume}/" "$tc_dir";
if ! [ -d ${tc_dir}/.git ]; then
rsync -a "${tc_volume}/.git" $tc_dir; # Docker for Windows compatibility
fi

cd "$tc_dir"
# In case the mirrored repo already exists, remove gitignored files
git clean -fdX

rm -rf "dist"
mkdir -p "${tc_volume}/dist"
ln -sf "${tc_volume}/dist" "dist"

if [ $# -eq 0 ]; then
set -- tarball traffic_monitor traffic_ops traffic_ops_ort traffic_portal traffic_router traffic_stats grove grove/grovetccfg docs
fi

for project in "$@"; do
./build/build.sh "${project}" 2>&1 | tee "dist/build-${project//\//-}.log"
done
Loading