Skip to content
Open
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
5 changes: 1 addition & 4 deletions buildchain/buildchain/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from buildchain import ROOT


# /!\ All the global defined here must be documented in BUILDING.md /!\
# /!\ All the global defined here must be documented in docs/developer/building/configuration.rst /!\


# Project name.
Expand Down Expand Up @@ -58,14 +58,11 @@ class ExtCommand(enum.Enum):
GIT = os.getenv("GIT_BIN", "git")
GOFMT = os.getenv("GOFMT_BIN", "gofmt")
HARDLINK = os.getenv("HARDLINK_BIN", "hardlink")
HELM = os.getenv("HELM_BIN", "helm")
IMPLANTISOMD5 = os.getenv("IMPLANTISOMD5_BIN", "implantisomd5")
MAKE = os.getenv("MAKE_BIN", "make")
MKISOFS = os.getenv("MKISOFS_BIN", "mkisofs")
SKOPEO = os.getenv("SKOPEO_BIN", "skopeo")
TOX = os.getenv("TOX_BIN", "tox")
VAGRANT = os.getenv("VAGRANT_BIN", "vagrant")
KUSTOMIZE = os.getenv("KUSTOMIZE_BIN", "kustomize")

@property
def command_name(self) -> str:
Expand Down
11 changes: 6 additions & 5 deletions buildchain/buildchain/iso.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@
FILE_TREES: Tuple[helper.FileTree, ...] = (
helper.FileTree(
basename="_iso_add_tree",
source_prefix=Path("examples"),
files=(
Path("examples/new-node.yaml"),
Path("examples/new-node_vagrant.yaml"),
Path("examples/prometheus-sparse.yaml"),
Path("examples/loki-sparse.yaml"),
Path("new-node.yaml"),
Path("new-node_vagrant.yaml"),
Path("prometheus-sparse.yaml"),
Path("loki-sparse.yaml"),
),
destination_directory=constants.ISO_ROOT,
task_dep=["_iso_mkdir_root"],
Expand Down Expand Up @@ -131,7 +132,7 @@
"DEVELOPMENT_RELEASE": "1"
if versions.VERSION_SUFFIX == "-dev"
else "0",
"BUILD_TIMESTAMP": dt.datetime.utcnow().strftime(
"BUILD_TIMESTAMP": dt.datetime.now(dt.timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%SZ"
),
"BUILD_HOST": socket.gethostname(),
Expand Down
15 changes: 8 additions & 7 deletions docs/developer/building/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Available options are:
- ``VAGRANT_PROVIDER``: type of machine to spawn with Vagrant
- ``VAGRANT_UP_ARGS``: command line arguments to pass to ``vagrant up``
- ``VAGRANT_SNAPSHOT_NAME``: name of auto generated Vagrant snapshot
- ``DOCKER_BIN``: Docker binary (name or path to the binary)
- ``GIT_BIN``: Git binary (name or path to the binary)
- ``GOFMT_BIN``: gofmt binary (name or path to the binary)
- ``HARDLINK_BIN``: hardlink binary (name or path to the binary)
- ``IMPLANTISOMD5_BIN``: implantisomd5 binary (name or path to the binary)
- ``MAKE_BIN``: Make binary (name or path to the binary)
- ``MKISOFS_BIN``: mkisofs binary (name or path to the binary)
- ``SKOPEO_BIN``: skopeo binary (name or path to the binary)
- ``VAGRANT_BIN``: Vagrant binary (name or path to the binary)
- ``GOFMT_BIN``: gofmt binary (name or path to the binary)
- ``OPERATOR_SDK_BIN``: the Operator SDK binary (name or path to the binary)

Default settings are equivalent to the following ``.env``:

Expand All @@ -29,11 +29,12 @@ Default settings are equivalent to the following ``.env``:
export BUILD_ROOT=_build
export VAGRANT_PROVIDER=virtualbox
export VAGRANT_UP_ARGS="--provision --no-destroy-on-error --parallel --provider $VAGRANT_PROVIDER"
export DOCKER_BIN=docker
export HARDLINK_BIN=hardlink
export VAGRANT_SNAPSHOT_NAME=bootstrap.autosnapshot
export GIT_BIN=git
export GOFMT_BIN=gofmt
export HARDLINK_BIN=hardlink
export IMPLANTISOMD5_BIN=implantisomd5
export MAKE_BIN=make
export MKISOFS_BIN=mkisofs
export SKOPEO_BIN=skopeo
export VAGRANT_BIN=vagrant
export GOFMT_BIN=gofmt
export OPERATOR_SDK_BIN=operator-sdk
11 changes: 6 additions & 5 deletions doit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ BUILDCHAIN=buildchain
BUILDENV="${BUILDCHAIN}/.venv"
# requirements.txt for the buildchain.
REQUIREMENTS="${BUILDCHAIN}/requirements.txt"
# Dummy file to keep track of when the virtual environment was installed.
WITNESS_FILE="${BUILDENV}/installed.tstamp"
# Marker file defined by PEP 405 to keep track of when the venv was created.
MARKER_FILE="${BUILDENV}/pyvenv.cfg"
# File containing environment variables.
DOTENV=./.env

Expand All @@ -30,6 +30,7 @@ then
exit 1
fi

# Get unix timestamp (seconds since epoch)
if [ "$OSTYPE" = "Darwin" ]
then
GET_FILE_STAMP='stat -f %m'
Expand All @@ -39,15 +40,14 @@ fi

# Can't use `[ file1 -nt file2 ]` directly because it's not POSIX :'(
REQ_TSTAMP=$($GET_FILE_STAMP "${REQUIREMENTS}")
WIT_TSTAMP=$($GET_FILE_STAMP "${WITNESS_FILE}" 2> /dev/null || echo '0')
MKR_TSTAMP=$($GET_FILE_STAMP "${MARKER_FILE}" 2> /dev/null || echo '0')

# Install/reinstall the virtual environment only if it either doesn't exist or
# the requirements have changed since its creation.
if [ "${REQ_TSTAMP}" -gt "${WIT_TSTAMP}" ]
if [ "${REQ_TSTAMP}" -gt "${MKR_TSTAMP}" ]
then
"${PYTHON_SYS}" -m venv --clear "${BUILDENV}"
"${BUILDENV}/bin/pip" install -r "${REQUIREMENTS}"
touch "${WITNESS_FILE}"
fi

# Load customized environment variables from dotenv file, if exists.
Expand All @@ -57,4 +57,5 @@ then
. "${DOTENV}"
fi

# Run doit and pass all arguments to it.
exec "${BUILDENV}/bin/python" -m doit "$@"