Skip to content

Commit be47012

Browse files
authored
refactor
1 parent 65ae7d7 commit be47012

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

htop-appimage.sh

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
11
#!/bin/sh
2-
set -u
2+
3+
set -eu
4+
5+
export ARCH="$(uname -m)"
6+
export APPIMAGE_EXTRACT_AND_RUN=1
7+
38
APP=htop
49
APPDIR="$APP".AppDir
510
SITE="htop-dev/htop"
11+
UPINFO="gh-releases-zsync|$(echo $GITHUB_REPOSITORY | tr '/' '|')|continuous|*$ARCH.AppImage.zsync"
12+
APPIMAGETOOL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage"
613

714
# CREATE DIRECTORIES
8-
[ -n "$APP" ] && mkdir -p ./"$APP/$APPDIR" && cd ./"$APP/$APPDIR" || exit 1
15+
mkdir -p ./"$APP"/AppDir
16+
cd ./"$APP"/AppDir
917

1018
# DOWNLOAD AND BUILD HTOP
1119
CURRENTDIR="$(dirname "$(readlink -f "$0")")" # DO NOT MOVE THIS
12-
version=$(wget -q https://api.github.com/repos/$SITE/releases -O - | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*releases.*htop.*tar.xz' | head -1)
13-
wget "$version" && tar fx ./*tar* && cd ./htop* && ./autogen.sh && ./configure --prefix="$CURRENTDIR" --enable-sensors --enable-static \
14-
&& make && make install && cd .. && rm -rf ./htop* ./*tar* || exit 1
20+
HTOP_URL=$(wget -q https://api.github.com/repos/$SITE/releases -O - \
21+
| sed 's/[()",{} ]/\n/g' | grep -oi 'https.*releases.*htop.*tar.xz' | head -1)
22+
23+
wget "$HTOP_URL"
24+
tar fx ./*.tar.*
25+
26+
cd ./htop*
27+
./autogen.sh
28+
./configure --prefix="$CURRENTDIR" --enable-sensors --enable-static
29+
make
30+
make install
31+
cd ..
32+
rm -rf ./htop* ./*.tar.*
1533

1634
# PREPARE APPIMAGE
17-
#cp ./share/applications/*.desktop ./ && cp ./share/icons/*/*/*/* ./htop.svg && ln -s ./htop.svg ./.DirIcon || exit 1 # Causes a sigsegv with appimagetool
18-
cp ./share/applications/*.desktop ./ && cp ./share/pixmaps/* ./htop.png && ln -s ./htop.png ./.DirIcon || exit 1 # Doesn't cause the sigsegv.
35+
cp ./share/applications/*.desktop ./
36+
cp ./share/pixmaps/* ./htop.png
37+
ln -s ./htop.png ./.DirIcon
1938

2039
# AppRun
2140
cat >> ./AppRun << 'EOF'
22-
#!/bin/sh
41+
#!/usr/bin/env sh
2342
CURRENTDIR="$(dirname "$(readlink -f "$0")")"
24-
"$CURRENTDIR/bin/htop" "$@"
43+
"$CURRENTDIR"/bin/htop "$@"
2544
EOF
26-
chmod a+x ./AppRun
27-
APPVERSION=$(./AppRun -V | awk '{print $2}')
28-
if [ -z "$APPVERSION" ]; then echo "Failed to get version from htop"; exit 1; fi
45+
chmod +x ./AppRun
46+
VERSION="$(./AppRun -V | awk '{print $2}')"
2947

3048
# MAKE APPIMAGE
3149
cd ..
32-
APPIMAGETOOL=$(wget -q https://api.github.com/repos/probonopd/go-appimage/releases -O - | sed 's/"/ /g; s/ /\n/g' | grep -oi 'https.*continuous.*tool.*86_64.*mage$')
33-
wget -q "$APPIMAGETOOL" -O ./appimagetool && chmod a+x ./appimagetool
34-
35-
# Do the thing!
36-
ARCH=x86_64 VERSION="$APPVERSION" ./appimagetool -s ./"$APPDIR"
37-
ls ./*.AppImage || { echo "appimagetool failed to make the appimage"; exit 1; }
38-
[ -n "$APP" ] && mv ./*.AppImage .. && cd .. && rm -rf ./"$APP"
50+
wget -q "$APPIMAGETOOL" -O ./appimagetool
51+
chmod +x ./appimagetool
52+
./appimagetool --comp zstd \
53+
--mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 \
54+
-n -u "$UPINFO" "$PWD"/AppDir "$PWD"/"$APP"-"$VERSION"-anylinux-"$ARCH".AppImage
55+
mv ./*.AppImage* ..
56+
rm -rf ./"$APP"
3957
echo "All Done!"

0 commit comments

Comments
 (0)