New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake: Support to build deb, rpm, & macOS pkg packages #228
Merged
micahsnyder
merged 4 commits into
Cisco-Talos:main
from
micahsnyder:CLAM-1533-macos-installer
Aug 18, 2021
Merged
CMake: Support to build deb, rpm, & macOS pkg packages #228
micahsnyder
merged 4 commits into
Cisco-Talos:main
from
micahsnyder:CLAM-1533-macos-installer
Aug 18, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9931d09
to
7b5a77d
Compare
8a58bea
to
9a8bcdd
Compare
1ee317f
to
e9cbcdf
Compare
CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
The Jenkinsfile renames the tarball, removing the version string suffix. This is problematic because A) we want that suffix when we publish release candidates and B) the tarball should extract with the same directory name as the tarball name.
e9cbcdf
to
2960acb
Compare
|
Fixed merge conflict, which was in changes that I'd made to the INSTALL.md. I removed the changes to INSTALL.md since that got an overhaul just a couple days ago and my changes were no longer relevant. This is ready for review. I'm certain there are improvements to be made, but I think it's in good working order and we can build off of this later based on user feedback. |
Xcode (and perhaps some other generators?) do not like targets that have only object files. See: https://cmake.org/cmake/help/latest/command/add_library.html#object-libraries And: https://cmake.org/pipermail/cmake/2016-May/063479.html This issue manifests when using `-G Xcode` on macOS as the library dylibs being missing when linking with other binaries. This commit removes the object libraries for libclamav, libfreshclam, libclamunrar_iface, libclamunrar, libclammspack, and (lib)common because they were used by static or shared libs that didn't themselves have any added sources. Add getter & setter for the debug flag, so it isn't referenced by unit tests or other code that links with libclamav. This is needed because global variables are exported symbols on Windows.
If ncurses or pdcurses are static libraries, they are not properly detected. First, the user compiling clamav needs to specify if the include path is for NCURSES or PDCURSES, which will differentiate the two. I've updated the INSTALL.md file to show this. Second, the wrong variable was being used to add the include path to the Curses::curses target, which means that clamdtop would fail to include ncurses.h. I fixed this.
2960acb
to
7fd1e08
Compare
ragusaa
approved these changes
Aug 18, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.


CMake/CPack is already used to build:
This commit adds support for building:
This should also enable building FreeBSD packages, but while I was able
to build all of the static dependencies using Mussels, CMake/CPack 3.20
provided by the FreeBSD pkg system didn't appear to have the the FreeBSD
generator.
The package names are will be in this format:
clamav-...
This includes changing the Windows .zip and .msi installer names.
E.g.:
Notes about building the packages:
I've only tested this with building ClamAV using static dependencies that
I build using the clamav_deps "host-static" recipes from the "clamav"
Mussels cookbook. Eg:
msl build clamav_deps -t host-static
Here's an example configuration to build clam in this way, installing to
/usr/local/clamav:
Then
makeand then one of these, depending on the platform:On macOS you'll need to
pip3 install markdownso that the NEWS.md file canbe converted to html so it will render in the installer.
On RPM-based systems, you'll need rpmbuild (install rpm-build)
This commit also fixes an issue where the html manual (if present) was
not correctly added to the Windows (or now other) install packages.