add libjq as a module in flatpak

99 views Asked by At

I initially created a simple flatpak manifest , but then the following error occured: PrayerApp: error while loading shared libraries: libjq.so.1: cannot open shared object file: No such file or directory

I then tried to add jq as a module, like this:

{
  "app-id": "com.github.MaxBrandtner.Test",
  "runtime": "org.gnome.Platform",
  "runtime-version": "44",
  "sdk": "org.gnome.Sdk",
  "command": "Test",
  "modules": [
    {
      "name": "Test",
      "buildsystem": "meson",
      "sources": [
        {
          "type": "dir",
          "path": "."
        }
      ]
    },
    {
      "name": "jq",
      "buildsystem": "simple",
      "sources": [
        {
          "type": "git",
          "url": "https://github.com/jqlang/jq"
        }
      ],
      "build-commands": [
        "git submodule update --init",
        "autoreconf -i",
        "./configure --with-oniguruma=builtin",
        "make -j8",
        "make check",
        "make install"
      ]
    }
  ]
}

Normally you would call sudo make install, but since sudo isn't an available command in the flatpak-build environment I tried make install instead.

But the following flatpak manifest failed with the following error:

make[4]: Entering directory '/run/build/jq/modules/oniguruma/src'
 /usr/bin/mkdir -p '/usr/local/lib'
/usr/bin/mkdir: cannot create directory ‘/usr/local’: Read-only file system
make[4]: *** [Makefile:478: install-libLTLIBRARIES] Error 1
make[4]: Leaving directory '/run/build/jq/modules/oniguruma/src'
make[3]: *** [Makefile:722: install-am] Error 2
make[3]: Leaving directory '/run/build/jq/modules/oniguruma/src'
make[2]: *** [Makefile:499: install-recursive] Error 1
make[2]: Leaving directory '/run/build/jq/modules/oniguruma'
make[1]: *** [Makefile:1189: install-recursive] Error 1
make[1]: Leaving directory '/run/build/jq'
make: *** [Makefile:1710: install] Error 2
Error: module jq: Child process exited with code 2

How can I configure the manifest file correctly. (Note I don't know if I need to do the same to for libcurl)? I know I still need to add the wayland and x11 socket as well as give networking permissions. (I am using -ljq as a linker option instead of using the libjq pkgconfig, because the package config has been added in version 1.7 and many systems are still on jq 1.6)(The program is written in c and a libadwaita app).

1

There are 1 answers

0
MaxBrandtner On

The issue lay with ./configure not having been provided with the following option ./configure --with-oniguruma=builtin --prefix=/app --libdir=/app/lib. The corrected json is

{
        "app-id":"com.github.MaxBrandtner.Test",
        "runtime":"org.gnome.Platform",
        "runtime-version":"44",
        "sdk":"org.gnome.Sdk",
        "command":"Test",
        "modules":[
                {
                        "name":"Test",
                        "buildsystem":"meson",
                        "sources":[
                                {
                                "type":"dir",
                                "path":"."
                                }
                        ]
                },
                {
                        "name":"jq",
                        "buildsystem":"simple",
                        "sources":[
                                {
                                        "type":"git",
                                        "url":"https://github.com/jqlang/jq"
                                }
                        ],
                        "build-commands":[
                                "git submodule update --init",
                                "autoreconf -i",
                                "./configure --with-oniguruma=builtin --prefix=/app --libdir=/app/lib",
                                "make -j8",
                                "make check",
                                "make install"
                        ]
                }

        ]
}