File indexing completed on 2022-09-20 15:20:11

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 /in/
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 rm -rfv mkdir /in/<%= name %>.AppDir
0029 mkdir /in/<%= name %>.AppDir/
0030 
0031 cd /in/
0032 wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
0033 chmod a+x linuxdeployqt-continuous-x86_64.AppImage
0034 
0035 cd /in/<%= name %>.AppDir
0036 
0037 #Move binary/desktop/icon into AppDir
0038 mv /opt/usr/bin/<%= binary %> .
0039 mv /opt/usr/share/applications/org.kde.<%= binary %>.desktop <%= binary %>.desktop
0040 cp /opt/usr/share/icons/hicolor/48x48/apps/*<%= name %>* .
0041 
0042 
0043 #All the plugins do not seem to be getting in. Manual copy.
0044 mkdir -p ./plugins; cp -rfv /opt/usr/lib/qt5/plugins/phonon4qt5_backend $_
0045 #mkdir -p ./usr/lib/qml/
0046 mkdir -p ./usr/{share,bin,sbin,lib}
0047 mkdir ./etc
0048 mv /opt/usr/plugins/kf5/kio/* ./plugins/
0049 rsync -aruxv --progress /opt/usr/plugins/ ./plugins/
0050 rsync -aruxv --progress /opt/usr/share/ ./usr/share/
0051 rsync -aruxv --progress /opt/etc/ ./etc/
0052 rsync -aruxv --progress /opt/usr/qml/ ./qml/
0053 rsync -aruxv --progress /opt/usr/resources/ ./usr/bin/
0054 rsync -aruxv --progress /opt/usr/translations/ ./usr/bin/
0055 cp /usr/lib/x86_64-linux-gnu/pulseaudio/*.so* ./usr/lib/
0056 
0057 mkdir ./lib
0058 cp /usr/lib/x86_64-linux-gnu/pulseaudio/*.so* ./lib/
0059 cp -rfv /usr/share/mime ./usr/share/
0060 cp /etc/mime.types ./etc/
0061 update-mime-database ./usr/share/mime
0062 
0063 mv /opt/usr/libexec/Qt* ./usr/bin/ || true
0064 mv /opt/usr/lib/x86_64-linux-gnu/libexec/kf5/* ./usr/bin/ || true
0065 cp -rfv /opt/usr/lib/x86_64-linux-gnu/* /opt/usr/lib/
0066 unset LD_LIBRARY_PATH
0067 ../linuxdeployqt-continuous-x86_64.AppImage <%= name %> -verbose=3 -bundle-non-qt-libs -qmldir=/opt/usr/qml
0068 
0069 patch_usr
0070 glibc_needed
0071 delete_blacklisted
0072 #Cleanup
0073 # We don't bundle the developer stuff
0074 rm -rf ./usr/include || true
0075 rm -rf ./usr/lib/cmake || true
0076 rm -rf ./lib/cmake || true
0077 rm -rf ./usr/lib/pkgconfig || true
0078 rm -rf ./usr/share/ECM/ || true
0079 rm -rf ./usr/share/gettext || true
0080 rm -rf ./usr/share/pkgconfig || true
0081 rm -rf ./usr/mkspecs/ || true
0082 rm -rf ./usr/gettext-* || true
0083 rm -rf ./usr/autoconf-* || true
0084 rm -rf ./usr/automake-* || true
0085 rm -rf ./usr/libtool-* || true
0086 rm -rf ./libexec || true
0087 rm -rf ./usr/share/cmake-3.8 || true
0088 rm -rf ./usr/share/man || true
0089 rm -rf ./usr/share/doc/ECM || true
0090 rm -rf ./usr/share/doc/libdbusmenu-qt5-doc || true
0091 rm -rf ./usr/share/gtk-doc || true
0092 rm -rf ./usr/share/wallpapers || true
0093 rm -rf ./usr/share/aclocal || true
0094 rm -rf ./usr/share/bash-completion || true
0095 rm -rf ./usr/share/common-lisp || true
0096 rm -rf ./usr/share/cups || true
0097 rm -rf ./usr/share/doc/{cups,gettext,gnupg,libasprintf,pcre} || true
0098 rm -rf ./usr/share/gir-1.0 || true
0099 rm -rf ./usr/share/gnupg || true
0100 rm -rf ./usr/share/gobject-introspection-1.0 || true
0101 rm -rf ./usr/share/util-macros || true
0102 find . -name '*.a' -exec rm {} \;
0103 strip -g $(find . -type f -exec) || true
0104 
0105 #Add back libkrb5
0106 cp /usr/lib/x86_64-linux-gnu/libkrb5* ./lib/
0107 get_desktopintegration <%= name %>
0108 cd /app/src
0109 git clone git://anongit.kde.org/scratch/brauch/appimage-exec-wrapper
0110 cd /app/src/appimage-exec-wrapper/
0111 make clean
0112 make
0113 cp -v exec.so /<%= name %>.AppDir/exec_wrapper.so
0114 rm -rfv  /app/src/appimage-exec-wrapper
0115 cd /<%= name %>.AppDir
0116 rm AppRun
0117 #Create AppRun
0118 cat > AppRun << EOF
0119 #!/bin/bash
0120 DIR="\`dirname \"\$0\"\`"
0121 HERE="\`( cd \"\$DIR\" && pwd )\`"
0122 export LD_PRELOAD=\$HERE/exec_wrapper.so
0123 export QML2_IMPORT_PATH=\$HERE/qml
0124 export QT_PLUGIN_PATH=\$HERE/plugins
0125 export GRANTLEE_PLUGIN_PATH=\$HERE/plugins
0126 export PATH=\$HERE/usr/bin/:\$HERE/usr/sbin/:\$HERE/usr/games/:\$HERE/bin/:\$HERE/sbin/:\$PATH
0127 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
0128 export XDG_DATA_DIRS=\$HERE/usr/share:\$HOME/.local/share:\$HERE/share:/usr/local/share/:/usr/share:\$XDG_DATA_DIRS
0129 export XDG_DATA_HOME=\$HOME/.local/share
0130 export XDG_CONFIG_DIRS=\$HERE/.config:\$HERE/etc/xdg:\$XDG_CONFIG_DIRS
0131 export KDE_FORK_SLAVES=1
0132 export KF5_LIBEXEC_DIR=\$HERE/usr/bin
0133 export GST_PLUGIN_PATH=\$HERE/lib
0134 export GST_PLUGIN_SCANNER=\$HERE/bin
0135 
0136 \$HERE/usr/bin/blinken
0137 PGID=$(ps -o pid,pgid,comm | grep AppRun)
0138 trap "trap - SIGTERM && kill -- -$PGID" SIGINT SIGTERM EXIT
0139 
0140 EOF
0141 chmod +x AppRun
0142 mv <%= binary %> ./usr/bin/
0143 cp <%= binary %>.desktop ./usr/share/applications/
0144 cd /
0145 wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
0146 chmod a+x appimagetool-x86_64.AppImage
0147 
0148 ARCH=$(arch)
0149 DATE=$(date +"%Y%m%d")
0150 
0151 APPIMAGEFILENAME="<%= name %>-git$DATE-$ARCH.AppImage"
0152 
0153 #Re set LD_LIBRARY_PATH
0154 export LD_LIBRARY_PATH=/opt/usr/lib:/opt/usr/lib/x86_64-linux-gnu:/usr/lib:/usr/lib64
0155 ./appimagetool-x86_64.AppImage -v -s  /<%= name %>.AppDir /appimage/$APPIMAGEFILENAME