The bare array ({[...]}) for top level list of entries is invalid. It
seems better to print empty string than nothing. This is workaround
for broken utils, better is to define a table name.
Addresses: https://github.com/karelzak/util-linux/issues/1339
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'lscpu-json-types' of https://github.com/t-8ch/util-linux:
lscpu: use optional json values
libsmartcols: add support for optional boolean values
lscpu: use json types
The code should be able to keep track about previous content and print
JSON objects separator automatically.
Signed-off-by: Karel Zak <kzak@redhat.com>
* add default sort column, set by scols_sort_table()
* sort tree according to default sort column also in scols_sort_table_by_tree()
The function scols_sort_table() does not sort tree branches if tree
is not enabled. The function scols_sort_table_by_tree() does not care
if tree is enabled and it always follows parent->child relations. For
scols_sort_table_by_tree() we need to follow order in branches if
previously scols_sort_table() has been called.
For example lsblk calls
scols_sort_table(tb, cl);
scols_sort_table_by_tree(tb);
for list-like output (for example lsblk -P) and users assume the
same order as for tree (lsblk --tree).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1940607
Signed-off-by: Karel Zak <kzak@redhat.com>
The whole thing is complicated by the fact that we have two layers
of libraries: e.g. libmount also needs libblkid. If we just tell meson
to make libmount static, this is not enough, because we also need it
to link to a static libblkid. Hence in the case of libs that link to
other libs internally, we need to create a different object with a
a different set of link_with items.
To avoid building the libraries twice, libfdisk and libmount are first
built into an internal "convenience" library, which is then linked into
the static and shared versions as appropriate.
To build: meson build && ninja -C build
To run tests: ninja -C build check
To install for packaging: DESTDIR=/var/tmp/inst ninja -C build install
To install for realz: sudo ninja -C build install
v2:
- Optional items are now based on the 'feature' feature in meson.
Built libraries which are disabled turn into disabler() objects
and also poison any executables which link to them.
What is there:
- building of the binaries and libs and the python module
- installation of binaries, libs, python module, localization files,
man pages, pkgconfig files
- running of tests
- most options to configure build equivalently to the
./configure settings
Partially implemented:
- disabling of stuff when things missing. In the C code, the defines
are all used, so that should be fine. In the build system, some
files should be skipped, but that is probably not always done properly.
Getting this right might require some testing of various build option
combinations to get the details right.
Not implemented:
- static builds of fdisk and other binaries
- things marked with XXX or FIXME
- ???
Differences:
- .la files are not created. They are useless and everybody hates them.
- Requires.private in pkgconfig files are not present in the
autogenerated .pc file. Not sure if they should be there or not. If
necessary, they can be added by hand.
- man pages and systemd units are installed by the install target. Not
sure why 'make install' doesn't do that.
- the split between / and /usr is probably wrong. But it's all pointless
anyway, so maybe we could simplify things but not implementing it at
all under meson?
This patch add support to format multi-line cells (columns with
SCOLS_FL_WRAP) to arrays in JSON output.
For example mountpoints[] in lsblk output:
Normal output:
$ lsblk -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
NAME FSTYPE TYPE MOUNTPOINTS
sdc1 btrfs part /mnt/A
/mnt/test
/mnt/B
JSON output:
$ lsblk -J -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
{
"blockdevices": [
{
"name": "sdc1",
"fstype": "btrfs",
"type": "part",
"mountpoints": [
"/mnt/A",
"/mnt/test",
"/mnt/B"
]
}
]
}
Signed-off-by: Karel Zak <kzak@redhat.com>
The shells are very restrictive about variable names, only [:alnum:]
chars are allowed (and alphabetic chars as the first char). The
library will replace "bad" chars with "_". The char '%' at the end is
replaced by _PCT.
Addresses: https://github.com/karelzak/util-linux/issues/1201
Signed-off-by: Karel Zak <kzak@redhat.com>
Old:
$ echo -e "$(tput smul)A$(tput rmul) B\nC D" | column --table
A B
C D
Fixed:
$ echo -e "$(tput smul)A$(tput rmul) B\nC D" | ./column --table
A B
C D
Addresses: https://github.com/karelzak/util-linux/issues/1011
Signed-off-by: Karel Zak <kzak@redhat.com>
The logger and rtwake time function changes continue the same fixes as
previous commit - use thread safe functions. The libsmartcols condition
removal is possible because width must be greater than tb->termwidth that is
size_t and cannot be smaller than zero. And remove couple FIXME's that are
old and unlikely ever to get fixed.
Reference: 3160589d86
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Now we implement the same thing on more places. Let's add one set of
functions to walk the tree and use it everywhere.
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/grouping.c:115:26: warning: declaration of ‘ln’ shadows a
previous local [-Wshadow]
libsmartcols/src/grouping.c:108:24: note: shadowed declaration is here
Signed-off-by: Sami Kerola <kerolasa@iki.fi>