Skip to content

Commit

Permalink
Add basic vagrant compilation capability
Browse files Browse the repository at this point in the history
Add 	FREECAD_USER_DATA environment variable required to support snap on ubuntu which is using Apparmor to
	limit application access to filesystem.
Add	automatic snap build on Xenial (ubuntu 16.04) within Vagrant build
Info	Build results are into /home/vagrant/Results (deb + snap
  • Loading branch information
Jean-Marie Verdun authored and wwmayer committed Jun 16, 2016
1 parent c832fb5 commit b0eea10
Show file tree
Hide file tree
Showing 12 changed files with 835 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/App/Application.cpp
Expand Up @@ -1909,7 +1909,12 @@ void Application::ExtractUserPath()
if (pwd == NULL)
throw Base::Exception("Getting HOME path from system failed!");
mConfig["UserHomePath"] = pwd->pw_dir;
std::string appData = pwd->pw_dir;
char *path="/tmp";
if ( FCUserData=getenv("FREECAD_USER_DATA") )
path=FCUserData;
else
path= pwd->pw_dir;
std::string appData(path);
Base::FileInfo fi(appData.c_str());
if (!fi.exists()) {
// This should never ever happen
Expand Down
261 changes: 261 additions & 0 deletions vagrant/FreeCAD.sh
@@ -0,0 +1,261 @@
#!/bin/bash
# Vagrant provisioning script to build up FreeCAD based on OCCT 7 and Salome 7.7.1 on Linux Ubuntu
# (c) 2016 Jean-Marie Verdun / vejmarie (vejmarie@ruggedpod.qyshare.com)
# Released under GPL v2.0
# Provided without any warranty
# Warning: compilation time is long quite long
# Must add the autlogin script
# Must add a lightdm start / reboot ?
FREECAD_GIT_BRANCH="https://github.com/vejmarie/FreeCAD"

function create_deb {
rm -rf /tmp/$1-$2
mkdir /tmp/$1-$2
mkdir /tmp/$1-$2/DEBIAN
echo "Package:$1" >> /tmp/$1-$2/DEBIAN/control
echo "Version:$2" >> /tmp/$1-$2/DEBIAN/control
echo "Section:base" >> /tmp/$1-$2/DEBIAN/control
echo "Priority:optional" >> /tmp/$1-$2/DEBIAN/control
echo "Architecture:amd64" >> /tmp/$1-$2/DEBIAN/control
echo "Depends:"$3 >> /tmp/$1-$2/DEBIAN/control
echo "Maintainer:vejmarie@ruggedpod.qyshare.com" >> /tmp/$1-$2/DEBIAN/control
echo "Homepage:http://ruggedpod.qyshare.com" >> /tmp/$1-$2/DEBIAN/control
echo "Description:TEST PACKAGE" >> /tmp/$1-$2/DEBIAN/control
file_list=`ls -ltd $(find /opt/local/FreeCAD-0.17) | awk '{ print $9}'`
for file in $file_list
do
is_done=`cat /tmp/stage | grep $file`
if [ "$is_done" == "" ]
then
# The file must be integrated into the new deb
cp --parents $file /tmp/$1-$2
echo $file >> /tmp/stage
fi
done
current_dir=`pwd`
cd /tmp
dpkg-deb --build $1-$2
mv $1-$2.deb $1-$2_trusty-amd64.deb
cd $current_dir
}

# If we are running ubuntu we must know if we are under Xenial (latest release) or Trusty which
# doesn't support the same package name

is_ubuntu=`lsb_release -a | grep -i Distributor | awk '{ print $3}'`
if [ "$is_ubuntu" == "Ubuntu" ]
then
ubuntu_version=`lsb_release -a | grep -i codename | awk '{ print $2 }'`
if [ "$ubuntu_version" == "xenial" ]
then
package_list=" doxygen \
libboost1.58-dev \
libboost-filesystem1.58-dev \
libboost-program-options1.58-dev \
libboost-python1.58-dev \
libboost-regex1.58-dev \
libboost-signals1.58-dev \
libboost-system1.58-dev \
libboost-thread1.58-dev \
libcoin80v5 \
libcoin80-dev \
libeigen3-dev \
libpyside-dev \
libqtcore4 \
libshiboken-dev \
libxerces-c-dev \
libxmu-dev \
libxmu-headers \
libxmu6 \
libxmuu-dev \
libxmuu1 \
pyside-tools \
python-dev \
python-pyside \
python-matplotlib \
qt4-dev-tools \
qt4-qmake \
libqtwebkit-dev \
shiboken \
swig"
else
ubuntu_version="unknown"
package_list=" doxygen \
libboost1.55-dev \
libboost-filesystem1.55-dev \
libboost-program-options1.55-dev \
libboost-python1.55-dev \
libboost-regex1.55-dev \
libboost-signals1.55-dev \
libboost-system1.55-dev \
libboost-thread1.55-dev \
libcoin80 \
libcoin80-dev \
libeigen3-dev \
libpyside-dev \
libqtcore4 \
libshiboken-dev \
libxerces-c-dev \
libxmu-dev \
libxmu-headers \
libxmu6 \
libxmuu-dev \
libxmuu1 \
pyside-tools \
python-dev \
python-pyside \
python-matplotlib \
qt4-dev-tools \
qt4-qmake \
shiboken \
swig"
fi
fi
sudo apt-get update
sudo apt-get install -y dictionaries-common
sudo apt-get install -y $package_list
sudo apt-get install -y python-pivy
sudo apt-get install -y git
sudo apt-get install -y cmake
sudo apt-get install -y g++
sudo apt-get install -y libfreetype6-dev
sudo apt-get install -y tcl8.5-dev tk8.5-dev
sudo apt-get install -y libtogl-dev
sudo apt-get install -y libhdf5-dev
sudo apt-get install -y xfce4 xfce4-goodies
sudo apt-get install -y xubuntu-default-settings
sudo apt-get install -y lightdm
sudo apt-get install -y automake
sudo apt-get install -y libcanberra-gtk-module
sudo apt-get install -y libcanberra-gtk3-module overlay-scrollbar-gtk2 unity-gtk-module-common libatk-bridge2.0-0 unity-gtk2-module libatk-adaptor
myversion=`lsb_release -a | grep -i Distributor | awk '{ print $3}'`
if [ "$myversion" != "Ubuntu" ]
then
sudo cat /etc/lightdm/lightdm.conf | sed 's/\#autologin-user=/autologin-user=vagrant/' > /tmp/lightdm.conf
sudo cp /tmp/lightdm.conf /etc/lightdm/lightdm.conf
sudo /etc/init.d/lightdm start
sudo apt-get install libmed
sudo apt-get install libmedc
sudo apt-get install -y libmed-dev
sudo apt-get install -y libmedc-dev
else
cat <<EOF >& /tmp/lightdm.conf
[SeatDefaults]
user-session=xfce
autologin-session=xfce
autologin-user=ubuntu
autologin-user-timeout=0
greeter-session=xfce
pam-service=lightdm-autologin
EOF
sudo cp /tmp/lightdm.conf /etc/lightdm/
sudo rm /etc/lightdm/lightdm-gtk-greeter.conf
sudo /etc/init.d/lightdm start &

# Building MED

git clone https://github.com/vejmarie/libMED.git
cd libMED
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/opt/local/FreeCAD-0.17 ..
make -j 2
sudo make install
cd ../..
fi

# I must create the package

create_deb MED 3.10 ""

# Building VTK

wget http://www.vtk.org/files/release/7.0/VTK-7.0.0.tar.gz
gunzip VTK-7.0.0.tar.gz
tar xf VTK-7.0.0.tar
rm VTK-7.0.0.tar
cd VTK-7.0.0
mkdir build
cd build
# cmake .. -DVTK_RENDERING_BACKEND=OpenGL
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/opt/local/FreeCAD-0.17 -DVTK_Group_Rendering:BOOL=OFF -DVTK_Group_StandAlone:BOOL=ON -DVTK_RENDERING_BACKEND=None
make -j 2
sudo make install

create_deb VTK 7.0 ""

# Building OCCT

cd ../..
wget "http://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=b00770133187b83761e651df50051b2fa3433858;sf=tgz"
mv "index.html?p=occt.git;a=snapshot;h=b00770133187b83761e651df50051b2fa3433858;sf=tgz" occt.tgz
gunzip occt.tgz
tar xf occt.tar
rm occt.tar
cd occt-b007701
grep -v vtkRenderingFreeTypeOpenGL src/TKIVtk/EXTERNLIB >& /tmp/EXTERNLIB
\cp /tmp/EXTERNLIB src/TKIVtk/EXTERNLIB
grep -v vtkRenderingFreeTypeOpenGL src/TKIVtkDraw/EXTERNLIB >& /tmp/EXTERNLIB
\cp /tmp/EXTERNLIB src/TKIVtkDraw/EXTERNLIB
mkdir build
cd build
# cmake .. -DUSE_VTK:BOOL=ON
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/opt/local/FreeCAD-0.17 -DUSE_VTK:BOOL=OFF
sudo make -j 2
sudo make install

create_deb OCCT 7.0 "vtk (>= 7.0), med (>= 3.10)"

# Building Netgen

cd ../..
git clone https://github.com/vejmarie/Netgen
cd Netgen/netgen-5.3.1
./configure --prefix=/opt/local/FreeCAD-0.17 --with-tcl=/usr/lib/tcl8.5 --with-tk=/usr/lib/tk8.5 --enable-occ --with-occ=/opt/local/FreeCAD-0.17 --enable-shared --enable-nglib CXXFLAGS="-DNGLIB_EXPORTS -std=gnu++11"
make -j 2
sudo make install
cd ../..
sudo cp -rf Netgen/netgen-5.3.1 /usr/share/netgen

create_deb Netgen 5.3.1 "occt (>= 7.0)"

#building FreeCAD

git clone $FREECAD_GIT_BRANCH
cd FreeCAD
git checkout occt7
cat cMake/FindOpenCasCade.cmake | sed 's/\/usr\/local\/share\/cmake\//\/opt\/local\/FreeCAD-0.17\/lib\/cmake/' > /tmp/FindOpenCasCade.cmake
cp /tmp/FindOpenCasCade.cmake cMake/FindOpenCasCade.cmake
cp cMake/FindOpenCasCade.cmake cMake/FindOPENCASCADE.cmake
cd ..
mkdir build
cd build
cmake ../FreeCAD -DCMAKE_INSTALL_PREFIX:PATH=/opt/local/FreeCAD-0.17 -DBUILD_FEM=1 -DBUILD_FEM_NETGEN=1 -DCMAKE_CXX_FLAGS="-DNETGEN_V5"
make -j 2
make install
create_deb FreeCAD 0.17 "netgen (>= 5.3.1), occt (>= 7.0), med (>= 3.10)"
source_dir=`pwd`
cd /tmp
mkdir deb
mv *.deb deb
cd deb
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

if [ "$ubuntu_version" == "xenial" ]
then
#Let's build the snap
mkdir snap
cd snap
cp -Rf $source_dir/FreeCAD/vagrant/Xenial .
cd Xenial
apt-get install -y snapcraft
./generate_yaml.sh
snapcraft
mv freecad_0.17_amd64.snap /tmp
fi
mkdir $source_dir/Results
mv /tmp/*.deb $source_dir/Results
if [ -f "/tmp/freecad_0.17_amd64.snap" ]
then
mv /tmp/freecad_0.17_amd64.snap $source_dir/Results
fi
2 changes: 2 additions & 0 deletions vagrant/README
@@ -0,0 +1,2 @@
To build FreeCAD on trusty/xenial using vagrant please copy either Vagrantfile.trusty/Vagrantfile.xenial to Vagrantfile then kick from this directory vagrant up. Go have a drink compilation can be very long
Build results are kept into the vm, use vagrant ssh to connect to it and go into Results directory where you will get your deb and snap files
76 changes: 76 additions & 0 deletions vagrant/Vagrantfile.trusty
@@ -0,0 +1,76 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
# config.vm.box = "debian/jessie64"
# config.vm.box = "ubuntu/xenial64"
config.vm.box = "ubuntu/trusty64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "./source"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
vb.gui = true
# # Customize the amount of memory on the VM:
vb.memory = "4096"
vb.cpus = 2
end

config.vm.provision :shell, path: "FreeCAD.sh"

#
# View the documentation for the provider you are using for more
# information on available options.

# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
end

0 comments on commit b0eea10

Please sign in to comment.