News for hackers. Stuff that matters.
Re:Who helps your Linux distribution run smoothly? Thank a p... by peterwwillis on Thursday February 20, 2014 @12:30PM (#7272186)
In an ideal world, software developers should merely prepare their software to make it easier for packagers to whip up a package based on a template. As a packager I know the pain of having to discover the magical way a piece of code is intended to be built, tracking down its dependencies, and stringing together the means of packaging the finished product based on how the developer assembled it.

Some of the problems you'll face when packaging random code:

  * non-standard version numbers
  * non-standard file paths
  * non-standard configure/make/install routines (or none at all)
  * custom or non-standard build/install tools
  * lack of build/configure/install documentation
  * lack of dependency documentation (including what versions of what dependencies might conflict)
  * code that isn't portable past the desktop the developer wrote it on
  * lack of best practices in setting up multi-user permissions
  * lack of pre/post install scripts
  * lack of simple init scripts
  * lack of minimal configuration files
  * lack of pidfile, log rotation, crontab, environment, and other necessary ops functions
  * patching code just to get them to build and install on your distro
  * bundled, highly patched, third-party software (!!!)
Learning to make packages is easy, but what's even easier is leaving your source in a state that's convenient for packagers of all distros to put it together with little or no effort. Here's some suggestions on how to do this:

1. Make sure your code is portable. Please, try not to hardcode things; use a 'configure'-type process to allow someone to override things like file paths, usernames, and other variable data. Test it on multiple architectures or distributions to see what kind of dependencies you might need to document.

2. PLEASE use a standard configure/make/make install method for your language, and don't write one yourself or depend on some backwards antiquated build tool that nobody uses. Interpreted languages often have their own standard, and compiled languages often use autoconf/automake. Learn them and use them, or at the very least, make an incredibly basic Makefile. And please document the expected permissions and users (chowns/chgrps/chmods).

3. Make sure that you can run one command for each of the configure/make/make install steps. Make sure it can be passed options or environment variables to change the root directory to install into. Make sure your install procedure puts them all in Filesystem Hierarchy Standard paths. Make sure it works as a non-root user; the packager will add the permissions and ownership as metadata to the package.

4. Provide working samples of all the things your app will need. Crontabs, log rotation, pid file tracking for daemons, configuration files, documentation, init scripts, preinstall/postinstall/uninstall scripts.

5. For the love of god, use standard version numbers. Either X.XXXX, X.XX.XX, or X.X.X.X. Pick one and stick with it. Otherwise different distros might actually use different version schemes for their packages which confuses everyone. Please don't include any non-numeric characters (fuck you, openssl! hex doesn't belong in versions!!!)

6. Fully document your ChangeLogs. A packager needs to know that your new release now requires a newer dependency or breaks ABI compatibility, because now they have to modify the metadata of the package to specify what deps will or won't work. Remember that users often install and uninstall different versions of different software.

