git: cba515834b61 - main - archivers/7-zip: add new port

From: Max Brazhnikov <makc_at_FreeBSD.org>
Date: Fri, 10 Dec 2021 15:17:24 UTC
The branch main has been updated by makc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cba515834b610de4ee050a032e5eed4b9180fbac

commit cba515834b610de4ee050a032e5eed4b9180fbac
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2021-12-10 15:11:29 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2021-12-10 15:13:26 +0000

    archivers/7-zip: add new port
    
    This is console version of original 7-Zip archiver released for Linux:
    https://sourceforge.net/p/sevenzip/discussion/45797/thread/cec5e63147/
    
    The sources are packed with 7z, therefore p7zip is required to build this port.
---
 archivers/7-zip/Makefile                           | 40 ++++++++++++++++++++++
 archivers/7-zip/distinfo                           |  3 ++
 archivers/7-zip/files/patch-CPP_7zip_7zip__gcc.mak | 20 +++++++++++
 archivers/7-zip/files/patch-CPP_7zip_var__gcc.mak  | 12 +++++++
 .../7-zip/files/patch-CPP_Windows_SystemInfo.cpp   | 18 ++++++++++
 archivers/7-zip/pkg-descr                          |  9 +++++
 archivers/Makefile                                 |  1 +
 7 files changed, 103 insertions(+)

