Skip to content

Commit 490983b

Browse files
authored
Merge pull request #1407 from DominiqueDevinci/contrib_cmake
CMake : possibility to override the PYTHON_SITE_PACKAGES_INSTALL_DIR
2 parents 6b4b30a + e88f16f commit 490983b

File tree

4 files changed

+89
-6
lines changed

4 files changed

+89
-6
lines changed

CMakeLists.txt

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,72 @@ message(STATUS " ")
340340
message(STATUS "OVAL:")
341341
message(STATUS "base probe support: ${ENABLE_PROBES}")
342342
message(STATUS "SEAP msgid bit-size: ${SEAP_MSGID_BITS}")
343-
message(STATUS "independent probes: ${ENABLE_PROBES_INDEPENDENT}")
344-
message(STATUS "unix probes: ${ENABLE_PROBES_UNIX}")
345-
message(STATUS "linux probes: ${ENABLE_PROBES_LINUX}")
346-
message(STATUS "solaris probes: ${ENABLE_PROBES_SOLARIS}")
343+
344+
message(STATUS "")
345+
message(STATUS "Independent probes: ${ENABLE_PROBES_INDEPENDENT}")
346+
message(STATUS " Independent family probe: ${OPENSCAP_PROBE_INDEPENDENT_FAMILY}")
347+
message(STATUS " Independent system info probe: ${OPENSCAP_PROBE_INDEPENDENT_SYSTEM_INFO}")
348+
message(STATUS " Independent variable probe: ${OPENSCAP_PROBE_INDEPENDENT_VARIABLE}")
349+
350+
message(STATUS "")
351+
message(STATUS "Independent probes incompatible with WIN32 (WIN32 status: ${IS_WIN32})")
352+
message(STATUS " Independent environmentvariable probe: ${OPENSCAP_PROBE_INDEPENDENT_ENVIRONMENTVARIABLE}")
353+
message(STATUS " Independent environmentvariable58 probe: ${OPENSCAP_PROBE_INDEPENDENT_ENVIRONMENTVARIABLE58}")
354+
message(STATUS " Independent filehash probe: ${OPENSCAP_PROBE_INDEPENDENT_FILEHASH}")
355+
message(STATUS " Independent filehash58 probe: ${OPENSCAP_PROBE_INDEPENDENT_FILEHASH58}")
356+
message(STATUS " Independent sql probe (depends on opendbx): ${OPENSCAP_PROBE_INDEPENDENT_SQL}")
357+
message(STATUS " Independent sql57 probe (depends on opendbx): ${OPENSCAP_PROBE_INDEPENDENT_SQL57}")
358+
message(STATUS " Independent textfilecontent probe: ${OPENSCAP_PROBE_INDEPENDENT_TEXTFILECONTENT}")
359+
message(STATUS " Independent textfilecontent54 probe: ${OPENSCAP_PROBE_INDEPENDENT_TEXTFILECONTENT54}")
360+
message(STATUS " Independent xmlfilecontent probe: ${OPENSCAP_PROBE_INDEPENDENT_XMLFILECONTENT}")
361+
message(STATUS " ")
362+
363+
364+
message(STATUS "Unix probes: ${ENABLE_PROBES_UNIX}")
365+
message(STATUS " Unix dnscache probe: ${OPENSCAP_PROBE_UNIX_DNSCACHE}")
366+
message(STATUS " Unix file probe: ${OPENSCAP_PROBE_UNIX_FILE}")
367+
message(STATUS " Unix fileextendedattribute probe (depends on xattrh): ${OPENSCAP_PROBE_UNIX_FILEEXTENDEDATTRIBUTE}")
368+
message(STATUS " Unix gconf probe (depends on gconf): ${OPENSCAP_PROBE_UNIX_GCONF}")
369+
message(STATUS " Unix interface probe: ${OPENSCAP_PROBE_UNIX_INTERFACE}")
370+
message(STATUS " Unix password probe: ${OPENSCAP_PROBE_UNIX_PASSWORD}")
371+
message(STATUS " Unix process probe: ${OPENSCAP_PROBE_UNIX_PROCESS}")
372+
message(STATUS " Unix process58 probe (depends on CAP): ${OPENSCAP_PROBE_UNIX_PROCESS58}")
373+
message(STATUS " Unix routingtable probe: ${OPENSCAP_PROBE_UNIX_ROUTINGTABLE}")
374+
message(STATUS " Unix runlevel probe: ${OPENSCAP_PROBE_UNIX_RUNLEVEL}")
375+
message(STATUS " Unix shadow probe: ${OPENSCAP_PROBE_UNIX_SHADOW}")
376+
message(STATUS " Unix symlink probe: ${OPENSCAP_PROBE_UNIX_SYMLINK}")
377+
message(STATUS " Unix sysctl probe: ${OPENSCAP_PROBE_UNIX_SYSCTL}")
378+
message(STATUS " Unix uname probe: ${OPENSCAP_PROBE_UNIX_UNAME}")
379+
message(STATUS " Unix xinetd probe: ${OPENSCAP_PROBE_UNIX_XINETD}")
380+
message(STATUS " ")
381+
382+
message(STATUS "Linux probes: ${ENABLE_PROBES_LINUX}")
383+
message(STATUS " Linux dpkginfo probe (depends on aptpkg): ${OPENSCAP_PROBE_LINUX_DPKGINFO}")
384+
message(STATUS " Linux iflisteners probe: ${OPENSCAP_PROBE_LINUX_IFLISTENERS}")
385+
message(STATUS " Linux inetlisteningservers probe: ${OPENSCAP_PROBE_LINUX_INETLISTENINGSERVERS}")
386+
message(STATUS " Linux partition probe (depends on blkid): ${OPENSCAP_PROBE_LINUX_PARTITION}")
387+
message(STATUS " Linux rpminfo probe (depends on rpm): ${OPENSCAP_PROBE_LINUX_RPMINFO}")
388+
message(STATUS " Linux rpmverify probe (depends on rpm): ${OPENSCAP_PROBE_LINUX_RPMVERIFY}")
389+
message(STATUS " Linux rpmverifyfile probe (depends on rpm): ${OPENSCAP_PROBE_LINUX_RPMVERIFYFILE}")
390+
message(STATUS " Linux rpmverifypackage probe (depends on rpm): ${OPENSCAP_PROBE_LINUX_RPMVERIFYPACKAGE}")
391+
message(STATUS " Linux selinuxboolean probe (depends on selinux): ${OPENSCAP_PROBE_LINUX_SELINUXBOOLEAN}")
392+
message(STATUS " Linux selinuxsecuritycontext probe (depends on selinux): ${OPENSCAP_PROBE_LINUX_SELINUXSECURITYCONTEXT}")
393+
message(STATUS " Linux systemdunitdependency probe (depends on dbus): ${OPENSCAP_PROBE_LINUX_SYSTEMDUNITDEPENDENCY}")
394+
message(STATUS " Linux systemdunitproperty probe (depends on dbus): ${OPENSCAP_PROBE_LINUX_SYSTEMDUNITPROPERTY}")
347395
message(STATUS " ")
348396

