|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2026 Aurora Operations, Inc. |
| 4 | +# |
| 5 | +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0 |
| 6 | +# |
| 7 | +# This work is dual licensed. |
| 8 | +# You may use it under Apache-2.0 or GPL-2.0 at your option. |
| 9 | +# |
| 10 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 | +# you may not use this file except in compliance with the License. |
| 12 | +# You may obtain a copy of the License at |
| 13 | +# |
| 14 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | +# |
| 16 | +# Unless required by applicable law or agreed to in writing, software |
| 17 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | +# See the License for the specific language governing permissions and |
| 20 | +# limitations under the License. |
| 21 | +# |
| 22 | +# OR |
| 23 | +# |
| 24 | +# This program is free software; you can redistribute it and/or |
| 25 | +# modify it under the terms of the GNU General Public License |
| 26 | +# as published by the Free Software Foundation; either version 2 |
| 27 | +# of the License, or (at your option) any later version. |
| 28 | +# |
| 29 | +# This program is distributed in the hope that it will be useful, |
| 30 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 | +# GNU General Public License for more details. |
| 33 | +# |
| 34 | +# You should have received a copy of the GNU General Public License |
| 35 | +# along with this program; if not, see |
| 36 | +# <https://www.gnu.org/licenses/>. |
| 37 | + |
| 38 | +PROJECT="$1" |
| 39 | +LIBNAT20_BR_BUILD_DIR="${2:-${LIBNAT20_ROOT}/buildroot.build}" |
| 40 | +LIBNAT20_ROOT="${3:-$(pwd)}" |
| 41 | + |
| 42 | +LIBNAT20_BR_BUILD_DIR="$(readlink -f "${LIBNAT20_BR_BUILD_DIR}")" |
| 43 | +LIBNAT20_ROOT="$(readlink -f "${LIBNAT20_ROOT}")" |
| 44 | + |
| 45 | + |
| 46 | +case "$PROJECT" in |
| 47 | + qemu) |
| 48 | + ;; |
| 49 | + *) |
| 50 | + echo "Usage: bootstrap.sh <project> <buildroot_build_dir> <libnat20_root>" |
| 51 | + echo |
| 52 | + echo "This script bootstraps the Buildroot environment for the Dice project." |
| 53 | + echo |
| 54 | + echo "This script may be run from any directory, as long as the libnat20 root" |
| 55 | + echo "directory is specified correctly. The first parameter specifies the project." |
| 56 | + echo "See valid options below." |
| 57 | + echo "The second parameter specifies the out of tree Buildroot build directory." |
| 58 | + echo "It uses \"buildroot.build\" inside of the libnat20 root directory by default." |
| 59 | + echo "The third parameter specifies the libnat20 root directory." |
| 60 | + echo "It uses the current working directory by default." |
| 61 | + echo |
| 62 | + echo "Available projects:" |
| 63 | + echo " qemu - Setup Buildroot for the QEMU-based Dice emulator" |
| 64 | + exit 0 |
| 65 | + ;; |
| 66 | +esac |
| 67 | + |
| 68 | +if [ -e "${LIBNAT20_BR_BUILD_DIR}" ]; then |
| 69 | + echo "Buildroot build directory ${LIBNAT20_BR_BUILD_DIR} already exists." |
| 70 | + exit 1 |
| 71 | +fi |
| 72 | + |
| 73 | +if [ ! -d "${LIBNAT20_ROOT}/examples/linux/br_external" ]; then |
| 74 | + echo "Directory ${LIBNAT20_ROOT}/examples/linux/br_external does not exist." |
| 75 | + echo "Please make sure \"${LIBNAT20_ROOT}\" points to the libnat20 root directory." |
| 76 | + exit 1 |
| 77 | +fi |
| 78 | + |
| 79 | +mkdir -p "${LIBNAT20_BR_BUILD_DIR}" |
| 80 | +pushd ${LIBNAT20_BR_BUILD_DIR} |
| 81 | + |
| 82 | +echo "LIBNAT20_BR_BUILD_DIR=${LIBNAT20_BR_BUILD_DIR}" | tee .env |
| 83 | +echo "LIBNAT20_ROOT=${LIBNAT20_ROOT}" | tee -a .env |
| 84 | + |
| 85 | +cp ${LIBNAT20_ROOT}/examples/linux/br_external/utils/envsetup.sh ./ |
| 86 | + |
| 87 | +# Checkout buildroot |
| 88 | +git clone --depth 1 --branch "2025.08.1" https://gitlab.com/buildroot.org/buildroot.git |
| 89 | + |
| 90 | +# Install the buildroot config |
| 91 | +case "$PROJECT" in |
| 92 | + qemu) |
| 93 | + cp ${LIBNAT20_ROOT}/examples/linux/br_external/configs/qemu_br_defconfig buildroot/.config |
| 94 | + cp ${LIBNAT20_ROOT}/examples/linux/br_external/run-qemu.sh ./ |
| 95 | + ;; |
| 96 | + esac |
| 97 | + |
| 98 | +pushd buildroot |
| 99 | + |
| 100 | +make BR2_EXTERNAL=${LIBNAT20_ROOT}/examples/linux/br_external oldconfig |
| 101 | + |
| 102 | +popd |
| 103 | +popd |
| 104 | + |
| 105 | +echo |
| 106 | +echo "Now enter buildroot and run make:" |
| 107 | +echo " $ cd ${LIBNAT20_BR_BUILD_DIR}/buildroot" |
| 108 | +echo ' $ make' |
0 commit comments