Help me to build snap package


#1

Hello. I have a script that builds the application I need. I want to pack it in snap. But there are errors that I can not solve. Please help me figure it out.

My snapcraft.yaml:
name: viz
version: '1.2.3'
summary: Seed node for VIZ network
description: |
  Seed node for support VIZ network

grade: devel
confinement: devmode

apps:
  vizd:
    command: $SNAP/bin/vizd --resync
  vizd-replay-blockchain:
    command: $SNAP/bin/vizd --replay-blockchain
  vizd-replay-corrupted:
    command: $SNAP/bin/vizd --replay-if-corrupted

parts:
  viz:
    plugin: autotools
    source: https://github.com/VIZ-World/viz-world
    source-type: git
    source-branch: mainnet-dev
    configflags:
       - -DCMAKE_BUILD_TYPE=Release
    build-packages:
       - build-essential
       - autoconf
       - automake
       - cmake
       - g++
       - libssl-dev
       - libtool
       - make
       - pkg-config
       - python3
       - python3-jinja2
       - libboost-chrono-dev
       - libboost-context-dev
       - libboost-coroutine-dev
       - libboost-date-time-dev
       - libboost-filesystem-dev
       - libboost-iostreams-dev
       - libboost-locale-dev
       - libboost-program-options-dev
       - libboost-serialization-dev
       - libboost-signals-dev
       - libboost-system-dev
       - libboost-test-dev
       - libboost-thread-dev
       - doxygen
       - libncurses5-dev
       - libreadline-dev
       - perl

Error:
Checking connectivity... done.
Submodule path 'thirdparty/fc/vendor/websocketpp': checked out '378437aecdcb1dfe62096ffd5d944bf1f640ccc3'
Building viz 
autoreconf -i
autoreconf: 'configure.ac' or 'configure.in' is required
Failed to run 'autoreconf -i' for 'viz': Exited with code 1.
Verify that the part is using the correct parameters and try again.

#2

I found a mistake:

plugin: cmake

But still there is an error:

[ 39%] Building CXX object thirdparty/fc/CMakeFiles/fc.dir/git_revision.cpp.o
/mysnaps/viz/parts/viz/build/thirdparty/fc/git_revision.cpp:4:40: error: ‘HEAD’ was not declared in this scope
 #define FC_GIT_REVISION_UNIX_TIMESTAMP HEAD-HASH-NOTFOUND
                                        ^
/mysnaps/viz/parts/viz/build/thirdparty/fc/git_revision.cpp:9:46: note: in expansion of macro ‘FC_GIT_REVISION_UNIX_TIMESTAMP’
 const uint32_t git_revision_unix_timestamp = FC_GIT_REVISION_UNIX_TIMESTAMP;
                                              ^
/mysnaps/viz/parts/viz/build/thirdparty/fc/git_revision.cpp:4:45: error: ‘HASH’ was not declared in this scope
 #define FC_GIT_REVISION_UNIX_TIMESTAMP HEAD-HASH-NOTFOUND
                                             ^
/mysnaps/viz/parts/viz/build/thirdparty/fc/git_revision.cpp:9:46: note: in expansion of macro ‘FC_GIT_REVISION_UNIX_TIMESTAMP’
 const uint32_t git_revision_unix_timestamp = FC_GIT_REVISION_UNIX_TIMESTAMP;
                                              ^
/mysnaps/viz/parts/viz/build/thirdparty/fc/git_revision.cpp:4:50: error: ‘NOTFOUND’ was not declared in this scope
 #define FC_GIT_REVISION_UNIX_TIMESTAMP HEAD-HASH-NOTFOUND
                                                  ^
/mysnaps/viz/parts/viz/build/thirdparty/fc/git_revision.cpp:9:46: note: in expansion of macro ‘FC_GIT_REVISION_UNIX_TIMESTAMP’
 const uint32_t git_revision_unix_timestamp = FC_GIT_REVISION_UNIX_TIMESTAMP;
                                              ^
