git: dc2fd08d670c - main - archivers/ccmix: new port had been added (+)

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Thu, 11 Aug 2022 17:24:37 UTC
The branch main has been updated by danfe:

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

commit dc2fd08d670c889d403d4d2e1b692e78e364429a
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2022-08-11 17:23:14 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2022-08-11 17:23:14 +0000

    archivers/ccmix: new port had been added (+)
    
    It's a command-line tool to create and extract from archive files in
    the Westwood Studios MIX format and can handle all of the three main
    variants used in classic Westwood games.
    
    WWW: https://github.com/OmniBlade/ccmix
---
 archivers/Makefile                                 |  1 +
 archivers/ccmix/Makefile                           | 42 ++++++++++++++++++++
 archivers/ccmix/distinfo                           |  5 +++
 archivers/ccmix/files/patch-Makefile               | 32 +++++++++++++++
 .../ccmix/files/patch-src_gmdedit_gmdedit.cpp      | 24 +++++++++++
 archivers/ccmix/files/patch-src_mix__file.cpp      | 11 ++++++
 archivers/ccmix/files/patch-src_mixid.cpp          | 46 ++++++++++++++++++++++
 archivers/ccmix/pkg-descr                          |  9 +++++
 8 files changed, 170 insertions(+)

diff --git a/archivers/Makefile b/archivers/Makefile
index b822ef0cddb6..d5d9a7c17e85 100644
--- a/archivers/Makefile
+++ b/archivers/Makefile
@@ -17,6 +17,7 @@
     SUBDIR += c-blosc
     SUBDIR += c-blosc2
     SUBDIR += cabextract
+    SUBDIR += ccmix
     SUBDIR += cmdpack
     SUBDIR += dact
     SUBDIR += deb2targz
