From 03bf608a0cc1423ce5c38d661501005004ffd405 Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Tue, 3 Jun 2025 08:24:42 -0700 Subject: [PATCH] Fix a few more issues with new installation method --- .github/workflows/install.yml | 4 +- bin/wally-environment-check.sh | 91 ++++++++++++++++++---------------- bin/wally-package-install.sh | 2 +- 3 files changed, 51 insertions(+), 46 deletions(-) diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index f9ca8c3b7..20699ee15 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -149,7 +149,7 @@ jobs: # Update setup.sh if using a custom $RISCV path - name: Update setup.sh if: ${{ matrix.riscv_path != null }} - run: sed -i 's,/opt/riscv,${{ matrix.riscv_path }},g' setup.sh + run: sed -i 's,~/riscv,${{ matrix.riscv_path }},g' setup.sh # Upload installation logs for debugging - name: Upload Installation Logs uses: actions/upload-artifact@v4 @@ -168,7 +168,7 @@ jobs: - name: make tests run: | source setup.sh - make riscof zsbl deriv --jobs $(nproc --ignore 1) + make riscof zsbl deriv coverage --jobs $(nproc --ignore 1) # Run standard regression, skipping distros that are known to be broken with Verilator - name: Regression if: ${{ matrix.regressionFail != true }} diff --git a/bin/wally-environment-check.sh b/bin/wally-environment-check.sh index 6c635fa25..a36f788aa 100755 --- a/bin/wally-environment-check.sh +++ b/bin/wally-environment-check.sh @@ -141,11 +141,12 @@ fi # Check flags clean=false no_buildroot=false +packages_only=false while [[ "$#" -gt 0 ]]; do case $1 in -c|--clean) clean=true ;; --no-buildroot) no_buildroot=true ;; - --no-args) ;; # Ignore this flag, workaround for sourcing this script in other scripts + --packages-only) packages_only=true;; -h|--help) echo -e "Usage: $0 [\$RISCV] [options]" echo -e "${BOLD}Options:${ENDC}" @@ -161,50 +162,54 @@ done # Check if root ROOT=$( [ "${EUID:=$(id -u)}" == 0 ] && echo true || echo false); -# Set installation directory based on execution privileges -# If the script is run as root, the default installation path is /opt/riscv -# If the script is run as a user, the default installation path is ~/riscv -# The installation path can be overridden with a positional argument passed to the script. -if [ "$ROOT" == true ]; then - export RISCV="${RISCV:-/opt/riscv}" -else - export RISCV="${RISCV:-$HOME/riscv}" -fi - -# Set environment variables -export PATH=$RISCV/bin:$PATH:/usr/bin -export PKG_CONFIG_PATH=$RISCV/lib64/pkgconfig:$RISCV/lib/pkgconfig:$RISCV/share/pkgconfig:$RISCV/lib/x86_64-linux-gnu/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} - -# Check for incompatible PATH environment variable before proceeding with installation -if [[ ":$PATH:" == *::* || ":$PATH:" == *:.:* ]]; then - echo -e "${FAIL_COLOR}Error: You seem to have the current working directory in your \$PATH environment variable." - echo -e "This won't work. Please update your \$PATH and try again.${ENDC}" - exit 1 -fi - -# Increasing NUM_THREADS will speed up parallel compilation of the tools -NUM_THREADS=$(nproc --ignore 1) # One less than the total number of threads - -# Check available memory -total_mem=$(grep MemTotal < /proc/meminfo | awk '{print $2}') -total_mem_gb=$((total_mem / 1024 / 1024)) - -# Reduce number of threads for systems with less than 8 GB of memory -if ((total_mem < 8400000 )) ; then - NUM_THREADS=1 - echo -e "${WARNING_COLOR}Detected less than or equal to 8 GB of memory. Using a single thread for compiling tools. This may take a while.${ENDC}" -fi - -# Create installation directory -mkdir -p "$RISCV"/logs -mkdir -p "$RISCV"/versions - ### Print system information ### echo -e "${OK_COLOR}${UNDERLINE}Detected information${ENDC}" echo "Distribution: $PRETTY_NAME" echo "Version: $VERSION" echo "Running as root: $ROOT" -echo "Installation path: $RISCV" -echo "Number of cores: $(nproc)" -echo "Total memory: $total_mem_gb GB" -echo "Using $NUM_THREADS thread(s) for compilation" + +if [ $packages_only != true ]; then + # Set installation directory based on execution privileges + # If the script is run as root, the default installation path is /opt/riscv + # If the script is run as a user, the default installation path is ~/riscv + # The installation path can be overridden with a positional argument passed to the script. + if [ "$ROOT" == true ]; then + export RISCV="${RISCV:-/opt/riscv}" + else + export RISCV="${RISCV:-$HOME/riscv}" + fi + + # Set environment variables + export PATH=$RISCV/bin:$PATH:/usr/bin + export PKG_CONFIG_PATH=$RISCV/lib64/pkgconfig:$RISCV/lib/pkgconfig:$RISCV/share/pkgconfig:$RISCV/lib/x86_64-linux-gnu/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} + + # Check for incompatible PATH environment variable before proceeding with installation + if [[ ":$PATH:" == *::* || ":$PATH:" == *:.:* ]]; then + echo -e "${FAIL_COLOR}Error: You seem to have the current working directory in your \$PATH environment variable." + echo -e "This won't work. Please update your \$PATH and try again.${ENDC}" + exit 1 + fi + + # Increasing NUM_THREADS will speed up parallel compilation of the tools + NUM_THREADS=$(nproc --ignore 1) # One less than the total number of threads + + # Check available memory + total_mem=$(grep MemTotal < /proc/meminfo | awk '{print $2}') + total_mem_gb=$((total_mem / 1024 / 1024)) + + # Reduce number of threads for systems with less than 8 GB of memory + if ((total_mem < 8400000 )) ; then + NUM_THREADS=1 + echo -e "${WARNING_COLOR}Detected less than or equal to 8 GB of memory. Using a single thread for compiling tools. This may take a while.${ENDC}" + fi + + # Create installation directory + mkdir -p "$RISCV"/logs + mkdir -p "$RISCV"/versions + + # Print more system information + echo "Installation path: $RISCV" + echo "Number of cores: $(nproc)" + echo "Total memory: $total_mem_gb GB" + echo "Using $NUM_THREADS thread(s) for compilation" +fi diff --git a/bin/wally-package-install.sh b/bin/wally-package-install.sh index d3de78cf7..25e7ac3cf 100755 --- a/bin/wally-package-install.sh +++ b/bin/wally-package-install.sh @@ -36,7 +36,7 @@ if [ -z "$FAMILY" ]; then dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" WALLY="$(dirname "$dir")" export WALLY - source "${dir}"/wally-environment-check.sh "--no-args" + source "${dir}"/wally-environment-check.sh "--packages-only" fi