Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statically linked appstreamcli #128

Closed
probonopd opened this issue Aug 19, 2017 · 11 comments
Closed

Statically linked appstreamcli #128

probonopd opened this issue Aug 19, 2017 · 11 comments

Comments

@probonopd
Copy link

A statically linked appstreamcli of the latest release would be tremendously helpful, since the AppStream spec and the tool are evolving and currently users suffer from outdated versions delivered with distributions. This is especially cumbersome for LTS and Enterprise distributions.

Hence, it would be very welcome if this project could build and provide a static version.

@hughsie
Copy link
Collaborator

hughsie commented Aug 20, 2017

As an aside, I think a web service where you could check AppData would be a really useful thing to have. Personally I'd much rather have appstreamcli in the default flatpak freedesktop runtime, which could be updated nightly.

@probonopd
Copy link
Author

I am trying to do a static build, so I added to the top of CMakeLists.txt:

SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
SET(CMAKE_EXE_LINKER_FLAGS "-static")

But I run into:

[ 44%] Building C object tools/CMakeFiles/appstreamcli.dir/ascli-actions-pkgmgr.c.o
[ 46%] Building C object tools/CMakeFiles/appstreamcli.dir/ascli-actions-misc.c.o
[ 47%] Linking C executable appstreamcli
/usr/bin/ld: attempted static link of dynamic object `../src/libappstream.so.0.11.4'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/appstreamcli.dir/build.make:227: recipe for target 'tools/appstreamcli' failed
make[2]: *** [tools/appstreamcli] Error 1
CMakeFiles/Makefile2:250: recipe for target 'tools/CMakeFiles/appstreamcli.dir/all' failed
make[1]: *** [tools/CMakeFiles/appstreamcli.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

What do I need to do?

@probonopd
Copy link
Author

probonopd commented Aug 20, 2017

Note to self how I made a self-standing AppImage: AppImage/AppImageKit#225 (comment)

@probonopd
Copy link
Author

@ximion let me know whether you would like to have a PR that generates such an AppImage from the Travis CI build. It would be 20 MB large because it would have to bundle all involved libraries and the loader.

@ximion
Copy link
Owner

ximion commented Aug 20, 2017

I am not very keen on shipping any "official" binary here, because I would not use (and test) that, and I prefer people building their own AppStream version.
But if there is anything I can do to make it easier to build a static version, PRs welcome! (building that in Travis would also be fine, just shipping it as an official binary is something I wouldn't like to do currently).
Please note that the next release will likely use Meson exclusively already - I have never built anything statically linked with Meson yet, so I would have to learn how to do it myself first as well.

@hughsie Coincidentally I have written a tiny web service that does exactly that (check AppStream files with ascli), it was part of my D experiments. In order to make the thing available publicly, I would need to basically rewrite some chunks, because the code was just a learning exercise (and it's not very good).
Having AS in the Flatpak runtime would make a lot of sense, but I guess that wouldn't help AppImageKit (also, would it be okay to continuously update AS in the runtime?).

@probonopd
Copy link
Author

@ximion for AppImage, a static build (or a library that still runs on 14.04 LTS) could go into appimagetool (the tool that is used to generate AppImages). Currently appimagetool only verifies AppStream metainfo files if appstreamcli and/or appstream-util is installed on the host (which may well be very outdated and lead to false alarms, or even worse, defective metainfo files).

@ximion
Copy link
Owner

ximion commented Aug 30, 2017

Meson allows you to make a version of appstreamcli that is statically linked to libappstream relatively easily.
Linking in all the other libraries is not done automatically though, I guess that doing that will be a lot more challenging.

With libappstream linked in statically, appstreamcli still requires these libraries:

linux-vdso.so.1
libglib-2.0.so.0
libgobject-2.0.so.0
libgio-2.0.so.0
libxml2.so.2
libyaml-0.so.2 
libstemmer.so.0d 
libc.so.6 
libpcre.so.3 
libpthread.so.0 
libffi.so.6 
libgmodule-2.0.so.0 
libz.so.1 
libselinux.so.1 
libresolv.so.2 
libmount.so.1 
libdl.so.2 
libicui18n.so.57 
libicuuc.so.57 
libicudata.so.57 
liblzma.so.5 
libm.so.6 
libblkid.so.1 
librt.so.1 
libstdc++.so.6 
libgcc_s.so.1 
libuuid.so.1 

(only the dependency on libstemmer can be switched off)

@ximion
Copy link
Owner

ximion commented Oct 1, 2017

@probonopd I don't think there is much I can do in AppStream itself as of now - things might get easy for you when mesonbuild/meson#484 is resolved, and linking libappstream into appstreamcli as static library is also an easy task, but anything more is more tedious to do.

@probonopd
Copy link
Author

OK @ximion thanks for the hint. In the meantime, I am happily using an appstreamcli-x86_64.AppImage that I've put together with this method. Works for me on Ubuntu 14.04 on Travis CI.

@probonopd
Copy link
Author

Maybe a hosted version as a webservice would be a solution - people could POST their file there for validation and get back a response.

@ximion
Copy link
Owner

ximion commented Dec 10, 2017

That could relatively easily be done, but I am very worried about the volume of requests that service would get (and I'd have to figure out where to host it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants