BlinCT
Dec. 9, 2018, 9:15 p.m.

SNAP Tutorial 02. Sample snap package of Qt 5.11.0 based application

I would like to welcome everyone to the continuation of the topic concerning a self-sufficient snap package.
A lot of time has passed since the publication of the previous article in which I began to acquaint you with snap technology from my experience and application. All the fault of time, business, and laziness, of course, was also present)
But we will now continue the topic)


Next, we will analyze this technology on the example of my application. I must say that it is not yet fully prepared, but something that works in it. Some functionality is being remade in it. Below the link you can download it from my dropbox. So far, the application is not in the official store because it is not yet fully ready.
In the following articles we will look at how to put an application in the store.

Project structure:

  1. /
  2. --scripts
  3. ----bin
  4. ------projecttimer
  5. ----Qt
  6. --snap
  7. ----gui
  8. ----snapcraft.yaml

snap package

Installing the application is simple, transfer to the computer and in the console.
sudo snap install —dangerous <имя пакета>
A very important nuance, the application will not work on the system if you have an AMD card and proprietary drivers are installed. Problem with libdrm. This is now being solved, but so far the situation has this form.

  1. name: managetime
  2. version: "0.1.0"
  3. summary: timer
  4. description: |
  5. Application for time management
  6. confinement: strict
  7. grade: stable
  8. architectures: [amd64]
  9.  
  10. base: core18
  11.  
  12. apps:
  13. managetime:
  14. command: bin/projecttimer
  15. plugs:
  16. - home
  17. - unity7
  18. - x11
  19. - opengl
  20. - pulseaudio
  21. - wayland
  22. - network
  23. - desktop
  24. - desktop-legacy
  25. environment:
  26. XDG_RUNTIME_DIR: /run/user/1000
  27. __EGL_VENDOR_LIBRARY_DIRS: $SNAP/etc/glvnd/egl_vendor.d:$SNAP/usr/share/glvnd/egl_vendor.d
  28. # XKB config
  29. XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
  30. # Qt Platform to Wayland
  31. #QT_QPA_PLATFORM: wayland
  32. QT_QPA_PLATFORM: xcb
  33. QTCHOOSER_NO_GLOBAL_DIR: 1
  34. QT_SELECT: snappy-qt5
  35. # Qt Modules
  36. LD_LIBRARY_PATH: $SNAP/Qt/5.11.0/gcc_64/lib:$LD_LIBRARY_PATH
  37. QT_PLUGIN_PATH: $SNAP/Qt/5.11.0/gcc_64/plugins
  38. QML2_IMPORT_PATH: $QML2_IMPORT_PATH:$SNAP/Qt/5.11.0/gcc_64/qml
  39. QT_QPA_PLATFORM_PLUGIN_PATH: $SNAP/Qt/5.11.0/gcc_64/plugins/platforms
  40. # XDG Config
  41. XDG_CONFIG_DIRS: $SNAP/etc/xdg:$SNAP/usr/xdg:$XDG_CONFIG_DIRS
  42. XDG_DATA_DIRS: $SNAP/usr/share:$XDG_DATA_DIRS
  43. # Font Config and themes
  44. FONTCONFIG_PATH: $SNAP/etc/fonts/conf.d
  45. FONTCONFIG_FILE: $SNAP/etc/fonts/fonts.conf
  46. # Tell libGL where to find the drivers
  47. LIBGL_DRIVERS_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri
  48. parts:
  49. managetime:
  50. plugin: dump
  51. source: scripts
  52. source-type: local
  53. build-attributes:
  54. - keep-execstack
  55.  
  56. integration:
  57. plugin: nil
  58. stage-packages:
  59. - libc6
  60. - zlib1g
  61. - libstdc++6
  62. - libgcc1
  63. - libglib2.0-0
  64. - libpcre3
  65. - libxext6
  66. - libx11-6
  67. - libxcb1
  68. - libxau6
  69. - libxdmcp6
  70. - libbsd0
  71. - libxdamage1
  72. - libxfixes3
  73. - libx11-xcb1
  74. - libxcb-glx0
  75. - libxcb-dri3-0
  76. - libxcb-present0
  77. - libxcb-dri2-0
  78. - libxxf86vm1
  79. - libxshmfence1
  80. - libxcb-sync1
  81. - libpulse-mainloop-glib0
  82. - libpulse0
  83. - libsystemd0
  84. - liblzma5
  85. - liblz4-1
  86. - libgcrypt20
  87. - libgpg-error0
  88. - libwrap0
  89. - libsndfile1
  90. - libflac8
  91. - libogg0
  92. - libvorbis0a
  93. - libvorbisenc2
  94. - libasyncns0
  95. - libdbus-1-3
  96. - libfontconfig1
  97. - libfreetype6
  98. - libpng16-16
  99. - libexpat1
  100. - libxi6
  101. - libxrender1
  102. - libdrm2
  103. - libwayland-client0
  104. - libwayland-cursor0
  105. - libffi6
  106. - libxkbcommon0
  107. - libxcomposite1
  108. - libgl1
  109. - libgl1-mesa-dri
  110. - libgl1-mesa-glx
  111. - libdrm-common
  112. - libtinfo5

