From 315a3680124f33ddbd6d694b5fba19fe1938e682 Mon Sep 17 00:00:00 2001 From: aixiao Date: Tue, 4 Apr 2023 15:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0arm=E6=9E=B6=E6=9E=84?= =?UTF-8?q?=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 12 +- clamav/build-libclamav.sh | 10 +- clamav/libclamav_rust/Cargo.lock | 4 +- get_architecture.sh | 286 +++++++++++++++++++++++++++++++ 4 files changed, 300 insertions(+), 12 deletions(-) create mode 100644 get_architecture.sh diff --git a/Makefile b/Makefile index ac42a99..d0b9a01 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ else CMAKE := cmake endif -ARCH := $(shell uname -m) +ARCH := $(shell bash get_architecture.sh) IPTC_CFLAGS += -DHAVE_CONFIG_H -I./libiptc -D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_REENTRANT @@ -27,14 +27,16 @@ ip2region_CFLAGS += -Os -g -Wall -I/ip2region -c ip2region_LIB += ip2region.o xdb_searcher.o CLAMAV_CFLAGS += -DHAVE_CONFIG_H -I./clamav/libclamav -I./clamav/ -I./clamav/libclamunrar_iface -I./clamav/common -isystem ./clamav/ -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIE -Wall -Wextra -Wformat-security -std=gnu90 -CLAMAV_LIB += ./clamav/clamscan/clamscan.c.o ./clamav/clamscan/manager.c.o ./clamav/libcommon.a -Wl,-rpath,/lib /lib/libclamav.so.11.0.0 -lmspack ./clamav/libclamav_rust/$(ARCH)-unknown-linux-gnu/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lssl -lcrypto -lz -lcurl -lsystemd +CLAMAV_LIB += ./clamav/clamscan/clamscan.c.o ./clamav/clamscan/manager.c.o ./clamav/libcommon.a -Wl,-rpath,/lib /lib/libclamav.so.11.0.0 -lmspack ./clamav/libclamav_rust/$(ARCH)/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lssl -lcrypto -lz -lcurl -lsystemd FRESHCLAM_CFLAGS += -DHAVE_CONFIG_H -I./clamav/libfreshclam -I./clamav/common -I./clamav/libclamav -I./clamav/libclamunrar_iface -isystem ./clamav/ -isystem ./clamav/libclamav_rust -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIE -Wall -Wextra -Wformat-security -std=gnu90 -FRESHCLAM_LIB += ./clamav/freshclam/freshclam.c.o ./clamav/freshclam/execute.c.o ./clamav/freshclam/notify.c.o -Wl,-rpath,/lib /lib/libfreshclam.so.2.0.2 ./clamav/libcommon.a -Wl,-rpath,/lib /lib/libclamav.so.11.0.0 -lmspack ./clamav/libclamav_rust/$(ARCH)-unknown-linux-gnu/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lz -lsystemd -lcurl -lssl -lcrypto -lresolv +FRESHCLAM_LIB += ./clamav/freshclam/freshclam.c.o ./clamav/freshclam/execute.c.o ./clamav/freshclam/notify.c.o -Wl,-rpath,/lib /lib/libfreshclam.so.2.0.2 ./clamav/libcommon.a -Wl,-rpath,/lib /lib/libclamav.so.11.0.0 -lmspack ./clamav/libclamav_rust/$(ARCH)/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lz -lsystemd -lcurl -lssl -lcrypto -lresolv LIBCOMMON__CFLAGS += -DHAVE_CONFIG_H -I./clamav/common -I./clamav/libclamav -I./clamav/ -I./clamav/libclamunrar_iface -isystem ./clamav/ -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIC -Wall -Wextra -Wformat-security LIBCOMMON_LIB += ./clamav/common/cert_util.c.o ./clamav/common/actions.c.o ./clamav/common/clamdcom.c.o ./clamav/common/getopt.c.o ./clamav/common/hostid.c.o ./clamav/common/idmef_logging.c.o ./clamav/common/misc.c.o ./clamav/common/optparser.c.o ./clamav/common/output.c.o ./clamav/common/tar.c.o ./clamav/common/linux/cert_util_linux.c.o + + all: conf.o rhost.o libiptc.o ccronexpr.o $(CC) $(ip2region_CFLAGS) ip2region/ip2region.c $(CC) $(ip2region_CFLAGS) ip2region/xdb_searcher.c @@ -54,7 +56,7 @@ all: conf.o rhost.o libiptc.o ccronexpr.o libclamav_rust: cd clamav/libclamav_rust && $(CMAKE) -E env CARGO_CMD=build CARGO_TARGET_DIR=./ MAINTAINER_MODE=OFF RUSTFLAGS="" \ - cargo build --target $(ARCH)-unknown-linux-gnu --target-dir ./ + cargo build --target $(ARCH) --target-dir ./ cd .. libclamav: @@ -85,5 +87,5 @@ clean: rm -rf ${PWD}/clamav/libclamav.so.11 rm -rf ${PWD}/clamav/libfreshclam.so.2 rm -rf clamav/libclamav_rust/debug - rm -rf clamav/libclamav_rust/$(ARCH)-unknown-linux-gnu + rm -rf clamav/libclamav_rust/$(ARCH) diff --git a/clamav/build-libclamav.sh b/clamav/build-libclamav.sh index 67c9d37..76ed92b 100644 --- a/clamav/build-libclamav.sh +++ b/clamav/build-libclamav.sh @@ -251,12 +251,12 @@ gcc -DHAVE_CONFIG_H -DTFM_CHECK -DTHIS_IS_LIBCLAMAV -Dclamav_EXPORTS -I./libcla gcc -DHAVE_CONFIG_H -DTFM_CHECK -DTHIS_IS_LIBCLAMAV -Dclamav_EXPORTS -I./libclamunrar_iface -I./libclamav/.. -I./libclamav -isystem /usr/include/libxml2 -isystem ./ -isystem /usr/include/json-c -isystem ./libclamav_rust -fPIC -Wall -Wextra -Wformat-security -std=gnu90 -o ./libclamav/gif.c.o -c ./libclamav/gif.c -ARCH=$(uname -m) +ARCH=$(bash ../get_architecture.sh) cc -fPIC -shared -Wl,-soname,libclamav.so.11 -o libclamav.so.11.0.0 \ ./libclamav/regex/strlcpy.c.o ./libclamav/regex/regcomp.c.o ./libclamav/regex/regerror.c.o ./libclamav/regex/regexec.c.o ./libclamav/regex/regfree.c.o ./libclamav/7z/7zAlloc.c.o ./libclamav/7z/7zBuf.c.o ./libclamav/7z/7zBuf2.c.o ./libclamav/7z/7zCrc.c.o ./libclamav/7z/7zCrcOpt.c.o ./libclamav/7z/7zDec.c.o ./libclamav/7z/7zFile.c.o ./libclamav/7z/7zIn.c.o ./libclamav/7z/7zStream.c.o ./libclamav/7z/Bcj2.c.o ./libclamav/7z/Bra.c.o ./libclamav/7z/Bra86.c.o ./libclamav/7z/BraIA64.c.o ./libclamav/7z/CpuArch.c.o ./libclamav/7z/Delta.c.o ./libclamav/7z/Lzma2Dec.c.o ./libclamav/7z/LzmaDec.c.o ./libclamav/7z/Ppmd7.c.o ./libclamav/7z/Ppmd7Dec.c.o ./libclamav/7z/Xz.c.o ./libclamav/7z/XzCrc64.c.o ./libclamav/7z/XzDec.c.o ./libclamav/7z/XzIn.c.o ./libclamav/yara_compiler.c.o ./libclamav/yara_exec.c.o ./libclamav/yara_hash.c.o ./libclamav/yara_parser.c.o ./libclamav/yara_arena.c.o ./libclamav/yara_grammar.c.o ./libclamav/yara_lexer.c.o ./libclamav/tomsfastmath/addsub/fp_add.c.o ./libclamav/tomsfastmath/addsub/fp_add_d.c.o ./libclamav/tomsfastmath/addsub/fp_addmod.c.o ./libclamav/tomsfastmath/addsub/fp_cmp.c.o ./libclamav/tomsfastmath/addsub/fp_cmp_d.c.o ./libclamav/tomsfastmath/addsub/fp_cmp_mag.c.o ./libclamav/tomsfastmath/addsub/fp_sub.c.o ./libclamav/tomsfastmath/addsub/fp_sub_d.c.o ./libclamav/tomsfastmath/addsub/fp_submod.c.o ./libclamav/tomsfastmath/addsub/s_fp_add.c.o ./libclamav/tomsfastmath/addsub/s_fp_sub.c.o ./libclamav/tomsfastmath/bin/fp_radix_size.c.o ./libclamav/tomsfastmath/bin/fp_read_radix.c.o ./libclamav/tomsfastmath/bin/fp_read_signed_bin.c.o ./libclamav/tomsfastmath/bin/fp_read_unsigned_bin.c.o ./libclamav/tomsfastmath/bin/fp_reverse.c.o ./libclamav/tomsfastmath/bin/fp_s_rmap.c.o ./libclamav/tomsfastmath/bin/fp_signed_bin_size.c.o ./libclamav/tomsfastmath/bin/fp_to_signed_bin.c.o ./libclamav/tomsfastmath/bin/fp_to_unsigned_bin.c.o ./libclamav/tomsfastmath/bin/fp_toradix.c.o ./libclamav/tomsfastmath/bin/fp_toradix_n.c.o ./libclamav/tomsfastmath/bin/fp_unsigned_bin_size.c.o ./libclamav/tomsfastmath/bit/fp_cnt_lsb.c.o ./libclamav/tomsfastmath/bit/fp_count_bits.c.o ./libclamav/tomsfastmath/bit/fp_div_2.c.o ./libclamav/tomsfastmath/bit/fp_div_2d.c.o ./libclamav/tomsfastmath/bit/fp_lshd.c.o ./libclamav/tomsfastmath/bit/fp_mod_2d.c.o ./libclamav/tomsfastmath/bit/fp_rshd.c.o ./libclamav/tomsfastmath/divide/fp_div.c.o ./libclamav/tomsfastmath/divide/fp_div_d.c.o ./libclamav/tomsfastmath/divide/fp_mod.c.o ./libclamav/tomsfastmath/divide/fp_mod_d.c.o ./libclamav/tomsfastmath/exptmod/fp_2expt.c.o ./libclamav/tomsfastmath/exptmod/fp_exptmod.c.o ./libclamav/tomsfastmath/misc/fp_ident.c.o ./libclamav/tomsfastmath/misc/fp_set.c.o ./libclamav/tomsfastmath/mont/fp_montgomery_calc_normalization.c.o ./libclamav/tomsfastmath/mont/fp_montgomery_reduce.c.o ./libclamav/tomsfastmath/mont/fp_montgomery_setup.c.o ./libclamav/tomsfastmath/mul/fp_mul.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba.c.o ./libclamav/tomsfastmath/mul/fp_mul_2.c.o ./libclamav/tomsfastmath/mul/fp_mul_2d.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_12.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_17.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_20.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_24.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_28.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_3.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_32.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_4.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_48.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_6.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_64.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_7.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_8.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_9.c.o ./libclamav/tomsfastmath/mul/fp_mul_comba_small_set.c.o ./libclamav/tomsfastmath/mul/fp_mul_d.c.o ./libclamav/tomsfastmath/mul/fp_mulmod.c.o ./libclamav/tomsfastmath/numtheory/fp_invmod.c.o ./libclamav/tomsfastmath/sqr/fp_sqr.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_12.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_17.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_20.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_24.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_28.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_3.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_32.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_4.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_48.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_6.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_64.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_7.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_8.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_9.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_generic.c.o ./libclamav/tomsfastmath/sqr/fp_sqr_comba_small_set.c.o ./libclamav/tomsfastmath/sqr/fp_sqrmod.c.o ./libclamav/bytecode_nojit.c.o ./libclamav/blob.c.o ./libclamav/conv.c.o ./libclamav/fpu.c.o ./libclamav/hashtab.c.o ./libclamav/iowrap.c.o ./libclamav/json_api.c.o ./libclamav/others_common.c.o ./libclamav/qsort.c.o ./libclamav/sf_base64decode.c.o ./libclamav/str.c.o ./libclamav/strlcat.c.o ./libclamav/table.c.o ./libclamav/text.c.o ./libclamav/uniq.c.o ./libclamav/www.c.o ./libclamav/disasm.c.o ./libclamav/filtering.c.o ./libclamav/matcher-ac.c.o ./libclamav/matcher-bm.c.o ./libclamav/matcher-byte-comp.c.o ./libclamav/matcher-hash.c.o ./libclamav/matcher-pcre.c.o ./libclamav/matcher.c.o ./libclamav/regex_pcre.c.o ./libclamav/cvd.c.o ./libclamav/dconf.c.o ./libclamav/dsig.c.o ./libclamav/readdb.c.o ./libclamav/cache.c.o ./libclamav/crtmgr.c.o ./libclamav/crypto.c.o ./libclamav/filetypes.c.o ./libclamav/fmap.c.o ./libclamav/mpool.c.o ./libclamav/others.c.o ./libclamav/perflogging.c.o ./libclamav/scanners.c.o ./libclamav/textdet.c.o ./libclamav/version.c.o ./libclamav/htmlnorm.c.o ./libclamav/jsparse/js-norm.c.o ./libclamav/textnorm.c.o ./libclamav/partition_intersection.c.o ./libclamav/special.c.o ./libclamav/hostid_internal.c.o ./libclamav/stats_json.c.o ./libclamav/stats.c.o ./libclamav/bytecode_api_decl.c.o ./libclamav/bytecode_api.c.o ./libclamav/bytecode_detect.c.o ./libclamav/bytecode_vm.c.o ./libclamav/bytecode.c.o ./libclamav/events.c.o ./libclamav/7z_iface.c.o ./libclamav/explode.c.o ./libclamav/inflate64.c.o ./libclamav/lzma_iface.c.o ./libclamav/lzw/lzwdec.c.o ./libclamav/xz_iface.c.o ./libclamav/arc4.c.o ./libclamav/rijndael.c.o ./libclamav/entconv.c.o ./libclamav/dlp.c.o ./libclamav/autoit.c.o ./libclamav/binhex.c.o ./libclamav/cpio.c.o ./libclamav/ishield.c.o ./libclamav/libmspack.c.o ./libclamav/msexpand.c.o ./libclamav/nsis/bzlib.c.o ./libclamav/nsis/infblock.c.o ./libclamav/nsis/nulsft.c.o ./libclamav/hwp.c.o ./libclamav/msdoc.c.o ./libclamav/msxml_parser.c.o ./libclamav/msxml.c.o ./libclamav/ole2_extract.c.o ./libclamav/xlm_extract.c.o ./libclamav/ooxml.c.o ./libclamav/rtf.c.o ./libclamav/vba_extract.c.o ./libclamav/asn1.c.o ./libclamav/elf.c.o ./libclamav/execs.c.o ./libclamav/macho.c.o ./libclamav/pe_icons.c.o ./libclamav/pe.c.o ./libclamav/rebuildpe.c.o ./libclamav/aspack.c.o ./libclamav/fsg.c.o ./libclamav/mew.c.o ./libclamav/packlibs.c.o ./libclamav/petite.c.o ./libclamav/spin.c.o ./libclamav/unsp.c.o ./libclamav/upack.c.o ./libclamav/upx.c.o ./libclamav/wwunpack.c.o ./libclamav/yc.c.o ./libclamav/line.c.o ./libclamav/mbox.c.o ./libclamav/message.c.o ./libclamav/phish_domaincheck_db.c.o ./libclamav/phish_allow_list.c.o ./libclamav/phishcheck.c.o ./libclamav/regex_list.c.o ./libclamav/regex_suffix.c.o ./libclamav/sis.c.o ./libclamav/tnef.c.o ./libclamav/uuencode.c.o ./libclamav/swf.c.o ./libclamav/pdf.c.o ./libclamav/pdfng.c.o ./libclamav/pdfdecode.c.o ./libclamav/xdp.c.o ./libclamav/unarj.c.o ./libclamav/is_tar.c.o ./libclamav/untar.c.o ./libclamav/unzip.c.o ./libclamav/adc.c.o ./libclamav/dmg.c.o ./libclamav/xar.c.o ./libclamav/egg.c.o ./libclamav/mbr.c.o ./libclamav/gpt.c.o ./libclamav/apm.c.o ./libclamav/hfsplus.c.o ./libclamav/iso9660.c.o ./libclamav/openioc.c.o ./libclamav/jpeg.c.o ./libclamav/png.c.o ./libclamav/tiff.c.o ./libclamav/gif.c.o \ - -lmspack ./libclamav_rust/${ARCH}-unknown-linux-gnu/debug/libclamav_rust.a -lssl -lcrypto -lz -lbz2 -lpcre2-8 -lxml2 -ljson-c -ldl -lm -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lc + -lmspack ./libclamav_rust/${ARCH}/debug/libclamav_rust.a -lssl -lcrypto -lz -lbz2 -lpcre2-8 -lxml2 -ljson-c -ldl -lm -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lc @@ -286,7 +286,7 @@ clamscan() cc -DHAVE_CONFIG_H -I./libclamav -I./ -I./libclamunrar_iface -I./common -isystem ./ -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIE -Wall -Wextra -Wformat-security -std=gnu90 -o ./clamscan/clamscan.c.o -c ./clamscan/clamscan.c cc -DHAVE_CONFIG_H -I./libclamav -I./ -I./libclamunrar_iface -I./common -isystem ./ -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIE -Wall -Wextra -Wformat-security -std=gnu90 -o ./clamscan/manager.c.o -c ./clamscan/manager.c cc ./clamscan/clamscan.c.o ./clamscan/manager.c.o -o clamscan.bin \ - ./libcommon.a ./libclamav.so.11.0.0 -lmspack ./libclamav_rust/${ARCH}-unknown-linux-gnu/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lssl -lcrypto -lz -lcurl -lsystemd + ./libcommon.a ./libclamav.so.11.0.0 -lmspack ./libclamav_rust/${ARCH}/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lssl -lcrypto -lz -lcurl -lsystemd } @@ -301,7 +301,7 @@ libfreshclam() cc -DHAVE_CONFIG_H -Dfreshclam_EXPORTS -I./libfreshclam -I./common -I./libclamav -I./ -I./libclamunrar_iface -isystem libclamav_rust -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIC -Wall -Wextra -Wformat-security -std=gnu90 -o libfreshclam/dns.c.o -c libfreshclam/dns.c cc -fPIC -shared -Wl,-soname,libfreshclam.so.2 -o libfreshclam.so.2.0.2 \ libfreshclam/libfreshclam.c.o libfreshclam/libfreshclam_internal.c.o libfreshclam/dns.c.o \ - ./libcommon.a -lcurl -lssl -lcrypto -lresolv ./libclamav.so.11.0.0 -lssl -lcrypto -lmspack ./libclamav_rust/${ARCH}-unknown-linux-gnu/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lz -lsystemd + ./libcommon.a -lcurl -lssl -lcrypto -lresolv ./libclamav.so.11.0.0 -lssl -lcrypto -lmspack ./libclamav_rust/${ARCH}/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lz -lsystemd } @@ -318,7 +318,7 @@ freshclam() cc freshclam/freshclam.c.o freshclam/execute.c.o freshclam/notify.c.o \ -o freshclam.bin \ - ./libfreshclam.so.2.0.2 ./libcommon.a ./libclamav.so.11.0.0 /usr/lib/x86_64-linux-gnu/libmspack.so ./libclamav_rust/${ARCH}-unknown-linux-gnu/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc /usr/lib/x86_64-linux-gnu/libbz2.so /usr/lib/x86_64-linux-gnu/libpcre2-8.so /usr/lib/x86_64-linux-gnu/libxml2.so /usr/lib/x86_64-linux-gnu/libjson-c.so -lc -ldl -lm /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libsystemd.so /usr/lib/x86_64-linux-gnu/libcurl.so /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libcrypto.so -lresolv + ./libfreshclam.so.2.0.2 ./libcommon.a ./libclamav.so.11.0.0 /usr/lib/x86_64-linux-gnu/libmspack.so ./libclamav_rust/${ARCH}/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc /usr/lib/x86_64-linux-gnu/libbz2.so /usr/lib/x86_64-linux-gnu/libpcre2-8.so /usr/lib/x86_64-linux-gnu/libxml2.so /usr/lib/x86_64-linux-gnu/libjson-c.so -lc -ldl -lm /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libsystemd.so /usr/lib/x86_64-linux-gnu/libcurl.so /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libcrypto.so -lresolv } diff --git a/clamav/libclamav_rust/Cargo.lock b/clamav/libclamav_rust/Cargo.lock index 92de508..a3b9197 100644 --- a/clamav/libclamav_rust/Cargo.lock +++ b/clamav/libclamav_rust/Cargo.lock @@ -894,9 +894,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "spin" -version = "0.9.4" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ "lock_api", ] diff --git a/get_architecture.sh b/get_architecture.sh new file mode 100644 index 0000000..5262d41 --- /dev/null +++ b/get_architecture.sh @@ -0,0 +1,286 @@ +: + + +check_proc() { + # Check for /proc by looking for the /proc/self/exe link + # This is only run on Linux + if ! test -L /proc/self/exe ; then + err "fatal: Unable to find /proc/self/exe. Is /proc mounted? Installation cannot proceed without /proc." + fi +} + +say() { + printf 'rustup: %s\n' "$1" +} + +err() { + say "$1" >&2 + exit 1 +} + +need_cmd() { + if ! check_cmd "$1"; then + err "need '$1' (command not found)" + fi +} + +check_cmd() { + command -v "$1" > /dev/null 2>&1 +} + +assert_nz() { + if [ -z "$1" ]; then err "assert_nz $2"; fi +} + +# Run a command that should never fail. If the command fails execution +# will immediately terminate with an error showing the failing +# command. +ensure() { + if ! "$@"; then err "command failed: $*"; fi +} + +# This is just for indicating that commands' results are being +# intentionally ignored. Usually, because it's being executed +# as part of error handling. +ignore() { + "$@" +} + +get_bitness() { + need_cmd head + # Architecture detection without dependencies beyond coreutils. + # ELF files start out "\x7fELF", and the following byte is + # 0x01 for 32-bit and + # 0x02 for 64-bit. + # The printf builtin on some shells like dash only supports octal + # escape sequences, so we use those. + local _current_exe_head + _current_exe_head=$(head -c 5 /proc/self/exe ) + if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then + echo 32 + elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then + echo 64 + else + err "unknown platform bitness" + fi +} + + +get_architecture() { + local _ostype _cputype _bitness _arch _clibtype + _ostype="$(uname -s)" + _cputype="$(uname -m)" + _clibtype="gnu" + + if [ "$_ostype" = Linux ]; then + if [ "$(uname -o)" = Android ]; then + _ostype=Android + fi + if ldd --version 2>&1 | grep -q 'musl'; then + _clibtype="musl" + fi + fi + + if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then + # Darwin `uname -m` lies + if sysctl hw.optional.x86_64 | grep -q ': 1'; then + _cputype=x86_64 + fi + fi + + if [ "$_ostype" = SunOS ]; then + # Both Solaris and illumos presently announce as "SunOS" in "uname -s" + # so use "uname -o" to disambiguate. We use the full path to the + # system uname in case the user has coreutils uname first in PATH, + # which has historically sometimes printed the wrong value here. + if [ "$(/usr/bin/uname -o)" = illumos ]; then + _ostype=illumos + fi + + # illumos systems have multi-arch userlands, and "uname -m" reports the + # machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86 + # systems. Check for the native (widest) instruction set on the + # running kernel: + if [ "$_cputype" = i86pc ]; then + _cputype="$(isainfo -n)" + fi + fi + + case "$_ostype" in + + Android) + _ostype=linux-android + ;; + + Linux) + check_proc + _ostype=unknown-linux-$_clibtype + _bitness=$(get_bitness) + ;; + + FreeBSD) + _ostype=unknown-freebsd + ;; + + NetBSD) + _ostype=unknown-netbsd + ;; + + DragonFly) + _ostype=unknown-dragonfly + ;; + + Darwin) + _ostype=apple-darwin + ;; + + illumos) + _ostype=unknown-illumos + ;; + + MINGW* | MSYS* | CYGWIN* | Windows_NT) + _ostype=pc-windows-gnu + ;; + + *) + err "unrecognized OS type: $_ostype" + ;; + + esac + + case "$_cputype" in + + i386 | i486 | i686 | i786 | x86) + _cputype=i686 + ;; + + xscale | arm) + _cputype=arm + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + fi + ;; + + armv6l) + _cputype=arm + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + + armv7l | armv8l) + _cputype=armv7 + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + + aarch64 | arm64) + _cputype=aarch64 + ;; + + x86_64 | x86-64 | x64 | amd64) + _cputype=x86_64 + ;; + + mips) + _cputype=$(get_endianness mips '' el) + ;; + + mips64) + if [ "$_bitness" -eq 64 ]; then + # only n64 ABI is supported for now + _ostype="${_ostype}abi64" + _cputype=$(get_endianness mips64 '' el) + fi + ;; + + ppc) + _cputype=powerpc + ;; + + ppc64) + _cputype=powerpc64 + ;; + + ppc64le) + _cputype=powerpc64le + ;; + + s390x) + _cputype=s390x + ;; + riscv64) + _cputype=riscv64gc + ;; + *) + err "unknown CPU type: $_cputype" + + esac + + # Detect 64-bit linux with 32-bit userland + if [ "${_ostype}" = unknown-linux-gnu ] && [ "${_bitness}" -eq 32 ]; then + case $_cputype in + x86_64) + if [ -n "${RUSTUP_CPUTYPE:-}" ]; then + _cputype="$RUSTUP_CPUTYPE" + else { + # 32-bit executable for amd64 = x32 + if is_host_amd64_elf; then { + echo "This host is running an x32 userland; as it stands, x32 support is poor," 1>&2 + echo "and there isn't a native toolchain -- you will have to install" 1>&2 + echo "multiarch compatibility with i686 and/or amd64, then select one" 1>&2 + echo "by re-running this script with the RUSTUP_CPUTYPE environment variable" 1>&2 + echo "set to i686 or x86_64, respectively." 1>&2 + echo 1>&2 + echo "You will be able to add an x32 target after installation by running" 1>&2 + echo " rustup target add x86_64-unknown-linux-gnux32" 1>&2 + exit 1 + }; else + _cputype=i686 + fi + }; fi + ;; + mips64) + _cputype=$(get_endianness mips '' el) + ;; + powerpc64) + _cputype=powerpc + ;; + aarch64) + _cputype=armv7 + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + riscv64gc) + err "riscv64 with 32-bit userland unsupported" + ;; + esac + fi + + # Detect armv7 but without the CPU features Rust needs in that build, + # and fall back to arm. + # See https://github.com/rust-lang/rustup.rs/issues/587. + if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7 ]; then + if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then + # At least one processor does not have NEON. + _cputype=arm + fi + fi + + _arch="${_cputype}-${_ostype}" + + RETVAL="$_arch" + + + echo $_arch +} + +get_architecture \ No newline at end of file