Deb package creation script

From FreeCAD Documentation
Jump to navigation Jump to search
Other languages:
English • ‎español • ‎italiano

This script makes a .deb package out of FreeCAD source. You need the checkinstall package installed. To use it, just:

  • edit the script and change manually the config lines if needed
  • copy it to your freecad source dir,
  • make it executable,
  • make sure your source will compile without errors (do a "make" first),
  • then run the script.

Note: this script has been made for Ubuntu Gusty, there might be slight differences in dependency packages names if you use another version of Ubuntu/Debian. If you have more info on this, please add it here...

For Ubuntu Hardy

  • remove libumfpack4 from dependencies (currently not used by FreeCAD)

  1. !/usr/bin/env python
  2. this script builds a .deb package of FreeCAD
  3. use it instead of 'make + make install' to generate a nice package for your debian-based system!
  1. config - edit manually if needed

maintainer='' # put your own email here! version='0.7' # the current FreeCAD version build=False # if true, freecad will be compiled (make) before anything else. I suggest to use True only when you are sure it will compile without errors Otherwise do "make" first, then run this script. occinclude='/usr/include/opencascade' # where your occ include files reside. Only used if build=True. installdir='/opt/FreeCAD' # where you want to install FreeCAD cflags='"-O2"' # my usual 64bit optimizations are "-O3 -march=athlon64". Leave an empty string "" if not sure.

  1. end of config
  1. start

import os

  1. build FreeCAD, if needed

if build: cmd='./configure --with-occ-include='+occinclude+' --prefix='+installdir+' CFLAGS='+cflags+' CXXFLAGS='+cflags os.system(cmd) os.system('make')

  1. retrieve release version number from source

vfile=open("src/Build/Version.h") for i in vfile: if (i.find("FCRevision ") != -1): revline = i release = revline.split('"')[1]

  1. creating Checkinstall files

debinstall = open('debinstall-pak','w') # shellscript containing the installation procedure debinstall.write('#!/bin/sh\n') debinstall.write('make install\n') debinstall.write('cp debian/freecad.desktop /usr/share/applications\n') debinstall.write('cp src/Gui/Icons/FCIcon.xpm /usr/share/pixmaps') debinstall.close()

os.system('chmod +x debinstall-pak')

postinstall = open('postinstall-pak','w') # shellscript to be run after freecad is installed postinstall.write('#!/bin/sh\n') postinstall.write('ln -s '+installdir+'/bin/FreeCAD /usr/bin/freecad') postinstall.close()

preremove = open('preremove-pak','w') # shellscript to be run before freecad is removed preremove.write('#!/bin/sh\n') preremove.write('rm /usr/bin/freecad') preremove.close()

description = open('description-pak','w') # package description description.write("FreeCAD is an Open Source CAx RAD based on OpenCasCade, Qt and Python. It features some key concepts like macro recording, workbenches, ability to run as a server and dynamically loadable application extensions and it is designed to be platform independent. For more details see") description.close()

  1. executing Checkinstall

dependencies='"opencascade, python, libc6-dev, libstdc++6, libboost-date-time-dev, libboost-filesystem-dev, libboost-graph-dev, libboost-iostreams-dev, libboost-program-options-dev, libboost-regex-dev, libboost-serialization-dev, libboost-signals-dev, libqt4-gui, zlib1g, libxerces27, libxt6, libsoqt4-dev, libxmu6, libxi6, libcoin40c2, libgl1-mesa-dev, libx11-6, libxext6, libgts-0.7-5, libumfpack4, libcv1, libqt4-qt3support, freeglut3-dev, libglu1-mesa-dev, libglu1-xorg-dev, libglut3-dev"' cmd='checkinstall --backup=no --fstrans=no --install=no --maintainer='+maintainer+' --pkgversion='+version+' --pkgrelease='+release+' --pkgname="freecad" --pkggroup="Graphics" --requires='+dependencies+' ./debinstall-pak' os.system(cmd)

  1. removing temp files

os.system('rm -r *pak')