Cantata – AppImageHub

Cantata is available as an AppImage which means "one app = one file", which you can download and run on your Linux system while you don't need a package manager and nothing gets changed in your system. Awesome!


This is a companion discussion topic for the original entry at https://appimage.github.io/Cantata/

Hello!

I am using appimage tool to package Cantata.
When running the appimage after creation I get:
execv error: Exec format error

What could I troubleshoot?
Thanks!

AppRun

#!/bin/sh

HERE=“$(dirname “$(readlink -f “$0”)”)”
EXEC=“${HERE}/usr/bin/cantata”
exec “${EXEC}”

[Desktop Entry]
Type=Application
Name=Cantata
GenericName=Music Player Client
GenericName[bs]=Muzički player klijent
GenericName[da]=Musikafspiller-klient
GenericName[de]=Grafischer Musik Player Client
GenericName[es]=Cliente de reproducción de música
GenericName[fi]=Musiikkisoitinasiakas
GenericName[fr]=Client de lecture de musique
GenericName[gl]=Cliente de reprodución de música
GenericName[hu]=Zenelejátszókliens
GenericName[it]=Lettore musicale
GenericName[jv]=Musik Player Client
GenericName[ko]=음악 플레이어 클라이언트
GenericName[ms]=Klien Pemain Musik
GenericName[nb]=Musikkavspiller-klient
GenericName[oc]=Client de lectura de musica
GenericName[pl]=Odtwarzacz muzyki
GenericName[pt]=Reprodutor de música
GenericName[pt_BR]=Reprodutor Multimídia
GenericName[ru]=Клиент музыкального проигрывателя
GenericName[sq]=Clienti player muzike
GenericName[tr]=Muzik Çalıcı İstemcisi
Comment=Listen and manage music collection
Icon=cantata
Exec=cantata
Categories=Qt;KDE;AudioVideo;Player;
X-DBUS-StartupType=Unique
X-DBUS-ServiceName=mpd.cantata
Keywords=Music;MPD;

ARCH=x86_64 /home/anarcho/bin/Appimages/appimagetool-x86_64.AppImage /home/anarcho/Documents/CantataAppimage/Cantata.AppDir
appimagetool, continuous build (commit 8bbf694), build built on 2020-12-31 11:48:33 UTC
Using architecture x86_64
/home/anarcho/Documents/CantataAppimage/Cantata.AppDir should be packaged as Cantata-x86_64.AppImage
WARNING: AppStream upstream metadata is missing, please consider creating it
in usr/share/metainfo/cantata.appdata.xml
Please see Metadata Quickstart | AppStream | AppStream 0.16
for more information or use the generator at http://output.jsbin.com/qoqukof.
Generating squashfs…
Parallel mksquashfs: Using 8 processors
Creating 4.0 filesystem on Cantata-x86_64.AppImage, block size 131072.
[=====================================================================================/] 865/865 100%

Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
compressed data, compressed metadata, compressed fragments,
compressed xattrs, compressed ids
duplicates are removed
Filesystem size 35375.10 Kbytes (34.55 Mbytes)
40.04% of uncompressed filesystem size (88360.29 Kbytes)
Inode table size 5562 bytes (5.43 Kbytes)
41.44% of uncompressed inode table size (13422 bytes)
Directory table size 3812 bytes (3.72 Kbytes)
47.30% of uncompressed directory table size (8060 bytes)
Number of duplicate files found 3
Number of inodes 329
Number of files 239
Number of fragments 39
Number of symbolic links 10
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 80
Number of ids (unique uids + gids) 1
Number of uids 1
root (0)
Number of gids 1
root (0)
Embedding ELF…
Marking the AppImage as executable…
Embedding MD5 digest
Success

Please consider submitting your AppImage to AppImageHub, the crowd-sourced
central directory of available AppImages, by opening a pull request
at GitHub - AppImage/appimage.github.io: Given an URL to an AppImage, the GitHub action in this project inspects the AppImage and puts it into a community-maintained catalog

here is my AppDir directory:

try use this ?
cd $HERE/usr/bin
./cantata

Hey thanks for the reply.
That did not work either. Same print:
execv error: Exec format error

Maybe you can check your library environment variables PATH and LD _ LIBRARY _ PATH.

