mirror of
https://github.com/Phantop/appdwarf.git
synced 2025-01-09 05:37:04 +00:00
Rename to appdwarf and add main appdwarf script
Also adds in support for converting AppImages
This commit is contained in:
parent
6d358e2641
commit
1e1e9c4fdd
|
@ -6,13 +6,14 @@ Wine builds packed into a portable executables
|
|||
|
||||
These scripts automatically fetch the latest version of their respective program and compress them into a portable image using [dwarfs](https://github.com/mhx/dwarfs) in a similar format to an [AppImage.](https://appimage.org/)
|
||||
|
||||
The titular `appdwarf` utility supports both converting an AppDir or an existing AppImage file, either as a local file or from a URL.
|
||||
|
||||
## Requirements
|
||||
|
||||
In order to create the images, you will need:
|
||||
|
||||
- [dwarfs](https://github.com/mhx/dwarfs), specifically the `dwarfs` and `mkdwarfs` utilities (`dwarfs2` works, but you must either edit the script or link `dwarfs` to it)
|
||||
|
||||
- My `appdwarf` script from [here](https://github.com/Phantop/dotfiles/blob/main/.local/bin/appdwarf)
|
||||
|
||||
If you only wish to run an existing image, only `dwarfs` (or `dwarfs2`) is needed.
|
||||
|
||||
|
|
80
appdwarf
Executable file
80
appdwarf
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/bin/sh
|
||||
set -eo pipefail
|
||||
IFS=$'\n\t'
|
||||
version=1
|
||||
|
||||
usage(){
|
||||
echo "Usage: $0 [option] [FILE/FOLDER/URL]"
|
||||
echo " Compress a given AppDir (default)"
|
||||
echo " -a, --appimage Convert a given AppImage to appdwarf"
|
||||
echo " -u, --url Fetch AppImage from URL and convert to appdwarf"
|
||||
}
|
||||
|
||||
dwarf() {
|
||||
mkdwarfs -i "$1" -o "$(basename "$1").sh" --header <(cat << 'EOF'
|
||||
#!/bin/sh
|
||||
DIR=/tmp/.dwarf_$(basename "$0")$RANDOM
|
||||
mkdir "$DIR" 2> /dev/null
|
||||
dwarfs -o offset=auto "$0" "$DIR" 2> /dev/null
|
||||
"$DIR/AppRun" $@
|
||||
fusermount -uz "$DIR" 2> /dev/null
|
||||
rmdir "$DIR" 2> /dev/null
|
||||
exit
|
||||
EOF
|
||||
)
|
||||
|
||||
chmod +x "$(basename "$@").sh"
|
||||
}
|
||||
|
||||
appimage() {
|
||||
if [[ -f "$1" ]]
|
||||
then
|
||||
chmod +x "$1"
|
||||
./"$1" --appimage-extract || exit 1
|
||||
dwarf squashfs-root
|
||||
rm -rf squashfs-root
|
||||
mv squashfs-root.sh $(basename "$1" .AppImage).sh
|
||||
else
|
||||
echo "$1" is not a valid file
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
rm -rf squashfs-root
|
||||
|
||||
while true
|
||||
do
|
||||
case "$1" in
|
||||
--help | -h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--version)
|
||||
echo "$version"
|
||||
exit 0
|
||||
;;
|
||||
--appimage | -a)
|
||||
appimage "$2"
|
||||
exit 0
|
||||
;;
|
||||
--url | -u)
|
||||
file=$(basename "$2")
|
||||
wget "$2" -O "$file" || exit 1
|
||||
appimage "$file"
|
||||
rm "$file"
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift; break;;
|
||||
*)
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage
|
||||
exit 0
|
||||
else
|
||||
dwarf "$1"
|
||||
exit 0
|
||||
fi
|
1
mkgo
1
mkgo
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
PATH=$(dirname $(readlink -f "${0}")):$PATH
|
||||
DIR=/tmp/dwarf-portable-executable
|
||||
mkdir -p $DIR
|
||||
curl -L https://golang.org/$(curl -sL https://golang.org/dl | grep -wo dl/go.\*linux-amd64.tar.gz | head -n1) | tar xz -C$DIR
|
||||
|
|
1
mkjava
1
mkjava
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
PATH=$(dirname $(readlink -f "${0}")):$PATH
|
||||
DIR=/tmp/dwarf-portable-executable/java
|
||||
mkdir -p $DIR
|
||||
curl -L https://api.adoptopenjdk.net/v3/binary/latest/11/ga/linux/x64/jre/openj9/normal/adoptopenjdk | tar xz -C$DIR
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PATH=$(dirname $(readlink -f "${0}"))/../:$PATH
|
||||
start="$PWD"
|
||||
winedir=/tmp/dwarf-portable-executable/wine
|
||||
script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
||||
|
|
Loading…
Reference in a new issue