diff --git a/archivers/ccmix/Makefile b/archivers/ccmix/Makefile
new file mode 100644
index 000000000000..b6b43c06115e
--- /dev/null
+++ b/archivers/ccmix/Makefile
@@ -0,0 +1,42 @@
+PORTNAME=	ccmix
+PORTVERSION=	g20170612
+CATEGORIES=	archivers games
+MASTER_SITES=	SF/xccu/XCC%20Mixer/XCC%20Mixer%201.44:dat
+DISTFILES=	XCC_Mixer-1.44.zip:dat
+
+MAINTAINER=	danfe@FreeBSD.org
+COMMENT=	Westwood Studios MIX format file manipulator
+
+LICENSE=	GPLv2+
+
+LIB_DEPENDS=	libcryptopp.so:security/cryptopp
+
+USES=		gmake pkgconfig
+USE_GITHUB=	yes
+GH_ACCOUNT=	OmniBlade
+GH_TAGNAME=	4369c8f
+
+PLIST_FILES=	bin/ccmix bin/gmdedit bin/mixkey \
+		${DATADIR_REL}/global\ mix\ database.dat
+PORTDOCS=	README.md
+
+OPTIONS_DEFINE=	DOCS
+
+post-patch:
+	@${REINPLACE_CMD} -e '/ccmix program usage/s,/n,\\n, ; \
+		/gmd_dir/s,/usr/share/ccmix,${DATADIR},' \
+			${WRKSRC}/src/ccmix.cpp
+
+do-install:
+	${INSTALL_PROGRAM} ${INSTALL_WRKSRC}/build/* \
+		${STAGEDIR}${PREFIX}/bin
+	@${MKDIR} ${STAGEDIR}${DATADIR}
+	${INSTALL_DATA} ${WRKDIR}/global\ mix\ database.dat \
+		${STAGEDIR}${DATADIR}
+
+do-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${PORTDOCS:S,^,${INSTALL_WRKSRC}/,} \
+		${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.mk>
diff --git a/archivers/ccmix/distinfo b/archivers/ccmix/distinfo
new file mode 100644
index 000000000000..e1ce6b2867b4
--- /dev/null
+++ b/archivers/ccmix/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1497276455
+SHA256 (OmniBlade-ccmix-g20170612-4369c8f_GH0.tar.gz) = 523d0894aa6b00596813c397c01fd579dee9b2a6145a77e0f2b0c6b655a6fa66
+SIZE (OmniBlade-ccmix-g20170612-4369c8f_GH0.tar.gz) = 1695028
+SHA256 (XCC_Mixer-1.44.zip) = 7b3654f483b5da40af64d2d232c4c00a3e50be75aed75298bbc56dd9778f78f8
+SIZE (XCC_Mixer-1.44.zip) = 691768
diff --git a/archivers/ccmix/files/patch-Makefile b/archivers/ccmix/files/patch-Makefile
new file mode 100644
index 000000000000..b854792c5592
--- /dev/null
+++ b/archivers/ccmix/files/patch-Makefile
@@ -0,0 +1,32 @@
+--- Makefile.orig	2017-06-12 14:07:35 UTC
++++ Makefile
+@@ -1,4 +1,5 @@
+-CXXFLAGS=-g -Wall -Wextra -DNDEBUG $(OPTFLAGS)
++CXXFLAGS+=-Wall -Wextra -DNDEBUG $(OPTFLAGS)
++CPPFLAGS+=$(shell pkg-config --cflags libcryptopp)
+ LIBS=$(OPTLIBS)
+ PREFIX?=/usr/local
+ CC=g++
+@@ -19,11 +20,11 @@ gmd: $(OBJECTS) src/gmdedit/gmdedit.o
+ dev: all
+ 	
+ gmd: $(OBJECTS) src/gmdedit/gmdedit.o
+-	$(CC) src/gmdedit/gmdedit.o src/mixid.o src/mix_db_gamedb.o src/mix_db_gmd.o \
++	$(CXX) $(CXXFLAGS) src/gmdedit/gmdedit.o src/mixid.o src/mix_db_gamedb.o src/mix_db_gmd.o \
+ 	-o build/gmdedit
+ 
+ mixkey: src/mixkey/mixkey.o src/mixkey/mix_dexoder.o
+-	$(CC) src/mixkey/mixkey.o src/mixkey/mix_dexoder.o -o build/mixkey -lcryptopp
++	$(CXX) $(CXXFLAGS) src/mixkey/mixkey.o src/mixkey/mix_dexoder.o -o build/mixkey $(shell pkg-config --libs libcryptopp)
+ 
+ win32:
+ 	/usr/bin/make -f Makefile.win32 CC=i586-mingw32msvc-g++ \
+@@ -31,7 +32,7 @@ $(TARGET): build $(OBJECTS)
+ 
+ 	
+ $(TARGET): build $(OBJECTS)
+-	$(CC) $(OBJECTS) -o $(TARGET) -lcryptopp
++	$(CXX) $(CXXFLAGS) $(OBJECTS) -o $(TARGET) $(shell pkg-config --libs libcryptopp)
+ 
+ build:
+ 	@mkdir -p build
diff --git a/archivers/ccmix/files/patch-src_gmdedit_gmdedit.cpp b/archivers/ccmix/files/patch-src_gmdedit_gmdedit.cpp
new file mode 100644
index 000000000000..90450086b9a4
--- /dev/null
+++ b/archivers/ccmix/files/patch-src_gmdedit_gmdedit.cpp
@@ -0,0 +1,24 @@
+--- src/gmdedit/gmdedit.cpp.orig	2017-06-12 14:07:35 UTC
++++ src/gmdedit/gmdedit.cpp
+@@ -83,10 +83,6 @@ int main(int argc, char** argv) {
+     std::fstream ofh;
+     std::vector<t_namepair> names;
+     
+-    ifh.open(argv[1], std::ios_base::in|std::ios_base::binary);
+-    gmd.readDB(ifh);
+-    ifh.close();
+-    
+     if(argc < 4){
+         //menu();
+         std::cout << "Use: gmdedit gmdpath additionspath newgmdpath\n";
+@@ -106,6 +102,10 @@ int main(int argc, char** argv) {
+             }
+         }
+     }
++
++    ifh.open(argv[1], std::ios_base::in|std::ios_base::binary);
++    gmd.readDB(ifh);
++    ifh.close();
+ 
+     for(unsigned int i = 0; i < names.size(); i++) {
+         gmd.addName(game, names[i].first, names[i].second);
diff --git a/archivers/ccmix/files/patch-src_mix__file.cpp b/archivers/ccmix/files/patch-src_mix__file.cpp
new file mode 100644
index 000000000000..f89a57552846
--- /dev/null
+++ b/archivers/ccmix/files/patch-src_mix__file.cpp
@@ -0,0 +1,11 @@
+--- src/mix_file.cpp.orig	2017-06-12 14:07:35 UTC
++++ src/mix_file.cpp
+@@ -75,7 +75,7 @@ bool MixFile::open(const string path)
+     if (fh.is_open())
+         close();
+     
+-    fh.open(path.c_str(), fstream::in | fstream::out | fstream::binary);
++    fh.open(path.c_str(), fstream::in | fstream::binary);
+     if (!fh.is_open()) {
+         cout << "File " << path << " failed to open" << endl;
+         return false;
diff --git a/archivers/ccmix/files/patch-src_mixid.cpp b/archivers/ccmix/files/patch-src_mixid.cpp
new file mode 100644
index 000000000000..e6b2720b15d6
--- /dev/null
+++ b/archivers/ccmix/files/patch-src_mixid.cpp
@@ -0,0 +1,46 @@
+From c55a16f2a142c55f344480c3eecc6ecdedcfa735 Mon Sep 17 00:00:00 2001
+From: askeladdk <askeladdk@users.noreply.github.com>
+Date: Sat, 2 Jan 2016 14:15:35 +0100
+Subject: [PATCH] The filenames of unidentified files will be used as the
+ internal ID without being re-hashed. This lets you repack
+ unidentified files easily. Unidentified filenames are
+ detected if their name is exactly 8 characters long and
+ does not contain a dot ('.').
+
+--- src/mixid.cpp.orig	2017-06-12 14:07:35 UTC
++++ src/mixid.cpp
+@@ -8,7 +8,7 @@ namespace MixID 
+ {
+     namespace
+     {
+-        int32_t crc_table[256] = {
++        uint32_t crc_table[256] = {
+             0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+             0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+             0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+@@ -42,8 +42,6 @@ namespace MixID 
+             0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+             0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
+         
+-        const char* marker = "[id]";
+-        
+         uint32_t do_block(const void* data, int size);
+         
+         uint32_t do_block(const void* data, int size)
+@@ -62,7 +60,7 @@ namespace MixID 
+     {
+         //if the filename starts [id] treat next 8 chars as an id to convert to int
+         if(isIdName(fname)){
+-            return strId(fname.substr(4, 8));
++            return strId(fname);
+         }
+         std::transform(fname.begin(), fname.end(), fname.begin(),
+                 (int(*)(int)) toupper); // convert to uppercase
+@@ -128,6 +126,6 @@ namespace MixID 
+     
+     bool isIdName(std::string fname)
+     {
+-        return !strncmp(fname.c_str(), marker, strlen(marker));
++        return (fname.size() == 8) && (fname.find('.') == std::string::npos);
+     }
+ }
diff --git a/archivers/ccmix/pkg-descr b/archivers/ccmix/pkg-descr
new file mode 100644
index 000000000000..ae9cd3e0b2af
--- /dev/null
+++ b/archivers/ccmix/pkg-descr
@@ -0,0 +1,9 @@
+ccmix is a command-line tool to create and extract from archive files in
+the Westwood Studios MIX format.  The tool can create any of the three main
+variants used in classic Westwood games.  These are Tiberian Dawn versions,
+Red Alert versions with both encrypted and unencrypted file headers, and
+Tiberian Sun versions with encrypted and unencrypted file headers.  It also
+optionally adds the XCC extension of including a local filenames database
+to allow recovery of filenames from the one way hash they are stored as.
+
+WWW: https://github.com/OmniBlade/ccmix