|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# ============================================================================== |
| 4 | +# Script to build Salt (Onedir) for VyOS |
| 5 | +# ============================================================================== |
| 6 | + |
| 7 | +# Exit immediately on error |
| 8 | +set -e |
| 9 | + |
| 10 | +# Configuration |
| 11 | +ARCH=$(dpkg --print-architecture) |
| 12 | + |
| 13 | +# Uncomment SALT_REPO and ALT_VERSION variable to build Salt manually |
| 14 | +#SALT_REPO="https://github.com/saltstack/salt.git" |
| 15 | +#SALT_VERSION="v3006.19" |
| 16 | +TOOLS_REPO="https://github.com/saltstack/python-tools-scripts" |
| 17 | + |
| 18 | +# Check this page to find a correct relenv/python combination. |
| 19 | +# https://github.com/saltstack/relenv/releases |
| 20 | +RELENV_VERSION="0.22.2" |
| 21 | +RELENV_PYTHON_VERSION="3.11.14" |
| 22 | + |
| 23 | +# Specify the platform parameter, use x86_64 for amd64, arm64 for arm64 |
| 24 | +if [ "${ARCH}" = "arm64" ]; then |
| 25 | + BUILD_ARCH=${ARCH} |
| 26 | +else |
| 27 | + BUILD_ARCH="x86_64" |
| 28 | +fi |
| 29 | + |
| 30 | +# Specify the Python version currently used by VyOS. This version will be used to specify the correct requirements list, |
| 31 | +# for example: requirements/static/pkg/py3.11/tools.tx |
| 32 | +PYTHON_VERSION="3.11" |
| 33 | + |
| 34 | +BUILD_DIR="salt" |
| 35 | +OUTPUT_DIR="$BUILD_DIR/artifacts" |
| 36 | + |
| 37 | +# Prepare Build Directory |
| 38 | +mkdir -p "$BUILD_DIR" |
| 39 | +cd "$BUILD_DIR" |
| 40 | + |
| 41 | +if [ ! -d "python-tools-scripts" ]; then |
| 42 | + git clone ${TOOLS_REPO} |
| 43 | +fi |
| 44 | + |
| 45 | +# Setup Python Build Environment |
| 46 | +echo "Setting up build virtual environment..." |
| 47 | +if [ ! -d "venv-build" ]; then |
| 48 | + python3 -m venv venv-build |
| 49 | +fi |
| 50 | + |
| 51 | +# Install Python build requirements |
| 52 | +echo "Installing Python build requirements..." |
| 53 | +venv-build/bin/python3 -m pip install --upgrade pip |
| 54 | + |
| 55 | +# Install all required build tools |
| 56 | +venv-build/bin/python3 -m pip install relenv build packaging jinja2 pyyaml msgpack-python python-tools-scripts ppbt setuptools tornado |
| 57 | + |
| 58 | +# Install repo-specific tools if found |
| 59 | +if [ -f "requirements/static/pkg/py${PYTHON_VERSION}/tools.txt" ]; then |
| 60 | + venv-build/bin/python3 -m pip install -r requirements/static/pkg/py${PYTHON_VERSION}/tools.txt |
| 61 | +fi |
| 62 | + |
| 63 | +# Build the package |
| 64 | +echo "Starting Build..." |
| 65 | +export PYTHONPATH=$PYTHONPATH:$(pwd) |
| 66 | + |
| 67 | +# The build script below handles fetching the correct runtime version. |
| 68 | +venv-build/bin/python3 -m tools.pkg.build deb |
| 69 | + |
| 70 | +# Example: tools pkg build deb --relenv-version=0.22.2 --python-version=3.10.19 --arch=x86_64 |
| 71 | +venv-build/bin/tools pkg build deb --relenv-version=${RELENV_VERSION} --python-version=${RELENV_PYTHON_VERSION} --arch=${BUILD_ARCH} |
| 72 | + |
| 73 | +echo "List artifacts..." |
| 74 | +find ../ -name "*.deb" |
| 75 | + |
| 76 | +echo "Build finished successfully" |
0 commit comments