What’s the best way to distribute a binary application for Linux?

后端 未结 10 1770
梦如初夏
梦如初夏 2020-12-13 02:02

I just finished porting an application from Windows into Linux.
I have to create an installer of the application.
The application is not open source

相关标签:
10条回答
  • 2020-12-13 02:47

    Create a .tar.bz2 archive with the binary, then publish a feed for it, like this:

    <?xml version="1.0" ?>
    <interface uri="http://mysite/myprog.xml"
               xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
      <name>MyProgram</name>
      <summary>what it does</summary>
      <description>A longer description goes here.</description>
    
      <implementation main='bin/myprog'
                      id="sha1new=THEDIGEST"
                      version='1.0'>
        <archive href='http://mysite/myprogram-1.0.tar.bz2'
                 size='10000'/>
      </implementation>
    </interface>
    

    Sign it with your GPG key. You can use the tools on 0install.net to calculate the digest and add the GPG signature for you in the correct format.

    Then, put it on your web-site at the address in the uri attribute. Any user on most Linux distributions (e.g. Ubuntu, Fedora, Debian, Gentoo, ArchLinux, etc) can then install and run your program with:

    0launch http://mysite/myprog.xml
    

    Their system will also check for updates periodically. There are various GUIs for the different desktop environments, but the command-line will work everywhere.

    Also look at some of the existing feeds for inspiration.

    0 讨论(0)
  • 2020-12-13 02:48

    There is no best way (universally speaking). tar.gz the binaries, that should work.

    0 讨论(0)
  • 2020-12-13 02:55

    You may want to try out InstallBuilder. It is crossplatform (runs on Windows, Linux, Mac OS X, Solaris and nearly any other Unix platform out there). It is used by Intel, Motorola, GitHub, MySQL, Nokia/Trolltech and many other companies so you will be in good company :) In addition to binary installers, it can also create cross-distro RPMs and DEB packages.

    InstallBuilder is commercial, but we offer free licenses for open source programs and very significant discounts for mISVs or solo-developers, just drop us a line.

    0 讨论(0)
  • 2020-12-13 02:58

    There were a lot of good answers (mine included :)) here. Although that is more about binary compatibility (which you do need to worry about).

    For installer I would recommend autopackage (we successfully released several versions of our software with it), they did the "installer.sh" part already and more (desktop integration for example).

    You have to be careful and test your upgrade scenarios and stuff, depending on how complex you package structure is, but it is pretty neat overall. I fixed few bugs with dependency handling in 1.2.6, so it should be fine.

    UPDATE: The original question was deleted, so reposting full answer here, ignore all references to autopackage, that was merged into Listaller, not sure if relevant parts survived.

    For standard libraries (like crypto++, pthreads, etc) that are likely to be available in a distribution -- link dynamically and tell users to get them from their distro repository. Or link statically if it is feasible.

    For weird libraries that you must control version of (if you want to deploy Qt4 app on territory of enemy gnomes for example), compile them yourself and install into a private spot only your app knows about.

    Never install private libs into standard places unless you can be sure to not interfere with package systems of all distros you support. (and that they can't interfere with you either).

    Use rpath instead of LD_LIBRARY_PATH, and set it properly for all you binaries and all dlls that reference each other. You can set rpath on you binary to "$ORIGIN;$ORIGIN/../lib;/opt/my/private/libs" and have linker search those places before any standard paths. (have to setsome linker flag for origin to work I think). Make sure to set rpath on your libs too: for example QtGui needs QtCore, and if user happens to install standard package with different version, you absolutely don't want it picked up (exe -> ../lib/QtGui.so (4.4.3) -> /usr/local/lib/QtCore.so (4.4.2) -- a sure way to die early).

    If you compile with any rpath, you can change it later with chrpath, thus making it possible to tweak install location as part of post processing or install script.

    Maintain binary compatibility. GLIB_C is pretty much static for your users, so you should link against some sufficiently old version. 2.3 is a safe bet. You can use APBuild -- a gcc wrapper that enforces GLIB_C version and does few other binary compatibility tricks, so you don't have to compile all you apps on a really old distro.

    If you link to anything statically, it generally will have to be rebuilt with APBuild too, otherwise it is bound to drag newer GLIB_C symbols. All .so's you install privately will naturally have to be built with it too. Sometimes you have to patch third party libs to use older symbols. (I had to patch ruby to return real permissions instead of effective ones, since there is no such functions in older GLIB_C. Still not sure if I broke anything :)).

    For integration with desktop environments (file associations, mime-types, icons, start menu entries, etc) use xdg-utils. Beware though, like everything on linux they don't really like spaces in filenames :). Make sure to test those things on each target distro -- xdg implementations are riddled with bugs and quirks.

    For actual install you can either provide variety of native packages (rpm, deb and a few more), or roll out your own installer, or find installer that works on all distros bypassing native package managers. We successfully used Autopackage (same people who made APbuild) for that.

    0 讨论(0)
提交回复
热议问题