Bye RPM / DEB / tar! The next generation of full Platform Installer is coming!

Time:2021-10-18

Appimage is a format used to distribute portable software in Linux systems and does not require super user privileges to install them. It also allows Linux upstream developers to distribute their programs regardless of the differences between different Linux distributions. The core idea of appimage is one file, that is, one application. Each appimage contains the application and all the files required for the application to run.

Bye RPM / DEB / tar! The next generation of full Platform Installer is coming!Bye RPM / DEB / tar! The next generation of full Platform Installer is coming!

Appimage tool introduction

Like Linux itself, appimagekit is open source.

Bye RPM / DEB / tar! The next generation of full Platform Installer is coming!For all fairly modern Linux Desktop distributions.

simple

The core idea of appimage is: an application = a file. Each appimage contains the application and all the files required for the application to run. In other words, except for the basic components of the operating system itself, appimage does not need to rely on packages to run.

reliable

Appimage format is an ideal choice for upstream application packaging, which means that you can get the software directly from the developer without any intermediate steps, which is completely in line with the developer’s intention. Very fast.

fast

Appimage application can be downloaded and run directly without installation and root permission.

Appimage tool comparison

Compare the advantages and disadvantages of various software formats!

Comparison with DEB and RPM

  • advantage
  • Appimage format applications can run across distributions, and traditional formats are unavailable or difficult.
  • Appimage format can run without installation. It can run in the $home partition to save more partition space.
  • Appimage does not require root permission, saying goodbye to the era of entering passwords.
  • Appimage contains application dependencies, which can quickly distribute application versions without destroying system dependencies without being restricted by the software warehouse.
  • Appimage provides a variety of packaging methods, including manual packaging and script packaging.
  • inferiority
  • Appimage format will cause redundancy and large volume of the library, which is jokingly called “10000 libcs are installed in the system”.
  • Appimage is not checked. If someone from unknown source packs it, it may bring security risks.
  • Running an old appimage software still carries the dependency Library of the old version, which may bring risks.

Compare with snap and flatpak

  • advantage
  • Appimage does not need a runtime. Install snap and flatpak software to install its runtime.
  • Appimage format can run without installation. It can run in the $home partition to save more partition space.
  • Appimage does not require root permission, saying goodbye to the era of entering passwords.
  • Appimage does not need a software warehouse. Of course, it can also be provided, which is easy to spread.
  • Appimage is friendly to Chinese, including official websites and official documents, which have corresponding Chinese support.
  • inferiority
  • There is no sandbox mechanism.
  • Without the support of commercial companies, it took more than ten years to become influential.
  • It is not friendly to some customized distributions, such as Gentoo, archlinux, etc.

Appimage directory structure

Pay attention to the files and directory structure required by appimage!

The premise of using appimage series tools is that the program project or tool dependency format you write must meet the directory requirements of appdir. The approximate directory structure is as follows.

AppDir
└── AppRun
└── your_app.desktop
└── your_app.png
└── usr
    ├── bin
    │   └── your_app
    ├── lib
    └── share
        ├── applications
        │   └── your_app.desktop
        └── icons
            └── <theme>
                └── <resolution>
                    └── your_app.png
  • Apprun file
  • Must have
  • Start the main load application
  • The apprun file is the startup entry point file of the program, which needs executable permissions.
  • An apprun. C implementation is provided in the appimagekit project, but we can use languages, such as shell implementation, or only symbolic links with the main executable files.
  • your_ App.desktop file
  • Must have
  • It is similar to the shortcut of windows system, that is, double-click to run.
  • The [your_app]. Desktop file here will be displayed on the desktop and can exist as a link.
  • For the format, please refer to:https://specifications.freede…Spec / latest / ar01s06.html the easiest way to change this website is to find one.
