[lxc-devel] Building without libcap2?
Trent W. Buck
twb at cybersource.com.au
Mon Dec 20 01:09:20 UTC 2010
Michael Tokarev <mjt at tls.msk.ru> writes:
> 18.12.2010 00:12, Michael Tokarev wrote:
> []
>> Capabilities (libcap2) is a tiny library (on my i386
>> userspace it's just a 13Kb shared object), it has _no_
>> external dependencies whatsoever - neither at build nor
>> at run time (it does not use perl for one)
>
> And this is, in turn, incorrect. libcap2 does use
> perl at build time, in order to create list of
> currently defined capabilities from linux/capability.h.
> Two trivial inline perl scripts which are not
> architecture-dependent.
$(GPERF_OUTPUT): cap_names.list.h
perl -e 'print "struct __cap_token_s { const char *name; int index; };\n%{\nconst struct __cap_token_s *__cap_lookup_name(const char *, unsigned int);\n%}\n%%\n"; while ($$l = <>) { $$l =~ s/[\{\"]//g; $$l =~ s/\}.*// ; print $$l; }' < $< | gperf --ignore-case --language=ANSI-C --readonly --null-strings --global-table --hash-function-name=__cap_hash_name --lookup-function-name="__cap_lookup_name" -c -t -m20 $(INDENT) > $@
cap_names.list.h: Makefile $(KERNEL_HEADERS)/linux/capability.h
@echo "=> making $@ from $(KERNEL_HEADERS)/linux/capability.h"
perl -e 'while ($$l=<>) { if ($$l =~ /^\#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$$/) { $$tok=$$1; $$val=$$2; $$tok =~ tr/A-Z/a-z/; print "{\"$$tok\",$$val},\n"; } }' $(KERNEL_HEADERS)/linux/capability.h | fgrep -v 0x > $@
First one becomes
sed -e '1i strict __cap...' -e 's/[{"]//g' -e 's/}.*//'
Second one becomes
sed -rne 'y/A-Z/a-z/' -e 's/^#define[[:space:]]+(cap[_a-z]+)[[:space:]]+([[:digit:]]+)[[:space:]]+$/{"\1",\2},/p'
Untested, may contain GNUisms. YMMV, etc.
More information about the lxc-devel
mailing list