From cf4f2c6928eabc380eb46fb546809f040006e9c8 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Thu, 17 Aug 2023 12:24:55 +0200 Subject: [PATCH] Basic setup to build Picard AppImage with appimagecraft --- .gitignore | 5 +++++ AppRun | 11 ++++++++++ appimage.patch | 15 ++++++++++++++ appimagecraft.yml | 52 +++++++++++++++++++++++++++++++++++++++++++++++ build.sh | 18 ++++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 .gitignore create mode 100755 AppRun create mode 100644 appimage.patch create mode 100644 appimagecraft.yml create mode 100755 build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94561a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*~ +*.AppImage +*.AppImage.zsync +/build/ +/source/ diff --git a/AppRun b/AppRun new file mode 100755 index 0000000..9b14017 --- /dev/null +++ b/AppRun @@ -0,0 +1,11 @@ +#!/bin/sh + +export PATH="$APPDIR/usr/bin/:$PATH" + +# Prevent Qt to load plugins from system directories +unset QT_PLUGIN_PATH + +# Set the original working dir as the working dir. +# Ensures relative path arguments are resolved as expected. +cd $OWD +"$APPDIR"/usr/conda/bin/python "$APPDIR"/usr/conda/bin/picard "$@" diff --git a/appimage.patch b/appimage.patch new file mode 100644 index 0000000..6d077c0 --- /dev/null +++ b/appimage.patch @@ -0,0 +1,15 @@ +diff --git a/scripts/picard.in b/scripts/picard.in +index ab04f5546..fc53fdc7e 100644 +--- a/scripts/picard.in ++++ b/scripts/picard.in +@@ -1,8 +1,9 @@ + #!/usr/bin/env python3 + + try: ++ import os + from picard.tagger import main +- main('%(localedir)s', %(autoupdate)s) ++ main(os.path.join(os.environ.get('APPDIR', '/'), 'usr/conda/share/locale'), autoupdate=False) + except SystemExit: + raise # Just continue with a normal application exit + except: # noqa: E722,F722 # pylint: disable=bare-except diff --git a/appimagecraft.yml b/appimagecraft.yml new file mode 100644 index 0000000..c0ebe11 --- /dev/null +++ b/appimagecraft.yml @@ -0,0 +1,52 @@ +version: 1 + +project: + name: org.musicbrainz.Picard + # version: 2.9.1 + version_command: cd "$PROJECT_ROOT/source" && python -c "import picard; print(picard.__version__)" + +build: + null: + +scripts: + post_build: + - | # Link AppStream metadata + mkdir -p "$BUILD_DIR"/AppDir/usr/share/metainfo/ + cd "$BUILD_DIR"/AppDir/usr/share/metainfo/ + ln -s ../../conda/share/metainfo/org.musicbrainz.Picard.appdata.xml . + - | # Fetch fpcalc + FPCALC_VERSION=1.5.1 + FPCALC_PACKAGE=chromaprint-fpcalc-${FPCALC_VERSION}-linux-x86_64 + cd "$BUILD_DIR" + curl -Lo chromaprint-fpcalc.tar.gz "https://github.com/acoustid/chromaprint/releases/download/v${FPCALC_VERSION}/${FPCALC_PACKAGE}.tar.gz" + tar xzf chromaprint-fpcalc.tar.gz + mv ${FPCALC_PACKAGE}/ chromaprint-fpcalc + - | # Build libdiscid + LIBDISCID_VERSION=0.6.4 + LIBDISCID_PACKAGE=libdiscid-${LIBDISCID_VERSION} + cd "$BUILD_DIR" + curl -Lo libdiscid.tar.gz "https://github.com/metabrainz/libdiscid/releases/download/v${LIBDISCID_VERSION}/${LIBDISCID_PACKAGE}.tar.gz" + tar xzf libdiscid.tar.gz + mkdir ${LIBDISCID_PACKAGE}/build + cd ${LIBDISCID_PACKAGE}/build + cmake -DCMAKE_INSTALL_PREFIX=/usr/conda .. + make + make DESTDIR="$BUILD_DIR"/AppDir/ install + - | # Clean AppDir + rm -rf "$BUILD_DIR"/AppDir/usr/conda/include + +appimage: + linuxdeploy: + plugins: + - conda + extra_args: | + --icon-file "$PROJECT_ROOT"/source/resources/images/256x256/org.musicbrainz.Picard.png \ + --desktop-file "$PROJECT_ROOT"/source/org.musicbrainz.Picard.desktop \ + --custom-apprun "$PROJECT_ROOT"/AppRun \ + --executable "$BUILD_DIR"/chromaprint-fpcalc/fpcalc \ + environment: + PIP_REQUIREMENTS: . + raw_environment: + - PIP_WORKDIR="$PROJECT_ROOT/source/" + - OUTPUT=MusicBrainz-Picard-"$VERSION"-"$ARCH".AppImage + - UPD_INFO="gh-releases-zsync|phw|picard-daily|continuous|MusicBrainz-Picard-*$ARCH.AppImage.zsync" diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..74e8d67 --- /dev/null +++ b/build.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +APPIMAGECRAFT_URL="https://github.com/TheAssassin/appimagecraft/releases/download/continuous/appimagecraft-x86_64.AppImage" +ROOT_DIR=$(dirname "$0") +BUILD_DIR="$ROOT_DIR/build/" +SOURCE_DIR="$ROOT_DIR/source/" + +cd "$ROOT_DIR" + +wget -q "$APPIMAGECRAFT_URL" +chmod +x appimagecraft-x86_64.AppImage + +[ ! -d "$SOURCE_DIR" ] || rm -rf "$SOURCE_DIR" +git clone --depth 1 --branch master "https://github.com/metabrainz/picard.git" "$SOURCE_DIR" + +mkdir -p "$BUILD_DIR" +rm -rf "$BUILD_DIR"/* +./appimagecraft-x86_64.AppImage -d "$BUILD_DIR"