Add basic vagrant compilation capability

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
This commit is contained in:
Jean-Marie Verdun 2016-06-01 21:16:12 +02:00 committed by wmayer
parent c832fb5561
commit b0eea10e8e
12 changed files with 835 additions and 1 deletions

View File

@ -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

261
vagrant/FreeCAD.sh Normal file
View File

@ -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
vagrant/README Normal file
View File

@ -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

View File

@ -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

View File

@ -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 = 1
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

15
vagrant/Xenial/bin/launcher Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/x86_64-linux-gnu/dri
export GTK_PATH=$SNAP/usr/lib/x86_64-linux-gnu/gtk-2.0/modules
export LD_LIBRARY_PATH=$SNAP/usr/lib/x86_64-linux-gnu/gtk-2.0/modules:$LD_LIBRARY_PATH
export GTK_DATA_PREFIX=$SNAP_USER_DATA
export GTK_EXE_PREFIX=$SNAP/usr
export GDK_PIXBUF_MODULE_FILE=$SNAP/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache
export PYTHONHOME="$SNAP/usr"
export PYTHONPATH="$SNAP/usr"
export XDG_DATA_DIR="$SNAP/usr/share/glib-2.0/schemas"
export GSETTINGS_SCHEMA_DIR="$SNAP/usr/share/glib-2.0/schemas"
export I18NPATH=$SNAP/usr/share/i18n/locales
export LOCPATH=$SNAP/usr/lib/locale/
exec "$SNAP/opt/local/FreeCAD-0.17/bin/FreeCAD" -u $SNAP_USER_DATA/user.cfg -s $SNAP_USER_DATA/system.cfg "$@"

View File

@ -0,0 +1,67 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

105
vagrant/Xenial/generate_yaml.sh Executable file
View File

@ -0,0 +1,105 @@
#!/bin/bash
# snapcraft yaml automatic generation tool for FreeCAD 0.17
# (c) 2017 vejmarie
# Distributed under LGPL v2.0
# Please report bugs at vejmarie@ruggedpod.qyshare.com
rm snapcraft.yaml
lib_list=`ls /opt/local/FreeCAD-0.17/lib/*.so`
mod_list=`ls -ltd $(find /opt/local/FreeCAD-0.17/Mod) | awk '{ print $9}'`
bin_list=`ls -ltd $(find /opt/local/FreeCAD-0.17/bin) | awk '{ print $9}'`
data_list=`ls -ltd $(find /opt/local/FreeCAD-0.17/data) | awk '{ print $9}'`
python_list=`ls -ltd $(find /usr/lib/python2.7) | awk '{ print $9}'`
pyside_list=`ls -ltd $(find /usr/share/PySide/typesystems) | awk '{ print $9}'`
python_binary=`ls /usr/bin/python /usr/bin/py*2.7`
syslib=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/dri) | awk '{ print $9}'`
syslib2=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/gtk-2.0) | awk '{ print $9}'`
syslib3=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0) | awk '{ print $9}'`
syslib4=`ls -ltd $(find /usr/lib/locale) | awk '{ print $9}'`
syslib5=`ls -ltd $(find /usr/share/X11/locale) | awk '{ print $9}'`
syslib6=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/*gtk*) | awk '{ print $9}'`
syslib7=`ls -ltd $(find /usr/share/glib-2.0) | awk '{ print $9}'`
syslib8=`ls -ltd $(find /usr/share/i18n/locales) | awk '{ print $9}'`
echo "
name: freecad
version: 0.17
summary: development version
description: development version This version is far from being bug free but integrates the latest FreeCAD technologies
parts:
example-part:
plugin: copy
files:
bin/launcher : bin/launcher" >> snapcraft.yaml
# bin/FreeCAD : opt/local/FreeCAD-0.17/bin/FreeCAD" >> snapcraft.yaml
for i in $bin_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $lib_list
do
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
done
for i in $mod_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $data_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $python_list $pyside_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $python_binary
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $syslib $syslib2 $syslib3 $syslib4 $syslib5 $syslib6 $syslib7 $syslib8
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
# python:
# plugin: python2
echo "
snap:
- bin/launcher
- opt/local/FreeCAD-0.17/bin/FreeCAD
- opt
- usr" >> snapcraft.yaml
for i in $lib_list
do
second_name=`echo $i | sed 's/\///'`
echo " - $second_name" >> snapcraft.yaml
done
echo "
apps:
FreeCAD:
command: bin/launcher
plugs: [ locale-control,x11,opengl,network-bind,home,unity7 ]
" >> snapcraft.yaml

33
vagrant/Xenial/launcher Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
export I18NPATH=$SNAP/usr/share/i18n
export LOCPATH=$SNAP_USER_DATA
LANG=en_US
ENC=UTF-8
LOC="$LANG.$ENC"
# generate a locale so we get properly working charsets and graphics
if [ ! -e $SNAP_USER_DATA/$LOC ]; then
$SNAP/usr/bin/localedef --prefix=$SNAP_USER_DATA -f $ENC -i $LANG $SNAP_USER_DATA/$LOC
fi
export LC_ALL=$LOC
export LANG=$LOC
export LANGUAGE=${LANG%_*}
env >& $SNAP_USER_DATA/env
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/x86_64-linux-gnu/dri
export GTK_PATH=$SNAP/usr/lib/x86_64-linux-gnu/gtk-2.0/modules
export LD_LIBRARY_PATH=$SNAP/usr/lib/x86_64-linux-gnu/gtk-2.0/modules:$LD_LIBRARY_PATH
export GTK_DATA_PREFIX=$SNAP_USER_DATA
export GTK_EXE_PREFIX=$SNAP/usr
export GDK_PIXBUF_MODULE_FILE=$SNAP/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache
export PYTHONHOME="$SNAP/usr"
export PYTHONPATH="$SNAP/usr"
export XDG_DATA_DIR="$SNAP/usr/share/glib-2.0/schemas"
export GSETTINGS_SCHEMA_DIR="$SNAP/usr/share/glib-2.0/schemas"
export LANG=en_US.UTF-8
export FREECAD_USER_DATA="$SNAP_USER_DATA"
export XDG_CONFIG_HOME="$SNAP_USER_DATA"
exec "$SNAP/opt/local/FreeCAD-0.17/bin/FreeCAD" -u $SNAP_USER_DATA/user.cfg -s $SNAP_USER_DATA/system.cfg "$@"

