Mumble Snap - Protobuf Issues


#1

I have had some discussion with @elopio within Rocketchat, but thought maybe I should move the larger discussion into the forum for greater visibility.

I’m working on the Mumble snap (Repo Here), and have been running into some issues running the snapcraft cleanbuild command.

Error:

make[1]: Entering directory '/build_mumble/parts/mumble/build/src/mumble'
make -f Makefile.Release
make[2]: Entering directory '/build_mumble/parts/mumble/build/src/mumble'
protoc --cpp_out=. -I. -I.. ../../../src/src/Mumble.proto
/usr/lib/x86_64-linux-gnu/qt4/bin/uic ../../../src/src/mumble/ConfigDialog.ui -o ui_ConfigDialog.h
/usr/lib/x86_64-linux-gnu/qt4/bin/uic ../../../src/src/mumble/MainWindow.ui -o ui_MainWindow.h
/usr/lib/x86_64-linux-gnu/qt4/bin/uic ../../../src/src/mumble/ConnectDialogEdit.ui -o ui_ConnectDialogEdit.h
../../../src/src/Mumble.proto: File does not reside within any path specified using --proto_path (or -I).  You must specify a --proto_path which encompasses this file.  Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
Makefile.Release:440: recipe for target 'Mumble.pb.cc' failed
make[2]: *** [Mumble.pb.cc] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/build_mumble/parts/mumble/build/src/mumble'
Makefile:34: recipe for target 'release' failed
make[1]: *** [release] Error 2
make[1]: Leaving directory '/build_mumble/parts/mumble/build/src/mumble'
Makefile:189: recipe for target 'sub-src-mumble-make_default-ordered' failed
make: *** [sub-src-mumble-make_default-ordered] Error 2
Command '['/bin/sh', '/tmp/tmpgiqxzrmm', 'make', '-j4']' returned non-zero exit status 2

It seems like the protobuf patch isn’t working correctly, or I applied it incorrectly.

Patchfile:

diff --git a/src/mumble.pri b/src/mumble.pri
index f05be47..0683fda 100644
--- a/src/mumble.pri
+++ b/src/mumble.pri
@@ -17,7 +17,7 @@ pbh.input = PROTOBUF
 pbh.CONFIG *= no_link explicit_dependencies target_predeps
 
 pb.output = ${QMAKE_FILE_BASE}.pb.cc
-pb.commands = protoc --cpp_out=. -I. -I.. ${QMAKE_FILE_NAME}
+pb.commands = protoc --cpp_out=. -I. -I../../.. ${QMAKE_FILE_NAME}
 pb.input = PROTOBUF
 pb.CONFIG *= no_link explicit_dependencies
 pb.variable_out = SOURCES

#2

I think there is a bug here, because the qmake plugin uses src/main.pro during build, when it should use build/main.pro

With these changes, I can get your snap built:

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 0037a23..41ae2b2 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -19,12 +19,15 @@ parts:
     plugin: qmake
     source: https://github.com/mumble-voip/mumble.git
     source-tag: 1.2.19
-    prepare: git apply $SNAPCRAFT_STAGE/mumble.patch
+#    prepare: git apply $SNAPCRAFT_STAGE/mumble.patch
     qt-version: qt4
     options:
       - CONFIG+=no-server -recursive
-    project-files:
-      - "main.pro"
+#    project-files:
+#      - main.pro
+    install: |
+      mkdir $SNAPCRAFT_PART_INSTALL/bin
+      cp -R release/* $SNAPCRAFT_PART_INSTALL/bin
     build-packages:
       - build-essential
       - pkg-config

Apparently, the patch is not required. I’m sorry to have suggested that way.

@kyrofa @sergiusens take a look here: https://github.com/snapcore/snapcraft/blob/master/snapcraft/plugins/qmake.py#L108
Wouldn’t it be easier to set cwd to builddir in every plugin?


#3

Is this something on which we should build with the proposed changes to the YAML, or investigate further into the plugin changes?

edit - successful cleanbuild!!

If you don’t mind, a few follow up questions:

  • I’m assuming the following could be stripped out of my original YAML:
  patches:
    plugin: dump
    source: snap/patches
    prime: [-*]

I assume this as we are not patching anything anymore. Then I can dump the patch files in my repo as well.

  • Why do the addition and copy of those files make the build work now?

#4

So while the build works, the app has a ton of issues on run. So I’ll move onto that.


#5

Yes, you can remove the patches part now, and remove the patch file.

This is something that needs to be fixed in snapcraft.

I don’t understand your last question, we are not copying any new files. The trick was to remove the project-files, which is not needed anyway because qmake will use it even if not specified. Then the build steps runs everything from the src dir and it works. The snapcraft bug is that it should run everything from the build dir.


#6

In the revised YAML, you had added:

    install: |
      mkdir $SNAPCRAFT_PART_INSTALL/bin
      cp -R release/* $SNAPCRAFT_PART_INSTALL/bin

I’m just unsure of why that made it work. :slight_smile:


#7

Ah, yes, that part. Their qmake file leaves the compiled files in the release directory. Some projects, like this one, don’t have a proper install task.

So we need to move the files from the release dir, to the directory that will be copied inside the snap. That directory is parts/mumble/install, or $SNAPCRAFT_PART_INSTALL. Everything you put in there will end up in the snap. If you don’t put anything in there, the snap will be empty.


#8

Thanks for the explanation!

Lots of edge cases to learn. There seems to be a variety of ways to accomplish things within the snap ecosystem. Is there somewhere to read up on all of these things? For example I was trying look up and read up on things like “SNAPCRAFT_PART_INSTALL”.


#9

You can read about the install keyword, and the variable, here:

https://snapcraft.io/docs/build-snaps/scriptlets


#10

I think this is fixed now with this PR. I can’t test it here because I’m on a network which blocks ports. The application launches, and goes through the audio wizard fine, presents an indicator and operates as I expect mumble to work.