diff --git a/tools/build/AppImage/.gitignore b/tools/build/AppImage/.gitignore new file mode 100644 index 0000000000..f05dc26c66 --- /dev/null +++ b/tools/build/AppImage/.gitignore @@ -0,0 +1,4 @@ +AppDir +*.txt +*.AppImage +qt.conf diff --git a/tools/build/AppImage/build-with-conda.sh b/tools/build/AppImage/build-with-conda.sh new file mode 100755 index 0000000000..1d3fd352ee --- /dev/null +++ b/tools/build/AppImage/build-with-conda.sh @@ -0,0 +1,207 @@ +#!/bin/sh + +# *************************************************************************** +# * Copyright (c) 2023 Yorik van Havre * +# * and FreeCAD maintainers (looooo, adrianinsaval ) * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +# adapted from https://github.com/FreeCAD/FreeCAD-Bundle/blob/master/conda/linux/create_bundle.sh + +# This script produces a FreeCAD AppImage locally using conda repositories. It is a all-in-one +# script that can be run from anywhere and does not rely on the FreeCAD source code. It fetches +# everything form conda repositories. Therefore, you need to make sure they contain the FreeCAD +# package you want to build. An easy way to check is by searching for available FreeCAD packages: +# +# conda search "freecad=0.21.0" -c adrianinsaval/label/dev -c freecad -c conda-forge +# + + +# To use this scriipt, you will need: +# +# 1) Mambaforge from https://github.com/conda-forge/miniforge#mambaforge +# if you choose to not install the conda environment when installing Mambaforge, +# you will need to do it before running this script, by running the following +# in your terminal. This will make the "conda" and "mamba" commands available: +# eval "$(/home/yorik/Mambaforge/bin/conda shell.zsh hook)" +# (replace the Mambaforge path by yours and zsh by your shell name) +# +# 2) appimagetool from https://appimage.github.io/appimagetool/ +# place it in your exec path so it can be found by this script +# +# 3) a gpg key to sign the package +# +# 4) verify or change the config values here below +# +# 5) If you are on Fedora, there are lines to uncomment below in the script +# +# When done, just run this script and you should get an appimage with the +# corresponding sha hash in the current folder. +# +# To cleanup after build: Just delete the "AppDir" folder (not done automatically since +# next builds can reuse the downloaded packages). + +# config + +# make sure you have a gpg key for this email +gpg_key="yorik@freecad.org" +# the FreeCAD version we're looking for +target_version="0.21.0" +# make sure target_python matches the one FreeCAD is built with! Check with +# conda search "freecad=0.21.0" -c adrianinsaval/label/dev -c freecad -c conda-forge +target_python="3.10" + +# end config + +# export MAMBA_NO_BANNER=1 + +# building needed files +mkdir -p AppDir +cat > AppDir/AppRun < AppDir/packages.txt +sed -i "1s/.*/\nLIST OF PACKAGES:/" AppDir/packages.txt + +echo "\nDeleting unnecessary stuff" +rm -rf ${conda_env}/include +find ${conda_env} -name \*.a -delete +mv ${conda_env}/bin ${conda_env}/bin_tmp +mkdir ${conda_env}/bin +cp ${conda_env}/bin_tmp/freecad ${conda_env}/bin/ +cp ${conda_env}/bin_tmp/freecadcmd ${conda_env}/bin/ +cp ${conda_env}/bin_tmp/ccx ${conda_env}/bin/ +cp ${conda_env}/bin_tmp/python ${conda_env}/bin/ +cp ${conda_env}/bin_tmp/pip ${conda_env}/bin/ +cp ${conda_env}/bin_tmp/pyside2-rcc ${conda_env}/bin/ +cp ${conda_env}/bin_tmp/assistant ${conda_env}/bin/ +sed -i '1s|.*|#!/usr/bin/env python|' ${conda_env}/bin/pip +rm -rf ${conda_env}/bin_tmp + +echo "\nCreating qt config" +echo "[Paths]\nPrefix = ./../" > qt.conf +cp qt.conf ${conda_env}/bin/ +cp qt.conf ${conda_env}/libexec/ +rm qt.conf + +echo "\nCopying icons and .desktop file" +mkdir -p ${conda_env}/share/icons/hicolor/scalable/apps/ +cp ../../../src/Gui/Icons/freecad.svg ${conda_env}/share/icons/hicolor/scalable/apps/org.freecadweb.FreeCAD.svg +cp ${conda_env}/share/icons/hicolor/scalable/apps/org.freecadweb.FreeCAD.svg AppDir +mkdir -p ${conda_env}/share/icons/hicolor/64x64/apps/ +cp ../../../src/Gui/Icons/freecad-icon-64.png ${conda_env}/share/icons/hicolor/64x64/apps/org.freecadweb.FreeCAD.png +cp ${conda_env}/share/icons/hicolor/64x64/apps/org.freecadweb.FreeCAD.png AppDir +mkdir -p ${conda_env}/share/applications/ +cp ../../../src/XDGData/org.freecadweb.FreeCAD.desktop ${conda_env}/share/applications/ +sed -i "s/Exec\=FreeCAD\ \%F/Exec=AppRun/g" ${conda_env}/share/applications/org.freecadweb.FreeCAD.desktop +cp ${conda_env}/share/applications/org.freecadweb.FreeCAD.desktop AppDir +cp ../../../src/XDGData/org.freecadweb.FreeCAD.appdata.xml.in ${conda_env}/share/metainfo/org.freecadweb.FreeCAD.appdata.xml +sed -i "s/@PACKAGE_VERSION@/${target_version}/g" ${conda_env}/share/metainfo/org.freecadweb.FreeCAD.appdata.xml +sed -i "s/@APPDATA_RELEASE_DATE@/${target_date}/g" ${conda_env}/share/metainfo/org.freecadweb.FreeCAD.appdata.xml + +echo "\nCleaning" + +# Remove __pycache__ folders and .pyc files +find . -path "*/__pycache__/*" -delete +find . -name "*.pyc" -type f -delete + +# reduce size +rm -rf ${conda_env}/conda-meta/ +rm -rf ${conda_env}/doc/global/ +rm -rf ${conda_env}/share/gtk-doc/ +rm -rf ${conda_env}/lib/cmake/ + +# remove unnecessary development files +find . -name "*.h" -type f -delete +find . -name "*.cmake" -type f -delete + +# The following two lines must be uncommented if using this on Fedora 28 and up +# echo "\nAdd libnsl" +# cp ../../libc6/lib/$ARCH-linux-gnu/libnsl* ${conda_env}/lib/ + +echo "\nCreating the appimage" +chmod a+x ./AppDir/AppRun +appimagetool-${arch}.AppImage --sign-key ${gpg_key} AppDir ${package_name}.AppImage + +echo "\nCreating hash" +shasum -a 256 ${package_name}.AppImage > ${package_name}.AppImage-SHA256.txt + +echo "\nAll done! You can delete the AppDir folder"