daemon: add add_sprintf

Bring the add_sprintf function for stringsbuf from the library.

(cherry picked from commit 9b501fa5c6365958de362ecaf0f4e90c147978a2)
daemon: move AUGEAS_ERROR to the common header

Other than for current aug_* API, it will be useful for further code
using augeas directly.

(cherry picked from commit abb0b47e3f1b8b86d2d39c2a91782ac5ed4b134e)
daemon: lvm-filter: use augeas for setting the filter

The way to set the filter for lvm devices was to open lvm.conf, look
for uncommented "filter =" lines and replace the configuration there.
This had the issue that if there is no uncommented filter line, then the
filter cannot be changed at all; considering newer lvm2 releases ship a
sample configuration with no uncommented filter lines, then the old way
became wrong and not sufficient.

Instead, take a copy of the upstream lvm.aug lens, with a simple change
to allow parsing also negative values in configuration, and install it
in the daemon. When asking to change the lvm filter, use augeas making
sure to use this custom lens for the lvm.conf copy used within the
appliance.

(cherry picked from commit c916ea5b680776f70f21ecb224e0e2ca7031c0f4)
daemon: Check return value of end_stringsbuf.

Found by Coverity.

(cherry picked from commit d82cf08ce12ffd86e9f1588881dbe3f0ffd12294)
java: run: Add java/.libs to LD_LIBRARY_PATH so JVM finds the right JNI file.

(cherry picked from commit 6aa64ee3a3f1c990b5f9ce537f2b840273c3c1ba)
java: Fix bogus construction of all RStructList returned values (RHBZ#1073906).

Thanks Maarten on IRC for spotting the problem.

(cherry picked from commit d00840d727e4040a7958ecc613599d6ec2851e53)
java: Split long lines in generated output, and add other whitespace.

No functional change.

(cherry picked from commit 8c219636a272c4288f22392ff27b9c04580aecb4)
java: Factor out common field code in RStructList.

No functional change.

(cherry picked from commit 7a0e71f7331540809db5f539d1a9fe2af050c56a)
java: Use correct Set*Field JNI accessors to set fields of the appropriate type.

Using the wrong accessors (somehow - I have no idea how) caused other
fields in the struct to contain incorrect values.

(cherry picked from commit dff35285e491d1905d38c90d83fed98932cbc3b3)
bindtests: Fill in all fields in dummy lvm_pv struct.

Used for testing RStruct/RStructList return values, but only
in GObject and Java bindings.

(cherry picked from commit ebf8a3654ac4a691d48199adb8e92e182012a8c2)
java: Add regression test for RStruct/RStructList (RHBZ#1073906).

(cherry picked from commit 1ba2e3e14aa6d58bff26646a1328969fda44610f)
daemon: add sysroot_realpath

Similar to sysroot_path, but first resolves (using realpath) the given
path within sysroot.

(cherry picked from commit d7aec9c0d31c14b97c0bb93595d492fdd3741143)
daemon: scrub-file: resolve the path before calling scrub (RHBZ#1099490).

Resolve the given path within the chroot, so scrub can be invoked
outside the chroot on an already-resolved path.

Add few tests in scrub-file for this and other similar issues.

(cherry picked from commit 5d5e66ce334bf61bcc2e672d17d84dd0dd0dd364)
fish: list also aliases in the guestfish help (RHBZ#1103877).

Output also the aliases (telling which function they refer to) in
`guestfish -h`, together with non-alias functions.

(cherry picked from commit 5efbc8922ff3f338deb17b42bc7b63cc1545fcc0)
edit: fix --format documentation (RHBZ#1151738).

Use only --format=FMT as a way to specify a format, as the version
without the equal sign will not work for that.

(cherry picked from commit 145a188f7056d4414adef472e95cad5640d79511)
ls: in CSV mode, always have a checksum field (RHBZ#1151900).

Make sure to output the field for checksum even for non-regular files,
as empty, in CSV output mode. This ensures each line has the same number
of fields, regardless of the file type.

(cherry picked from commit e5befcacc5f7c1a6bd67fcdb92afede1a82d50eb)
cat, diff: avoid double slashes in paths (RHBZ#1151910).

In full_path, skip the trailing slash in the base directory when
different than "/", as the slash will eventually be added when building
the resulting path.
(cherry picked from commit 87941d183f4a96b4d936c2e94a79a60288f0dc74)
lib: fix newline in error output (RHBZ#923355).

(cherry picked from commit 41729c6556bbab7d5532a9a699848aa254b77d27)
customize: firstboot: make sure to run Linux scripts only once

If a script does not finish, hangs, etc, it would be executed again at
the next boot, since the injected firstboot.sh helper removes it only
after it finished.

Before executing a script, move it to another internal subdirectory
(scripts-done) and execute it from there, so it is not run again by
firstboot.sh.  The downside is that now scripts are executed only once
at all, so if a script fails it will not be attempted at the next boot.

Also, remove all the files found in scripts-done, as they have been run
(or at least attempted) in a previous boot.

This fixes RHBZ#1159651.
(cherry picked from commit f8ed15462fbb03c5b19972361f2a2e6fed4c5f02)
customize: firstboot: fix Linux log output

Pass -a to each tee invocation, otherwise just the last one (so only for
the last script executed) will appear in the log file.
(cherry picked from commit 25cad1e62fa73e9cfd9a0e3d1d330165b19339ec)