Script to compile in Debian/sid

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
mechanizedmedic
Posts: 5
Joined: Sun Jul 05, 2015 7:29 am

Script to compile in Debian/sid

Post by mechanizedmedic »

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!

I hope this helps someone! :-)

Code: Select all

#!/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.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Script to compile in Debian/sid

Post by triplus »

Thank you for sharing it with us.
jean.thil
Posts: 209
Joined: Tue Jul 28, 2015 7:28 am

Re: Script to compile in Debian/sid

Post by jean.thil »

Works perfectly on jessie. Thanks a lot.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Script to compile in Debian/sid

Post by sgrogan »

The get source line should be changed from

Code: Select all

git clone git://git.code.sf.net/p/free-cad/code $sourcedir
to

Code: Select all

git clone https://github.com/FreeCAD/FreeCAD.git $sourcedir
FreeCAD has switched to GitHub from SF recently
"fight the good fight"
kjb
Posts: 1
Joined: Sat Aug 01, 2015 6:55 pm

Re: Script to compile in Debian/sid

Post by kjb »

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!
mechanizedmedic
Posts: 5
Joined: Sun Jul 05, 2015 7:29 am

Re: Script to compile in Debian/sid

Post by mechanizedmedic »

sgrogan wrote:The get source line should be changed from

Code: Select all

git clone git://git.code.sf.net/p/free-cad/code $sourcedir
to

Code: Select all

git clone https://github.com/FreeCAD/FreeCAD.git $sourcedir
FreeCAD has switched to GitHub from SF recently
Thanks for the heads up! ...OP updated.
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. :D
jean.thil
Posts: 209
Joined: Tue Jul 28, 2015 7:28 am

Re: Script to compile in Debian/sid

Post by jean.thil »

It would be better if git was added as one of the dependencies.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Script to compile in Debian/sid

Post by jmaustpc »

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.
jean.thil
Posts: 209
Joined: Tue Jul 28, 2015 7:28 am

Re: Script to compile in Debian/sid

Post by jean.thil »

The script contains the following lines

Code: Select all

git fetch --all
git reset --hard origin/master
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,
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Script to compile in Debian/sid

Post by jmaustpc »

jean.thil wrote:The script contains the following lines

Code: Select all

git fetch --all
git reset --hard origin/master
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.
Post Reply