Goodbye RPM / DEB / tar! The next generation of full platform installation program is coming!

Time:2021-5-8

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

Goodbye RPM / DEB / tar! The next generation of full platform installation program is coming!Goodbye RPM / DEB / tar! The next generation of full platform installation program is coming!

Appimage tool introduction

Like Linux itself, appimagekit is open source.

Goodbye RPM / DEB / tar! The next generation of full platform installation program is coming!For all fairly modern Linux Desktop distributions.

simple

The core idea of appimage is: one application = one file. Each appimage contains the application and all the files it needs 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 quickly.

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!

Compared with DEB and RPM

  • advantage
  • Appimage format applications can run across distributions, but traditional formats are not available or difficult.
  • Appimage format can run without installation. It can run in $home partition to save more partition space.
  • Appimage doesn’t need root permission, saying goodbye to the era of password input.
  • Appimage contains application dependency, which can distribute application version quickly without destroying system dependency.
  • Appimage provides a variety of packaging methods, including manual packaging and script packaging.
  • inferiority
  • Appimage format will cause redundant and bulky libraries, which is called “the system has 10000 libcs installed”.
  • Appimage is not checked. If someone from an unknown source packs it, it may pose a security risk.
  • Running an old appimage software with an old version of the dependency library may bring risks.

Compared with snap and flatpak

  • advantage
  • Appimage does not need runtime. Install snap and flatpak software to install its runtime.
  • Appimage format can run without installation. It can run in $home partition to save more partition space.
  • Appimage doesn’t need root permission, saying goodbye to the era of password input.
  • Appimage doesn’t need a software warehouse. Of course, it can also have one, which is easy to spread.
  • Appimage is friendly to Chinese, including the official website 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 for the development to be influential.
  • It is not friendly to some customized distributions, such as Gentoo, archlinux, etc.

Appimage directory structure

Pay attention to the file 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 general 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
  • Applun file
  • It has to be
  • Start the main payload application
  • Among them, the apprun file is the startup entry point file of the program, which needs to have executable permissions.
  • An implementation of apprun. C is provided in the appimagekit project, but we can use languages, such as shell implementation, or only use symbolic links with the main executable files.
  • your_ App.desktop file
  • It has to be
  • Similar to Windows system shortcut, that is, double-click to run.
  • Our [your_ App]. Desktop files will be displayed on the desktop and can exist in the form of links.
  • The format can be referred to:https://specifications.freede…Spec / latest / ar01s06.html this website, the easiest way is to find a change, change it.
[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
  • It’s not necessary
  • The desktop display pattern of the provider package.
  • Version file
  • It’s not necessary
  • Used to display the version information of the program package.

Using appimagetool command

This paper introduces the format and common command parameters of appimage tool.

How to use the package command

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 appimagekit tool, it will attach the following parameters, which will provide some additional features and functions.

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

Goodbye RPM / DEB / tar! The next generation of full platform installation program is coming!

Using pkg2appimage tool

Pkg2appimage tool is suitable for turning DEB package into independent executable file of appimage!

If we have the corresponding binary files, whether they are zip files,. DEB files or PPA source files, we only need to write a description file in. YML format, and then use pkg2appimage tool to run it, which will help us transform and generate an appimage independent file, isn’t it very simple? The YML description file tells pkg2appimage where to get the required content and how to convert them into appimage.

#   Mode of implementation
$ bash -ex ./pkg2appimage recipes/XXX.yml

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

Now let’s take a look at the content of the 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:      #  Dependence relationship; 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:      #  Dependence relationship; 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 the independent program of 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 zip archives,. DEB files or files on PPA sources
# 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 needed 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 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

How to use Linux deployqt tool

Linuxdeployqt is a QT packaging tool under Linux!

Tool installation

#   Download linuxdeployqt 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 system executable file
$ sudo mv ./linuxdeployqt /usr/local/bin
$ sudo chmod 755 linuxdeployqt
#   View the Linux deploy QT version
$ sudo linuxdelpoyqt --version
linuxdeployqt 4 (commit 988d294), build 481 built on 2018-02-02 15:05:23 UTC
#   The - appimage option is used in the linuxdeployqt command
$ wget -c "https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage" -O /usr/local/bin/appimagetool
#   Become system executable file
$ sudo chmod a+x /usr/local/bin/appimagetool

packaged applications

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

Examples in official articles

A simple demonstration process of packaged software program cmake

Generate appdir packing 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

Package appimages with linuxdeploy

# 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…

Goodbye RPM / DEB / tar! The next generation of full platform installation program is coming!

Recommended Today

Looking for frustration 1.0

I believe you have a basic understanding of trust in yesterday’s article. Today we will give a complete introduction to trust. Why choose rust It’s a language that gives everyone the ability to build reliable and efficient software. You can’t write unsafe code here (unsafe block is not in the scope of discussion). Most of […]