forked from tmux/tmux
-
Notifications
You must be signed in to change notification settings - Fork 1
/
genappimage.sh
executable file
·130 lines (101 loc) · 3.39 KB
/
genappimage.sh
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Contributed by michaellee8 <[email protected]> in 2020
set -x
set -e
# Reference: https://docs.appimage.org/packaging-guide/from-source/native-binaries.html#id2
# Dependencies: sudo apt-get install pkg-config autotools automake \
# autoconf curl imagemagick
# building in temporary directory to keep system clean
# use RAM disk if possible (as in: not building on CI system
# like Travis, and RAM disk is available)
# DISABLED: It seems that linuxdeploy won't be executable on shared memory,
# maybe /dev/shm is marked as non-executable?
if [ "$CI" == "" ] && [ -d /dev/shm ] && false; then
TEMP_BASE=/dev/shm
else
TEMP_BASE=/tmp
fi
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" appimage-build-XXXXXX)
# make sure to clean up build dir, even if errors occur
cleanup () {
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
}
trap cleanup EXIT
# store repo root as variable
REPO_ROOT="$(git rev-parse --show-toplevel)"
OLD_CWD=$(readlink -f .)
mkdir -p "$BUILD_DIR/AppDir/usr"
cd $BUILD_DIR
# Obtain and compile libevent
git clone https://github.com/libevent/libevent --depth 1 \
-b release-2.1.12-stable
cd libevent
sh autogen.sh
./configure \
--prefix="$BUILD_DIR/AppDir/usr" \
--enable-shared
make -j4
make install
cd ../
# Obtain and compile libncursesw6 so that we get 256 color support
curl -OL https://invisible-island.net/datafiles/release/ncurses.tar.gz
tar -xf ncurses.tar.gz
NCURSES_DIR="$PWD/ncurses-6.2"
pushd "$NCURSES_DIR"
./configure --with-shared --prefix="$BUILD_DIR/AppDir/usr" \
--without-normal --without-debug
make -j4
make install
popd
# Configure tmux now to make sure it uses our libncursesw6
# and libevent
cd $REPO_ROOT
export LD_LIBRARY_PATH="$BUILD_DIR/AppDir/usr/lib"
# autoreconf -f -i
# autoconf
sh autogen.sh
export CPPFLAGS="-I$BUILD_DIR/AppDir/usr/include -I$BUILD_DIR/AppDir/usr/include/ncursesw"
export LDFLAGS="-L$BUILD_DIR/AppDir/usr/lib"
export PKG_CONFIG_PATH=$BUILD_DIR/AppDir/usr/lib/pkgconfig
./configure \
--prefix="$BUILD_DIR/AppDir/usr"
make -j4
make install
# Copy the AppData file to AppDir manually
# cp -r "$REPO_ROOT/data/metainfo" "$BUILD_DIR/AppDir/usr/share/"
# Custom AppRun to provide $ARGV0 issues when used with zsh
# Reference: https://github.com/neovim/neovim/blob/master/scripts/genappimage.sh
# Reference: https://github.com/neovim/neovim/issues/9341
cd $BUILD_DIR
cat << 'EOF' > AppDir/AppRun
#!/bin/bash
unset ARGV0
export TERMINFO=$APPDIR/usr/share/terminfo
exec "$(dirname "$(readlink -f "${0}")")/usr/bin/tmux" ${@+"$@"}
EOF
chmod 755 AppDir/AppRun
cat << 'EOF' > AppDir/tmux.desktop
[Desktop Entry]
X-AppImage-Name=tmux
X-AppImage-Version=1.0.0
X-AppImage-Arch=x86_64
Name=Tmux
Exec=tmux
Icon=favicon
Type=Application
Categories=Utility;
EOF
# Downloading linuxdeploy
curl -o ./linuxdeploy -L \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +rx ./linuxdeploy
# Requires imagemagick to convert favicon.ico
convert "$REPO_ROOT/logo/favicon.ico" "$REPO_ROOT/logo/favicon.png"
# favicon.ico here has multiple image size, we choose the largest one
cp "$REPO_ROOT/logo/favicon-1.png" "$BUILD_DIR/AppDir/favicon.png"
OUTPUT="tmux.appimage" ./linuxdeploy --appdir ./AppDir --output appimage \
--icon-file "$REPO_ROOT/logo/favicon.ico" \
--executable "$BUILD_DIR/AppDir/usr/bin/tmux"
mv "tmux.appimage" "$OLD_CWD"