Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions branch.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2019 by Delphix. All rights reserved.
#

#
# The "BRANCH" parameter tracks the upstream branch of linux-pkg. It is
# used to determine which branch of the linux package mirror will be used for
# the build if DEFAULT_GIT_BRANCH is not set. DEFAULT_GIT_BRANCH is set when
# linux pkg is built by the linux-pkg-build Jenkins jobs. The
# DEFAULT_GIT_BRANCH parameter should be updated by the release lead on
# branching.
#

DEFAULT_GIT_BRANCH="master"
5 changes: 0 additions & 5 deletions buildlist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ logmust mkdir artifacts
# default used if the revision is not set explicitly anywhere else.
#
export DEFAULT_REVISION="${DEFAULT_REVISION:-$(default_revision)}"
#
# Default branch to checkout when fetching source code for packages. Note that
# this can be overriden by per-package settings.
#
export DEFAULT_GIT_BRANCH="${DEFAULT_GIT_BRANCH:-master}"

#
# A list of target platform or versions to build modules for can be passed in
Expand Down
24 changes: 24 additions & 0 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ export DEBIAN_FRONTEND=noninteractive
# TODO: allow updating upstream for other branches than master
export REPO_UPSTREAM_BRANCH="upstreams/master"

#
# Determine DEFAULT_GIT_BRANCH. If it is unset, default to the branch set in
# branch.config.
#
if [[ -z "$DEFAULT_GIT_BRANCH" ]]; then
echo "DEFAULT_GIT_BRANCH is not set."
if ! source "$TOP/branch.config" 2>/dev/null; then
echo "No branch.config file found in repo root."
exit 1
fi

if [[ -z "$DEFAULT_GIT_BRANCH" ]]; then
echo "$DEFAULT_GIT_BRANCH parameter was not sourced from " \
"branch.config. Ensure branch.config is properly formatted with " \
"e.g. DEFAULT_GIT_BRANCH=\"<upstream-product-branch>\""
exit 1
fi

echo "Defaulting DEFAULT_GIT_BRANCH to branch $DEFAULT_GIT_BRANCH set in" \
"branch.config."

export DEFAULT_GIT_BRANCH
fi

# shellcheck disable=SC2086
function enable_colors() {
[[ -t 1 ]] && flags="" || flags="-T xterm"
Expand Down
41 changes: 41 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,48 @@
TOP="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source "$TOP/lib/common.sh"

#
# Update the sources.list file to point to our internal package mirror. If no
# mirror url is passed in, then the latest mirror snapshot is used.
#
configure_apt_sources() {
local package_mirror_url=''
if [[ -n "$DELPHIX_PACKAGE_MIRROR_MAIN" ]]; then
package_mirror_url="$DELPHIX_PACKAGE_MIRROR_MAIN"
else
local latest_url="http://linux-package-mirror.delphix.com/"
latest_url+="${DEFAULT_GIT_BRANCH}/latest/"
package_mirror_url=$(curl -LfSs -o /dev/null -w '%{url_effective}' \
"$latest_url" || die "Could not curl $latest_url")

package_mirror_url+="ubuntu"
fi

#
# Remove other sources in sources.list.d if they are present.
#
[[ -d /etc/apt/sources.list.d ]] && (
logmust sudo rm -rf /etc/apt/sources.list.d ||
die "Could not remove /etc/apt/sources.list.d"
)

sudo bash -c "cat <<-EOF >/etc/apt/sources.list
deb ${package_mirror_url} bionic main restricted universe multiverse
deb-src ${package_mirror_url} bionic main restricted universe multiverse

deb ${package_mirror_url} bionic-updates main restricted universe multiverse
deb-src ${package_mirror_url} bionic-updates main restricted universe multiverse

deb ${package_mirror_url} bionic-security main restricted universe multiverse
deb-src ${package_mirror_url} bionic-security main restricted universe multiverse

deb ${package_mirror_url} bionic-backports main restricted universe multiverse
deb-src ${package_mirror_url} bionic-backports main restricted universe multiverse
EOF" || die "/etc/apt/sources.list could not be updated"
}

logmust check_running_system
logmust configure_apt_sources
logmust sudo apt-get update

#
Expand Down