File indexing completed on 2022-09-27 15:18:54

0001 #!/bin/bash
0002 #
0003 # Copyright (C) 2016 Scarlett Clark <sgclark@kde.org>
0004 #
0005 # This library is free software; you can redistribute it and/or
0006 # modify it under the terms of the GNU Lesser General Public
0007 # License as published by the Free Software Foundation; either
0008 # version 2.1 of the License, or (at your option) version 3, or any
0009 # later version accepted by the membership of KDE e.V. (or its
0010 # successor approved by the membership of KDE e.V.), which shall
0011 # act as a proxy defined in Section 6 of version 3 of the license.
0012 #
0013 # This library is distributed in the hope that it will be useful,
0014 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016 # Lesser General Public License for more details.
0017 #
0018 # You should have received a copy of the GNU Lesser General Public
0019 # License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 cd /
0022 
0023 # Get helper functions
0024 wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
0025 . ./functions.sh
0026 rm -f functions.sh
0027 
0028 mkdir /<%= name %>.AppDir/
0029 
0030 cd /
0031 wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
0032 chmod a+x linuxdeployqt-continuous-x86_64.AppImage
0033 
0034 cd /<%= name %>.AppDir
0035 
0036 #Move binary/desktop/icon into AppDir
0037 mv /opt/usr/bin/<%= binary %> .
0038 mv /opt/usr/share/applications/org.kde.<%= binary %>.desktop <%= binary %>.desktop
0039 cp /opt/usr/share/icons/hicolor/48x48/apps/*<%= name %>* .
0040 
0041 
0042 #All the plugins do not seem to be getting in. Manual copy.
0043 mkdir -p ./plugins; cp -rfv /opt/usr/lib/qt5/plugins/phonon4qt5_backend $_
0044 #mkdir -p ./usr/lib/qml/
0045 mkdir -p ./usr/{share,bin,sbin,lib}
0046 mkdir ./etc
0047 #mv /opt/usr/plugins/akonadi/*  ./plugins/
0048 #mv /opt/usr/plugins/kf5/kio/* ./plugins/
0049 cp -rfv /opt/usr/lib/grantlee ./plugins/
0050 cp /opt/usr/lib/x86_64-linux-gnu/grantlee/5.1/*  ./plugins/grantlee/5.1/
0051 rsync -aruxv --progress /opt/usr/plugins/ ./plugins/
0052 rsync -aruxv --progress /opt/usr/share/ ./usr/share/
0053 rsync -aruxv --progress /opt/etc/ ./etc/
0054 rsync -aruxv --progress /opt/usr/qml/ ./qml/
0055 rsync -aruxv --progress /opt/usr/resources/ ./usr/bin/
0056 rsync -aruxv --progress /opt/usr/translations/ ./usr/bin/
0057 cp /usr/lib/x86_64-linux-gnu/pulseaudio/*.so* ./usr/lib/
0058 
0059 cp /opt/usr/bin/gst* ./usr/bin/
0060 mv /opt/usr/bin/*akonadi* ./usr/bin/
0061 mv /opt/usr/bin/gidmigrator ./usr/bin/
0062 mv /opt/usr/bin/msg* ./usr/bin/
0063 cp /opt/usr/bin/k* ./usr/bin/
0064 mv /opt/usr/bin/asapcat ./usr/bin/
0065 mv /opt/usr/bin/accountwizard ./usr/bin/
0066 mv /opt/usr/bin/ispdb ./usr/bin/
0067 mv /usr/sbin/mysql* ./usr/sbin/
0068 cp -rfv /usr/share/mysql ./usr/share/
0069 
0070 mv /in/mysqld-akonadi ./usr/sbin/
0071 chmod +x ./usr/sbin/mysqld-akonadi
0072 mv /in/mysql-global.conf ./etc/xdg/akonadi/
0073 mkdir ./lib
0074 rm -rfv /opt/usr/lib/gstreamer-1.0/include
0075 cp /opt/usr/lib/gstreamer-1.0/* ./lib/
0076 mv /opt/usr/lib/x86_64-linux-gnu/libfolderarchivesettings.so* ./lib/
0077 mv /opt/usr/lib/x86_64-linux-gnu/libkmindexreader.so* ./lib/
0078 mv /opt/usr/lib/x86_64-linux-gnu/libakonadi-singlefileresource.so* ./lib/
0079 mv /opt/usr/lib/x86_64-linux-gnu/libmaildir.so* ./lib/
0080 mv /opt/usr/lib/x86_64-linux-gnu/libKPimKDAV.so* ./lib/
0081 mv /opt/usr/lib/x86_64-linux-gnu/libkwalletbackend5.so* ./lib/
0082 cp /opt/usr/lib/x86_64-linux-gnu/libKPimGAPICore.so* ./lib/
0083 cp /usr/lib/x86_64-linux-gnu/pulseaudio/*.so* ./lib/
0084 cp /lib/x86_64-linux-gnu/libaio* ./lib/
0085 cp /usr/lib/x86_64-linux-gnu/libhcrypto* ./lib/
0086 cp /usr/lib/x86_64-linux-gnu/liblz4* ./lib/
0087 cp -rfv /usr/share/mime ./usr/share/
0088 cp /etc/mime.types ./etc/
0089 update-mime-database ./usr/share/mime
0090 
0091 mv /opt/usr/libexec/Qt* ./usr/bin/ || true
0092 mv /opt/usr/lib/x86_64-linux-gnu/libexec/kf5/* ./usr/bin/ || true
0093 mv /opt/usr/libexec/gstreamer-1.0/* ./usr/bin || true
0094 cp -rfv /opt/usr/lib/x86_64-linux-gnu/* /opt/usr/lib/
0095 unset LD_LIBRARY_PATH
0096 ../linuxdeployqt-1-x86_64.AppImage <%= name %> -verbose=3 -bundle-non-qt-libs -qmldir=/opt/usr/qml
0097 
0098 patch_usr
0099 glibc_needed
0100 delete_blacklisted
0101 #Cleanup
0102 # We don't bundle the developer stuff
0103 rm -rf ./usr/include || true
0104 rm -rf ./usr/lib/cmake || true
0105 rm -rf ./lib/cmake || true
0106 rm -rf ./usr/lib/pkgconfig || true
0107 rm -rf ./usr/share/ECM/ || true
0108 rm -rf ./usr/share/gettext || true
0109 rm -rf ./usr/share/pkgconfig || true
0110 rm -rf ./usr/mkspecs/ || true
0111 rm -rf ./usr/gettext-* || true
0112 rm -rf ./usr/autoconf-* || true
0113 rm -rf ./usr/automake-* || true
0114 rm -rf ./usr/libtool-* || true
0115 rm -rf ./libexec || true
0116 rm -rf ./usr/share/cmake-3.8 || true
0117 rm -rf ./usr/share/man || true
0118 rm -rf ./usr/share/doc/ECM || true
0119 rm -rf ./usr/share/doc/libdbusmenu-qt5-doc || true
0120 rm -rf ./usr/share/gtk-doc || true
0121 rm -rf ./usr/share/wallpapers || true
0122 rm -rf ./usr/share/aclocal || true
0123 rm -rf ./usr/share/bash-completion || true
0124 rm -rf ./usr/share/common-lisp || true
0125 rm -rf ./usr/share/cups || true
0126 rm -rf ./usr/share/doc/{cups,gettext,gnupg,libasprintf,pcre} || true
0127 rm -rf ./usr/share/gir-1.0 || true
0128 rm -rf ./usr/share/gnupg || true
0129 rm -rf ./usr/share/gobject-introspection-1.0 || true
0130 rm -rf ./usr/share/util-macros || true
0131 find . -name '*.a' -exec rm {} \;
0132 strip -g $(find . -type f -exec) || true
0133 
0134 #Add back libkrb5
0135 cp /usr/lib/x86_64-linux-gnu/libkrb5* ./lib/
0136 get_desktopintegration <%= name %>
0137 cd /app/src
0138 git clone git://anongit.kde.org/scratch/brauch/appimage-exec-wrapper
0139 cd /app/src/appimage-exec-wrapper/
0140 make clean
0141 make
0142 cp -v exec.so /<%= name %>.AppDir/exec_wrapper.so
0143 rm -rfv  /app/src/appimage-exec-wrapper
0144 cd /<%= name %>.AppDir
0145 rm AppRun
0146 #Create AppRun
0147 cat > AppRun << EOF
0148 #!/bin/bash
0149 DIR="\`dirname \"\$0\"\`"
0150 HERE="\`( cd \"\$DIR\" && pwd )\`"
0151 export LD_PRELOAD=\$HERE/exec_wrapper.so
0152 export QML2_IMPORT_PATH=\$HERE/qml
0153 export QT_PLUGIN_PATH=\$HERE/plugins
0154 export GRANTLEE_PLUGIN_PATH=\$HERE/plugins
0155 export PATH=\$HERE/usr/bin/:\$HERE/usr/sbin/:\$HERE/usr/games/:\$HERE/bin/:\$HERE/sbin/:\$PATH
0156 export LD_LIBRARY_PATH=\$HERE/usr/lib/:\$HERE/usr/lib/x86_64-linux-gnu/:\$HERE/usr/lib64/:\$HERE/lib/:\$HERE/lib/x86_64-linux-gnu/:\$HERE/lib64/:\$LD_LIBRARY_PATH
0157 export XDG_DATA_DIRS=\$HERE/usr/share:\$HOME/.local/share:\$HERE/share:/usr/local/share/:/usr/share:\$XDG_DATA_DIRS
0158 export XDG_DATA_HOME=\$HOME/.local/share
0159 export XDG_CONFIG_DIRS=\$HERE/.config:\$HERE/etc/xdg:\$XDG_CONFIG_DIRS
0160 export KDE_FORK_SLAVES=1
0161 export KF5_LIBEXEC_DIR=\$HERE/usr/bin
0162 export GST_PLUGIN_PATH=\$HERE/lib
0163 export GST_PLUGIN_SCANNER=\$HERE/bin
0164 
0165 \$HERE/usr/bin/kwalletd
0166 export AKONADI_DISABLE_AGENT_AUTOSTART
0167 \$HERE/usr/bin/akonadictl --instance kmail_appimage start
0168 export AKONADI_INSTANCE=kmail_appimage
0169 \$HERE/usr/sbin/mysql --protocol=SOCKET --socket=~/.local/share/akonadi/instance/kmail_appimage/socket-$(hostname)/mysql.socket
0170 <%= binary %> $@
0171 
0172 \$HERE/usr/bin/akonadictl --instance kmail_appimage stop
0173 \$HERE/usr/sbin/mysqladmin --no-defaults --default-character-set=utf8 --socket=~/.local/share/akonadi/instance/kmail_appimage/socket-$(hostname)/mysql.socket shutdown
0174 PGID=$(ps -o pid,pgid,comm | grep AppRun)
0175 trap "trap - SIGTERM && kill -- -$PGID" SIGINT SIGTERM EXIT
0176 
0177 EOF
0178 chmod +x AppRun
0179 mv <%= binary %> ./usr/bin/
0180 cp <%= binary %>.desktop ./usr/share/applications/
0181 cd /
0182 wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
0183 chmod a+x appimagetool-x86_64.AppImage
0184 
0185 ARCH=$(arch)
0186 DATE=$(date +"%Y%m%d")
0187 
0188 APPIMAGEFILENAME="<%= name %>-git$DATE-$ARCH.AppImage"
0189 
0190 #Re set LD_LIBRARY_PATH
0191 export LD_LIBRARY_PATH=/opt/usr/lib:/opt/usr/lib/x86_64-linux-gnu:/usr/lib:/usr/lib64
0192 ./appimagetool-x86_64.AppImage -v -s  /<%= name %>.AppDir /appimage/$APPIMAGEFILENAME