Add AppImage install and update bundle
This commit is contained in:
parent
a1b941e8f5
commit
91590ec08d
5 changed files with 211 additions and 11 deletions
55
packaging/build-release-bundle.sh
Executable file
55
packaging/build-release-bundle.sh
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
package_id="$(cargo pkgid --manifest-path "${root_dir}/Cargo.toml")"
|
||||
version="${package_id##*@}"
|
||||
bundle_name="Comicviewer-${version}-x86_64"
|
||||
appimage_name="${bundle_name}.AppImage"
|
||||
appimage="${root_dir}/dist/${appimage_name}"
|
||||
checksum="${appimage}.sha256"
|
||||
archive="${root_dir}/dist/${bundle_name}.tar.gz"
|
||||
archive_checksum="${archive}.sha256"
|
||||
work_dir="$(mktemp -d)"
|
||||
bundle_dir="${work_dir}/${bundle_name}"
|
||||
archive_mtime="${SOURCE_DATE_EPOCH:-$(git -C "${root_dir}" log -1 --format=%ct)}"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "${work_dir}"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ ! -f "${appimage}" ]]; then
|
||||
printf 'AppImage가 없습니다: %s\n' "${appimage}" >&2
|
||||
printf '%s\n' "먼저 packaging/build-appimage.sh를 실행하세요." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${bundle_dir}"
|
||||
(
|
||||
cd "${root_dir}/dist"
|
||||
sha256sum "${appimage_name}" > "${appimage_name}.sha256"
|
||||
)
|
||||
|
||||
install -m 0755 "${appimage}" "${bundle_dir}/${appimage_name}"
|
||||
install -m 0644 "${checksum}" "${bundle_dir}/${appimage_name}.sha256"
|
||||
install -m 0755 \
|
||||
"${root_dir}/packaging/install-or-update.sh" \
|
||||
"${bundle_dir}/install-or-update.sh"
|
||||
install -m 0644 \
|
||||
"${root_dir}/data/io.github.comicviewer.Comicviewer.desktop" \
|
||||
"${bundle_dir}/io.github.comicviewer.Comicviewer.desktop"
|
||||
install -m 0644 \
|
||||
"${root_dir}/data/io.github.comicviewer.Comicviewer.svg" \
|
||||
"${bundle_dir}/io.github.comicviewer.Comicviewer.svg"
|
||||
install -m 0644 "${root_dir}/docs/INSTALL.ko.md" "${bundle_dir}/README.ko.md"
|
||||
|
||||
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime="@${archive_mtime}" \
|
||||
-C "${work_dir}" -cf - "${bundle_name}" | gzip -n > "${archive}"
|
||||
(
|
||||
cd "${root_dir}/dist"
|
||||
sha256sum "$(basename "${archive}")" > "$(basename "${archive_checksum}")"
|
||||
)
|
||||
|
||||
printf 'Created %s\n' "${archive}"
|
||||
printf 'Created %s\n' "${archive_checksum}"
|
||||
93
packaging/install-or-update.sh
Executable file
93
packaging/install-or-update.sh
Executable file
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
app_id="io.github.comicviewer.Comicviewer"
|
||||
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||
install_dir="${HOME}/.local/opt/comicviewer"
|
||||
bin_dir="${HOME}/.local/bin"
|
||||
data_home="${XDG_DATA_HOME:-${HOME}/.local/share}"
|
||||
config_home="${XDG_CONFIG_HOME:-${HOME}/.config}"
|
||||
cache_home="${XDG_CACHE_HOME:-${HOME}/.cache}"
|
||||
applications_dir="${data_home}/applications"
|
||||
icons_dir="${data_home}/icons/hicolor/scalable/apps"
|
||||
installed_appimage="${install_dir}/Comicviewer.AppImage"
|
||||
launcher="${bin_dir}/comicviewer"
|
||||
installed_desktop="${applications_dir}/${app_id}.desktop"
|
||||
installed_icon="${icons_dir}/${app_id}.svg"
|
||||
temporary_appimage=""
|
||||
temporary_desktop=""
|
||||
|
||||
cleanup() {
|
||||
[ -z "${temporary_appimage}" ] || rm -f "${temporary_appimage}"
|
||||
[ -z "${temporary_desktop}" ] || rm -f "${temporary_desktop}"
|
||||
}
|
||||
trap cleanup EXIT HUP INT TERM
|
||||
|
||||
refresh_desktop() {
|
||||
if command -v update-desktop-database >/dev/null 2>&1; then
|
||||
update-desktop-database "${applications_dir}" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${1:-}" = "--uninstall" ]; then
|
||||
rm -f "${launcher}" "${installed_desktop}" "${installed_icon}" \
|
||||
"${installed_appimage}"
|
||||
rm -rf "${config_home}/comicviewer" "${data_home}/comicviewer" \
|
||||
"${cache_home}/comicviewer"
|
||||
rmdir "${install_dir}" 2>/dev/null || true
|
||||
refresh_desktop
|
||||
printf '%s\n' "Comicviewer와 설정, 읽기 기록, 캐시를 모두 제거했습니다."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$#" -ne 0 ]; then
|
||||
printf '사용법: %s [--uninstall]\n' "$(basename -- "$0")" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
set -- "${script_dir}"/Comicviewer-*-x86_64.AppImage
|
||||
if [ "$#" -ne 1 ] || [ ! -f "$1" ]; then
|
||||
printf '%s\n' "번들에서 Comicviewer AppImage 한 개를 찾을 수 없습니다." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
appimage="$1"
|
||||
checksum="${appimage}.sha256"
|
||||
desktop_file="${script_dir}/${app_id}.desktop"
|
||||
icon_file="${script_dir}/${app_id}.svg"
|
||||
|
||||
for required_file in "${checksum}" "${desktop_file}" "${icon_file}"; do
|
||||
if [ ! -f "${required_file}" ]; then
|
||||
printf '필수 파일이 없습니다: %s\n' "$(basename -- "${required_file}")" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
(cd "${script_dir}" && sha256sum -c "$(basename -- "${checksum}")")
|
||||
|
||||
mkdir -p "${install_dir}" "${bin_dir}" "${applications_dir}" "${icons_dir}"
|
||||
temporary_appimage="${install_dir}/.Comicviewer.AppImage.tmp.$$"
|
||||
temporary_desktop="${applications_dir}/.${app_id}.desktop.tmp.$$"
|
||||
|
||||
install -m 0755 "${appimage}" "${temporary_appimage}"
|
||||
mv -f "${temporary_appimage}" "${installed_appimage}"
|
||||
temporary_appimage=""
|
||||
ln -sfn "${installed_appimage}" "${launcher}"
|
||||
while IFS= read -r line || [ -n "${line}" ]; do
|
||||
case "${line}" in
|
||||
Exec=*) printf 'Exec="%s"\n' "${launcher}" ;;
|
||||
*) printf '%s\n' "${line}" ;;
|
||||
esac
|
||||
done < "${desktop_file}" > "${temporary_desktop}"
|
||||
chmod 0644 "${temporary_desktop}"
|
||||
mv -f "${temporary_desktop}" "${installed_desktop}"
|
||||
temporary_desktop=""
|
||||
install -m 0644 "${icon_file}" "${installed_icon}"
|
||||
refresh_desktop
|
||||
|
||||
if ! command -v gio >/dev/null 2>&1; then
|
||||
printf '%s\n' "주의: 원격 파일 접근을 위해 gvfs와 gvfs-smb를 설치하세요." >&2
|
||||
fi
|
||||
|
||||
printf '%s\n' "Comicviewer 설치 또는 업데이트를 완료했습니다."
|
||||
printf '실행: %s\n' "${launcher}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue