kicad/kicad-library-repos-install.patch

114 lines
4.5 KiB
Diff

Index: kicad-4.0.0-rc1/scripts/library-repos-install.sh
===================================================================
--- kicad-4.0.0-rc1.orig/scripts/library-repos-install.sh
+++ kicad-4.0.0-rc1/scripts/library-repos-install.sh
@@ -24,7 +24,8 @@
# Set where the library repos will go, use a full path
-WORKING_TREES=${WORKING_TREES:-~/kicad_sources}
+WORKING_TREES=~/.local/share/kicad
+KICAD_CONFIG_COMMON=~/.config/kicad/kicad_common
usage()
@@ -32,50 +33,35 @@ usage()
echo ""
echo " usage:"
echo ""
- echo "./library-sources-install.sh <cmd>"
+ echo "kicad-library-install.sh <cmd>"
echo " where <cmd> is one of:"
- echo " --install-prerequisites (install command tools needed here, run once first.)"
echo " --install-or-update (from github, the library sources.)"
+ echo " --download-all-libraries (download library sources from GitHub.)"
echo " --remove-all-libraries (remove all *.pretty from $WORKING_TREES/library-repos/. )"
echo " --remove-orphaned-libraries (remove local libraries which have been deleted or renamed at github.)"
echo " --list-libraries (show the full list of github libraries.)"
echo " --create-bat-file (cat a windows batch file, redirect to capture to disk.)"
echo ""
- echo "examples (with --install-prerequisites once first):"
- echo ' $ ./library-sources-install.sh --install-prerequisites'
- echo ' $ ./library-sources-install.sh --install-or-update'
+ echo "Default library directory is $WORKING_TREES/library-repos/"
}
-install_prerequisites()
-{
- # Find a package manager, PM
- PM=$( command -v yum || command -v apt-get )
-
- # assume all these Debian, Mint, Ubuntu systems have same prerequisites
- if [ "$(expr match "$PM" '.*\(apt-get\)')" == "apt-get" ]; then
- #echo "debian compatible system"
- sudo apt-get install \
- git \
- curl \
- sed
-
- # assume all yum systems have same prerequisites
- elif [ "$(expr match "$PM" '.*\(yum\)')" == "yum" ]; then
- #echo "red hat compatible system"
- # Note: if you find this list not to be accurate, please submit a patch:
- sudo yum install \
- git \
- curl \
- sed
+add_libraries_config()
+{
+ # Add libraries to config file
+ if [ ! -d "$KICAD_CONFIG_COMMON" ]; then
+ echo "[EnvironmentVariables]" > $KICAD_CONFIG_COMMON
+ echo "KIGITHUB=$WORKING_TREES/library-repos/" >> $KICAD_CONFIG_COMMON
+ echo "KISYSMOD=$WORKING_TREES/library-repos/kicad-library/modules/" >> $KICAD_CONFIG_COMMON
+ echo "KISYS3DMOD=$WORKING_TREES/library-repos/kicad-library/modules/packages3d/" >> $KICAD_CONFIG_COMMON
+ echo "KICAD_PTEMPLATES=$WORKING_TREES/library-repos/kicad-library/template/" >> $KICAD_CONFIG_COMMON
else
- echo
- echo "Incompatible System. Neither 'yum' nor 'apt-get' found. Not possible to"
- echo "continue. Please make sure to install git, curl, and sed before using this"
- echo "script."
- echo
- exit 1
+ sed -i 's|^KIGITHUB.*|KIGITHUB='$WORKING_TREES'/library-repos/|' $KICAD_CONFIG_COMMON
+ sed -i 's|^KISYSMOD.*|KISYSMOD='$WORKING_TREES'/library-repos/kicad-library/modules/|' $KICAD_CONFIG_COMMON
+ sed -i 's|^KISYS3DMOD.*|KISYS3DMOD='$WORKING_TREES'/library-repos/kicad-library/modules/packages3d/|' $KICAD_CONFIG_COMMON
+ sed -i 's|^KICAD_PTEMPLATES.*|KICAD_PTEMPLATES='$WORKING_TREES'/library-repos/kicad-library/template/|' $KICAD_CONFIG_COMMON
fi
+ cp $WORKING_TREES/library-repos/kicad-library/template/fp-lib-table.for-pretty ~/.config/kicad/fp-lib-table
}
@@ -137,9 +123,7 @@ detect_pretty_repos()
checkout_or_update_libraries()
{
if [ ! -d "$WORKING_TREES" ]; then
- sudo mkdir -p "$WORKING_TREES"
- echo " mark $WORKING_TREES as owned by me"
- sudo chown -R `whoami` "$WORKING_TREES"
+ mkdir -p "$WORKING_TREES"
fi
cd $WORKING_TREES
@@ -216,6 +200,7 @@ remove_orphaned_libraries()
if [ $# -eq 1 -a "$1" == "--install-or-update" ]; then
checkout_or_update_libraries
+ add_libraries_config
exit
fi
@@ -232,11 +217,6 @@ if [ $# -eq 1 -a "$1" == "--remove-all-l
fi
-if [ $# -eq 1 -a "$1" == "--install-prerequisites" ]; then
- install_prerequisites
- exit
-fi
-
if [ $# -eq 1 -a "$1" == "--list-libraries" ]; then
# use github API to get repos into PRETTY_REPOS var