diff --git a/archivers/7-zip/Makefile b/archivers/7-zip/Makefile
new file mode 100644
index 000000000000..1be9bc4e5268
--- /dev/null
+++ b/archivers/7-zip/Makefile
@@ -0,0 +1,40 @@
+PORTNAME=	7-zip
+DISTVERSION=	21.06
+CATEGORIES=	archivers
+MASTER_SITES=	https://www.7-zip.org/a/
+DISTNAME=	7z${DISTVERSION:S/.//}-src
+
+MAINTAINER=	makc@FreeBSD.org
+COMMENT=	Console version of the 7-Zip file archiver
+
+LIB_DEPENDS=	libsysinfo.so:devel/libsysinfo
+
+USES=		7z dos2unix gmake localbase
+
+MAKEFILE=	../../cmpl_clang.mak
+MAKE_ARGS=	LOCAL_FLAGS="${CFLAGS}" \
+		LOCAL_LIBS="${LIBS} -lsysinfo"
+
+NO_WRKSUBDIR=	yes
+BUILD_WRKSRC=	${WRKSRC}/CPP/7zip/Bundles/Alone2
+DOS2UNIX_FILES=	CPP/7zip/7zip_gcc.mak \
+		CPP/7zip/var_gcc.mak \
+		CPP/Windows/SystemInfo.cpp
+
+PLIST_FILES=	bin/7zz
+PORTDOCS=	7zC.txt 7zFormat.txt Methods.txt lzma.txt readme.txt \
+		src-history.txt
+
+OPTIONS_DEFINE=	DOCS
+
+post-patch:
+	${ECHO_CMD} > ${WRKSRC}/CPP/7zip/warn_clang.mak
+
+do-install:
+	${INSTALL_PROGRAM} ${BUILD_WRKSRC}/b/c/7zz ${STAGEDIR}/${PREFIX}/bin
+
+do-install-DOCS-on:
+	${MKDIR} ${STAGEDIR}${DOCSDIR} && \
+	${INSTALL_DATA} ${PORTDOCS:C,^,${WRKSRC}/DOC/,} ${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.mk>
diff --git a/archivers/7-zip/distinfo b/archivers/7-zip/distinfo
new file mode 100644
index 000000000000..3e4e5ddbc137
--- /dev/null
+++ b/archivers/7-zip/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1639126647
+SHA256 (7z2106-src.7z) = 675eaa90de3c6a3cd69f567bba4faaea309199ca75a6ad12bac731dcdae717ac
+SIZE (7z2106-src.7z) = 1215031
diff --git a/archivers/7-zip/files/patch-CPP_7zip_7zip__gcc.mak b/archivers/7-zip/files/patch-CPP_7zip_7zip__gcc.mak
new file mode 100644
index 000000000000..593e77c4da87
--- /dev/null
+++ b/archivers/7-zip/files/patch-CPP_7zip_7zip__gcc.mak
@@ -0,0 +1,20 @@
+--- CPP/7zip/7zip_gcc.mak.orig	2021-12-10 11:04:08 UTC
++++ CPP/7zip/7zip_gcc.mak
+@@ -22,7 +22,7 @@ CFLAGS_BASE_LIST = -c
+ # CFLAGS_BASE_LIST = -S
+ CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \
+  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
+- -fPIC
++ -fPIC $(LOCAL_FLAGS)
+ 
+ # -D_7ZIP_AFFINITY_DISABLE
+ 
+@@ -111,7 +111,7 @@ MY_MKDIR=mkdir -p
+ 
+ # LOCAL_LIBS=-lpthread
+ # LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
+-LIB2 = -lpthread -ldl
++LIB2 = $(LOCAL_LIBS) -lpthread
+ 
+ 
+ 
diff --git a/archivers/7-zip/files/patch-CPP_7zip_var__gcc.mak b/archivers/7-zip/files/patch-CPP_7zip_var__gcc.mak
new file mode 100644
index 000000000000..0e08d8ce2f50
--- /dev/null
+++ b/archivers/7-zip/files/patch-CPP_7zip_var__gcc.mak
@@ -0,0 +1,12 @@
+--- CPP/7zip/var_gcc.mak.orig	2021-12-10 10:31:55 UTC
++++ CPP/7zip/var_gcc.mak
+@@ -6,7 +6,7 @@ IS_ARM64=
+ CROSS_COMPILE=
+ MY_ARCH=
+ USE_ASM=
+-CC=$(CROSS_COMPILE)gcc
+-CXX=$(CROSS_COMPILE)g++
++CC=$(CC)
++CXX=$(CXX)
+ 
+ # -march=armv8-a+crc+crypto
diff --git a/archivers/7-zip/files/patch-CPP_Windows_SystemInfo.cpp b/archivers/7-zip/files/patch-CPP_Windows_SystemInfo.cpp
new file mode 100644
index 000000000000..bc362d111086
--- /dev/null
+++ b/archivers/7-zip/files/patch-CPP_Windows_SystemInfo.cpp
@@ -0,0 +1,18 @@
+--- CPP/Windows/SystemInfo.cpp.orig	2021-12-10 11:30:40 UTC
++++ CPP/Windows/SystemInfo.cpp
+@@ -20,6 +20,15 @@
+ 
+ #include <sys/auxv.h>
+ 
++#if defined(__FreeBSD__)
++unsigned long getauxval(unsigned long type)
++{
++    unsigned long aux = 0;
++    elf_aux_info(type, &aux, sizeof(aux));
++    return aux;
++}
++#endif
++
+ // #undef AT_HWCAP    // to debug
+ // #undef AT_HWCAP2   // to debug
+ 
diff --git a/archivers/7-zip/pkg-descr b/archivers/7-zip/pkg-descr
new file mode 100644
index 000000000000..daf58f3ec94b
--- /dev/null
+++ b/archivers/7-zip/pkg-descr
@@ -0,0 +1,9 @@
+7-Zip is a file archiver with a high compression ratio in 7z format with LZMA
+and LZMA2 compression. Supported formats:
+
+* Packing / unpacking: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
+* Unpacking only: AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS,
+  IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF,
+  UEFI, VDI, VHD, VMDK, WIM, XAR and Z
+
+WWW: https://www.7-zip.org/
diff --git a/archivers/Makefile b/archivers/Makefile
index 2cf1501e299f..caea780b16f5 100644
--- a/archivers/Makefile
+++ b/archivers/Makefile
@@ -1,5 +1,6 @@
     COMMENT = Archivers
 
+    SUBDIR += 7-zip
     SUBDIR += 9e
     SUBDIR += R-cran-zip
     SUBDIR += advancecomp