sudo apt -y install kicad kicad-libraries kicad-symbols kicad-footprints kicad-templates kicad-demos kicad-packages4d

# Deps for spice and sycira (maxima) and spice
sudo apt install -y ngspice maxima wxmaxima libtinyxml2-6 libzip5

# Convert KiCAD PCN files  to models for import im Openems Electromagnetic simulator <http://openems.de/.
sudo apt install -y pcbmodelgen

# freerouting
# It imports .dsn-files generated by the Specctra interface of the host system and exports Specctra session files.

# Additional steps for users of KiCad:

# 1.    Download the latest freerouting-executable.jar file from the Releases
# 2.    Start KiCad and open your project in Pcbnew.
# 3.    Export the PCB into Specctra DSN (File / Export... / Specctra DSN).
# 4.    Start the router by running the freerouting-executable.jar file, push the "Open Your Own Design" button and select the exported .dsn file in the file chooser.
# 5.    Do the routing.
# 6.    When you're finished, export the results into a Specctra session file (File / Export Specctra Session File). The router will generate a .ses file for you.
# 7.    Go back to KiCad's Pcbnew and import the results (File / Import Specctra Session...).

# Using the command line arguments:

# Freerouter was designed as a GUI program, but it also can function as a command line tool. Typically you would have an input file (e.g. Specctra DSN) that you exported from you EDA (e.g. KiCad). If this file has unconnected routes, you would want to wire those with autorouter, and save the result in a format that you can then import back into your EDA.

# The following command line arguments are supported by freerouter:

#    -de [design input file]: loads up a Specctra .dsn file at startup
#    -di [design input directory]: if the GUI is used, this sets the default folder for the open design dialogs
#    -dr [design rules file]: reads the rules from a previously saved .rules file
#    -do [design output file]: saves a Specctra board (.dsn), a Specctra session file (.ses) or Eagle session script file (.scr) when the routing is finished
#    -mp [number of passes]: sets the upper limit of the number of passes that will be performed
#    -l [language]: "de" for German, otherwise it's English

# A complete command line looks something like this if you are are using PowerShell on Windows:
# & "c:\Program Files\Java\jdk-11.0.6\bin\java.exe" -jar freerouting-executable.jar -de MyBoard.dsn -do MyBoard.ses -mp 100 -dr MyBoard.rules

# A complete command line looks something like this if you are using bash on linux:
# $ java -jar freerouting-executable.jar -de MyBoard.dsn -do MyBoard.ses -mp 100 -dr MyBoard.rules

# This would read the MyBoard.dsn file, do the auto-routing with the parameters defined in MyBoard.rules for the maximum of 100 passes, and then save the result into the MyBoard.ses file.

# https://techexplorations.com/blog/kicad/blog-kicad-5-how-to-use-the-freerouting-autorouter

sudo apt-get -y install openjdk-11-jre-headless

#PREFIX=/tmp
#NAME=freerouting
#PROJECT=freerouting/freerouting
#RELEASE=$(curl -s https://api.github.com/repos/${PROJECT}/releases/latest | grep tarball_url | cut -d '"' -f 4 | awk -F "/" {'print $8'} | tr -d v)
#
#wget -c -P ${PREFIX} http://github.com/${PROJECT}/releases/download/v${RELEASE}/${NAME}-${RELEASE}-linux-x64.zip
#unzip ${PREFIX}/${NAME}-${RELEASE}-linux-x64.zip

# The freerouter executable can be found here:
# ${PREFIX}/${NAME}-${RELEASE}-linux-x64/lib/app/freerouting-executable.jar

cd /var/tmp
##git clone http://github.com/miho/freerouting
#git clone http://github.com/freerouting/freerouting
#
#cd freerouting
#bash gradlew assemble
#
#echo "All four .jar files will be generated in the build\libs subfolder."
#
#echo "You would typically run the freerouting-executable.jar file."

# Color schemes
git clone http://github.com/pointhi/kicad-color-schemes

python3 kicad-color-schemes/patch.py kicad-color-schemes/eagle/ ~/.config/kicad/
