From patchwork Wed Oct 24 16:09:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Bavier X-Patchwork-Id: 23 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CC99916754; Wed, 24 Oct 2018 17:19:16 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id 8B89A165AB for ; Wed, 24 Oct 2018 17:19:11 +0100 (BST) Received: from localhost ([::1]:49329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFLsA-0000Up-Tn for patchwork@mira.cbaines.net; Wed, 24 Oct 2018 12:19:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFLs2-0008RP-V6 for guix-patches@gnu.org; Wed, 24 Oct 2018 12:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFLjO-0004bR-GQ for guix-patches@gnu.org; Wed, 24 Oct 2018 12:10:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36149) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gFLjO-0004ah-4c for guix-patches@gnu.org; Wed, 24 Oct 2018 12:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gFLjN-0005U1-Qi for guix-patches@gnu.org; Wed, 24 Oct 2018 12:10:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#32958] [PATCH] gnu: Add clamav. Resent-From: Eric Bavier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 24 Oct 2018 16:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32958 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Received: via spool by 32958-submit@debbugs.gnu.org id=B32958.154039739621062 (code B ref 32958); Wed, 24 Oct 2018 16:10:01 +0000 Received: (at 32958) by debbugs.gnu.org; 24 Oct 2018 16:09:56 +0000 Received: from localhost ([127.0.0.1]:40407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFLj8-0005TQ-SC for submit@debbugs.gnu.org; Wed, 24 Oct 2018 12:09:56 -0400 Received: from mail.onyx.syn-alias.com ([206.152.134.66]:19488 helo=smtp.centurylink.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFLj4-0005TA-Eq for 32958@debbugs.gnu.org; Wed, 24 Oct 2018 12:09:45 -0400 DKIM-Signature: v=1; a=rsa-sha1; d=centurylink.net; s=ctl201402; c=relaxed/simple; q=dns/txt; i=@centurylink.net; t=1540397376; h=From:Subject:Date:To:MIME-Version:Content-Type; bh=7xS/E3QuBtSs6XUB2Wlh8iFUzb0=; b=fs4EwQDgY6zdKdcCE50QC+i/31UA2yHQ3cATuViQun8ELxSLt9psD80SLjA/623l 7x6ybgU9dEDKRiycci83E2D6oHdFLBzQazIDD8ITQaGlxXBQ8ajnJxlkyIhwc59x AMxDJYWH9mRFpdfOxj1FWuxIz8DPc4AdhVWk80GE8NinOSy/ylK9rBNQjeYyYjOd oWIeuOVW7I8G7YEH+Lm5OXhsiiTZM4x09sl0jpG/CJcKbbBYnPWJsCqemB7udcw2 BtTXeuyrWDEXkNwtCPpKY8vHCZgDipS+a2IUlWP69k+WPcOiKXLB0uuaRDnPhRyt N+niT+swRk1GWOlsA9/HsQ==; X_CMAE_Category: , , X-CNFS-Analysis: v=2.2 cv=dM7ko6Rb c=1 sm=1 tr=0 a=MhzntBxPsQQsyKet5jur4A==:117 a=MhzntBxPsQQsyKet5jur4A==:17 a=KGjhK52YXX0A:10 a=smKx5t2vBNcA:10 a=zSv6zi-ZgakA:10 a=6p5tJGysAAAA:8 a=I_5RNyk1AAAA:8 a=m3aR0QT-H4MJpKmTA9EA:9 a=CjuIK1q_8ugA:10 a=inoG4m36AAAA:8 a=DeTtaYkFAAAA:8 a=mDV3o1hIAAAA:8 a=pGLkceISAAAA:8 a=mnYKqw1PrJMJn6RJHVcA:9 a=NEAV23lmAAAA:8 a=LC3U6v5cAAAA:8 a=DN4mnMEKBpwP8ickrTEA:9 a=tPundid6AAAA:8 a=mK_AVkanAAAA:8 a=iQMAAHXTKVChP_hzixMA:9 a=AkD41feu_dcGFPaPxSQA:9 a=_0FUqLgETZhrmoPQVCW9:22 a=Eh9yxdLE6B1twWrs3SXz:22 a=_Qgj-RFg6mImvLaOgLPg:22 a=u3kAxhQgt60KRQjNhRLG:22 a=_FVE-zBwftR9WsbkzFJk:22 a=krHwHidONISgUGlGLXRm:22 a=aPicV9olnlo_TREvANR5:22 a=3gWm3jAn84ENXaBijsEo:22 X-CM-Score: 0 X-Scanned-by: Cloudmark Authority Engine X-Authed-Username: ZXJpY2JhdmllckBjZW50dXJ5bGluay5uZXQ= Authentication-Results: smtp02.onyx.dfw.sync.lan smtp.user=ericbavier@centurylink.net; auth=pass (LOGIN) Received: from [97.116.181.145] ([97.116.181.145:35168] helo=localhost) by smtp.centurylink.net (envelope-from ) (ecelerity 3.6.25.56547 r(Core:3.6.25.0)) with ESMTPSA (cipher=AES256-GCM-SHA384) id 1B/B0-07019-F3990DB5; Wed, 24 Oct 2018 12:09:35 -0400 Date: Wed, 24 Oct 2018 11:09:27 -0500 From: Eric Bavier Message-ID: <20181024110927.7442ebf1@centurylink.net> In-Reply-To: <87bm8617cv.fsf@cbaines.net> References: <20181006190855.3537-1-mail@cbaines.net> <87d0sm26jc.fsf@cbaines.net> <20181006204919.67c71003@centurylink.net> <87bm8617cv.fsf@cbaines.net> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 32958@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches On Sun, 07 Oct 2018 09:36:16 +0100 Christopher Baines wrote: > Eric Bavier writes: > > > Hi Christopher, > > > > On Sat, 06 Oct 2018 20:56:23 +0100 > > Christopher Baines wrote: > > > >> Tags: moreinfo > >> > >> This probably isn't ready quite yet, as the source release includes > >> quite a bit of bundled software, and I've only had an initial attempt at > >> cleaning it up. I also haven't looked in to the test suite in detail. > > > > I've had a local clamav patch for a while now, and had just recently > > picked it up to dust it off for the 0.100.2 release. Much is similar > > to your patch, and I had started writing a clamd service. Do you mind > > if I merge some parts of your patch into mine and then send it here? > > Not at all Eric, that sounds great :) Here is my small series of patches. 1. Turns on RTTI in llvm by default. 2. Adds a TomsFastMath package that is otherwise bundled in clamav 3. Adds clamav. Uses a patch borrowed from debian to use a system tomsfastmath and uses a system llvm. A few tests that cannot pass inside the build container are skipped. I'm not posting my clamd-service at this time because it needs quite a bit more work. `~Eric From 6f9dfe688d0e7119f477d5418ffbf529c5a3f411 Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Fri, 28 Oct 2016 22:42:59 -0500 Subject: [PATCH 3/4] gnu: Add ClamAV. * gnu/packages/antivirus.scm: New file. * gnu/packages/patches/clamav-system-tomsfastmath.patch, gnu/packages/patches/clamav-config-llvm-libs.patch: New files. * gnu/local.mk (GNU_SYSTEM_MODULES): Add new module. (dist_patch_DATA): Add patches. Co-authored-by: Christopher Baines --- gnu/local.mk | 4 +- gnu/packages/antivirus.scm | 156 ++++++++++++++++++ .../patches/clamav-config-llvm-libs.patch | 14 ++ .../patches/clamav-system-tomsfastmath.patch | 102 ++++++++++++ 4 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/antivirus.scm create mode 100644 gnu/packages/patches/clamav-config-llvm-libs.patch create mode 100644 gnu/packages/patches/clamav-system-tomsfastmath.patch diff --git a/gnu/local.mk b/gnu/local.mk index 62e264f29..be27be6df 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -60,6 +60,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/android.scm \ %D%/packages/animation.scm \ %D%/packages/anthy.scm \ + %D%/packages/antivirus.scm \ %D%/packages/apl.scm \ %D%/packages/apr.scm \ %D%/packages/aspell.scm \ @@ -612,7 +613,8 @@ dist_patch_DATA = \ %D%/packages/patches/ceph-skip-collect-sys-info-test.patch \ %D%/packages/patches/ceph-skip-unittest_blockdev.patch \ %D%/packages/patches/chmlib-inttypes.patch \ - %D%/packages/patches/clang-3.5-libc-search-path.patch \ + %D%/packages/patches/clamav-config-llvm-libs.patch \ + %D%/packages/patches/clamav-system-tomsfastmath.patch \ %D%/packages/patches/clang-3.8-libc-search-path.patch \ %D%/packages/patches/clang-6.0-libc-search-path.patch \ %D%/packages/patches/clang-runtime-asan-build-fixes.patch \ diff --git a/gnu/packages/antivirus.scm b/gnu/packages/antivirus.scm new file mode 100644 index 000000000..f117e3080 --- /dev/null +++ b/gnu/packages/antivirus.scm @@ -0,0 +1,156 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016, 2017, 2018 Eric Bavier +;;; Copyright © 2018 Christopher Baines +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages antivirus) + #:use-module (guix licenses) + #:use-module (guix build-system gnu) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix utils) + #:use-module (gnu packages) + #:use-module (gnu packages autotools) + #:use-module (gnu packages bison) + #:use-module (gnu packages check) + #:use-module (gnu packages compression) + #:use-module (gnu packages curl) + #:use-module (gnu packages cyrus-sasl) + #:use-module (gnu packages flex) + #:use-module (gnu packages llvm) + #:use-module (gnu packages multiprecision) + #:use-module (gnu packages ncurses) + #:use-module (gnu packages pcre) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages tls) + #:use-module (gnu packages web) + #:use-module (gnu packages xml)) + +(define-public clamav + (package + (name "clamav") + (version "0.100.2") + (source (origin + (method url-fetch) + (uri (string-append "https://www.clamav.net/downloads/production/" + "clamav-" version ".tar.gz")) + (sha256 + (base32 + "1mkd41sxbjkfjinpx5b9kb85q529gj2s3d0klysssqhysh64ybja")) + (modules '((guix build utils))) + (snippet + '(begin + (for-each delete-file-recursively + '("win32" ;unnecessary + "libclamav/c++/llvm" ;use system llvm + "libclamunrar")))) ;non-free license + (patches + (search-patches "clamav-system-tomsfastmath.patch" + "clamav-config-llvm-libs.patch")))) + (build-system gnu-build-system) + (native-inputs + `(("bison" ,bison) + ("check" ,check) ;for tests + ("flex" ,flex) + ("pkg-config" ,pkg-config) + ;; The tomsfastmath patch touches configure.ac and Makefile.am + ("autoconf" ,autoconf) + ("automake" ,automake) + ("libtool" ,libtool))) + (inputs + `(("bzip2" ,bzip2) + ("libcurl" ,curl) + ("libjson" ,json-c) + ("libltdl" ,libltdl) + ("libmspack" ,libmspack) + ("llvm" ,llvm-3.6) ;requires <3.7, for JIT/verifier + ("ncurses" ,ncurses) + ("openssl" ,libressl) + ("pcre" ,pcre "bin") ;for pcre-config + ("sasl" ,cyrus-sasl) ;for linking curl with libtool + ("tomsfastmath" ,tomsfastmath) + ("xml" ,libxml2) + ("zlib" ,zlib))) + (arguments + `(#:configure-flags + (let-syntax ((with (syntax-rules () + ((_ name) + (string-append "--with-" name "=" + (assoc-ref %build-inputs name)))))) + (list "--disable-unrar" + "--enable-llvm" + "--with-system-llvm" + "--with-system-libmspack" + "--without-included-ltdl" + (with "xml") + (with "openssl") + (with "libjson") + (with "pcre") + (with "zlib") + (with "libcurl") + ;; For sanity, specifying --enable-* flags turns + ;; "support unavailable" warnings into errors. + "--enable-bzip2" + "--enable-check" + "--sysconfdir=/etc/clamav" + ;; Default database directory needs to be writeable + "--with-dbdir=/var/db/clamav")) + ;; install sample .conf files to %output/etc rather than /etc/clamav + #:make-flags (list (string-append "sysconfdir=" %output "/etc")) + #:phases (modify-phases %standard-phases + (add-after 'unpack 'reconf + (lambda _ (zero? (system* "autoreconf" "-vfi")))) + (add-before 'configure 'patch-llvm-config + (lambda _ + (substitute* '("libclamav/c++/detect.cpp" + "libclamav/c++/ClamBCRTChecks.cpp" + "libclamav/c++/bytecode2llvm.cpp") + (("llvm/Config/config.h") "llvm/Config/llvm-config.h")) + ;; `llvm-config --libfiles` inappropriately lists lib*.a + ;; libraries, rather than the lib*.so's that our llvm + ;; contains. They're used only for listing extra build + ;; dependencies, so ignore them until that's fixed. + (substitute* "libclamav/c++/Makefile.in" + (("@LLVMCONFIG_LIBFILES@") "")) + #t)) + (add-before 'check 'skip-clamd-tests + ;; XXX: The check?_clamd tests fail inside the build + ;; chroot, but pass outside. + (lambda _ + (substitute* "unit_tests/Makefile" + (("check2_clamd.sh.*check4_clamd.sh") "")) + #t))))) + (home-page "https://www.clamav.net") + (synopsis "Antivirus engine") + (description + "Clam AntiVirus is an anti-virus toolkit, designed especially for e-mail +scanning on mail gateways. It provides a number of utilities including a +flexible and scalable multi-threaded daemon, a command line scanner, and +advanced tool for automatic database updates. The core of the package is an +anti-virus engine available in the form of a shared library.") + (license (list license:gpl2+ ;ClamAV itself + license:lgpl2.1 ;libclamav/mspack.[ch] + license:public-domain ;libclamav/7z/*, libclamav/rijndael.[ch], etc... + (package-license bzip2) ;modified bzip2 source in libclamav/nsis + license:bsd-2 ;several files in libclamav + license:bsd-3 ;libclamav/{regex,qsort.c,swf.[ch] + license:ncsa ;libclamav/c++/PointerTracking.cpp + license:zlib ;libclamav/inf*.h + license:x11 ;libclamav/lzw + (license:non-copyleft "libclamav/strlcat.c") ;"OpenBSD" license + license:asl2.0 ;libclamav/yara* + license:expat)))) ;shared/getopt.[ch] diff --git a/gnu/packages/patches/clamav-config-llvm-libs.patch b/gnu/packages/patches/clamav-config-llvm-libs.patch new file mode 100644 index 000000000..054264ee2 --- /dev/null +++ b/gnu/packages/patches/clamav-config-llvm-libs.patch @@ -0,0 +1,14 @@ +Our llvm does not contain a single top-level library, so consult llvm-config +for the libraries that need to be linked against. + +--- clamav-0.100.2/libclamav/c++/configure.ac 2018-09-19 14:29:07.000000000 -0500 ++++ clamav-0.100.2/libclamav/c++/configure.ac 2018-10-06 21:45:09.377249158 -0500 +@@ -105,7 +105,7 @@ + + if test "x$llvm_linking" = "xdynamic"; then + AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`]) +- AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver]) ++ AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs $llvmcomp`]) + AC_SUBST(LLVMCONFIG_LIBFILES, []) + else + if test $llvmver_test -ge 350; then diff --git a/gnu/packages/patches/clamav-system-tomsfastmath.patch b/gnu/packages/patches/clamav-system-tomsfastmath.patch new file mode 100644 index 000000000..07ab79f3f --- /dev/null +++ b/gnu/packages/patches/clamav-system-tomsfastmath.patch @@ -0,0 +1,102 @@ +From 756ff89526b5ffaa7a4f49b1bbecf2ecbd6f85f9 Mon Sep 17 00:00:00 2001 +From: Andreas Cadhalpun +Date: Wed, 11 Mar 2015 20:03:15 +0100 +Subject: add support for system tomsfastmath + +Patch-Name: add-support-for-system-tomsfastmath.patch +--- + configure.ac | 2 ++ + libclamav/Makefile.am | 10 ++++++++-- + libclamav/bignum.h | 6 +++++- + libclamav/xdp.c | 2 +- + m4/reorganization/libs/tomsfastmath.m4 | 12 ++++++++++++ + 5 files changed, 28 insertions(+), 4 deletions(-) + create mode 100644 m4/reorganization/libs/tomsfastmath.m4 + +--- a/configure.ac ++++ b/configure.ac +@@ -82,6 +82,7 @@ m4_include([m4/reorganization/libs/xml.m + m4_include([m4/reorganization/libs/openssl.m4]) + m4_include([m4/reorganization/libs/json.m4]) + m4_include([m4/reorganization/libs/pcre.m4]) ++m4_include([m4/reorganization/libs/tomsfastmath.m4]) + + AM_MAINTAINER_MODE + m4_include([m4/reorganization/libs/libz.m4]) +@@ -285,6 +286,7 @@ else + fi + CL_MSG_STATUS([yara ],[$enable_yara],[$enable_yara]) + CL_MSG_STATUS([fts ],[yes],[$lfs_fts_msg]) ++CL_MSG_STATUS([tomsfastmath],[yes],[$tomsfastmath_msg]) + + + # Yep, downgrading the compiler avoids the bug too: +--- a/libclamav/Makefile.am ++++ b/libclamav/Makefile.am +@@ -496,8 +496,10 @@ libclamav_la_SOURCES += yara_arena.c \ + yara_clam.h + endif + +-libclamav_la_SOURCES += bignum.h\ +- bignum_fast.h\ ++libclamav_la_SOURCES += bignum.h ++ ++if !SYSTEM_TOMSFASTMATH ++libclamav_la_SOURCES += bignum_fast.h\ + tomsfastmath/addsub/fp_add.c\ + tomsfastmath/addsub/fp_add_d.c\ + tomsfastmath/addsub/fp_addmod.c\ +@@ -579,6 +581,10 @@ libclamav_la_SOURCES += bignum.h\ + tomsfastmath/sqr/fp_sqr_comba_generic.c\ + tomsfastmath/sqr/fp_sqr_comba_small_set.c\ + tomsfastmath/sqr/fp_sqrmod.c ++else ++libclamav_la_CFLAGS += $(TOMSFASTMATH_CFLAGS) ++libclamav_la_LIBADD += $(TOMSFASTMATH_LIBS) ++endif + + .PHONY: version.h.tmp + version.c: version.h +--- a/libclamav/bignum.h ++++ b/libclamav/bignum.h +@@ -1,9 +1,13 @@ + #ifndef BIGNUM_H_ + #define BIGNUM_H_ + ++#if HAVE_SYSTEM_TOMSFASTMATH ++#include ++#else + #define TFM_CHECK +- + #include "bignum_fast.h" ++#endif ++ + typedef fp_int mp_int; + #define mp_cmp fp_cmp + #define mp_toradix_n(a,b,c,d) fp_toradix_n(a,b,c,d) +--- a/libclamav/xdp.c ++++ b/libclamav/xdp.c +@@ -57,7 +57,7 @@ + #include "scanners.h" + #include "conv.h" + #include "xdp.h" +-#include "bignum_fast.h" ++#include "bignum.h" + #include "filetypes.h" + + static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz); +--- /dev/null ++++ b/m4/reorganization/libs/tomsfastmath.m4 +@@ -0,0 +1,12 @@ ++dnl Check for system tomsfastmath ++PKG_CHECK_MODULES([TOMSFASTMATH], [tomsfastmath], [have_system_tomsfastmath=yes], [have_system_tomsfastmath=no]) ++ ++AM_CONDITIONAL([SYSTEM_TOMSFASTMATH], [test "x$have_system_tomsfastmath" = "xyes"]) ++ ++if test "x$have_system_tomsfastmath" = "xyes"; then ++ AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [1], [link against system-wide tomsfastmath library]) ++ tomsfastmath_msg="External, $TOMSFASTMATH_CFLAGS $TOMSFASTMATH_LIBS" ++else ++ AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [0], [don't link against system-wide tomsfastmath library]) ++ tomsfastmath_msg="Internal" ++fi -- 2.19.1