EDIT: As of 2015/08/03 Debian/sid has began a transition to a new default compiler, which is causing all sorts of dependency issues for this script. The last time this happened there were a few months of pain, so (as always) be careful if you are running on Debian/sid. You never know when it will live up to its name!
Hello! This is my first post on the forum, though I've been a lurker here and on G+ for some time. I recently got annoyed with the compilation process and decided to script it. This works on Debian/unstable but should work on testing and stable, since there was a new release recently. This script will create individual source and build directories where ever you run it from. It does not build a package but I will be attempting that next!
#!/bin/bash
#script to build FreeCAD from source.
#written and tested in Debian/unstable (July 2015), should work on Jessie or newer.
##This section (package installation) is originally kanged from http://www.mirkopagliai.it/bash-scripting-check-for-and-install-missing-dependencies/
##assistance in getting it working was gained on Reddit: https://www.reddit.com/r/bash/comments/3avmkh/trying_to_learn_but_a_bit_flustered_with_this/
DEPENDENCIES=(build-essential cmake cmake-qt-gui python python-matplotlib libtool libcoin80-dev libcoin80-doc libsoqt4-dev libxerces-c-dev libboost-all-dev libqt4-dev libqt4-opengl-dev qt4-dev-tools python-dev python-pyside pyside-tools liboce-ocaf-dev oce-draw libeigen3-dev libqtwebkit-dev libshiboken-dev libpyside-dev libode-dev swig libzipios++-dev libfreetype6-dev libsimage-dev checkinstall python-pivy python-qt4 doxygen graphviz)
DPKGL=$(dpkg -l)
PKGSTOINSTALL=()
for ((i=0; i<${#DEPENDENCIES[@]}; i++)); do
if [[ ! $DPKGL =~ "ii ${DEPENDENCIES[$i]}" ]]; then
PKGSTOINSTALL+=( "${DEPENDENCIES[$i]}" )
fi
done
if [[ ${PKGSTOINSTALL[@]} != "" ]]; then
sudo apt-get install "${PKGSTOINSTALL[@]}"
fi
#define directories
builddir="freecad-build"
sourcedir="freecad-code"
#Check for source directory, create if it doesn't exist
if [[ -d "$sourcedir" ]]; then
echo "Source directory already exists... Updating source."
cd $sourcedir
git fetch --all
git reset --hard origin/master
cd ..
else
echo "Source directory does not exist... Pulling source."
git clone https://github.com/FreeCAD/FreeCAD.git $sourcedir
fi
#Check for build directory, create if it doesn't exist
if [ -d "$builddir" ]; then
echo "Build directory already exists."
else
mkdir freecad-build
echo "Build directory created."
fi
chown -R $USER:$USER ./*
cd $builddir
cmake -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Release ../freecad-code
make
Last edited by mechanizedmedic on Mon Aug 24, 2015 6:06 am, edited 4 times in total.
Thanks for the script, I'm sure it'll come handy at some point.
Also, recent versions of FreeCAD as a debian package would come very handy... The current version in unstable is still 0.14 and downloading all the dev libraries and compiling (takes a while on a dual-core laptop) is just plain silly when not wanting the bleeding edge but just the latest STABLE!
kjb wrote:Thanks for the script, I'm sure it'll come handy at some point.
Also, recent versions of FreeCAD as a debian package would come very handy... The current version in unstable is still 0.14 and downloading all the dev libraries and compiling (takes a while on a dual-core laptop) is just plain silly when not wanting the bleeding edge but just the latest STABLE!
It looks like whoever was packaging for Debian gave up well over a year ago. I've built local debs and installed them quite a few times but I'm unsure of how to go about becoming a maintainer -- or if I even have the time to learn and take on that responsibility. Even so, it makes me happy that this script has assisted someone other than myself.
jean.thil wrote:It would be better if git was added as one of the dependencies.
it is most likely that someone would want git to get and manage the code and its updates ...but technically would be possible to just download the code, unzip it and compile....so making git a dependency which makes it compulsory, would be seen as inappropriate, I imagine.
so including git makes sense.
Of course it is a detail, I can hardly imagine a linux user using a script to build a program and not understanding that he should install git when he encounters
so including git makes sense.
Of course it is a detail, I can hardly imagine a linux user using a script to build a program and not understanding that he should install git when he encounters
./fc_build: line 34: git: command not found
Regards,
oh right, I see. I should have read it before I commented, trying to do three things at once, sorry.