Linux: provide AppImages

Ideas for improvements and requests for new features in XnView MP

Moderators: XnTriq, helmut, xnview

Post Reply
djcj
Posts: 60
Joined: Wed Jan 08, 2014 3:37 pm

Linux: provide AppImages

Post by djcj »

As an alternative to .deb and .rpm packages, could you also provide AppImages?

From https://github.com/probonopd/AppImageKit/wiki:
What is an AppImage?
An AppImage is a downloadable file for Linux that contains an application and everything the application needs to run (e.g., libraries, icons, fonts, translations, etc.) that cannot be reasonably expected to be part of each target system.
It's kinda like a .App on OSX, and it works surprisingly well. It's a binary file with a compressed filesystem image attached, which will be mounted on start.

To create an AppImage you'll need to save this YAML file, ie. as XnViewMP.yml:

Code: Select all

app: XnViewMP

ingredients:
  dist: precise
  packages:
    - libasound2
    - libatk1.0-0
    - libc6
    - libcairo2
    - libcups2
    - libfontconfig1
    - libfreetype6
    - libgcc1
    - libgdk-pixbuf2.0-0
    - libgl1-mesa-glx
    - libglib2.0-0
    - libgstreamer0.10-0
    - libgstreamer-plugins-base0.10-0
    - libgtk2.0-0
    - libice6
    - libpango-1.0-0
    - libpangocairo-1.0-0
    - libpangoft2-1.0-0
    - libpulse0
    - libsm6
    - libsqlite3-0
    - libstdc++6
    - libx11-6
    - libx11-xcb1
    - libxcb1
    - libxcomposite1
    - libxext6
    - libxi6
    - libxml2
    - libxrender1
    - libxslt1.1
    - zlib1g
  sources:
    - deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe
    - deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe
    - deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe
  script:
    - VERSION=$(wget -q -O- http://www.xnview.com/xnviewmp_update.txt | sed -n -e 's/^version=//p' | sed -e 's/\r//g')
    - wget -c http://download.xnview.com/old_versions/XnViewMP-$(echo $VERSION | tr -d '.')-linux-x64.tgz
    - wget -c http://archive.ubuntu.com/ubuntu/pool/main/c/chrpath/chrpath_0.13-2build2_amd64.deb -O chrpath.deb
    - echo $VERSION > VERSION

script:
  - dpkg -x ../chrpath.deb ../chrpath
  - tar xf ../XnViewMP-*-linux-x64.tgz
  - ../chrpath/usr/bin/chrpath -d XnView/XnView
  - find XnView/* -type f -name *.so* -exec ../chrpath/usr/bin/chrpath -d '{}' \;
  - mkdir -p usr/bin usr/share/icons/hicolor/64x64/apps
  - mv XnView/ usr/
  - cat > usr/bin/xnviewmp <<\EOF
  - #!/bin/sh
  - usr="$(pwd)"
  - export GST_PLUGIN_PATH="$usr/lib/x86_64-linux-gnu/gstreamer-0.10"
  - export GST_PLUGIN_SCANNER="$usr/lib/x86_64-linux-gnu/gstreamer0.10/gstreamer-0.10/gst-plugin-scanner"
  - export LD_LIBRARY_PATH="$usr/XnView/lib:$usr/XnView/Plugins:$LD_LIBRARY_PATH"
  - export QT_PLUGIN_PATH="$usr/XnView/lib:$QT_PLUGIN_PATH"
  - "$usr/XnView/XnView" "$@"
  - EOF
  - chmod a+x usr/bin/xnviewmp
  - cat > xnviewmp.desktop <<\EOF
  - [Desktop Entry]
  - Type=Application
  - Name=XnView MP
  - Comment=Graphic viewer, browser, converter
  - Exec=xnviewmp %U
  - Terminal=false
  - Icon=xnviewmp
  - Categories=Graphics;
  - StartupNotify=true
  - MimeType=image/bmp;image/gif;image/jpeg;image/png;image/tiff;image/x-tga;image/x-pcx;image/jp2;
  - EOF
  - cp ./usr/XnView/xnview.png xnviewmp.png
  - cp xnviewmp.png ./usr/share/icons/hicolor/64x64/apps/
Make sure that FUSE (filesystem in userspace) is available, otherwise the final step of creating the AppImage will fail:

Code: Select all

sudo apt-get install fuse
sudo modprobe fuse
user="$(whoami)"
sudo usermod -a -G fuse $user
Then run this in shell:

Code: Select all

wget -O Recipe https://raw.githubusercontent.com/probonopd/AppImages/master/recipes/meta/Recipe
bash Recipe XnViewMP.yml
To figure out the dependencies you need to add to the packages list of the YAML file you can run this shell script inside XnView's directory:

Code: Select all

#!/bin/sh

echo "wait a few seconds..."

alldeps="$( (find ./* -type f -exec readelf -d '{}' 2>/dev/null \;) | grep 'NEEDED' | cut -d '[' -f2 | tr -d ']' | sort | uniq )"

for f in $alldeps; do
  if [ "x$(find ./* -name $f)" = "x" ]; then
    deps="$deps $f"
  fi
done

for f in $deps; do
  if [ "$f" = "libGL.so.1" ]; then
    pkgs="$pkgs libgl1-mesa-glx"
  else
    pkgs="$pkgs $(dpkg -S $f | grep "amd64" | grep "\/$f\$" | head -n1 | cut -d: -f1)"
  fi
done

echo ""
echo "dependencies are:"
echo "$pkgs" | tr ' ' '\n' | sort | uniq
A few notes:
  • since AppImages are already compressed, it's recommended to not put them into a zip or tar archive, but instead provide downloads to the raw .AppImage files
  • the older the system the binaries were build on, and the older the distribution set in the YAML file, the more downwards compatible are those AppImages
  • the AppImage created on my system has a size of 59 MiB, only 10 MiB bigger than the original tarball
  • the current build system only supports 64 bit x86 architecture (x86-64, amd64)
Last edited by djcj on Sun Jan 22, 2017 11:52 pm, edited 1 time in total.
User avatar
xnview
Author of XnView
Posts: 43442
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Linux: provide AppImages

Post by xnview »

i've added a 0.84 x64 Appimage link
Pierre.
User avatar
CreativeWorld
Posts: 139
Joined: Fri Dec 30, 2011 7:08 pm

Re: Linux: provide AppImages

Post by CreativeWorld »

I would also suggest to implement a snap distribution like Inkscape does:

http://snapcraft.io/
djcj
Posts: 60
Joined: Wed Jan 08, 2014 3:37 pm

Re: Linux: provide AppImages

Post by djcj »

xnview wrote:i've added a 0.84 x64 Appimage link
Great. Works well for me.

Here's an updated recipe for XnView MP 0.84:

Code: Select all

app: XnViewMP

ingredients:
  dist: precise
  packages:
    - libasound2
    - libatk1.0-0
    - libcairo2
    - libcups2
    - libdbus-1-3
    - libegl1-mesa
    - libfontconfig1
    - libfreetype6
    - libgdk-pixbuf2.0-0
    - libgl1-mesa-glx
    - libglib2.0-0
    - libgtk2.0-0
    - libice6
    - libjasper1
    - libpango-1.0-0
    - libpangocairo-1.0-0
    - libpangoft2-1.0-0
    - libpulse0
    - libsm6
    - libsqlite3-0
    - libx11-6
    - libx11-xcb1
    - libxcb1
    - libxext6
    - libxi6
    - libxrender1
    - zlib1g
  sources:
    - deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe
    - deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe
    - deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe
  script:
    - VERSION=$(wget -q -O- http://www.xnview.com/xnviewmp_update.txt | sed -n -e 's/^version=//p' | sed -e 's/\r//g')
    - wget -c http://download.xnview.com/old_versions/XnViewMP-$(echo $VERSION | tr -d '.')-linux-x64.tgz
    - wget -c http://archive.ubuntu.com/ubuntu/pool/main/c/chrpath/chrpath_0.13-2build2_amd64.deb -O chrpath.deb
    - echo $VERSION > VERSION
    - tar xf XnViewMP-*-linux-x64.tgz
    - rm -f XnView/XnView.desktop XnView/XnView.desktop~
    - dpkg -x chrpath.deb chrpath && rm chrpath.deb

script:
  - mv ../XnView/ usr/
  - ../chrpath/usr/bin/chrpath -d usr/XnView/XnView
  - find usr/XnView/* -type f -name *.so* -exec ../chrpath/usr/bin/chrpath -d '{}' \;
  - mkdir -p usr/bin usr/share/icons/hicolor/64x64/apps
  - cat > usr/bin/xnviewmp <<\EOF
  - #!/bin/sh
  - usr="$(pwd)"
  - export LD_LIBRARY_PATH="$usr/XnView/lib:$usr/XnView/Plugins:$LD_LIBRARY_PATH"
  - export QT_PLUGIN_PATH="$usr/XnView/lib:$QT_PLUGIN_PATH"
  - "$usr/XnView/XnView" "$@"
  - EOF
  - chmod a+x usr/bin/xnviewmp
  - cat > xnviewmp.desktop <<\EOF
  - [Desktop Entry]
  - Type=Application
  - Name=XnView MP
  - Comment=Graphic viewer, browser, converter
  - Exec=xnviewmp
  - Terminal=false
  - Icon=xnviewmp
  - Categories=Graphics;
  - StartupNotify=true
  - MimeType=image/bmp;image/gif;image/jpeg;image/png;image/tiff;image/x-tga;image/x-pcx;image/jp2;
  - EOF
  - cp ./usr/XnView/xnview.png xnviewmp.png
  - cp xnviewmp.png ./usr/share/icons/hicolor/64x64/apps/

Post Reply