Let's start with a short description:
confinement: имеет currently 3 modes of restrictions, strict, classic and devmode

  1. strict - strict limitation of the safety of the system core. The application will not have access to the system interfaces, user directory, network access, audio system and so on.
  2. devmode - debug mode. Used for developers.
  3. classic - The application has no limitations. Analog - deb packages, rpm. That is, the application has access to the system without restrictions.

base: core18 - The application is based on core18 which is responsible for the interfaces in the system and applications.

Apps: -application configuration part
managetime: - the name of the application in the system (for example, in the console when searching)

command: bin/projecttimer — what will be called by the name (managetime). There is also an option to place a script in front of the binary if you need to do something in the system before launching the application.

Plugs: - plugins that the application will use. Soon the user will see on the desktop during installation a window in which he will see where the application will climb and what it will do in the system. Simplify the understanding of the functional.

There are plugins that connect automatically, but there are some that need to be connected manually.

Environment: - environment setting. You can put this into a bash script and do something like this.
command: myconfig.sh bin/projecttimer
but I brought it here, as it is easier to see what is in the environment settings.

  1. parts:
  2. managetime:
  3. plugin: dump
  4. source: scripts

This all together says that you need to do to build the application, for example, compile from source, which means you will have a plugin: cmake, qmake or another option.
In my case, everything is copied from the scripts directory and placed in the package. It contains both the application binary itself and the necessary Qt

  1. integration:
  2. plugin: nil
  3. stage-packages:

here is the most interesting, in this part we indicate which packages and their versions are needed for the application to work and put them in isolation of the snap package itself.
Perhaps you ask how to find out about all the dependencies. I will answer, there are several options:

  1. ldd in the console for the application and see what it wants to work. By itself, the dependencies that it requires will have other dependencies) yes, it's fun to get to the end)
  2. drive in a dependency cycle and dependency dependencies.
  3. use interesting application linuxdeployqt

You feed the application a binary, the path to the libs that you used for the application (I'm talking about Qt) and this program will spit out to you both qt and system. If I'm not mistaken, this application will be in the snap soon. So the developer will make it easier to work with him.

In the next article we will discuss how to configure our application so that it can already be searched and launched not only from the console, but also from the graphics. Snap packet with service and how to start and stop it.

If you have questions or suggestions, please contact)
Thanks to all.

By article asked0question(s)

1

Comments

Only authorized users can post comments.
Please, Log in or Sign up
  • Last comments
  • Evgenii Legotckoi
    March 9, 2025, 9:02 p.m.
    К сожалению, я этого подсказать не могу, поскольку у меня нет необходимости в обходе блокировок и т.д. Поэтому я и не задавался решением этой проблемы. Ну выглядит так, что вам действитель…
  • VP
    March 9, 2025, 4:14 p.m.
    Здравствуйте! Я устанавливал Qt6 из исходников а также Qt Creator по отдельности. Все компоненты, связанные с разработкой для Android, установлены. Кроме одного... Когда пытаюсь скомпилиров…
  • ИМ
    Nov. 22, 2024, 9:51 p.m.
    Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
  • Evgenii Legotckoi
    Oct. 31, 2024, 11:37 p.m.
    Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
  • A
    Oct. 19, 2024, 5:19 p.m.
    Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html