cc1plus: warning: unrecognized command line option ‘-Wno-unused-local-typedef’
thirdparty/fc/CMakeFiles/fc.dir/build.make:2102: recipe for target 'thirdparty/fc/CMakeFiles/fc.dir/git_revision.cpp.o' failed
make[2]: *** [thirdparty/fc/CMakeFiles/fc.dir/git_revision.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-unused-local-typedef’
CMakeFiles/Makefile2:269: recipe for target 'thirdparty/fc/CMakeFiles/fc.dir/all' failed
make[1]: *** [thirdparty/fc/CMakeFiles/fc.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Failed to run 'make -j8' for 'viz': Exited with code 2.
Verify that the part is using the correct parameters and try again.

#3

I found a solution to the problem
How can I do it?

how to fix

The easy way to fix the issue is to delete the libraries/fc folder & fetch them again.

ie,

from the bitshares or STEEM source directory

rm -rf libraries/fc
git submodule update --init --recursive

your make command should work just fine!


#4

please put triple backticks ``` above and below any pasted content, else it gets unreadable in the forum …

to inject extra commands in the build you can use a scriptlet:

    override-build: |
      rm -rf libraries/fc
      git submodule update --init --recursive
      snapcraftctl build

the last line runs the normal build process.


#5

Thanks for the answer!

I do not understand to what content is this?

I did as you wrote, but got an error:

Building viz 
fatal: Not a git repository (or any parent up to mount point /mysnaps)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Failed to run 'override-build': Exit code was 128.

#6

anything you copy/paste into a post when you write it …


#7

Refer 4.5 Fenced code blocks


#8

Tnx!

git submodule update --init --recursive

performed in parts/viz/build, but need to run in parts/viz/src,
therefore an error occurs.
How to fix it?


#9

The content in parts/viz/src shouldn’t be touched as it is copied verbatim to parts/viz/build before building. You should try to avoid this behavior.


#10

Need to use override-pull:

name: viz
version: '1.2.3'
summary: Seed node for VIZ network
description: |
  Seed node for support VIZ network

grade: devel
confinement: devmode

apps:
  vizd:
    command: $SNAP/bin/vizd --resync
  vizd-replay-blockchain:
    command: $SNAP/bin/vizd --replay-blockchain
  vizd-replay-corrupted:
    command: $SNAP/bin/vizd --replay-if-corrupted
  
parts:
  viz:
    plugin: cmake
    source: https://github.com/VIZ-World/viz-world
    source-type: git
    source-branch: mainnet-dev
    configflags:
       - -DCMAKE_BUILD_TYPE=Release
       
    override-pull: |
       git clone https://github.com/VIZ-World/viz-world.git .
       git checkout mainnet-dev
       git submodule update --init --recursive
       
    build-packages:
       - build-essential
       - autoconf
       - automake
       - cmake
       - g++
       - libssl-dev
       - libtool
       - make
       - pkg-config
       - python3
       - python3-jinja2
       - libboost-chrono-dev
       - libboost-context-dev
       - libboost-coroutine-dev
       - libboost-date-time-dev
       - libboost-filesystem-dev
       - libboost-iostreams-dev
       - libboost-locale-dev
       - libboost-program-options-dev
       - libboost-serialization-dev
       - libboost-signals-dev
       - libboost-system-dev
       - libboost-test-dev
       - libboost-thread-dev
       - doxygen
       - libncurses5-dev
       - libreadline-dev
       - perl

Then the pull, biuld and stage passes without errors.
But the prime stage fails:

Priming viz 
Sorry, an error occurred in Snapcraft:
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 9, in <module>
    load_entry_point('snapcraft==2.43.1', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1037, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/_runner.py", line 93, in run
    ctx.forward(lifecyclecli.commands["snap"])
  File "/usr/lib/python3/dist-packages/click/core.py", line 552, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 136, in snap
    project = _execute(steps.PRIME, parts=[], **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 35, in _execute
    lifecycle.execute(step, project_config, parts)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 90, in execute
    executor.run(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 196, in run
    self._create_meta(step, processed_part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 359, in _create_meta
    self.config.validator.schema,
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 109, in create_snap_packaging
    packaging.write_snap_yaml()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 312, in write_snap_yaml
    snap_yaml = self._compose_snap_yaml()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 468, in _compose_snap_yaml
    snap_yaml["apps"] = self._wrap_apps(self._config_data["apps"])
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 567, in _wrap_apps
    self._wrap_app(app, apps[app])
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 575, in _wrap_app
    app[k] = self._wrap_exe(app[k], "{}-{}".format(k, name))
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 546, in _wrap_exe
    with open(exepath, "rb") as exefile:
FileNotFoundError: [Errno 2] No such file or directory: '/mysnaps/viz/prime/$SNAP/bin/vizd'
We would appreciate it if you created a bug report at
https://launchpad.net/snapcraft/+filebug with the above text included.

#11

The first argument of the app’s command must be a relative path from $SNAP to the executable, so the proper value should be bin/vizd instead of $SNAP/bin/vizd


#12

If I specify bin/vizd an error occurs:

FileNotFoundError: [Errno 2] No such file or directory: '/bin/vizd'
We would appreciate it if you created a bug report at
https://launchpad.net/snapcraft/+filebug with the above text included.

If I specify vizd then it works without errors:

Snapping 'viz' \                                                                                                                                                                                    
Snapped viz_1.2.3_amd64.snap

Why?


#13

It means that your viz executable is installed/staged/primed to /viz instead of the typical location /bin/viz

It isn’t necessary but you may try to move it to the bin directory.


#14

I looked at this areas:

/mysnaps/viz/parts/viz/install$ ls -l
total 12
drwxr-xr-x 2 root root 4096 ноя  9 15:25 bin
drwxr-xr-x 5 root root 4096 ноя  9 15:25 include
drwxr-xr-x 3 root root 4096 ноя  9 15:25 lib

/mysnaps/viz/stage$ ls -l
total 12
drwxr-xr-x 2 root root 4096 ноя  9 15:25 bin
drwxr-xr-x 5 root root 4096 ноя  9 15:25 include
drwxr-xr-x 3 root root 4096 ноя  9 15:25 lib
/mysnaps/viz/prime$ ls -l
total 16
drwxr-xr-x 2 root root 4096 ноя  9 15:25 bin
drwxr-xr-x 5 root root 4096 ноя  9 15:25 include
drwxr-xr-x 3 root root 4096 ноя  9 15:25 lib
drwxr-xr-x 3 root root 4096 ноя  9 15:25 meta

Looks fine.


#15

Oh, I mistaken the situation with the classic confinement. When classic confinement is not used the apps.appname.command key accepts command name that is available in the snap runtime command search PATHs, which include the bin directory.

The problem is why bin/vizd isn’t work as expected, but it should be fine as long as snapd can locate the proper executable.


#16

A typical value of the apps.app_name.command key:

    command: >
      bin/hello-launch
      "${SNAP}"/bin/locales-launch
      "${SNAP}"/bin/hello

The right angle bracket simply allows the space-separated command arguments to be folded into multiple lines.


#17

instead of:

you should be able to use:

    override-pull: |
      snapcraftctl pull
      git submodule update --init --recursive

that way you dont need to maintain the URL in two places :slight_smile:


#18

ogra, Lin-Buo-RenRegular, thank you very much!