2013-12-23 15:39:40 +00:00
|
|
|
#!/bin/bash -e
|
2013-10-22 14:28:30 +00:00
|
|
|
# Install KiCad from source onto either:
|
|
|
|
# -> a Ubuntu/Debian/Mint or
|
|
|
|
# -> a Red Hat
|
|
|
|
# compatible linux system.
|
|
|
|
#
|
2013-12-02 18:21:06 +00:00
|
|
|
# The "install_prerequisites" step is the only "distro dependent" one. That step could be modified
|
|
|
|
# for other linux distros.
|
|
|
|
#
|
|
|
|
# There are 3 package groups in a KiCad install:
|
|
|
|
# 1) Compiled source code in the form of executable programs.
|
|
|
|
# 2) User manuals and other documentation typically as *.pdf files.
|
|
|
|
# 3) a) Schematic parts, b) layout footprints, and c) 3D models for footprints.
|
|
|
|
#
|
|
|
|
# To achieve 1) source is checked out from its repo and compiled by this script then executables
|
|
|
|
# are installed using CMake.
|
|
|
|
# To achieve 2) documentation is checked out from its repo and installed using CMake.
|
|
|
|
# TO achieve 3a) and 3c) they are checked out from their repos and installed using CMake.
|
|
|
|
# To achieve 3b) a global fp-lib-table is put into your home directory which points to
|
|
|
|
# http://github.com/KiCad. No actual footprints are installed locally, internet access is used
|
|
|
|
# during program operation to fetch footprints from github as if it was a remote drive in the cloud.
|
|
|
|
# If you want to install those same KiCad footprints locally, you may run a separate script
|
|
|
|
# named library-repos-install.sh found in this same directory. That script requires that "git" be on
|
|
|
|
# your system whereas this script does not. The footprints require some means to download them and
|
|
|
|
# bzr-git seems not up to the task. wget or curl would also work.
|
2013-10-17 15:33:46 +00:00
|
|
|
|
|
|
|
|
2013-12-23 15:39:40 +00:00
|
|
|
# Since bash is invoked with -e by the first line of this script, all the steps in this script
|
|
|
|
# must succeed otherwise bash will abort at the first non-zero error code. Therefore any script
|
|
|
|
# functions must be crafted to anticipate numerous conditions, such that no command fails unless it
|
|
|
|
# is a serious situation.
|
|
|
|
|
|
|
|
|
2013-10-24 13:57:01 +00:00
|
|
|
# Set where the 3 source trees will go, use a full path
|
2013-10-17 15:33:46 +00:00
|
|
|
WORKING_TREES=~/kicad_sources
|
|
|
|
|
2014-05-06 05:23:57 +00:00
|
|
|
STABLE=tag:pre-kiway # currently the best mix of features and stabilty
|
|
|
|
TESTING=last:1 # the most recent
|
|
|
|
|
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
# Set this to STABLE or TESTING or other known revision number:
|
2014-05-06 05:23:57 +00:00
|
|
|
REVISION=$STABLE
|
|
|
|
|
|
|
|
# For info on revision syntax:
|
|
|
|
# $ bzr help revisionspec
|
|
|
|
|
|
|
|
|
2013-11-10 06:31:13 +00:00
|
|
|
# CMake Options
|
2014-06-11 05:00:30 +00:00
|
|
|
OPTS="$OPTS -DBUILD_GITHUB_PLUGIN=ON" # needed by $STABLE revision
|
2013-11-10 06:31:13 +00:00
|
|
|
|
|
|
|
# Python scripting, uncomment to enable
|
|
|
|
#OPTS="$OPTS -DKICAD_SCRIPTING=ON -DKICAD_SCRIPTING_MODULES=ON -DKICAD_SCRIPTING_WXPYTHON=ON"
|
|
|
|
|
2014-04-06 18:50:59 +00:00
|
|
|
# Use https under bazaar to retrieve repos because this does not require a
|
|
|
|
# launchpad.net account. Whereas lp:<something> requires a launchpad account.
|
|
|
|
# https results in read only access.
|
|
|
|
REPOS=https://code.launchpad.net
|
|
|
|
|
2014-04-06 19:12:37 +00:00
|
|
|
# This branch is a bzr/launchpad import of the Git repository
|
|
|
|
# at https://github.com/KiCad/kicad-library.git.
|
|
|
|
# It has schematic parts and 3D models in it.
|
|
|
|
LIBS_REPO=$REPOS/~kicad-product-committers/kicad/library
|
|
|
|
|
2014-04-06 18:50:59 +00:00
|
|
|
SRCS_REPO=$REPOS/~kicad-product-committers/kicad/product
|
|
|
|
DOCS_REPO=$REPOS/~kicad-developers/kicad/doc
|
2013-12-02 18:21:06 +00:00
|
|
|
|
2013-10-17 15:33:46 +00:00
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
echo " usage:"
|
|
|
|
echo ""
|
|
|
|
echo "./kicad-install.sh <cmd>"
|
|
|
|
echo " where <cmd> is one of:"
|
2013-12-02 18:21:06 +00:00
|
|
|
echo " --install-or-update (does full installation or update.)"
|
|
|
|
echo " --remove-sources (removes source trees for another attempt.)"
|
|
|
|
echo " --uninstall-libraries (removes KiCad supplied libraries.)"
|
|
|
|
echo " --uninstall-kicad (uninstalls all of KiCad but leaves source trees.)"
|
2013-10-17 15:33:46 +00:00
|
|
|
echo ""
|
|
|
|
echo "example:"
|
|
|
|
echo ' $ ./kicad-install.sh --install-or-update'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-22 14:28:30 +00:00
|
|
|
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 \
|
|
|
|
bzr \
|
|
|
|
bzrtools \
|
|
|
|
build-essential \
|
|
|
|
cmake \
|
|
|
|
cmake-curses-gui \
|
|
|
|
debhelper \
|
|
|
|
doxygen \
|
2013-12-13 15:35:05 +00:00
|
|
|
grep \
|
2013-10-23 11:40:17 +00:00
|
|
|
libbz2-dev \
|
2013-11-06 14:37:39 +00:00
|
|
|
libcairo2-dev \
|
2013-11-06 06:14:15 +00:00
|
|
|
libglew-dev \
|
2013-10-22 14:28:30 +00:00
|
|
|
libssl-dev \
|
2013-11-10 06:31:13 +00:00
|
|
|
libwxgtk2.8-dev \
|
|
|
|
python-wxgtk2.8
|
2013-10-22 14:28:30 +00:00
|
|
|
|
|
|
|
# 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:
|
2013-11-27 14:13:06 +00:00
|
|
|
sudo yum groupinstall "Development Tools"
|
|
|
|
sudo yum install \
|
2013-10-22 14:28:30 +00:00
|
|
|
bzr \
|
|
|
|
bzrtools \
|
2013-12-13 15:35:05 +00:00
|
|
|
bzip2-libs \
|
|
|
|
bzip2-devel \
|
2013-10-22 14:28:30 +00:00
|
|
|
cmake \
|
2013-11-27 14:13:06 +00:00
|
|
|
cmake-gui \
|
2013-10-22 14:28:30 +00:00
|
|
|
doxygen \
|
2013-11-27 14:13:06 +00:00
|
|
|
cairo-devel \
|
|
|
|
glew-devel \
|
2013-12-13 15:35:05 +00:00
|
|
|
grep \
|
2013-11-27 14:13:06 +00:00
|
|
|
openssl-devel \
|
|
|
|
wxGTK-devel \
|
|
|
|
wxPython
|
2013-10-22 14:28:30 +00:00
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "Incompatible System. Neither 'yum' nor 'apt-get' found. Not possible to continue."
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-11-07 18:15:58 +00:00
|
|
|
|
|
|
|
# ensure bzr name and email are set. No message since bzr prints an excellent diagnostic.
|
2014-04-11 13:30:30 +00:00
|
|
|
bzr whoami || {
|
|
|
|
echo "WARNING: You have not set bzr whoami, so I will set a dummy."
|
|
|
|
export BZR_EMAIL="Kicad Build <nobody@foo>"
|
|
|
|
}
|
2013-10-22 14:28:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-24 13:57:01 +00:00
|
|
|
rm_build_dir()
|
|
|
|
{
|
|
|
|
local dir="$1"
|
2013-12-23 15:39:40 +00:00
|
|
|
|
|
|
|
echo "removing directory $dir"
|
|
|
|
|
|
|
|
if [ -e "$dir/install_manifest.txt" ]; then
|
|
|
|
# this file is often created as root, so remove as root
|
|
|
|
sudo rm "$dir/install_manifest.txt" 2> /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$dir" ]; then
|
|
|
|
rm -rf "$dir"
|
|
|
|
fi
|
2013-10-24 13:57:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-31 19:12:14 +00:00
|
|
|
cmake_uninstall()
|
|
|
|
{
|
|
|
|
# assume caller set the CWD, and is only telling us about it in $1
|
|
|
|
local dir="$1"
|
|
|
|
|
|
|
|
cwd=`pwd`
|
|
|
|
if [ "$cwd" != "$dir" ]; then
|
|
|
|
echo "missing dir $dir"
|
|
|
|
elif [ ! -e install_manifest.txt ]; then
|
|
|
|
echo
|
|
|
|
echo "Missing file $dir/install_manifest.txt."
|
|
|
|
else
|
|
|
|
echo "uninstalling from $dir"
|
|
|
|
sudo make uninstall
|
|
|
|
sudo rm install_manifest.txt
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-13 15:35:05 +00:00
|
|
|
# Function set_env_var
|
|
|
|
# sets an environment variable globally.
|
|
|
|
set_env_var()
|
|
|
|
{
|
2013-12-23 15:39:40 +00:00
|
|
|
local var=$1
|
|
|
|
local val=$2
|
2013-12-13 15:35:05 +00:00
|
|
|
|
|
|
|
if [ -d /etc/profile.d ]; then
|
2013-12-23 15:39:40 +00:00
|
|
|
if [ ! -e /etc/profile.d/kicad.sh ] || ! grep "$var" /etc/profile.d/kicad.sh >> /dev/null; then
|
2013-12-13 15:35:05 +00:00
|
|
|
echo
|
2013-12-23 15:39:40 +00:00
|
|
|
echo "Adding environment variable $var to file /etc/profile.d/kicad.sh"
|
2013-12-13 15:35:05 +00:00
|
|
|
echo "Please logout and back in after this script completes for environment"
|
|
|
|
echo "variable to get set into environment."
|
2013-12-23 15:39:40 +00:00
|
|
|
sudo sh -c "echo export $var=$val >> /etc/profile.d/kicad.sh"
|
2013-12-13 15:35:05 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
elif [ -e /etc/environment ]; then
|
2013-12-23 15:39:40 +00:00
|
|
|
if ! grep "$var" /etc/environment >> /dev/null; then
|
2013-12-13 15:35:05 +00:00
|
|
|
echo
|
2013-12-23 15:39:40 +00:00
|
|
|
echo "Adding environment variable $var to file /etc/environment"
|
2013-12-13 15:35:05 +00:00
|
|
|
echo "Please reboot after this script completes for environment variable to get set into environment."
|
2013-12-23 15:39:40 +00:00
|
|
|
sudo sh -c "echo $var=$val >> /etc/environment"
|
2013-12-13 15:35:05 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-17 15:33:46 +00:00
|
|
|
install_or_update()
|
|
|
|
{
|
|
|
|
echo "step 1) installing pre-requisites"
|
2013-10-22 14:28:30 +00:00
|
|
|
install_prerequisites
|
2013-10-17 15:33:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
echo "step 2) make $WORKING_TREES if it does not exist"
|
|
|
|
if [ ! -d "$WORKING_TREES" ]; then
|
|
|
|
sudo mkdir -p "$WORKING_TREES"
|
|
|
|
echo " mark $WORKING_TREES as owned by me"
|
|
|
|
sudo chown -R `whoami` "$WORKING_TREES"
|
|
|
|
fi
|
|
|
|
cd $WORKING_TREES
|
|
|
|
|
|
|
|
|
|
|
|
echo "step 3) checking out the source code from launchpad repo..."
|
|
|
|
if [ ! -d "$WORKING_TREES/kicad.bzr" ]; then
|
2014-05-08 22:29:22 +00:00
|
|
|
bzr checkout -r $REVISION $SRCS_REPO kicad.bzr
|
2013-10-17 15:33:46 +00:00
|
|
|
echo " source repo to local working tree."
|
|
|
|
else
|
|
|
|
cd kicad.bzr
|
2014-05-06 05:23:57 +00:00
|
|
|
bzr up -r $REVISION
|
2013-10-17 15:33:46 +00:00
|
|
|
echo " local source working tree updated."
|
|
|
|
cd ../
|
|
|
|
fi
|
|
|
|
|
2014-04-06 19:12:37 +00:00
|
|
|
echo "step 4) checking out the schematic parts and 3D library repo."
|
2013-10-17 15:33:46 +00:00
|
|
|
if [ ! -d "$WORKING_TREES/kicad-lib.bzr" ]; then
|
2014-04-06 19:12:37 +00:00
|
|
|
bzr checkout $LIBS_REPO kicad-lib.bzr
|
2013-10-24 13:57:01 +00:00
|
|
|
echo ' kicad-lib checked out.'
|
2013-10-17 15:33:46 +00:00
|
|
|
else
|
|
|
|
cd kicad-lib.bzr
|
|
|
|
bzr up
|
2013-10-24 13:57:01 +00:00
|
|
|
echo ' kicad-lib repo updated.'
|
2013-10-17 15:33:46 +00:00
|
|
|
cd ../
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "step 5) checking out the documentation from launchpad repo..."
|
|
|
|
if [ ! -d "$WORKING_TREES/kicad-doc.bzr" ]; then
|
2014-04-06 18:50:59 +00:00
|
|
|
bzr checkout $DOCS_REPO kicad-doc.bzr
|
2013-10-17 15:33:46 +00:00
|
|
|
echo " docs checked out."
|
|
|
|
else
|
|
|
|
cd kicad-doc.bzr
|
|
|
|
bzr up
|
|
|
|
echo " docs working tree updated."
|
|
|
|
cd ../
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "step 6) compiling source code..."
|
|
|
|
cd kicad.bzr
|
2013-10-24 13:57:01 +00:00
|
|
|
if [ ! -d "build" ]; then
|
|
|
|
mkdir build && cd build
|
2013-11-10 06:31:13 +00:00
|
|
|
cmake $OPTS ../
|
2013-10-24 13:57:01 +00:00
|
|
|
else
|
|
|
|
cd build
|
|
|
|
# Although a "make clean" is sometimes needed, more often than not it slows down the update
|
|
|
|
# more than it is worth. Do it manually if you need to in this directory.
|
|
|
|
# make clean
|
|
|
|
fi
|
|
|
|
make -j4
|
2013-10-17 15:33:46 +00:00
|
|
|
echo " kicad compiled."
|
|
|
|
|
|
|
|
|
|
|
|
echo "step 7) installing KiCad program files..."
|
|
|
|
sudo make install
|
2013-10-17 19:03:36 +00:00
|
|
|
echo " kicad program files installed."
|
2013-10-17 15:33:46 +00:00
|
|
|
|
|
|
|
|
2013-12-02 18:21:06 +00:00
|
|
|
echo "step 8) installing libraries..."
|
2013-10-17 15:33:46 +00:00
|
|
|
cd ../../kicad-lib.bzr
|
2013-10-24 13:57:01 +00:00
|
|
|
rm_build_dir build
|
|
|
|
mkdir build && cd build
|
2013-10-17 15:33:46 +00:00
|
|
|
cmake ../
|
|
|
|
sudo make install
|
2013-12-23 15:39:40 +00:00
|
|
|
echo " kicad-lib.bzr installed."
|
2013-10-17 15:33:46 +00:00
|
|
|
|
|
|
|
|
2014-04-11 13:36:20 +00:00
|
|
|
echo "step 9) as non-root, install global fp-lib-table if none already installed..."
|
2013-12-02 18:21:06 +00:00
|
|
|
# install ~/fp-lib-table
|
2014-04-11 13:36:20 +00:00
|
|
|
if [ ! -e ~/fp-lib-table ]; then
|
|
|
|
make install_github_fp-lib-table
|
|
|
|
echo " global fp-lib-table installed."
|
|
|
|
fi
|
2013-12-02 18:21:06 +00:00
|
|
|
|
|
|
|
|
2013-10-17 19:03:36 +00:00
|
|
|
echo "step 10) installing documentation..."
|
2013-10-17 15:33:46 +00:00
|
|
|
cd ../../kicad-doc.bzr
|
2013-10-24 13:57:01 +00:00
|
|
|
rm_build_dir build
|
|
|
|
mkdir build && cd build
|
2013-10-17 15:33:46 +00:00
|
|
|
cmake ../
|
|
|
|
sudo make install
|
|
|
|
echo " kicad-doc.bzr installed."
|
2013-10-24 13:57:01 +00:00
|
|
|
|
2013-12-23 15:39:40 +00:00
|
|
|
echo "step 11) check for environment variables..."
|
2013-12-04 22:19:55 +00:00
|
|
|
if [ -z "${KIGITHUB}" ]; then
|
2013-12-13 15:35:05 +00:00
|
|
|
set_env_var KIGITHUB https://github.com/KiCad
|
2013-12-04 22:19:55 +00:00
|
|
|
fi
|
2013-12-23 15:39:40 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo 'All KiCad "--install-or-update" steps completed, you are up to date.'
|
|
|
|
echo
|
2013-10-17 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ $# -eq 1 -a "$1" == "--remove-sources" ]; then
|
2013-10-22 14:28:30 +00:00
|
|
|
echo "deleting $WORKING_TREES"
|
2013-10-24 13:57:01 +00:00
|
|
|
rm_build_dir "$WORKING_TREES/kicad.bzr/build"
|
|
|
|
rm_build_dir "$WORKING_TREES/kicad-lib.bzr/build"
|
|
|
|
rm_build_dir "$WORKING_TREES/kicad-doc.bzr/build"
|
2013-10-17 15:33:46 +00:00
|
|
|
rm -rf "$WORKING_TREES"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-10-22 14:28:30 +00:00
|
|
|
|
2013-10-17 15:33:46 +00:00
|
|
|
if [ $# -eq 1 -a "$1" == "--install-or-update" ]; then
|
|
|
|
install_or_update
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-10-31 19:12:14 +00:00
|
|
|
|
|
|
|
if [ $# -eq 1 -a "$1" == "--uninstall-libraries" ]; then
|
|
|
|
cd "$WORKING_TREES/kicad-lib.bzr/build"
|
|
|
|
cmake_uninstall "$WORKING_TREES/kicad-lib.bzr/build"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-12-02 18:21:06 +00:00
|
|
|
|
|
|
|
if [ $# -eq 1 -a "$1" == "--uninstall-kicad" ]; then
|
|
|
|
cd "$WORKING_TREES/kicad.bzr/build"
|
|
|
|
cmake_uninstall "$WORKING_TREES/kicad.bzr/build"
|
|
|
|
|
|
|
|
cd "$WORKING_TREES/kicad-lib.bzr/build"
|
|
|
|
cmake_uninstall "$WORKING_TREES/kicad-lib.bzr/build"
|
|
|
|
|
|
|
|
# this may fail since "uninstall" support is a recent feature of this repo:
|
|
|
|
cd "$WORKING_TREES/kicad-doc.bzr/build"
|
|
|
|
cmake_uninstall "$WORKING_TREES/kicad-doc.bzr/build"
|
|
|
|
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2013-10-17 15:33:46 +00:00
|
|
|
usage
|