Skip to content

Instantly share code, notes, and snippets.

@reox
Last active March 19, 2019 01:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reox/522922a1a61bdeb5038950edd484f48f to your computer and use it in GitHub Desktop.
Save reox/522922a1a61bdeb5038950edd484f48f to your computer and use it in GitHub Desktop.
Build a debian package from FreeCAD yourself.
#!/bin/bash
set -e
#################################
# NOTE:
# This assumes you have a user `builder` and a folder `/home/builder/packages`.
# it will clone FreeCAD there and start pbuilder using pdebuild.
# For me this works using debian sid. (stretch/buster will probably not work!)
#
# After the build has finished, it will import the packes into a reprepro
# which is setup at /srv/repo
#
# So before using this script, you probably want to remove certain steps
# and change the paths, according to your setup.
#################################
ROOTFOLDER=/home/builder/packages
cd $ROOTFOLDER
if [ -d FreeCAD ]; then
echo "Deleting old FreeCAD repo"
rm -rf FreeCAD
fi
## Now for the FreeCAD Build...
git clone https://github.com/FreeCAD/FreeCAD.git
pushd FreeCAD
FREECAD_MAJOR=$(egrep -o "^set\(PACKAGE_VERSION_MAJOR \".*\"" CMakeLists.txt | cut -d " " -f 2 | tr -d \")
FREECAD_MINOR=$(egrep -o "^set\(PACKAGE_VERSION_MINOR \".*\"" CMakeLists.txt | cut -d " " -f 2 | tr -d \")
DEBVERSION="$FREECAD_MAJOR.$FREECAD_MINOR+git$(date +%Y%m%d%H%M)-1"
echo "======================================"
echo "==> Building FreeCAD $DEBVERSION"
echo "======================================"
# Create Version File
# This is the same as pulling the gitversioning repo but much faster, also it has always the correct hash.
echo "#define FCVersionMajor \"$FREECAD_MAJOR\"" | tee -a src/Build/Version.h
echo "#define FCVersionMinor \"$FREECAD_MINOR\"" | tee -a src/Build/Version.h
echo "#define FCVersionName \"$(egrep -o "^set\(PACKAGE_VERSION_NAME \".*\"" CMakeLists.txt | cut -d " " -f 2 | tr -d \")\"" | tee -a src/Build/Version.h
echo "#define FCRevision \"$(git rev-list master --count) (Git)\"" | tee -a src/Build/Version.h
echo "#define FCRevisionDate \"$(git show -s --format=%ci)\"" | tee -a src/Build/Version.h
echo "#define FCRepositoryURL \"git://github.com/FreeCAD/FreeCAD.git master\"" | tee -a src/Build/Version.h
echo "#define FCRepositoryHash \"$(git show -s --format=%H)\"" | tee -a src/Build/Version.h
echo "#define FCRepositoryBranch \"master\"" | tee -a src/Build/Version.h
# Does not work on debian...
# git remote add gitpackaging https://git.launchpad.net/~freecad-maintainers/+git/gitpackaging
# ...therefore using this fork:
git remote add gitpackaging https://github.com/reox/FreeCAD_gitpackaging.git
git remote update
# dailybuild-occt-qt5 uses python3 but produces a not working version currently...
git merge gitpackaging/dailybuild-occt-qt5-py2 --allow-unrelated-histories --no-edit
# New version
dch --newversion "$DEBVERSION" --distribution unstable "Daily build"
# This script uses pbuilder, but you can also use dpkg-buildpackage here...
sudo pbuilder update
pdebuild --logfile /dev/null
popd
echo "======================================"
echo "==> Building has finished!"
echo "======================================"
CHANGES=$(find /var/cache/pbuilder/result -name freecad-daily_\*.changes -type f -printf '%T@ %p\n' | sort | tail -n 1 | cut -f2- -d" ")
reprepro -b /srv/repo include sid "$CHANGES"
echo "======================================"
echo "==> Cleanup"
echo "======================================"
# Delete old stuff
find $ROOTFOLDER -maxdepth 1 -type f -name freecad-daily\* -exec rm -v {} \;
# Not sure why these files are also there?
rm -v /var/cache/pbuilder/result/freecad-daily*
echo "======================================"
echo "==> Finished!"
echo "======================================"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment