m4sterchain commented on code in PR #206: URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/206#discussion_r2192123661
########## scripts/runtime/bin/switch_config: ########## @@ -0,0 +1,132 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Switch active configurations + +SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")/../config" + +# Function to show usage +show_usage() { + echo "Usage: $0 [OPTIONS]" + echo "" + echo "Options:" + echo " --ta <config> Switch TA configuration only" + echo " --host <config> Switch Host configuration only" + echo " --status Show current active configuration" + echo " --list List all available configurations" + echo " --help Show this help message" + echo "" + echo "Examples:" + echo " $0 --ta std/aarch64 # Switch TA only" + echo " $0 --host aarch64 # Switch Host only" + echo " $0 --status # Show current status" + echo " $0 --list # List available configs" +} + +# Function to show current status +show_status() { + echo "=== Current Active Configuration ===" + echo "TA: $(readlink "$SCRIPT_DIR/ta/active" 2>/dev/null || echo "NOT SET")" + echo "Host: $(readlink "$SCRIPT_DIR/host/active" 2>/dev/null || echo "NOT SET")" +} + +# Function to get available configs for a directory +get_available_configs() { + local config_dir="$1" + find "$config_dir" -type f ! -name "active" | sed "s|$config_dir/||" | sort +} + +# Function to list available configurations +list_configs() { + echo "Available TA configurations:" + get_available_configs "$SCRIPT_DIR/ta" + echo "" + echo "Available Host configurations:" + get_available_configs "$SCRIPT_DIR/host" +} + +# Function to check if config exists +check_existence() { + local config_path="$1" + [ -n "$config_path" ] && [ -f "$SCRIPT_DIR/$config_path" ] +} + +# Function to switch config +switch_config() { + local config_type="$1" + local config_name="$2" + echo "Switching $config_type to: $config_name" + (cd "$SCRIPT_DIR/$config_type" && ln -sf "$config_name" active) Review Comment: This is a nice-to-have feature that we can support in a follow-up commit. ########## scripts/runtime/environment: ########## @@ -15,104 +17,81 @@ # specific language governing permissions and limitations # under the License. -# This script is written into .bashrc to set up toolchains when enter the docker, like: -# docker run -it \ -# -e TA_ARCH=aarch64 \ -# -e CA_ARCH=arm \ -# -e STD=y \ -# teaclave-dev bash +# ============================================================================= +# config/environment (Main configuration - loads active configs) +# ============================================================================= + +# Exit on any error +set -euo pipefail Review Comment: These lines will be removed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org For additional commands, e-mail: dev-h...@teaclave.apache.org