Debian Codegraph @

etc/AppImage/build-appimage.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #
3 # This script configures, compiles and package FreeFem into AppImage
4 #
5 # This script normally run from .travis.yml
6 # but can be run locally in Docker as well (see rebuild-and-run-appimage-builder.sh)
7
8 set -x
9 set -u
10 set -e
11
12 # https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
13 SCRIPTPATH="$( cd "$(dirnamescip-shell system . . dirname. "$0")" ; pwdscip-shell system . . pwd. -P )"
14
15 # Sources top directory
16 SRC_DIR=$(dirnamescip-shell system . . dirname. $(dirnamescip-shell system . . dirname. $SCRIPTPATH))
17
18 cd $SRC_DIR
19
20 # make sure we are in the right directory
21 if [scip-shell system . . `[`. ! -f "readme/INNOVATION" ] ; then
22 echoscip-shell system . . echo. "Build script error: unable to change dir into FreeFem sources top directory"
23 exit 1
24 fi
25
26
27 TOOLDIR="$HOME/opt"
28
29 # Download AppImage Linux Deploy tool
30 LINUX_DEPLOY_TOOL="$TOOLDIR/linuxdeploy-x86_64.AppDir/AppRun"
31 APPIMAGE_TOOL="$TOOLDIR/appimagetool-x86_64.AppDir/AppRun"
32
33 function appimage_get_and_extractscip-shell shell shell-project 0.0.0 appimage_get_and_extract().()
34 {
35 local url="$1"
36
37 local appimage=$(basenamescip-shell system . . basename. $url)
38 local appname="${appimage%.*}"
39
40 mkdirscip-shell system . . mkdir. -p "$HOME/opt"
41 pushd "$HOME/opt"
42 rmscip-shell system . . rm. -rf "squashfs-root"
43 rmscip-shell system . . rm. -rf "${appname}.AppDir"
44 wget -c $url
45 chmodscip-shell system . . chmod. +x "$appimage"
46 ./$appimage --appimage-extract
47 rmscip-shell system . . rm. -f "$appimage"
48 mvscip-shell system . . mv. squashfs-root "${appname}.AppDir"
49 popd
50 }
51
52 if [scip-shell system . . `[`. ! -e "$LINUX_DEPLOY_TOOL" ] ; then
53 appimage_get_and_extractscip-shell shell shell-project 0.0.0 appimage_get_and_extract(). \
54 "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
55 fi
56
57 if [scip-shell system . . `[`. ! -e "$APPIMAGE_TOOL" ] ; then
58 appimage_get_and_extractscip-shell shell shell-project 0.0.0 appimage_get_and_extract(). \
59 "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
60 fi
61
62
63 # TODO: when migration from Autoconf to CMake will be finished in FreeFem project,
64 # we need to update configure and build commands here to something like:
65 # cmake . -DCMAKE_INSTALL_PREFIX=/usr
66 # make
67 # make install DESTDIR=$SRC_DIR/AppDir
68 # https://docs.appimage.org/packaging-guide/from-source/native-binaries.html#cmake
69
70 autoreconfscip-shell system . . autoreconf. -i
71 ./configure \
72 CFLAGS='-fpermissive' \
73 CXXFLAGS='-fpermissive' \
74 --prefix=$SRC_DIR/AppDir/usr \
75 --enable-download \
76 --enable-optim \
77 --enable-generic
78 ./3rdparty/getall -a
79 makescip-shell system . . make.
80 makescip-shell system . . make. install
81
82 # TODO: ffglut tool is missing now
83 # To try to add it, add --with-glut to ./configure
84 # and add 'freeglut3-dev' to apt-get install list.
85
86 # Remove some extras that not need in AppImage
87 rmscip-shell system . . rm. -rf $SRC_DIR/AppDir/usr/lib/ff++/4.1/include
88 rmscip-shell system . . rm. -rf $SRC_DIR/AppDir/usr/lib/ff++/4.1/examples
89 rmscip-shell system . . rm. -rf $SRC_DIR/AppDir/usr/share/freefem++/4.1/examples
90 rmscip-shell system . . rm. -rf $SRC_DIR/AppDir/usr/share/doc/
91
92
93 # Create additional files need to AppImage
94 mkdirscip-shell system . . mkdir. -p AppDir/usr/share/applications/
95 catscip-shell system . . cat. << EOF > AppDir/usr/share/applications/FreeFem.desktop
96 [Desktop Entry]
97 Name=FreeFEM
98 Type=Application
99 Exec=freefem-apprun.sh
100 Icon=freefem
101 Comment=Easy to use PDE solver
102 Categories=Science;
103 Terminal=true
104 EOF
105
106 mkdirscip-shell system . . mkdir. -p AppDir/usr/share/icons/hicolor/32x32/apps
107 cpscip-shell system . . cp. etc/logo/logo.png AppDir/usr/share/icons/hicolor/32x32/apps/freefem.png
108
109 mkdirscip-shell system . . mkdir. -p AppDir/usr/bin
110 cpscip-shell system . . cp. etc/AppImage/freefem-apprun.sh AppDir/usr/bin/freefem-apprun.sh
111
112 # Use it if you want resulting file to be FreeFem-3f71f1f-x86_64.AppImage for ex.
113 # export VERSION=$(git rev-parse --short HEAD)
114
115 $LINUX_DEPLOY_TOOL --appdir AppDir
116
117 # the output will be FreeFem-x86_64.AppImage
118 envscip-shell system . . env. ARCH=x86_64 $APPIMAGE_TOOL AppDir