397+
message(STATUS "Solaris probes: ${ENABLE_PROBES_SOLARIS}")
398+
message(STATUS " Solaris isainfo probe: ${OPENSCAP_PROBE_SOLARIS_ISAINFO}")
399+
message(STATUS " ")
400+
401+
402+
message(STATUS "Windows probes: ${ENABLE_PROBES_WINDOWS}")
403+
message(STATUS " Windows accesstoken probe: ${OPENSCAP_PROBE_WINDOWS_ACCESSTOKEN}")
404+
message(STATUS " Windows registry probe: ${OPENSCAP_PROBE_WINDOWS_REGISTRY}")
405+
message(STATUS " Windows wmi57 probe: ${OPENSCAP_PROBE_WINDOWS_WMI57}")
406+
message(STATUS " ")
407+
408+
349409
message(STATUS "Language bindings:")
350410
message(STATUS "python3 bindings: ${ENABLE_PYTHON3}")
351411
message(STATUS "perl bindings: ${ENABLE_PERL}")

docs/developer/developer.adoc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ pcre-devel perl-XML-Parser perl-XML-XPath perl-devel python36-devel rpm-devel sw
7575
bzip2-devel gcc-c++
7676
----
7777

78-
On Ubuntu 16.04, the command to install the build dependencies is:
78+
On Ubuntu 16.04, Debian 8 or Debian 9, the command to install the build dependencies is:
7979

8080
----
8181
sudo apt-get install -y cmake libdbus-1-dev libdbus-glib-1-dev libcurl4-openssl-dev \
8282
libgcrypt20-dev libselinux1-dev libxslt1-dev libgconf2-dev libacl1-dev libblkid-dev \
8383
libcap-dev libxml2-dev libldap2-dev libpcre3-dev python-dev swig libxml-parser-perl \
84-
libxml-xpath-perl libperl-dev libbz2-dev librpm-dev g++
84+
libxml-xpath-perl libperl-dev libbz2-dev librpm-dev g++ libapt-pkg-dev
8585
----
8686

8787
When you have all the build dependencies installed you can build the library.
@@ -97,6 +97,22 @@ $ cd build/
9797
$ cmake ../
9898
$ make
9999
----
100+
101+
On Ubuntu 18.04 and potentially other distro, the python3 dist-packages path is wrong.
102+
If the following command:
103+
104+
----
105+
$ python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
106+
----
107+
108+
returns "/usr/local/lib/python3/dist-packages" instead of a path like
109+
"/usr/local/lib/python3.6/dist-packages", you must override this path,
110+
otherwise you will not be able to import openscap_api.
111+
112+
----
113+
$ cmake ../ -DPYTHON_SITE_PACKAGES_INSTALL_DIR=/usr/local/lib/python3.6/dist-packages
114+
----
115+
100116
--
101117

102118
. *Build the HTML documentation*

swig/python3/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ add_custom_command(OUTPUT ${PYTHON_COMPILED_FILES}
2424
)
2525
add_custom_target(python3_compile ALL DEPENDS ${PYTHON_COMPILED_FILES})
2626

27+
if(NOT PYTHON_SITE_PACKAGES_INSTALL_DIR)
2728
execute_process(COMMAND
2829
${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True, prefix='${CMAKE_INSTALL_PREFIX}'))"
2930
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_INSTALL_DIR
3031
OUTPUT_STRIP_TRAILING_WHITESPACE
3132
)
33+
endif()
34+
3235
install(TARGETS ${SWIG_MODULE_openscap_py_REAL_NAME}
3336
DESTINATION ${PYTHON_SITE_PACKAGES_INSTALL_DIR}
3437
)

utils/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ if(ENABLE_OSCAP_UTIL_DOCKER)
4545
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
4646
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
4747
)
48+
49+
if(NOT PYTHON_SITE_PACKAGES_INSTALL_DIR)
4850
execute_process(COMMAND
4951
${OSCAP_DOCKER_PYTHON} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False, False, prefix='${CMAKE_INSTALL_PREFIX}'))"
5052
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_INSTALL_DIR
5153
OUTPUT_STRIP_TRAILING_WHITESPACE
5254
)
55+
endif()
56+
5357
install(DIRECTORY oscap_docker_python
5458
DESTINATION ${PYTHON_SITE_PACKAGES_INSTALL_DIR}
5559
)

0 commit comments

Comments
 (0)