mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(appimage): DwarFS AppImages unpack without proot (#3161)
This commit is contained in:
1 parent
f934feb457
commit
43ff1db06b
12 files changed
+208
-1
No files matched your search
@@ -0,0 +1,49 @@
|
||||
Parts of the DwarFS project are licensed under the MIT license, while others are
|
||||
licensed under the GPL-3.0 license. In general, the code used to *read* DwarFS
|
||||
images is licensed under the MIT license, while the code used to *write* DwarFS
|
||||
images is licensed under the GPL-3.0 license. Also, all testing/benchmarking
|
||||
code is currently licensed under the GPL-3.0 license.
|
||||
|
||||
That means you can use `mkdwarfs` to create images and then use these images
|
||||
with only the MIT-licensed code.
|
||||
|
||||
The following libraries and associated header files are licensed under the
|
||||
MIT license:
|
||||
|
||||
- `dwarfs_common`
|
||||
- `dwarfs_compressor`
|
||||
- `dwarfs_decompressor`
|
||||
- `dwarfs_extractor`
|
||||
- `dwarfs_reader`
|
||||
|
||||
The following libraries and associated header files are licensed under the
|
||||
GPL-3.0 license:
|
||||
|
||||
- `dwarfs_rewrite`
|
||||
- `dwarfs_writer`
|
||||
|
||||
Each header and source file should contain an SPDX identifier near the top
|
||||
of the file.
|
||||
|
||||
Please also check the licenses of the projects that DwarFS depends on.
|
||||
|
||||
----
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) Marcus Holland-Moritz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -27,6 +27,7 @@ GAME_ENVIRONMENT = os.path.join(HOME, ".config", "droiddeck", "game-environment.
|
||||
BIN_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
PRELOADS = "/usr/local/lib/droiddeck-fex"
|
||||
URUNTIME = "/usr/local/lib/droiddeck/uruntime"
|
||||
DWARFSEXTRACT = "/usr/local/lib/droiddeck/dwarfsextract"
|
||||
HOST_PRELOAD = "/etc/ld.so.preload"
|
||||
FEX_APPID = "3127680"
|
||||
OWN_FEX = "/usr/local"
|
||||
@@ -824,6 +825,30 @@ def extracted():
|
||||
return os.path.isdir("squashfs-root")
|
||||
|
||||
|
||||
def dwarfs_image(image):
|
||||
try:
|
||||
offset = appimage_offset(image)
|
||||
with open(image, "rb") as f:
|
||||
f.seek(offset)
|
||||
return f.read(6) == b"DWARFS"
|
||||
except (OSError, ValueError, struct.error):
|
||||
return False
|
||||
|
||||
|
||||
def dwarfs_extract(image):
|
||||
clear_extracted()
|
||||
os.mkdir("squashfs-root")
|
||||
with open(image, "rb") as source:
|
||||
status = subprocess.call([DWARFSEXTRACT, "--input", "/proc/self/fd/%d" % source.fileno(),
|
||||
"--image-offset=%d" % appimage_offset(image), "--output", "squashfs-root",
|
||||
"--log-level=error"], stdout=subprocess.DEVNULL, pass_fds=(source.fileno(),))
|
||||
if status == 0 and extracted():
|
||||
return True
|
||||
say("dwarfsextract could not extract it (status %d)" % status)
|
||||
clear_extracted()
|
||||
return False
|
||||
|
||||
|
||||
def want_fex():
|
||||
with locked():
|
||||
update_own_fex()
|
||||
@@ -869,6 +894,10 @@ def extract(image):
|
||||
return 0
|
||||
say("uruntime could not extract it (status %d)" % status)
|
||||
clear_extracted()
|
||||
if os.access(DWARFSEXTRACT, os.X_OK) and dwarfs_image(image) and dwarfs_extract(image):
|
||||
if x86:
|
||||
want_fex()
|
||||
return 0
|
||||
fex = prepare() if x86 else None
|
||||
if fex is not None:
|
||||
status = subprocess.call([fex["bin"], image, "--appimage-extract"], stdout=subprocess.DEVNULL,
|
||||
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
wrapper=${1:?usage: unwrap-dwarfs.sh WRAPPER OUTPUT}
|
||||
output=${2:?usage: unwrap-dwarfs.sh WRAPPER OUTPUT}
|
||||
[ "$(tail -c 32 "$wrapper" | head -c 8)" = "SQUEEZE!" ] || { echo "unwrap-dwarfs.sh: $wrapper has no SQUEEZE! trailer" >&2; exit 1; }
|
||||
packed=$(tail -c 16 "$wrapper" | od -An -tu8 -N8 | tr -d ' ')
|
||||
[ "$packed" -gt 0 ] && [ "$packed" -le $(( $(wc -c < "$wrapper") - 32 )) ] || { echo "unwrap-dwarfs.sh: bad payload size in $wrapper" >&2; exit 1; }
|
||||
tail -c $((packed + 32)) "$wrapper" | head -c "$packed" | zstd -dcq > "$output"
|
||||
@@ -1,3 +1,7 @@
|
||||
URUNTIME_VERSION=v0.8.1
|
||||
URUNTIME_ASSET=uruntime-appimage-lite-aarch64
|
||||
URUNTIME_SHA256=8485ae20eb0bfd4eaeac38d7fd7f78e153b391c718cf33ff07879605683be1ea
|
||||
DWARFS_VERSION=v0.15.7
|
||||
DWARFS_ASSET=dwarfs-fuse-extract-0.15.7-Linux-aarch64
|
||||
DWARFS_SHA256=edb698186db6b162c755770ffabfcc05482bb7105a716fd943548e64244b0fd2
|
||||
DWARFS_PAYLOAD_SHA256=cc3b3e342ca6537139d8c90d3c0a00236cf786bb61bdccf019e5ed0ca5917a7a
|
||||
Reference in new issue
Block a user