How do I go about that?

You can use “export” to add temporary variable paths in the AppRun, and you can use the./X. Appimage --appimage-extract to extract working appimages to learn how they are set up

Ok. I will have to research what you are talking about. Thanks.

Here is an example:

"

#!/bin/bash
set -e

if [ ! -z "$DEBUG" ] ; then
  env
  set -x
fi

THIS="$0"
# http://stackoverflow.com/questions/3190818/
args=("$@")
NUMBER_OF_ARGS="$#"

if [ -z "$APPDIR" ] ; then
  # Find the AppDir. It is the directory that contains AppRun.
  # This assumes that this script resides inside the AppDir or a subdirectory.
  # If this script is run inside an AppImage, then the AppImage runtime likely has already set $APPDIR
  path="$(dirname "$(readlink -f "${THIS}")")"
  while [[ "$path" != "" && ! -e "$path/$1" ]]; do
    path=${path%/*}
  done
  APPDIR="$path"
fi

export PATH="${APPDIR}:${APPDIR}/usr/sbin:${PATH}"
export XDG_DATA_DIRS="./share/:/usr/share/gnome:/usr/local/share/:/usr/share/:${XDG_DATA_DIRS}"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${LD_LIBRARY_PATH}"
export XDG_DATA_DIRS="${APPDIR}"/usr/share/:"${XDG_DATA_DIRS}":/usr/share/gnome/:/usr/local/share/:/usr/share/
export GSETTINGS_SCHEMA_DIR="${APPDIR}/usr/share/glib-2.0/schemas:${GSETTINGS_SCHEMA_DIR}"

BIN="$APPDIR/siyuan"

if [ -z "$APPIMAGE_EXIT_AFTER_INSTALL" ] ; then
  trap atexit EXIT
fi

isEulaAccepted=1

atexit()
{
  if [ $isEulaAccepted == 1 ] ; then
    if [ $NUMBER_OF_ARGS -eq 0 ] ; then
      exec "$BIN"
    else
      exec "$BIN" "${args[@]}"
    fi
  fi
}

error()
{
  if [ -x /usr/bin/zenity ] ; then
    LD_LIBRARY_PATH="" zenity --error --text "${1}" 2>/dev/null
  elif [ -x /usr/bin/kdialog ] ; then
    LD_LIBRARY_PATH="" kdialog --msgbox "${1}" 2>/dev/null
  elif [ -x /usr/bin/Xdialog ] ; then
    LD_LIBRARY_PATH="" Xdialog --msgbox "${1}" 2>/dev/null
  else
    echo "${1}"
  fi
  exit 1
}

yesno()
{
  TITLE=$1
  TEXT=$2
  if [ -x /usr/bin/zenity ] ; then
    LD_LIBRARY_PATH="" zenity --question --title="$TITLE" --text="$TEXT" 2>/dev/null || exit 0
  elif [ -x /usr/bin/kdialog ] ; then
    LD_LIBRARY_PATH="" kdialog --title "$TITLE" --yesno "$TEXT" || exit 0
  elif [ -x /usr/bin/Xdialog ] ; then
    LD_LIBRARY_PATH="" Xdialog --title "$TITLE" --clear --yesno "$TEXT" 10 80 || exit 0
  else
    echo "zenity, kdialog, Xdialog missing. Skipping ${THIS}."
    exit 0
  fi
}

check_dep()
{
  DEP=$1
  if [ -z $(which "$DEP") ] ; then
    echo "$DEP is missing. Skipping ${THIS}."
    exit 0
  fi
}

if [ -z "$APPIMAGE" ] ; then
  APPIMAGE="$APPDIR/AppRun"
  # not running from within an AppImage; hence using the AppRun for Exec=
fi

"

you are welcome. i’m studying, too.

Ok that may be on point. In a file I unpacked from an old Cantata appimage that no longer worked and located at
Cantata.AppDir/usr/bin/cantata.wrapper
there is a similar script.
I have no idea about it though.

#!/bin/bash

# The purpose of this script is to provide lightweight desktop integration
# into the host system without special help from the host system.
# If you want to use it, then place this in usr/bin/$APPNAME.wrapper
# and set it as the Exec= line of the .desktop file in the AppImage.
#
# For example, to install the appropriate icons for Scribus,
# put them into the AppDir at the following locations:
#
# ./usr/share/icons/default/128x128/apps/scribus.png
# ./usr/share/icons/default/128x128/mimetypes/application-vnd.scribus.png
#
# Note that the filename application-vnd.scribus.png is derived from
# and must be match MimeType=application/vnd.scribus; in scribus.desktop
# (with "/" characters replaced by "-").
#
# Then, change Exec=scribus to Exec=scribus.wrapper and place the script
# below in usr/bin/scribus.wrapper and make it executable.
# When you run AppRun, then AppRun runs the wrapper script below
# which in turn will run the main application.
#
# TODO:
# Handle multiple versions of the same AppImage?
# Handle removed AppImages? Currently we are just setting TryExec=
# See http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#DELETE
# Possibly move this to the C runtime that is part of every AppImage?

# Exit on errors
set -e

# Be verbose if $DEBUG=1 is set
if [ ! -z "$DEBUG" ] ; then
  env
  set -x
fi

THIS="$0"
args=("$@") # http://stackoverflow.com/questions/3190818/
NUMBER_OF_ARGS="$#"

# Please do not change $VENDORPREFIX as it will allow for desktop files
# belonging to AppImages to be recognized by future AppImageKit components
# such as desktop integration daemons
VENDORPREFIX=appimagekit

find-up () {
  path="$(dirname "$(readlink -f "${THIS}")")"
  while [[ "$path" != "" && ! -e "$path/$1" ]]; do
    path=${path%/*}
  done
  echo -n "$path" # Needs to return something
}

if [ -z $APPDIR ] ; then
  # Find the AppDir. It is the directory that contains AppRun.
  # This assumes that this script resides inside the AppDir or a subdirectory.
  # If this script is run inside an AppImage, then the AppImage runtime
  # likely has already set $APPDIR
  APPDIR=$(find-up "AppRun")
fi

FILENAME="$(readlink -f "${THIS}")"
DIRNAME=$(dirname $FILENAME)

DESKTOPFILE=$(find "$APPDIR" -maxdepth 1 -name "*.desktop" | head -n 1)
DESKTOPFILE_NAME=$(basename "${DESKTOPFILE}")

APP_FULL=$(sed -n -e 's/^Name=//p' "${DESKTOPFILE}" | head -n 1)
APP=$(echo "$APP_FULL" | tr -c -d '[:alnum:]')
if [ -z "$APP" ] || [ -z "$APP_FULL" ] ; then
  APP=$(echo "$DESKTOPFILE_NAME" | sed -e 's/.desktop//g')
  APP_FULL="$APP"
fi

RETURN="yes"

if [[ "$FILENAME" != *.wrapper ]] ; then
  echo "${THIS} is not named correctly. It should be named \$Exec.wrapper"
  exit 0
fi

BIN=$(echo "$FILENAME" | sed -e 's|.wrapper||g')
if [[ ! -f "$BIN" ]] ; then
  echo "$BIN not found"
  exit 0
fi

trap atexit EXIT

# Note that the following handles 0, 1 or more arguments (file paths)
# which can include blanks but uses a bashism; can the same be achieved
# in POSIX-shell? (FIXME)
# http://stackoverflow.com/questions/3190818
atexit()
{
  if [ -z "$SKIP" ] ; then
    if [ $NUMBER_OF_ARGS -eq 0 ] ; then
      exec "${BIN}"
    else
      exec "${BIN}" "${args[@]}"
    fi
  fi
}

error()
{
  if [ -x /usr/bin/zenity ] ; then
    LD_LIBRARY_PATH="" zenity --error --text "${1}" 2>/dev/null
  elif [ -x /usr/bin/kdialog ] ; then
    LD_LIBRARY_PATH="" kdialog --msgbox "${1}" 2>/dev/null
  elif [ -x /usr/bin/Xdialog ] ; then
    LD_LIBRARY_PATH="" Xdialog --msgbox "${1}" 2>/dev/null
  else
    echo "${1}"
  fi
  exit 1
}

yesno()
{
  TITLE=$1
  TEXT=$2
  if [ -x /usr/bin/zenity ] ; then
    LD_LIBRARY_PATH="" zenity --question --title="$TITLE" --text="$TEXT" 2>/dev/null && RETURN="yes" || RETURN="no"
  elif [ -x /usr/bin/kdialog ] ; then
    LD_LIBRARY_PATH="" kdialog --caption "" --title "$TITLE" -yesno "$TEXT" && RETURN="yes" || RETURN="no"
  elif [ -x /usr/bin/Xdialog ] ; then
    LD_LIBRARY_PATH="" Xdialog --title "$TITLE" --clear --yesno "$TEXT" 10 80 && RETURN="yes" || RETURN="no"
  else
    echo "zenity, kdialog, Xdialog missing. Skipping ${THIS}."
    exit 0
  fi
}

check_prevent()
{
  FILE=$1
  if [ -e "$FILE" ] ; then
    exit 0
  fi
}

check_dep()
{
  DEP=$1
  if [ -z $(which $DEP) ] ; then
    echo "$DEP is missing. Skipping ${THIS}."
    exit 0
  fi
}

# Determine where the desktop file should be installed
if [[ $EUID -ne 0 ]]; then
   DESTINATION_DIR_DESKTOP="$HOME/.local/share/applications"
   STAMP_DIR="$HOME/.local/share/$VENDORPREFIX"
   SYSTEM_WIDE=""
else
   # TODO: Check $XDG_DATA_DIRS
   DESTINATION_DIR_DESKTOP="/usr/local/share/applications"
   STAMP_DIR="/etc/$VENDORPREFIX"
   SYSTEM_WIDE="--mode system" # for xdg-mime and xdg-icon-resource
fi

# Remove desktop integration for this AppImage
if [ "x$1" = "x--remove-appimage-desktop-integration" ] ; then
  SKIP="yes"
  rm -f "$STAMP_DIR/${APP}_no_desktopintegration" "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME"
  check_dep xdg-desktop-menu
  xdg-desktop-menu forceupdate
  exit 0
fi

# Exit immediately if one of these files is present
# (e.g., because the desktop environment wants to handle desktop integration itself)
check_prevent "$HOME/.local/share/$VENDORPREFIX/no_desktopintegration"
check_prevent "/usr/share/$VENDORPREFIX/no_desktopintegration"
check_prevent "/etc/$VENDORPREFIX/no_desktopintegration"

# Exit immediately if appimaged is running
pidof appimaged >/dev/null 2>&1 && exit 0

# Exit immediately if $DESKTOPINTEGRATION is not empty
if [ ! -z "$DESKTOPINTEGRATION" ] ; then
  exit 0
fi

# Check whether dependencies are present in base system (we do not bundle these)
# http://cgit.freedesktop.org/xdg/desktop-file-utils/
check_dep desktop-file-validate
check_dep update-desktop-database
check_dep desktop-file-install
check_dep xdg-icon-resource
check_dep xdg-mime
check_dep xdg-desktop-menu

# Exit immediately if one of these files is present (disabled per app)
check_prevent "$HOME/.local/share/$VENDORPREFIX/${APP}_no_desktopintegration"
check_prevent "/usr/share/$VENDORPREFIX/${APP}_no_desktopintegration"
check_prevent "/etc/$VENDORPREFIX/${APP}_no_desktopintegration"

if [ ! -f "$DESKTOPFILE" ] ; then
  echo "Desktop file is missing. Please run ${THIS} from within an AppImage."
  exit 0
fi

if [ -z "$APPIMAGE" ] ; then
  APPIMAGE="$APPDIR/AppRun"
  # Not running from within an AppImage; hence using the AppRun for Exec=
fi

ICONFILE="$APPDIR/.DirIcon"

# $XDG_DATA_DIRS contains the default paths /usr/local/share:/usr/share
# desktop file has to be installed in an applications subdirectory
# of one of the $XDG_DATA_DIRS components
if [ -z "$XDG_DATA_DIRS" ] ; then
  echo "\$XDG_DATA_DIRS is missing. Please run ${THIS} from within an AppImage."
  exit 0
fi

# Check if the desktop file is already there
# and if so, whether it points to the same AppImage
if [ -e "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME" ] ; then
  # echo "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME already there"
  EXEC=$(grep "^Exec=" "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME" | head -n 1 | cut -d " " -f 1)
  # echo $EXEC
  if [ "Exec=\"$APPIMAGE\"" == "$EXEC" ] ; then
    exit 0
  fi
fi

# We ask the user only if we have found no reason to skip until here
if [ -z "$SKIP" ] ; then
  yesno "Install" "Would you like to integrate $APPIMAGE with your system?\n\nThis will add it to your applications menu and install icons.\nIf you don't do this you can still launch the application by double-clicking on the AppImage."
fi

if [ "$RETURN" = "no" ] ; then
  yesno "Disable question?" "Should this question be permanently disabled for $APP?\n\nTo re-enable this question you have to delete\n\"$STAMP_DIR/${APP}_no_desktopintegration\""
  if [ "$RETURN" = "yes" ] ; then
    mkdir -p "$STAMP_DIR"
    touch "$STAMP_DIR/${APP}_no_desktopintegration"
  fi
  exit 0
fi

# If the user has agreed, rewrite and install the desktop file, and the MIME information
if [ -z "$SKIP" ] ; then
  # desktop-file-install is supposed to install .desktop files to the user's
  # applications directory when run as a non-root user,
  # and to /usr/share/applications if run as root
  # but that does not really work for me...
  #
  # For Exec we must use quotes
  # For TryExec quotes is not supported, so, space must be replaced to \s
  # https://askubuntu.com/questions/175404/how-to-add-space-to-exec-path-in-a-thumbnailer-descrption/175567
  RESOURCE_NAME=$(echo "$VENDORPREFIX-$DESKTOPFILE_NAME" | sed -e 's/.desktop//g')
  desktop-file-install --rebuild-mime-info-cache \
    --vendor=$VENDORPREFIX --set-key=Exec --set-value="\"${APPIMAGE}\" %U" \
    --set-key=X-AppImage-Comment --set-value="Generated by ${THIS}" \
    --set-icon="$RESOURCE_NAME" --set-key=TryExec --set-value=${APPIMAGE// /\\s} "$DESKTOPFILE" \
    --dir "$DESTINATION_DIR_DESKTOP"
  chmod a+x "$DESTINATION_DIR_DESKTOP/"*
  # echo $RESOURCE_NAME

  # delete "Actions" entry and add an "Uninstall" action
  sed -i -e '/^Actions=/d' "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME"
  cat >> "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME" << EOF

Actions=Uninstall;

[Uninstall]
Name=Remove desktop integration for $APP_FULL
Exec="$APPIMAGE" --remove-appimage-desktop-integration

EOF

  # Install the icon files for the application; TODO: scalable
  ICONS=$(find "${APPDIR}/usr/share/icons/" -iwholename "*/apps/${APP}.png" 2>/dev/null || true)
  for ICON in $ICONS ; do
    ICON_SIZE=$(echo "${ICON}" | rev | cut -d "/" -f 3 | rev | cut -d "x" -f 1)
    xdg-icon-resource install --context apps --size ${ICON_SIZE} "${ICON}" "${RESOURCE_NAME}"
  done

  # Install mime type
  find "${APPDIR}/usr/share/mime/" -type f -name *xml -exec xdg-mime install $SYSTEM_WIDE --novendor {} \; 2>/dev/null || true

  # Install the icon files for the mime type; TODO: scalable
  ICONS=$(find "${APPDIR}/usr/share/icons/" -iwholename "*/mimetypes/*.png" 2>/dev/null || true)
  for ICON in $ICONS ; do
    ICON_SIZE=$(echo "${ICON}" | rev | cut -d "/" -f 3 | rev | cut -d "x" -f 1)
    xdg-icon-resource install --context mimetypes --size ${ICON_SIZE} "${ICON}" $(basename $ICON | sed -e 's/.png//g')
  done

  xdg-desktop-menu forceupdate
  gtk-update-icon-cache # for MIME
fi

Do I need to link to the wrapper from the AppRun file?

This script is outdated. Please don’t use it anymore.

Desktop integration should be handled by appimaged from GitHub - probonopd/go-appimage: Go implementation of AppImage tools. Still experimental or similar tools system-wide. Desktop integration should not be handled by each application’s AppImage anymore.