summaryrefslogtreecommitdiffstats
path: root/build/linux/PrepareAppDir.sh
blob: 17fd782dcb4dd89dba22bdb1af06d503fc84d8d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
#
# Used to prepare the AppDir bundle directory. -*- mode: sh -*-
#
# Written by Tristan Van Berkom <tristan@upstairslabs.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU 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

APP_DIR_ROOT=$1
BUNDLE_DIR=$2

if test -z ${APP_DIR_ROOT} || test -z ${BUNDLE_DIR}; then
    echo "Usage ./PrepareAppDir.sh /path/to/AppImage/Install /path/to/glade/build/linux"
    exit 0;
fi

echo -n "Removing various unwanted files from the image... "
# Remove static libraries and libtool archives
rm -f `find ${APP_DIR_ROOT} -name "*.a"`
rm -f `find ${APP_DIR_ROOT} -name "*.la"`

# Remove include directory
rm -rf ${APP_DIR_ROOT}/include

# Remove various stuff in /share
rm -rf ${APP_DIR_ROOT}/share/man
rm -rf ${APP_DIR_ROOT}/share/info
rm -rf ${APP_DIR_ROOT}/share/help
rm -rf ${APP_DIR_ROOT}/share/doc
rm -rf ${APP_DIR_ROOT}/share/gtk-doc
rm -rf ${APP_DIR_ROOT}/share/gdb
rm -rf ${APP_DIR_ROOT}/share/gdm
rm -rf ${APP_DIR_ROOT}/share/vala
rm -rf ${APP_DIR_ROOT}/share/pkgconfig
rm -rf ${APP_DIR_ROOT}/share/gnome
rm -rf ${APP_DIR_ROOT}/share/xml
rm -rf ${APP_DIR_ROOT}/share/bash-completion
rm -rf ${APP_DIR_ROOT}/share/appdata
rm -rf ${APP_DIR_ROOT}/share/dbus-1
rm -rf ${APP_DIR_ROOT}/share/glib-2.0/codegen
rm -rf ${APP_DIR_ROOT}/share/glib-2.0/gdb
rm -rf ${APP_DIR_ROOT}/share/glib-2.0/gettext

# Remove the binaries we dont need
mv ${APP_DIR_ROOT}/bin/glade ${APP_DIR_ROOT}/glade
mv ${APP_DIR_ROOT}/bin/glade-previewer ${APP_DIR_ROOT}/glade-previewer
rm -f ${APP_DIR_ROOT}/bin/*
mv ${APP_DIR_ROOT}/glade ${APP_DIR_ROOT}/bin
mv ${APP_DIR_ROOT}/glade-previewer ${APP_DIR_ROOT}/bin
rm -f ${APP_DIR_ROOT}/libexec/*

# jhbuild meta directory
rm -rf ${APP_DIR_ROOT}/_jhbuild
echo "Done."

echo -n "Removing encoded rpath from all binaries... "
chrpath -d ${APP_DIR_ROOT}/bin/glade
chrpath -d ${APP_DIR_ROOT}/bin/glade-previewer
chrpath -d `find ${APP_DIR_ROOT} -name "*.so"`
echo "Done."

echo -n "Setting up symlinks for new environment... "
WORK_DIR=`pwd`

# Create a /usr link in the install prefix, this is for AppImageKit to find the desktop icon properly
cd ${APP_DIR_ROOT}
ln -s . usr

# Create a symlink at ${APP_DIR_ROOT}${APP_DIR_ROOT} which
# links back to the root of the bundle.
#
# All our paths are relative to the jhbuild prefix, so we need
# this symlink to pretend that the build prefix is the root.
mkdir -p ${APP_DIR_ROOT}/${APP_DIR_ROOT%Install}
cd ${APP_DIR_ROOT}/${APP_DIR_ROOT%Install}
ln -s ../../.. Install

# Restore working directory
cd $WORK_DIR
echo "Done."

echo -n "Installing desktop file and runner script... "
cp ${APP_DIR_ROOT}/share/applications/glade.desktop ${APP_DIR_ROOT}
cat ${BUNDLE_DIR}/AppRun | sed -e "s|@APP_DIR_ROOT@|${APP_DIR_ROOT}|g" > ${APP_DIR_ROOT}/AppRun
chmod +x ${APP_DIR_ROOT}/AppRun
echo "Done."

echo -n "Fixing pixbuf loaders to have bundle relative paths... "
# Post process the loaders.cache file to use relative paths, we use a for loop here
# just because we're not sure the exact location, it could be in lib or lib64
for cache in `find ${APP_DIR_ROOT} -path "*gdk-pixbuf-2.0/2.10.0/loaders.cache"`; do
    cat $cache | sed -e "s|${APP_DIR_ROOT}|\.${APP_DIR_ROOT}|g" > $cache.1 && mv $cache.1 $cache;
done
echo "Done."