Fix localized icon names
[appimagekit/gsi.git] / test-appimagetool.sh
blob8e656232e9c0d0c23b1a4bee983723256e5fe2e6
1 #! /bin/bash
3 set -e
4 set -E
5 set -o functrace
7 # this script attempts to package appimagetool as an AppImage with... surprise, appimagetool
9 tempdir=$(mktemp -d /tmp/appimage-test.XXXXXXXX)
10 thisdir=$(dirname $(readlink -f "$0"))
12 appimagetool=$(readlink -f "$1")
14 # make sure to use the built mksquashfs
15 export PATH=$(dirname "$appimagetool"):"$PATH"
17 if [ ! -f "$appimagetool" ] || [ ! -x "$appimagetool" ]; then
18 echo "Usage: $0 <path to appimagetool>"
19 exit 1
22 if [ "$TRAVIS" == true ]; then
23 # TODO: find way to get colored log on Travis
24 log() { echo -e "\n$*\n"; }
25 else
26 log() { echo -e "\n$(tput setaf 2)$(tput bold)$*$(tput sgr0)\n"; }
29 # debug log
30 trap '[[ $FUNCNAME = exithook ]] || { last_lineno=$real_lineno; real_lineno=$LINENO; }' DEBUG
32 exithook() {
33 local exitcode="$1"
34 local lineno=${last_lineno:-$2}
36 if [ $exitcode -ne 0 ]; then
37 echo "$(tput setaf 1)$(tput bold)Test run failed: error in line $lineno$(tput sgr0)"
38 else
39 log "Tests succeeded!"
42 rm -r "$tempdir";
44 exit $exitcode
47 trap 'exithook $? $LINENO ${BASH_LINENO[@]}' EXIT
49 # real script begins here
50 cd "$tempdir"
52 log "create a sample AppDir"
53 mkdir -p appimagetool.AppDir/usr/share/metainfo/
54 cp "$thisdir"/resources/{appimagetool.*,AppRun} appimagetool.AppDir/
55 #cp "$thisdir"/resources/usr/share/metainfo/appimagetool.appdata.xml appimagetool.AppDir/usr/share/metainfo/
56 cp "$appimagetool" appimagetool.AppDir/
57 mkdir -p appimagetool.AppDir/usr/share/applications
58 cp appimagetool.AppDir/appimagetool.desktop appimagetool.AppDir/usr/share/applications
60 log "create a file that should be ignored"
61 touch appimagetool.AppDir/to-be-ignored
63 log "create an AppImage without an ignore file to make sure it is bundled"
64 "$appimagetool" appimagetool.AppDir appimagetool.AppImage || false
65 "$appimagetool" -l appimagetool.AppImage | grep -q to-be-ignored || false
67 log "now set up the ignore file, and check that the file is properly ignored"
68 echo "to-be-ignored" > .appimageignore
69 "$appimagetool" appimagetool.AppDir appimagetool.AppImage
70 "$appimagetool" -l appimagetool.AppImage | grep -q to-be-ignored && false
72 log "remove the default ignore file, and check if an explicitly passed one works, too"
73 rm .appimageignore
74 echo "to-be-ignored" > ignore
75 "$appimagetool" appimagetool.AppDir appimagetool.AppImage --exclude-file ignore || false
76 "$appimagetool" -l appimagetool.AppImage | grep -q to-be-ignored && false
78 log "check whether files in both .appimageignore and the explicitly passed file work"
79 touch appimagetool.AppDir/to-be-ignored-too
80 echo "to-be-ignored-too" > .appimageignore
81 "$appimagetool" appimagetool.AppDir appimagetool.AppImage --exclude-file ignore
82 "$appimagetool" -l appimagetool.AppImage | grep -q to-be-ignored || true
83 "$appimagetool" -l appimagetool.AppImage | grep -q to-be-ignored-too || true
85 log "check whether AppImages built from the exact same AppDir are the same files (reproducible builds, #625)"
86 "$appimagetool" appimagetool.AppDir appimagetool.AppImage.1
87 "$appimagetool" appimagetool.AppDir appimagetool.AppImage.2
88 hash1=$(sha256sum appimagetool.AppImage.1 | awk '{print $1}')
89 hash2=$(sha256sum appimagetool.AppImage.2 | awk '{print $1}')
90 if [ "$hash1" != "$hash2" ]; then
91 echo "Hash $hash1 doesn't match hash $hash2!"
92 exit 1