Build: Unify Flatpak manifests

This commit is contained in:
Stenzek
2023-09-30 12:38:21 +10:00
parent 28c13c0ac4
commit 90d0029c34
11 changed files with 45 additions and 130 deletions

View File

@ -1,5 +1,5 @@
.flatpak-builder/
build/
repo/
org.duckstation.duckstation.metainfo.xml
org.duckstation.DuckStation.metainfo.xml
*.flatpak

View File

@ -1,69 +0,0 @@
{
"app-id": "org.duckstation.duckstation",
"runtime": "org.kde.Platform",
"runtime-version": "6.5",
"sdk": "org.kde.Sdk",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.llvm16"
],
"command": "duckstation-qt",
"finish-args": [
"--device=all",
"--allow=bluetooth",
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=pulseaudio",
"--talk-name=org.freedesktop.ScreenSaver"
],
"modules": [
"modules/20-sdl2.json",
"modules/21-libbacktrace.json",
{
"name": "duckstation",
"buildsystem": "cmake",
"build-options": {
"strip": false,
"no-debuginfo": true,
"config-opts": [
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON",
"-DBUILD_NOGUI_FRONTEND=OFF",
"-DBUILD_QT_FRONTEND=ON",
"-DBUILD_TESTS=OFF",
"-DCMAKE_C_COMPILER=/usr/lib/sdk/llvm16/bin/clang",
"-DCMAKE_CXX_COMPILER=/usr/lib/sdk/llvm16/bin/clang++",
"-DCMAKE_EXE_LINKER_FLAGS_INIT=-fuse-ld=lld",
"-DCMAKE_MODULE_LINKER_FLAGS_INIT=-fuse-ld=lld",
"-DCMAKE_SHARED_LINKER_FLAGS_INIT=-fuse-ld=lld",
"-DDISABLE_GEN_SCM_VERSION=ON"
]
},
"sources": [
{
"type": "git",
"url": "https://github.com/stenzek/duckstation.git",
"branch": "master",
"commit": "@GIT_HASH@"
},
{
"type": "file",
"path": "org.duckstation.duckstation.metainfo.xml"
},
{
"type": "file",
"path": "scmversion.cpp",
"dest": "src/scmversion"
}
],
"post-install": [
"cp -a \"${FLATPAK_BUILDER_BUILDDIR}/bin\" ${FLATPAK_DEST}",
"install -Dm644 scripts/duckstation-qt.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/org.duckstation.duckstation.png",
"install -Dm644 scripts/duckstation-qt.desktop ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop",
"desktop-file-edit --set-key=Icon --set-value=org.duckstation.duckstation ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop",
"install -Dm644 org.duckstation.duckstation.metainfo.xml ${FLATPAK_DEST}/share/metainfo/org.duckstation.duckstation.metainfo.xml"
]
}
]
}

View File

@ -1,5 +1,5 @@
{
"app-id": "org.duckstation.duckstation",
"app-id": "org.duckstation.DuckStation",
"runtime": "org.kde.Platform",
"runtime-version": "6.5",
"sdk": "org.kde.Sdk",
@ -47,10 +47,9 @@
],
"post-install": [
"cp -a \"${FLATPAK_BUILDER_BUILDDIR}/bin\" ${FLATPAK_DEST}",
"install -Dm644 scripts/duckstation-qt.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/org.duckstation.duckstation.png",
"install -Dm644 scripts/duckstation-qt.desktop ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop",
"desktop-file-edit --set-key=Icon --set-value=org.duckstation.duckstation ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop",
"install -Dm644 scripts/flatpak/org.duckstation.duckstation.metainfo.xml ${FLATPAK_DEST}/share/metainfo/org.duckstation.duckstation.metainfo.xml"
"install -Dm644 scripts/org.duckstation.DuckStation.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/org.duckstation.DuckStation.png",
"install -Dm644 scripts/org.duckstation.DuckStation.desktop ${FLATPAK_DEST}/share/applications/org.duckstation.DuckStation.desktop",
"install -Dm644 scripts/flatpak/org.duckstation.DuckStation.metainfo.xml ${FLATPAK_DEST}/share/metainfo/org.duckstation.DuckStation.metainfo.xml"
]
}
]

View File

@ -9,34 +9,24 @@ if [[ $# -lt 1 ]]; then
fi
OUTDIR=$(realpath "$1")
OUTMANIFEST="${OUTDIR}/${APPID}.json"
echo -n "Get revision: "
pushd "${SCRIPTDIR}" >/dev/null
GIT_HASH=$(git rev-parse HEAD)
popd >/dev/null
echo "${GIT_HASH}"
echo "Updating files in ${OUTDIR}..."
mkdir -p "${OUTDIR}"
rm -fr "${OUTDIR}/modules"
cp -a "${SCRIPTDIR}/modules" "${OUTDIR}/modules"
cp "${SCRIPTDIR}/flathub.json" "${OUTDIR}/${APPID}.json"
pushd "${SCRIPTDIR}"
GIT_DATE=$(git log -1 --pretty=%cd --date=short)
GIT_VERSION=$(git tag --points-at HEAD)
GIT_HASH=$(git rev-parse HEAD)
echo "Generate AppStream XML..."
"${SCRIPTDIR}/../../scripts/generate-metainfo.sh" "${OUTDIR}"
if [[ "${GIT_VERSION}" == "" ]]; then
GIT_VERSION=$(git describe --tags --dirty --exclude latest --exclude preview --exclude legacy --exclude previous-latest | tr -d '\r\n')
if [[ "${GIT_VERSION}" == "" ]]; then
GIT_VERSION=$(git rev-parse HEAD)
fi
fi
"${SCRIPTDIR}/../../scripts/generate-metainfo.sh" "${OUTDIR}/${APPID}.metainfo.xml"
popd
# Change App ID, because flathub uses the wrong name.
sed -i -e "s/org.duckstation.duckstation/org.duckstation.DuckStation/g" "${OUTDIR}/${APPID}.json" "${OUTDIR}/${APPID}.metainfo.xml"
# Fill in version details.
sed -i -e "s/@GIT_VERSION@/${GIT_VERSION}/" "${OUTDIR}/${APPID}.json"
sed -i -e "s/@GIT_DATE@/${GIT_DATE}/" "${OUTDIR}/${APPID}.json"
sed -i -e "s/@GIT_HASH@/${GIT_HASH}/" "${OUTDIR}/${APPID}.json"
# Apparently we don't have git history.
pushd "${OUTDIR}"
"${SCRIPTDIR}/../../src/scmversion/gen_scmversion.sh"
popd
echo "Patching Manifest Sources..."
jq ".modules[2].sources = ["\
"{\"type\": \"git\", \"url\": \"https://github.com/stenzek/duckstation.git\", \"commit\": \"${GIT_HASH}\", \"disable-shallow-clone\": true},"\
"{\"type\": \"file\", \"path\": \"org.duckstation.DuckStation.metainfo.xml\", \"dest\": \"scripts/flatpak\"}]" \
"${SCRIPTDIR}/${APPID}.json" > "${OUTMANIFEST}"