Re:Who helps your Linux distribution run smoothly? Thank a p... by angersock on Thursday February 20, 2014 @01:36PM (#7272678)
"2. PLEASE use a standard configure/make/make install method for your language, and don't write one yourself or depend on some backwards antiquated build tool that nobody uses. Interpreted languages often have their own standard, and compiled languages often use autoconf/automake. Learn them and use them, or at the very least, make an incredibly basic Makefile. And please document the expected permissions and users (chowns/chgrps/chmods)."

This, a thousand times this.

A basic Makefile is always preferable to me finding a problem with your magical unicorn make system of choice (read: CMake).

Re:Who helps your Linux distribution run smoothly? Thank a p... by Peaker on Friday February 21, 2014 @04:42AM (#7276136)
The problem is that make and all make-based systems that do anything non-trivial (e.g: code generation) are terrible. They all do dependency graph computation prior to starting building, which in the case of code generation + dependency scanning is simply wrong. They all become painful with complexity. They all end up with false negatives, where you have to "make clean" to continue working reliably. They cannot pass parameters to sub-targets in order to build the same target in slightly different ways for different contexts (e.g: Unit tests vs system).
Re:Who helps your Linux distribution run smoothly? Thank a p... by angersock on Friday February 21, 2014 @11:47AM (#7277800)
And yet, for all that, they've worked for 30 years.
Re:Who helps your Linux distribution run smoothly? Thank a p... by Peaker on Saturday February 22, 2014 @11:33AM (#7282543)
For some value of "worked", in which people generally have to "make clean" every now and then, have false negatives that cause crpytic bugs now and then.

Not to mention auto-generated code being extremely difficult to work with.

All companies I worked at had replaced "make" with something in-house, because make is simply horrible.

Re:Who helps your Linux distribution run smoothly? Thank a p... by rcxdude on Thursday February 20, 2014 @02:02PM (#7272840)
cmake is standard enough now that 'magical unicorn' is rather unfair. I've had more difficulty with bare/automake makefile-based systems than with cmake (not that cmake is at all stellar: but it can at least handle spaces in filenames).
Re:Who helps your Linux distribution run smoothly? Thank a p... by matthiasv on Thursday February 20, 2014 @02:37PM (#7273028)
However, CMake sucks in terms of installation paths. Ever tried installing a library into a libdir other than ${prefix}/lib? In the worst case, the developer tries to "fix" this by guessing the architecture and append a magical 64. This works on some distributions but of course not all of them.

I got sick and tired of this situation and wrote a small CMake module [1] that accepts standard configure options to determine the installation path.

[1] http://bloerg.net/2013/10/29/turning-cmake-into-a-good-unix-...

Re:Who helps your Linux distribution run smoothly? Thank a p... by leif on Thursday February 20, 2014 @11:20PM (#7275422)
For other cmake writers out there, this isn't hard.

    set(LIBDIR lib CACHE STRING "lib dir")
    install(${lib_targets} DESTINATION ${LIBDIR})
That's what I do and I am able to build packages with it just fine, that send the libs to wherever the hell they want them.
Re:Who helps your Linux distribution run smoothly? Thank a p... by matthiasv on Friday February 21, 2014 @02:02AM (#7275776)
I am not saying it is hard, I just wanted to point out that CMake does not provide something like this out of the box. Quite the contrary, now every developer has to re-invent this tiny wheel, and I've seen this going wrong several times.
Re:Who helps your Linux distribution run smoothly? Thank a p... by JNRowe on Thursday February 20, 2014 @03:24PM (#7273302)
Not sure where the cut off is or should be, but it doesn't feel standard to me.

On my anecdotal desktop install there are two packages that use cmake; awesome and taskwarrior.

Grep'ing the ebuilds on this Gentoo box, shows me ~400 packages out of ~16000 that use cmake(excluding KDE where it clearly is standard). A lot of the remaining ones seem to be very project specific too(70 leechcraft, 11 fcitx, 10 opensync).

Re:Who helps your Linux distribution run smoothly? Thank a p... by keenerd on Thursday February 20, 2014 @04:23PM (#7273707)
Grepping the PKGBUILDs on Arch looks quite a bit different

Official: 547 out of 5115 use cmake.

Unofficial: 5167 out of 47069 use cmake.

A lot of these offer plain Makefiles too, but cmake is decently popular and hard to dismiss.

Re:Who helps your Linux distribution run smoothly? Thank a p... by peterwwillis on Thursday February 20, 2014 @04:58PM (#7273942)
For me it's not really about difficulty, it's about extra time. Is it going to take me extra time to find, download, install, and learn how to use your unusual build tool? If so, that sucks. Using the most standard/common build tools saves packagers headaches.

Autoconf/Automake are more popular so it's going to be a lot easier on packagers if developers use them. But if they use them incorrectly, packagers will have to hack on the Makefiles when they could have run a bootstrapper like autoreconf.

Re:Who helps your Linux distribution run smoothly? Thank a p... by endgame on Thursday February 20, 2014 @05:02PM (#7273983)
Given the GNU makefile conventions ( https://www.gnu.org/prep/standards/html_node/Makefile-Conven... ), I'd say that packaging with automake is preferable to hand-rolling a Makefile.

If you don't know automake, this tutorial is fantastic: https://www.lrde.epita.fr/~adl/autotools.html

Re:Who helps your Linux distribution run smoothly? Thank a p... by gkya on Thursday February 20, 2014 @07:05PM (#7274565)
I wish I did not.