[Desktop Entry]
Name=Hypnos
Exec=hypnos %F
Icon=hypnos
Type=Application
Categories=Audio;AudioVideo;
Comment=Music Player and Library
MimeType=inode/directory;audio/flac;
Name[en]=Hypnos
Terminal=false
StartupNotify=true
NoDisplay=false
  • your_ App.png file
  • Not necessary
  • The desktop display pattern of the provider package.
  • Version file
  • Not necessary
  • Used to display the version information corresponding to the program package.

Appimagetool command

Describes the use format and common command parameters of appimage tool.

Packaging command use

The appimagetool command is used to generate an appimage program from the existing appdir directory.

Usage:
  appimagetool [OPTION...] SOURCE [DESTINATION] - Generate, extract, and inspect AppImages
Help Options:
  -h, --help                  Show help options
Application Options:
  -l, --list                  List files in SOURCE AppImage
  -u, --updateinformation     Embed update information STRING; if zsyncmake is installed, generate zsync file
  -g, --guess                 Guess update information based on Travis CI or GitLab environment variables
  --bintray-user              Bintray user name
  --bintray-repo              Bintray repository
  --version                   Show version number
  -v, --verbose               Produce verbose output
  -s, --sign                  Sign with gpg[2]
  --comp                      Squashfs compression
  -n, --no-appstream          Do not check AppStream metadata
  --exclude-file              Uses given file as exclude file for mksquashfs, in addition to .appimageignore.
  --runtime-file              Runtime file to use
  --sign-key                  Key ID to use for gpg[2] signatures
  --sign-args                 Extra arguments to use when signing with gpg

Use of packaged files

If we run a program built by the appimagekit tool, it will attach the following parameters, which will provide some additional features and functions.

# usage
./appimagetool-x86_64.AppImage some.AppDir

Bye RPM / DEB / tar! The next generation of full Platform Installer is coming!

Using pkg2appimage tool

Pkg2appimage tool is suitable for turning packages in DEB format into independent executable files of appimage!

If we already have a corresponding binary file, whether it is a zip archive file, a file in. DEB format or a file on the PPA source, we only need to write a description file in. YML format, and then use the pkg2appimage tool to run it, which will help us convert and generate an appimage independent file. Is it very simple? The YML description file tells pkg2appimage where to get the required content and how to convert them to appimage.

#   Execution mode
$ bash -ex ./pkg2appimage recipes/XXX.yml

If you only see the short answer, you are too young. You don’t know how bad the configuration file in YML format is. Really, after reading the introduction of the configuration file in the official document and the sample software of the official warehouse, I was a little confused about YML. However, after reading it several times, you will find that it is not difficult to write. It is just that when we make mistakes again, we can adjust the configuration file in time, and we can print the independent file we need normally.

Now let’s take a look at the writing content of YML file! As we can see, the. YML file consists of three parts: the body part, the dependency part, and the script part.

app:   zstd         #  Software name
binpatch: true   # chdir()
overwrite: true  # union file system
ingredients:      #  Dependencies; Where does the content of the package come from
  dist: bionic
  package: zstd
  sources:
    - deb http://archive.ubuntu.com/ubuntu/ bionic main universe