88
vagrant/Xenial/reset Executable file
View File

@ -0,0 +1,88 @@
#!/bin/sh
# snapcraft reset script
# distributed under LGPL v2
if [ ! -e /var/lib/dpkg/status ]; then
echo "This script only works on Ubuntu Classic"
exit 1
fi
if [ "$(id -u)" != 0 ]; then
echo "This script needs to be run as root"
exit 1
fi
echo "This script will permanently destroy and reset all state in snapd"
echo "You will loose all of your installed snaps"
echo
echo "Type: DESTROY to remove all of your snap state"
echo
read consent
if [ "$consent" != "DESTROY" ]; then
echo "No consent, aborting"
exit 0
fi
echo
echo "ABOUT TO DESTROY ALL OF STATE OF SNAPD"
echo
echo "Interrupt the script in 10 seconds to abort"
sleep 10 || exit
echo
echo "DESTROYING ALL STATE OF SNAPD"
if systemctl is-active --quiet snapd.service snapd.socket; then
snapd_was_active=yes
echo
echo "Stoping snapd..."
echo
(
set -x
systemctl stop snapd.socket snapd.service
)
else
echo "Skipping stopping snapd as systemctl reports it's inactive."
fi
echo
echo "Unmounting all snaps..."
echo
(
set -x
umount /var/lib/snapd/snaps/*.snap
)
echo
echo "Removing all support files and state..."
echo
(
set -x
rm -rvf /var/lib/snapd/*
)
echo
echo "Removing generated systemd units..."
echo
(
set -x
rm -vf /etc/systemd/system/snap-*.mount
rm -vf /etc/systemd/system/snap-*.service
rm -vf /etc/systemd/system/multi-user.target.wants/snap-*.mount
)
echo
echo "Removing generated executable wrappers..."
echo
(
set -x
rm -vrf /snap/*
)
if [ "$snapd_was_active" = "yes" ]; then
echo
echo "Starting snapd"
(
set -x
systemctl start snapd.socket
)
fi

106
vagrant/generate_yaml.sh Executable file
View File

@ -0,0 +1,106 @@
#!/bin/bash
# snapcraft yaml automatic generation tool for FreeCAD 0.17
# (c) 2017 vejmarie
# Distributed under LGPL v2.0
# Please report bugs at vejmarie@ruggedpod.qyshare.com
rm snapcraft.yaml
lib_list=`ls /opt/local/FreeCAD-0.17/lib/*.so`
mod_list=`ls -ltd $(find /opt/local/FreeCAD-0.17/Mod) | awk '{ print $9}'`
bin_list=`ls -ltd $(find /opt/local/FreeCAD-0.17/bin) | awk '{ print $9}'`
data_list=`ls -ltd $(find /opt/local/FreeCAD-0.17/data) | awk '{ print $9}'`
python_list=`ls -ltd $(find /usr/lib/python2.7) | awk '{ print $9}'`
pyside_list=`ls -ltd $(find /usr/share/PySide/typesystems) | awk '{ print $9}'`
python_binary=`ls /usr/bin/python /usr/bin/py*2.7`
syslib=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/dri) | awk '{ print $9}'`
syslib2=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/gtk-2.0) | awk '{ print $9}'`
syslib3=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0) | awk '{ print $9}'`
syslib4=`ls -ltd $(find /usr/lib/locale) | awk '{ print $9}'`
syslib5=`ls -ltd $(find /usr/share/X11/locale) | awk '{ print $9}'`
syslib6=`ls -ltd $(find /usr/lib/x86_64-linux-gnu/*gtk*) | awk '{ print $9}'`
syslib7=`ls -ltd $(find /usr/share/glib-2.0) | awk '{ print $9}'`
syslib8=`ls -ltd $(find /usr/share/i18n/) | awk '{ print $9}'`
syslib9=`ls /usr/bin/locale*`
echo "
name: freecad
version: 0.17
summary: development version
description: development version This version is far from being bug free but integrates the latest FreeCAD technologies
parts:
example-part:
plugin: copy
files:
bin/launcher : bin/launcher" >> snapcraft.yaml
# bin/FreeCAD : opt/local/FreeCAD-0.17/bin/FreeCAD" >> snapcraft.yaml
for i in $bin_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $lib_list
do
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
done
for i in $mod_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $data_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $python_list $pyside_list
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $python_binary
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
for i in $syslib $syslib2 $syslib3 $syslib4 $syslib5 $syslib6 $syslib7 $syslib8 $syslib9
do
if [ ! -d "$i" ]
then
second_name=`echo $i | sed 's/\///'`
echo " $i : $second_name" >> snapcraft.yaml
fi
done
# python:
# plugin: python2
echo "
snap:
- bin/launcher
- opt/local/FreeCAD-0.17/bin/FreeCAD
- opt
- usr" >> snapcraft.yaml
for i in $lib_list
do
second_name=`echo $i | sed 's/\///'`
echo " - $second_name" >> snapcraft.yaml
done
echo "
apps:
FreeCAD:
command: bin/launcher
plugs: [ locale-control,x11,opengl,network-bind,home,unity7 ]
" >> snapcraft.yaml