47 lines
1.8 KiB
Bash
Executable file
47 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
linuxdeploy="${LINUXDEPLOY:-linuxdeploy-x86_64.AppImage}"
|
|
output_dir="${OUTPUT_DIR:-${root_dir}/dist}"
|
|
work_dir="$(mktemp -d)"
|
|
app_dir="${work_dir}/Comicviewer.AppDir"
|
|
|
|
cleanup() {
|
|
rm -rf "${work_dir}"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
cargo build --manifest-path "${root_dir}/Cargo.toml" --release
|
|
mkdir -p "${output_dir}"
|
|
mkdir -p "${app_dir}/usr/share/metainfo"
|
|
install -m 0644 \
|
|
"${root_dir}/data/io.github.comicviewer.Comicviewer.metainfo.xml" \
|
|
"${app_dir}/usr/share/metainfo/io.github.comicviewer.Comicviewer.appdata.xml"
|
|
|
|
output_path="${output_dir}/Comicviewer-0.1.0-x86_64.AppImage"
|
|
export LDAI_OUTPUT="${output_path}"
|
|
export PATH="$(dirname "${linuxdeploy}"):${PATH}"
|
|
export APPIMAGE_EXTRACT_AND_RUN=1
|
|
export NO_STRIP=1
|
|
|
|
# The GTK plugin assumes this optional module directory exists on every distro.
|
|
gtk_plugin="$(command -v linuxdeploy-plugin-gtk.sh || true)"
|
|
if [[ -n "${gtk_plugin}" ]] && [[ ! -d "$(pkg-config --variable=libdir gtk4)/gtk-4.0" ]]; then
|
|
patched_plugin="${work_dir}/linuxdeploy-plugin-gtk.sh"
|
|
cp "${gtk_plugin}" "${patched_plugin}"
|
|
sed -i 's| copy_lib_tree "$gtk4_libdir" "$APPDIR/"| if [ -d "$gtk4_libdir" ]; then copy_lib_tree "$gtk4_libdir" "$APPDIR/"; fi|' "${patched_plugin}"
|
|
chmod +x "${patched_plugin}"
|
|
export PATH="${work_dir}:${PATH}"
|
|
fi
|
|
|
|
"${linuxdeploy}" \
|
|
--appdir "${app_dir}" \
|
|
--executable "${root_dir}/target/release/comicviewer" \
|
|
--desktop-file "${root_dir}/data/io.github.comicviewer.Comicviewer.desktop" \
|
|
--icon-file "${root_dir}/data/io.github.comicviewer.Comicviewer.svg" \
|
|
--custom-apprun "${root_dir}/packaging/AppRun" \
|
|
--plugin gtk \
|
|
--output appimage
|
|
|
|
echo "Created ${output_path}"
|