script:
  - cat > ./zstd.desktop  <<EOF
  - [Desktop Entry]
  - Type=Application
  - Terminal=true
  - Name=zstd
  - Exec=zstd
  - Icon=transmission-tray-icon.png
  - Categories=Development;
  - EOF
  - cat > ./AppRun <<EOF
  - #!/bin/sh
  - HERE=$(dirname $(readlink -f "
app:   zstd         #  Software name
binpatch: true   # chdir()
overwrite: true  # union file system
ingredients:      #  Dependencies; Where does the content of the package come from
  dist: bionic
  package: zstd
  sources:
    - deb http://archive.ubuntu.com/ubuntu/ bionic main universe
script:
  - cat > ./zstd.desktop  <<EOF
  - [Desktop Entry]
  - Type=Application
  - Terminal=true
  - Name=zstd
  - Exec=zstd
  - Icon=transmission-tray-icon.png
  - Categories=Development;
  - EOF
  - cat > ./AppRun <<EOF
  - #!/bin/sh
  - HERE=$(dirname $(readlink -f "${0}"))
  - export LD_LIBRARY_PATH="${HERE}"/usr/lib:$PATH
  - "${HERE}"/usr/bin/zstd [email protected]
  - EOF
  - chmod a+x ./AppRun
"))   - export LD_LIBRARY_PATH="${HERE}"/usr/lib:$PATH   - "${HERE}"/usr/bin/zstd [email protected]   - EOF   - chmod a+x ./AppRun
#   Execute the following command to generate a separate program for zstd
$ pkg2appimage ./zstd-appimage.yml
  • The overall section
  • Must exist
  • Contains the name of the application
  • The name must match the package name of the main entry file
app: zstd
  • The ingredients section
  • Must exist
  • Describes how to get binary content into appimage
  • Can it contain a zip archive, a file in. DEB format, or a file on the PPA source
# Using ingredients from a binary archive
ingredients:
  script:
    - DLD=$(wget -q "https://api.github.com/repos/atom/atom/releases/latest" -O - | grep -E "https.*atom-amd64.tar.gz" | cut -d'"' -f4)
    - wget -c $DLD
    - tar zxvf atom*tar.gz
# Using ingredients from a debian repository
ingredients:
  dist: xenial
  sources:
    - deb http://archive.ubuntu.com/ubuntu/ xenial main universe
    - deb http://download.opensuse.org/repositories/isv:/KDAB/xUbuntu_16.04/ /
# Using ingredients from an Ubuntu PPA
ingredients:
  dist: xenial
  sources:
    - deb http://us.archive.ubuntu.com/ubuntu/ xenial main universe
  ppas:
    - geany-dev/ppa
# Using local deb files
ingredients:
  dist: xenial
  sources:
    - deb http://us.archive.ubuntu.com/ubuntu/ xenial main universe
  debs:
    - /home/area42/kdenlive.deb
    - /home/area42/kdenlive/*
# Excluding certain packages
ingredients:
  dist: xenial
  packages:
    - multisystem
    - gksu
  sources:
    - deb http://us.archive.ubuntu.com/ubuntu/ xenial main universe
    - deb http://liveusb.info/multisystem/depot all main
  exclude:
    - qemu
    - qemu-kvm
    - cryptsetup
    - libwebkitgtk-3.0-0
    - dmsetup
# Pretending certain versions of dependencies being installed
ingredients:
  dist: xenial
  sources:
    - deb http://archive.ubuntu.com/ubuntu/ xenial main universe
  ppas:
    - otto-kesselgulasch/gimp-edge
  pretend:
    - libcups2 1.7.2-0ubuntu1
# Arbitrary scripts in the ingredients section
ingredients:
  script:
    - URL=$(wget -q https://www.fosshub.com/JabRef.html -O - | grep jar | cut -d '"' -f 10)
    - wget -c "$URL"
    - wget -c --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jre-8u66-linux-x64.tar.gz
  • The script section
  • Must exist
  • The script section may contain any shell commands required to convert binary content into appdir suitable for generating appimage
# The script section needs to copy ingredients into place
ingredients:
  dist: xenial
  sources:
    - deb http://archive.ubuntu.com/ubuntu/ xenial main universe
  script:
    - DLD=$(wget -q "https://github.com/feross/webtorrent-desktop/releases/" -O - | grep _amd64.deb | head -n 1 | cut -d '"' -f 2)
    - wget -c "https://github.com/$DLD"
script:
  - mv opt/webtorrent-desktop/* usr/bin/
  - sed -i -e 's|/opt/webtorrent-desktop/||g' webtorrent-desktop.desktop
# The script section needs to copy ingredients into place
ingredients:
  script:
    - wget -c "https://telegram.org/dl/desktop/linux" --trust-server-names
    - tar xf tsetup.*.tar.xz
script:
  - cp ../Telegram/Telegram ./usr/bin/telegram-desktop
# The script section needs to copy icon and .desktop file in place
script:
  - tar xf ../fritzing* -C usr/bin/ --strip 1
  - mv usr/bin/fritzing.desktop .
# The script section needs to copy icon and .desktop file in place
script:
  -  # Workaround for:
  -  # https://bugzilla.mozilla.org/show_bug.cgi?id=296568
  - cat > firefox.desktop <<EOF
  - [Desktop Entry]
  - Type=Application
  - Name=Firefox
  - Icon=firefox
  - Exec=firefox %u
  - Categories=GNOME;GTK;Network;WebBrowser;
  - MimeType=text/html;text/xml;application/xhtml+xml;
  - StartupNotify=true
  - EOF
# The script section needs to copy icon and .desktop file in place
script:
  - cp ./usr/share/applications/FBReader.desktop fbreader.desktop
  - sed -i -e 's|Exec=FBReader|Exec=fbreader|g' fbreader.desktop
  - sed -i -e 's|Name=.*|Name=FBReader|g' fbreader.desktop
  - sed -i -e 's|Icon=.*|Icon=fbreader|g' fbreader.desktop
  - mv usr/bin/FBReader usr/bin/fbreader
  - cp usr/share/pixmaps/FBReader.png fbreader.png

The following example is the YML configuration file given in the official repository of PIP.

# Converting Python applications packaged with pip
app: mu.codewith.editor
ingredients:
  dist: xenial
  sources:
    - deb http://us.archive.ubuntu.com/ubuntu/ xenial xenial-updates xenial-security main universe
    - deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main universe
    - deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main universe
  packages:
    - python3.4-venv
  script:
    - wget -c https://raw.githubusercontent.com/mu-editor/mu/master/conf/mu.codewith.editor.png
    - wget -c https://raw.githubusercontent.com/mu-editor/mu/master/conf/mu.appdata.xml
script:
  - cp ../mu.codewith.editor.png ./usr/share/icons/hicolor/256x256/
  - cp ../mu.codewith.editor.png .
  - mkdir -p usr/share/metainfo/ ; cp ../mu.appdata.xml usr/share/metainfo/
  - virtualenv --python=python3 usr
  - ./usr/bin/pip3 install mu-editor
  - cat > usr/share/applications/mu.codewith.editor.desktop <<EOF
  - [Desktop Entry]
  - Type=Application
  - Name=Mu
  - Comment=A Python editor for beginner programmers
  - Icon=mu.codewith.editor
  - Exec=python3 bin/mu-editor %F
  - Terminal=false
  - Categories=Application;Development;
  - Keywords=Python;Editor;microbit;micro:bit;
  - StartupWMClass=mu
  - MimeType=text/x-python3;text/x-python3;
  - EOF
  - cp usr/share/applications/mu.codewith.editor.desktop .
  - usr/bin/pip3 freeze | grep "mu-editor" | cut -d "=" -f 3 >> ../VERSION

The following example is the YML configuration file given in the official repository of atom, the code editor.

app: Atom
ingredients:
  script:
    - DLD=$(wget -q "https://api.github.com/repos/atom/atom/releases/latest"  -O - | grep -E "https.*atom-amd64.tar.gz" | cut -d'"' -f4)
    - wget -c $DLD
    - echo $DLD | cut -d/ -f8 > VERSION
    - tar zxvf atom*tar.gz
script:
  - cp -r ../atom-*/* usr/bin/
  - find . -name atom.png -exec cp {} atom.png ;
  - cat > atom.desktop <<EOF
  - [Desktop Entry]
  - Type=Application
  - Name=Atom
  - Icon=atom
  - Exec=atom %u
  - Categories=Development;IDE;
  - Comment=The hackable text editor
  - EOF

Using the Linux deployqt tool

Linuxdeployqt is a QT packaging tool under Linux!

Tool installation

#   Download the Linux deployqt tool
$ wget "https://github.com/probonopd/linuxdeployqt/releases/download/7/linuxdeployqt-7-x86_64.AppImage"
#   Rename linuxdeployqt name
$ mv linuxdeployqt-continuous-x86_64.AppImage linuxdeployqt
#   Become a system executable
$ sudo mv ./linuxdeployqt /usr/local/bin
$ sudo chmod 755 linuxdeployqt
#   View the Linux deployqt version
$ sudo linuxdelpoyqt --version
linuxdeployqt 4 (commit 988d294), build 481 built on 2018-02-02 15:05:23 UTC
#   The Linux deployqt command uses the - appimage option
$ wget -c "https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage" -O /usr/local/bin/appimagetool
#   Become a system executable
$ sudo chmod a+x /usr/local/bin/appimagetool

packaged applications

#   You can't be sure of success
$   linuxdeployqt  < Own project name >  - appimage

Sample demos in official articles

Simple demonstration process of packaged software program – cmake

Generate appdir package directory

# fetch sources (you could as well use a tarball etc.)
> git clone https://github.com/linuxdeploy/QtQuickApp.git
> cd QtQuickApp
# build out of source
> mkdir build
> cd build
# configure build system
# the flags below are the bare minimum that is needed, the app might define additional variables that might have to be set
> cmake .. -DCMAKE_INSTALL_PREFIX=/usr
# build the application on all CPU cores
> make -j$(nproc)
# now "install" resources into future AppDir
> make install DESTDIR=AppDir
AppDir
└── AppRun
└── your_app.desktop
└── your_app.png
└── usr
    ├── bin
    │   └── your_app
    ├── lib
    └── share
        ├── applications
        │   └── your_app.desktop
        └── icons
            └── <theme>
                └── <resolution>
                    └── your_app.png

Using Linux deploy to package appimages

# get linuxdeploy's AppImage
> wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
> chmod +x linuxdeploy-x86_64.AppImage
# run linuxdeploy and generate an AppDir
> ./linuxdeploy-x86_64.AppImage --appdir AppDir

Official cmake tool Packaging example

#! /bin/bash
set -x
set -e
# building in temporary directory to keep system clean
# use RAM disk if possible (as in: not building on CI system like Travis, and RAM disk is available)
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
    TEMP_BASE=/dev/shm
else
    TEMP_BASE=/tmp
fi
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" appimage-build-XXXXXX)
# make sure to clean up build dir, even if errors occur
cleanup () {
    if [ -d "$BUILD_DIR" ]; then
        rm -rf "$BUILD_DIR"
    fi
}
trap cleanup EXIT
# store repo root as variable
REPO_ROOT=$(readlink -f $(dirname $(dirname $0)))
OLD_CWD=$(readlink -f .)
# switch to build dir
pushd "$BUILD_DIR"
# configure build files with CMake
# we need to explicitly set the install prefix, as CMake's default is /usr/local for some reason...
cmake "$REPO_ROOT" -DCMAKE_INSTALL_PREFIX=/usr
# build project and install files into AppDir
make -j$(nproc)
make install DESTDIR=AppDir
# now, build AppImage using linuxdeploy and linuxdeploy-plugin-qt
# download linuxdeploy and its Qt plugin
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
# make them executable
chmod +x linuxdeploy*.AppImage
# make sure Qt plugin finds QML sources so it can deploy the imported files
export QML_SOURCES_PATHS="$REPO_ROOT"/src
# initialize AppDir, bundle shared libraries for QtQuickApp, use Qt plugin to bundle additional resources, and build AppImage, all in one single command
./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin qt --output appimage
# move built AppImage back into original CWD
mv QtQuickApp*.AppImage "$OLD_CWD"

Author: Escape
Link:https://www.escapelife.site/p…

Bye RPM / DEB / tar! The next generation of full Platform Installer is coming!