From 0cc09d6df6b8278e27c6ae4a74f56399069fe04f Mon Sep 17 00:00:00 2001 From: "S.shiva krishna reddy" <128881036+Shiva0krishna@users.noreply.github.com> Date: Fri, 14 Feb 2025 22:05:42 +0530 Subject: [PATCH 1/2] Update install-eSim.sh changes include - KICAD-6 to KICAD-8 , creating a virtual env to install pythno packages without any confilicts , placing the SKY130 PDK in a standard, system-wide location by copying and removing instaed of moving(solves file synchronisation conflicts ) and error handlng and including edge cases --- Ubuntu/install-eSim.sh | 146 +++++++++++++++++++++++++---------------- 1 file changed, 91 insertions(+), 55 deletions(-) diff --git a/Ubuntu/install-eSim.sh b/Ubuntu/install-eSim.sh index 0d36709d0..f5ace6751 100755 --- a/Ubuntu/install-eSim.sh +++ b/Ubuntu/install-eSim.sh @@ -16,7 +16,7 @@ # Sumanto Kar, Partha Singha Roy # ORGANIZATION: eSim Team, FOSSEE, IIT Bombay # CREATED: Wednesday 15 July 2015 15:26 -# REVISION: Tuesday 31 December 2024 17:28 +# REVISION: Friday 14 February 2025 10:00 #============================================================================= # All variables goes here @@ -54,32 +54,46 @@ function createConfigFile echo "IMAGES = %(eSim_HOME)s/images" >> $config_dir/$config_file echo "VERSION = %(eSim_HOME)s/VERSION" >> $config_dir/$config_file echo "MODELICA_MAP_JSON = %(eSim_HOME)s/library/ngspicetoModelica/Mapping.json" >> $config_dir/$config_file - + } -function installNghdl -{ - +function installNghdl { echo "Installing NGHDL..........................." - unzip -o nghdl.zip - cd nghdl/ + + # Check if NGHDL is already extracted + if [ -d "nghdl" ]; then + echo "nghdl/ directory already exists. Skipping unzip..." + else + unzip -o nghdl.zip || { echo "Failed to unzip nghdl.zip"; exit 1; } + echo "Successfully extracted nghdl.zip" + fi + + cd nghdl/ || { echo "Failed to change directory to nghdl/"; exit 1; } + chmod +x install-nghdl.sh - # Do not trap on error of any command. Let NGHDL script handle its own errors. - trap "" ERR + trap "" ERR - ./install-nghdl.sh --install # Install NGHDL - - # Set trap again to error_exit function to exit on errors - trap error_exit ERR + ./install-nghdl.sh --install + + trap error_exit ERR + + # Verify if NGHDL was installed successfully + if ! command -v ghdl >/dev/null; then + echo "Error: NGHDL installation failed" + exit 1 + fi + + echo "NGHDL installation completed successfully." ngspiceFlag=1 - cd ../ + cd ../ || { echo "Failed to return to parent directory"; exit 1; } } + function installSky130Pdk { @@ -93,33 +107,38 @@ function installSky130Pdk # Copy SKY130 library echo "Copying SKY130 PDK........................." - sudo mkdir -p /usr/share/local/ - sudo mv sky130_fd_pr /usr/share/local/ + echo "Directory created" + # sudo mv sky130_fd_pr /usr/share/local/ + # placing the SKY130 PDK in a standard, system-wide location. + + sudo cp -R sky130_fd_pr /usr/share/local/ + + sudo rm -rf sky130_fd_pr # Change ownership from root to the user sudo chown -R $USER:$USER /usr/share/local/sky130_fd_pr/ } +function installKicad { + echo "Installing KiCad..." -function installKicad -{ - - echo "Installing KiCad..........................." - - kicadppa="kicad/kicad-6.0-releases" + kicadppa="kicad/kicad-8.0-releases" findppa=$(grep -h -r "^deb.*$kicadppa*" /etc/apt/sources.list* > /dev/null 2>&1 || test $? = 1) + if [ -z "$findppa" ]; then - echo "Adding KiCad-6 ppa to local apt-repository" - sudo add-apt-repository -y ppa:kicad/kicad-6.0-releases - sudo apt-get update + echo "Adding KiCad-8 PPA to local apt repository..." + sudo add-apt-repository -y ppa:kicad/kicad-8.0-releases + sudo apt update else - echo "KiCad-6 is available in synaptic" + echo "KiCad-8 PPA is already added." fi - sudo apt-get install -y --no-install-recommends kicad kicad-footprints kicad-libraries kicad-symbols kicad-templates + echo "Installing KiCad and necessary libraries..." + sudo apt install -y --no-install-recommends kicad + echo "KiCad installation completed successfully!" } @@ -191,48 +210,63 @@ function installDependency } -function copyKicadLibrary -{ +function copyKicadLibrary { + set -e # Exit immediately on error + trap 'echo "An error occurred! Exiting..."; exit 1' ERR - #Extract custom KiCad Library - tar -xJf library/kicadLibrary.tar.xz + echo "Extracting custom KiCad Library..." + tar -xJf library/kicadLibrary.tar.xz -C library || { echo "Extraction failed!"; exit 1; } - if [ -d ~/.config/kicad/6.0 ];then - echo "kicad config folder already exists" - else - echo ".config/kicad/6.0 does not exist" - mkdir -p ~/.config/kicad/6.0 + # Detect the latest installed KiCad version + kicad_config_dir="$HOME/.config/kicad" + latest_version=$(ls "$kicad_config_dir" | grep -E "^[0-9]+\.[0-9]+$" | sort -V | tail -n 1) + + if [ -z "$latest_version" ]; then + latest_version="8.0" # Default to the latest known version + mkdir -p "$kicad_config_dir/$latest_version" + echo "Created KiCad config directory: $kicad_config_dir/$latest_version" + else + echo "Using existing KiCad version: $latest_version" fi - # Copy symbol table for eSim custom symbols - cp kicadLibrary/template/sym-lib-table ~/.config/kicad/6.0/ - echo "symbol table copied in the directory" + kicad_version_dir="$kicad_config_dir/$latest_version" - # Copy KiCad symbols made for eSim - sudo cp -r kicadLibrary/eSim-symbols/* /usr/share/kicad/symbols/ + # Copy the symbol table for eSim custom symbols + echo "Copying symbol table..." + cp library/kicadLibrary/template/sym-lib-table "$kicad_version_dir/" - set +e # Temporary disable exit on error - trap "" ERR # Do not trap on error of any command - - # Remove extracted KiCad Library - not needed anymore - rm -rf kicadLibrary + # Ensure KiCad symbols directory exists + kicad_symbols_dir="/usr/share/kicad/symbols" + if [ ! -d "$kicad_symbols_dir" ]; then + echo "Creating KiCad symbols directory..." + sudo mkdir -p "$kicad_symbols_dir" + fi - set -e # Re-enable exit on error - trap error_exit ERR + # Copy custom symbols using rsync for better reliability + echo "Copying eSim custom symbols..." + sudo rsync -av library/kicadLibrary/eSim-symbols/ "$kicad_symbols_dir/" - #Change ownership from Root to the User - sudo chown -R $USER:$USER /usr/share/kicad/symbols/ + # Cleanup: Remove extracted KiCad Library (not needed anymore) + echo "Removing extracted KiCad library..." + rm -rf library/kicadLibrary + # Change ownership from root to the user only if needed + if [ "$(stat -c "%U" "$kicad_symbols_dir")" != "$USER" ]; then + echo "Changing ownership of KiCad symbols directory..." + sudo chown -R "$USER:$USER" "$kicad_symbols_dir" + fi + + echo "KiCad Library successfully copied and configured!" } + function createDesktopStartScript { - # Generating new esim-start.sh + # Generating new esim-start.sh echo '#!/bin/bash' > esim-start.sh echo "cd $eSim_Home/src/frontEnd" >> esim-start.sh - echo "source $config_dir/env/bin/activate" >> esim-start.sh echo "python3 Application.py" >> esim-start.sh # Make it executable @@ -382,11 +416,12 @@ elif [ $option == "--uninstall" ];then echo "Removing KiCad..........................." sudo apt purge -y kicad kicad-footprints kicad-libraries kicad-symbols kicad-templates sudo rm -rf /usr/share/kicad - sudo rm /etc/apt/sources.list.d/kicad* rm -rf $HOME/.config/kicad/6.0 - echo "Removing Virtual env......................." - sudo rm -r $config_dir/env + echo "Removing Makerchip......................." + pip3 uninstall -y hdlparse + pip3 uninstall -y makerchip-app + pip3 uninstall -y sandpiper-saas echo "Removing SKY130 PDK......................" sudo rm -R /usr/share/local/sky130_fd_pr @@ -420,3 +455,4 @@ else echo "--install" echo "--uninstall" fi + From d3ba66b3f0c000648b3fabcf305b4788236ab05f Mon Sep 17 00:00:00 2001 From: "S.shiva krishna reddy" <128881036+Shiva0krishna@users.noreply.github.com> Date: Sun, 30 Mar 2025 18:35:20 +0530 Subject: [PATCH 2/2] Update install-eSim.sh Updated dependency issues and updated version of KICAD 8 from version 6. --- Ubuntu/install-eSim.sh | 91 +++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/Ubuntu/install-eSim.sh b/Ubuntu/install-eSim.sh index f5ace6751..a286f9888 100755 --- a/Ubuntu/install-eSim.sh +++ b/Ubuntu/install-eSim.sh @@ -16,7 +16,7 @@ # Sumanto Kar, Partha Singha Roy # ORGANIZATION: eSim Team, FOSSEE, IIT Bombay # CREATED: Wednesday 15 July 2015 15:26 -# REVISION: Friday 14 February 2025 10:00 +# REVISION: Sunday 30 March 2024 18:40 #============================================================================= # All variables goes here @@ -54,46 +54,32 @@ function createConfigFile echo "IMAGES = %(eSim_HOME)s/images" >> $config_dir/$config_file echo "VERSION = %(eSim_HOME)s/VERSION" >> $config_dir/$config_file echo "MODELICA_MAP_JSON = %(eSim_HOME)s/library/ngspicetoModelica/Mapping.json" >> $config_dir/$config_file - + } -function installNghdl { - echo "Installing NGHDL..........................." - - # Check if NGHDL is already extracted - if [ -d "nghdl" ]; then - echo "nghdl/ directory already exists. Skipping unzip..." - else - unzip -o nghdl.zip || { echo "Failed to unzip nghdl.zip"; exit 1; } - echo "Successfully extracted nghdl.zip" - fi - - cd nghdl/ || { echo "Failed to change directory to nghdl/"; exit 1; } +function installNghdl +{ + echo "Installing NGHDL..........................." + unzip -o nghdl.zip + cd nghdl/ chmod +x install-nghdl.sh - trap "" ERR + # Do not trap on error of any command. Let NGHDL script handle its own errors. + trap "" ERR - ./install-nghdl.sh --install - - trap error_exit ERR - - # Verify if NGHDL was installed successfully - if ! command -v ghdl >/dev/null; then - echo "Error: NGHDL installation failed" - exit 1 - fi - - echo "NGHDL installation completed successfully." + ./install-nghdl.sh --install # Install NGHDL + + # Set trap again to error_exit function to exit on errors + trap error_exit ERR ngspiceFlag=1 + cd ../ - cd ../ || { echo "Failed to return to parent directory"; exit 1; } } - function installSky130Pdk { @@ -107,25 +93,21 @@ function installSky130Pdk # Copy SKY130 library echo "Copying SKY130 PDK........................." - sudo mkdir -p /usr/share/local/ - echo "Directory created" - # sudo mv sky130_fd_pr /usr/share/local/ - # placing the SKY130 PDK in a standard, system-wide location. - sudo cp -R sky130_fd_pr /usr/share/local/ - - sudo rm -rf sky130_fd_pr + sudo mkdir -p /usr/share/local/ + sudo mv sky130_fd_pr /usr/share/local/ # Change ownership from root to the user sudo chown -R $USER:$USER /usr/share/local/sky130_fd_pr/ } + function installKicad { echo "Installing KiCad..." kicadppa="kicad/kicad-8.0-releases" - findppa=$(grep -h -r "^deb.*$kicadppa*" /etc/apt/sources.list* > /dev/null 2>&1 || test $? = 1) + findppa=$(grep -h -r "^deb.$kicadppa" /etc/apt/sources.list* > /dev/null 2>&1 || test $? = 1) if [ -z "$findppa" ]; then echo "Adding KiCad-8 PPA to local apt repository..." @@ -142,23 +124,21 @@ function installKicad { } -function installDependency -{ - +function installDependency { set +e # Temporary disable exit on error trap "" ERR # Do not trap on error of any command - # Update apt repository echo "Updating apt index files..................." sudo apt-get update set -e # Re-enable exit on error trap error_exit ERR - echo "Instaling virtualenv......................." - sudo apt install python3-virtualenv + echo "Installing virtualenv......................." + sudo apt install -y python3-virtualenv echo "Creating virtual environment to isolate packages " + rm -rf $config_dir/env virtualenv $config_dir/env echo "Starting the virtual env..................." @@ -167,6 +147,9 @@ function installDependency echo "Upgrading Pip.............................." pip install --upgrade pip + echo "Reinstalling Matplotlib and PyQt5 to fix corrupted dependencies" + pip install --force-reinstall --no-cache-dir PyQt5 PyQt5-sip matplotlib + echo "Installing Xterm..........................." sudo apt-get install -y xterm @@ -175,14 +158,13 @@ function installDependency echo "Installing PyQt5..........................." sudo apt-get install -y python3-pyqt5 - + echo "Installing Matplotlib......................" sudo apt-get install -y python3-matplotlib - + echo "Installing Distutils......................." sudo apt-get install -y python3-distutils - - # Install NgVeri Depedencies + echo "Installing Pip3............................" sudo apt install -y python3-pip @@ -198,7 +180,6 @@ function installDependency echo "Installing SandPiper Saas.................." pip3 install sandpiper-saas - echo "Installing Hdlparse......................" pip3 install hdlparse @@ -210,6 +191,9 @@ function installDependency } + + + function copyKicadLibrary { set -e # Exit immediately on error trap 'echo "An error occurred! Exiting..."; exit 1' ERR @@ -259,14 +243,13 @@ function copyKicadLibrary { echo "KiCad Library successfully copied and configured!" } - - function createDesktopStartScript { - # Generating new esim-start.sh + # Generating new esim-start.sh echo '#!/bin/bash' > esim-start.sh echo "cd $eSim_Home/src/frontEnd" >> esim-start.sh + echo "source $config_dir/env/bin/activate" >> esim-start.sh echo "python3 Application.py" >> esim-start.sh # Make it executable @@ -416,12 +399,11 @@ elif [ $option == "--uninstall" ];then echo "Removing KiCad..........................." sudo apt purge -y kicad kicad-footprints kicad-libraries kicad-symbols kicad-templates sudo rm -rf /usr/share/kicad + sudo rm /etc/apt/sources.list.d/kicad* rm -rf $HOME/.config/kicad/6.0 - echo "Removing Makerchip......................." - pip3 uninstall -y hdlparse - pip3 uninstall -y makerchip-app - pip3 uninstall -y sandpiper-saas + echo "Removing Virtual env......................." + sudo rm -r $config_dir/env echo "Removing SKY130 PDK......................" sudo rm -R /usr/share/local/sky130_fd_pr @@ -455,4 +437,3 @@ else echo "--install" echo "--uninstall" fi -