#!/usr/bin/env bash # Modified by vii from komaruworld/mocktail. See README "About this fork". # Copyright 2026 Mocktail Project Authors # SPDX-License-Identifier: Apache-2.0 set -Eeuo pipefail umask 022 readonly REPOSITORY="${1:?Flatpak repository path is required}" readonly BUNDLE="${2:?Flatpak bundle path is required}" readonly PUBLIC_KEY="${3:?GPG public key path is required}" readonly OUTPUT="${4:?Pages output path is required}" readonly BASE_URL="https://coderdayton.github.io/nightcap" readonly APP_ID="io.github.CoderDayton.nightcap" readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" readonly PROJECT_DIR="$(dirname -- "${SCRIPT_DIR}")" [[ -d "${REPOSITORY}" && ! -L "${REPOSITORY}" ]] || { printf 'Flatpak repository is missing or unsafe: %s\n' "${REPOSITORY}" >&2 exit 1 } [[ -f "${BUNDLE}" && ! -L "${BUNDLE}" ]] || { printf 'Flatpak bundle is missing or unsafe: %s\n' "${BUNDLE}" >&2 exit 1 } [[ -s "${PUBLIC_KEY}" && ! -L "${PUBLIC_KEY}" ]] || { printf 'Flatpak public key is missing or unsafe: %s\n' "${PUBLIC_KEY}" >&2 exit 1 } [[ ! -e "${OUTPUT}" ]] || { printf 'Pages output already exists: %s\n' "${OUTPUT}" >&2 exit 1 } mkdir -p -- "${OUTPUT}" cp -a -- "${REPOSITORY}" "${OUTPUT}/repo" install -m 0644 -- "${BUNDLE}" "${OUTPUT}/Nightcap-x86_64.flatpak" install -m 0644 -- "${PUBLIC_KEY}" "${OUTPUT}/nightcap-flatpak.gpg" install -m 0644 -- \ "${PROJECT_DIR}/packaging/${APP_ID}.svg" \ "${OUTPUT}/nightcap.svg" touch -- "${OUTPUT}/.nojekyll" readonly GPG_KEY="$(base64 --wrap=0 "${PUBLIC_KEY}")" cat >"${OUTPUT}/nightcap.flatpakrepo" <"${OUTPUT}/nightcap.flatpakref" <