Hi
I have simple C++ daemon (backup app) and it use 2 libraries. I want make snap for it. Now I have my project stored locally, but I got an error:
$ snapcraft --debug
Using 'snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Launching a VM.
snap "core18" has no updates available
Using 'snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Failed to pull source: unable to determine source type of 'Src/Libs/Common'.
Check that the URL is correct or consider specifying `source-type` for this part. See `snapcraft help sources` for more information.
I suppose I wrongly set source or source-subdir variables. I assume those variables are related to ../ directory where snapcraft.yaml is stored (in my case it is Snap dir). My snapcraft.yaml file is as follow:
name: backup
version: '0.1'
summary: Simple backup daemon
description: |
Simple backup daemon.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
base: core18
apps:
kopia:
command: desktop-launch $SNAP/bin/Kopia
# environment:
# LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/local/lib
parts:
smtpclient:
plugin: qmake
source: Src/Libs/SmtpClient-for-Qt-1.1
source-subdir: Src/Libs/SmtpClient-for-Qt-1.1
common:
plugin: qmake
source: Src/Libs/Common
source-subdir: Src/Libs/Common
kopia:
after: [desktop-qt5, common, smtpclient]
plugin: qmake
source: Src/Kopia/
source-subdir: Src/Kopia/
options: [LIBS+=-L../../../stage/usr/local/lib]
# options: [QT_INSTALL_LIBS=../../../stage/usr/local/lib]
build-packages:
- build-essential
- qttools5-dev
stage-packages:
- coreutils
- p7zip
- libqt5core5a
- libqt5network5
- libxcomposite1
- libxcursor1
- libxinerama1
- libxrandr2
- libatk1.0-0
- libgtk2.0-0
My questions are:
Is this allowed to create snap from simple local file system based C++ project?
Do I have to create git repository in order to properly create snap?
name: backup
version: '0.1'
summary: Simple backup daemon
description: |
Simple backup daemon.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
base: core18
apps:
kopia:
command: desktop-launch $SNAP/bin/Kopia
parts:
smtpclient:
plugin: qmake
source: ./Src/Libs/SmtpClient-for-Qt-1.1
common:
plugin: qmake
source: ./Src/Libs/Common
kopia:
after: [desktop-qt5, common, smtpclient]
plugin: qmake
source: ./Src/Kopia/
options: [LIBS+=-L../../../stage/usr/local/lib]
build-packages:
- build-essential
- qttools5-dev
stage-packages:
- coreutils
- p7zip
- libqt5core5a
- libqt5network5
- libxcomposite1
- libxcursor1
- libxinerama1
- libxrandr2
- libatk1.0-0
- libgtk2.0-0
Now error is like this:
$ snapcraft --debug
Using 'snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Launching a VM.
snap "core18" has no updates available
Using 'snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Failed to pull source: unable to determine source type of './Src/Libs/SmtpClient-for-Qt-1.1'.
Check that the URL is correct or consider specifying `source-type` for this part. See `snapcraft help sources` for more information.
No. Without ./ it not works at all. But with source-type: local it makes some progress and stops with error:
NotADirectoryError: β/root/project/Src/Libs/Commonβ is not a directory
And in true there is no such dir in virtual machineβ¦
[I corect preformated code - now it is display correctly.]
It is something worng with this? Should be Src Snap sub dir child?
Any help will be appreciated.
./Src/Libs/Common is real sub dir in my project. Root is Kopia3 dir. Your filing is based on proportional font and on squeezing spaces by this crapy forum - with fixed with font you will be able see this hierarchy correctly. Sorry for this side effect but I cant force this forum to use βpreformatedβ style as expected - in most cases it is ignored or used partially (it makes idiotic many posts).
I use pastebin.com to show this file hierarchy correctly: https://pastebin.com/96wYqERw
I follow the testsnap source and source-type and source-subdir style and update my snapcraft.yaml:
name: backup
version: '0.1'
summary: Simple backup daemon
description: |
Simple backup daemon.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
base: core18
apps:
kopia:
command: desktop-launch $SNAP/bin/Kopia
parts:
smtpclient:
plugin: qmake
source: .
source-type: local
source-subdir: Src/Libs/SmtpClient-for-Qt-1.1
common:
plugin: qmake
source: .
source-type: local
source-subdir: Src/Libs/Common
kopia:
after: [common, smtpclient]
plugin: qmake
source: .
source-type: local
source-subdir: Src/Kopia
options: [LIBS+=-L../../../stage/usr/local/lib]
build-packages:
- build-essential
- qttools5-dev
stage-packages:
- coreutils
- p7zip
- libqt5core5a
- libqt5network5
- libxcomposite1
- libxcursor1
- libxinerama1
- libxrandr2
- libatk1.0-0
- libgtk2.0-0
Current log error is here: https://pastebin.com/j4Hi0G0J
My project sources are here: http://szyk.jcom.pl/Kopia3.7z
(How ever it is not strictly open source project, you have my officially permissions to use it in testing purposes)
I checked it if it is compilable and it works as expected. It works also as expected - it does create backup of my files twice a week.
Warning: I use Kubuntu 18.04 Lts as my desktop system. Maybe this problems are due to slighty outdated distro? I. e. I also canβt create flatpack packages due to outdated flatpack in my distro.
I updated my posts in the way embrace code sections in βpreβ and βcodeβ html tags.
Just one quick thing. My build was able to get much further than yours without doing anything β well, almost anything. I had to rename Snap -> snap. I am using the snap version of snapcraft as well as the snap version of multipass. A build on my 18.04 LTS machine eventually failed because it couldnβt find some libs. I will play with this more tomorrow.
Which use virtual machine (need to be enabled in the bios) because It reports an error: βsnap linker differ from system linkerβ (or something like this).
I will be glad if you post here step by step instruction how you build snap package for my Kopia3 on Ubuntu 18.04 system (list of necessary modifications in the project and bash commands will be enough - exclude required install packages - I can manage this on my own).
Thank you for your effort!
This snap builds, installs, and runs (no window tho . . . not sure itβs supposed to have one) on my 18.04 machine with snap versions of snap and multipass. I think the override-build parts are not normally necessary if your project follows certain Makefile protocols like 'make install β etc, but Iβm not familiar with qmake. Anyway, this will get you much further, I think:
name: kopia
version: '0.1'
summary: Simple backup daemon
description: |
Simple backup daemon.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
base: core18
apps:
kopia:
command: desktop-launch $SNAP/bin/Kopia
environment:
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/local/lib
parts:
smtpclient:
plugin: qmake
source: .
source-type: local
source-subdir: Src/Libs/SmtpClient-for-Qt-1.1
build-packages:
- build-essential
- qttools5-dev
common:
plugin: qmake
source: .
source-type: local
source-subdir: Src/Libs/Common
build-packages:
- build-essential
- qttools5-dev
desktop-qt5:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: qt
plugin: make
make-parameters: ["FLAVOR=qt5"]
build-packages:
- qtbase5-dev
- dpkg-dev
stage-packages:
- libxkbcommon0
- ttf-ubuntu-font-family
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libqt5gui5
- libgdk-pixbuf2.0-0
- libqt5svg5 # for loading icon themes which are svg
- try: [appmenu-qt5] # not available on core18
- locales-all
kopia:
after: [common, smtpclient, desktop-qt5]
plugin: qmake
source: .
source-type: local
source-subdir: Src/Kopia
options: [LIBS+=-L$SNAPCRAFT_STAGE/usr/local/lib]
build-packages:
- build-essential
- qttools5-dev
override-build: |
snapcraftctl build
cp Src/Kopia/Kopia $SNAPCRAFT_PART_INSTALL/bin/.
stage-packages:
- coreutils
- p7zip
- libqt5core5a
- libqt5network5
- libxcomposite1
- libxcursor1
- libxinerama1
- libxrandr2
- libatk1.0-0
- libgtk2.0-0
This snap builds, installs, and runs (no window tho . . . not sure itβs supposed to have one) on my 18.04 machine with snap versions of snap and multipass.
There is no window - this is a daemon. But in order to run properly you have to edit ./Systemd/Kopia.ini and run InstallKopia.sh (for now I am not sure how to attach these files to snap and how to call InstallKopia.sh after installation).