mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-29 10:18:30 +00:00
archivers/unrar-iconv: Convert to a normal port
Maintainer could refresh the patch and update to newer unrar later.
This commit is contained in:
parent
70fc1370fd
commit
bc7eae1ab8
@ -1,21 +1,47 @@
|
||||
PORTNAME= unrar
|
||||
PORTVERSION= 6.24
|
||||
PORTEPOCH= 6
|
||||
CATEGORIES= archivers
|
||||
MASTER_SITES= https://www.rarlab.com/rar/
|
||||
PKGNAMESUFFIX= -iconv
|
||||
DISTNAME= unrarsrc-6.2.12
|
||||
|
||||
MAINTAINER= yarodin@gmail.com
|
||||
COMMENT= Extract, view & test RAR archives
|
||||
WWW= https://www.rarlab.com/
|
||||
|
||||
MASTERDIR= ${.CURDIR}/../unrar
|
||||
LICENSE= UNRAR
|
||||
LICENSE_NAME= UnRAR license
|
||||
LICENSE_FILE= ${WRKSRC}/license.txt
|
||||
LICENSE_PERMS= auto-accept dist-mirror pkg-mirror
|
||||
|
||||
EXTRA_PATCHES= ${.CURDIR}/files/patch-iconv
|
||||
USES= compiler:c++11-lang cpe iconv
|
||||
|
||||
CPPFLAGS+= -DWITH_ICONV -I${LOCALBASE}/include
|
||||
LDFLAGS+= -L${LOCALBASE}/lib ${ICONV_LIB}
|
||||
USES= iconv
|
||||
LDFLAGS+= -L${LOCALBASE}/lib ${ICONV_LIB} -lpthread
|
||||
MAKE_ARGS= CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" STRIP="${STRIP_CMD}"
|
||||
MAKEFILE= makefile
|
||||
WRKSRC= ${WRKDIR}/unrar
|
||||
|
||||
PLIST_FILES= bin/unrar
|
||||
|
||||
CONFLICTS_INSTALL= unrar
|
||||
|
||||
post-install:
|
||||
CPE_VENDOR= rarlab
|
||||
|
||||
OPTIONS_DEFINE= OPENSSL_AES
|
||||
OPTIONS_DEFAULT=OPENSSL_AES
|
||||
OPENSSL_AES_DESC= Use OpenSSL implementation of AES
|
||||
|
||||
OPENSSL_AES_CPPFLAGS= -DOPENSSL_AES -I${OPENSSLINC}
|
||||
OPENSSL_AES_LDFLAGS= ${${OPENSSLLIB} == /usr/lib :? :-L${OPENSSLLIB}} -lcrypto
|
||||
OPENSSL_AES_USES= ssl
|
||||
|
||||
do-install:
|
||||
${INSTALL_PROGRAM} ${WRKSRC}/unrar ${STAGEDIR}${PREFIX}/bin/
|
||||
@${ECHO_MSG} "===> Added iconv support, see new switches:"
|
||||
@${ECHO_MSG} " la, ll and lo at \"unrar -?\""
|
||||
@${ECHO_MSG} "===> REMEMBER!!!: Windows rar archives using old DOS encodings as internal encoding."
|
||||
@${ECHO_MSG} " CP866 for russian lang for example."
|
||||
|
||||
.include "${MASTERDIR}/Makefile"
|
||||
.include <bsd.port.mk>
|
||||
|
3
archivers/unrar-iconv/distinfo
Normal file
3
archivers/unrar-iconv/distinfo
Normal file
@ -0,0 +1,3 @@
|
||||
TIMESTAMP = 1703227796
|
||||
SHA256 (unrarsrc-6.2.12.tar.gz) = a008b5f949bca9bb4ffa1bebbfc8b3c14b89df10a10354809b845232d5f582e5
|
||||
SIZE (unrarsrc-6.2.12.tar.gz) = 246918
|
13
archivers/unrar-iconv/files/patch-os.hpp
Normal file
13
archivers/unrar-iconv/files/patch-os.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
--- os.hpp.orig 2023-01-17 16:25:54 UTC
|
||||
+++ os.hpp
|
||||
@@ -173,6 +173,10 @@
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
+#ifdef OPENSSL_AES
|
||||
+#include <openssl/evp.h>
|
||||
+#endif // OPENSSL_AES
|
||||
+
|
||||
#ifdef S_IFLNK
|
||||
#define SAVE_LINKS
|
||||
#endif
|
136
archivers/unrar-iconv/files/patch-rijndael.cpp
Normal file
136
archivers/unrar-iconv/files/patch-rijndael.cpp
Normal file
@ -0,0 +1,136 @@
|
||||
--- rijndael.cpp.orig 2023-01-17 16:25:54 UTC
|
||||
+++ rijndael.cpp
|
||||
@@ -3,6 +3,8 @@
|
||||
**************************************************************************/
|
||||
#include "rar.hpp"
|
||||
|
||||
+#ifndef OPENSSL_AES
|
||||
+
|
||||
#ifdef USE_SSE
|
||||
#include <wmmintrin.h>
|
||||
#endif
|
||||
@@ -75,6 +77,7 @@ inline void Copy128(byte *dest,const byte *src)
|
||||
#endif
|
||||
}
|
||||
|
||||
+#endif // OPENSSL_AES
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
@@ -82,14 +85,41 @@ inline void Copy128(byte *dest,const byte *src)
|
||||
|
||||
Rijndael::Rijndael()
|
||||
{
|
||||
+#ifndef OPENSSL_AES
|
||||
if (S5[0]==0)
|
||||
GenerateTables();
|
||||
+#endif // OPENSSL_AES
|
||||
CBCMode = true; // Always true for RAR.
|
||||
}
|
||||
|
||||
|
||||
void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVector)
|
||||
{
|
||||
+#ifdef OPENSSL_AES
|
||||
+ const EVP_CIPHER *cipher;
|
||||
+ switch(keyLen)
|
||||
+ {
|
||||
+ case 128:
|
||||
+ cipher = EVP_aes_128_cbc();
|
||||
+ break;
|
||||
+ case 192:
|
||||
+ cipher = EVP_aes_192_cbc();
|
||||
+ break;
|
||||
+ case 256:
|
||||
+ cipher = EVP_aes_256_cbc();
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
+ EVP_CIPHER_CTX_init(&ctx);
|
||||
+ EVP_CipherInit_ex(&ctx, cipher, NULL, key, initVector, Encrypt);
|
||||
+ EVP_CIPHER_CTX_set_padding(&ctx, 0);
|
||||
+#else
|
||||
+ EVP_CIPHER_CTX_init(ctx);
|
||||
+ EVP_CipherInit_ex(ctx, cipher, NULL, key, initVector, Encrypt);
|
||||
+ EVP_CIPHER_CTX_set_padding(ctx, 0);
|
||||
+#endif
|
||||
+#else // OPENSSL_AES
|
||||
// Check SIMD here instead of constructor, so if object is a part of some
|
||||
// structure memset'ed before use, these variables are not lost.
|
||||
#if defined(USE_SSE)
|
||||
@@ -141,6 +171,7 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint
|
||||
|
||||
if(!Encrypt)
|
||||
keyEncToDec();
|
||||
+#endif // OPENSSL_AES
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +180,15 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
|
||||
if (inputLen <= 0)
|
||||
return;
|
||||
|
||||
+#ifdef OPENSSL_AES
|
||||
+ int outLen;
|
||||
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
+ EVP_CipherUpdate(&ctx, outBuffer, &outLen, input, inputLen);
|
||||
+#else
|
||||
+ EVP_CipherUpdate(ctx, outBuffer, &outLen, input, inputLen);
|
||||
+#endif
|
||||
+ return;
|
||||
+#else // OPENSSL_AES
|
||||
size_t numBlocks = inputLen/16;
|
||||
#if defined(USE_SSE)
|
||||
if (AES_NI)
|
||||
@@ -213,6 +253,7 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
|
||||
input += 16;
|
||||
}
|
||||
Copy128(m_initVector,prevBlock);
|
||||
+#endif // OPENSSL_AES
|
||||
}
|
||||
|
||||
|
||||
@@ -288,6 +329,15 @@ void Rijndael::blockDecrypt(const byte *input, size_t
|
||||
if (inputLen <= 0)
|
||||
return;
|
||||
|
||||
+#ifdef OPENSSL_AES
|
||||
+ int outLen;
|
||||
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
+ EVP_CipherUpdate(&ctx, outBuffer, &outLen, input, inputLen);
|
||||
+#else
|
||||
+ EVP_CipherUpdate(ctx, outBuffer, &outLen, input, inputLen);
|
||||
+#endif
|
||||
+ return;
|
||||
+#else // OPENSSL_AES
|
||||
size_t numBlocks=inputLen/16;
|
||||
#if defined(USE_SSE)
|
||||
if (AES_NI)
|
||||
@@ -356,6 +406,8 @@ void Rijndael::blockDecrypt(const byte *input, size_t
|
||||
}
|
||||
|
||||
memcpy(m_initVector,iv,16);
|
||||
+
|
||||
+#endif // OPENSSL_AES
|
||||
}
|
||||
|
||||
|
||||
@@ -426,7 +478,7 @@ void Rijndael::blockDecryptNeon(const byte *input, siz
|
||||
}
|
||||
#endif
|
||||
|
||||
-
|
||||
+#ifndef OPENSSL_AES
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ALGORITHM
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -555,7 +607,7 @@ void Rijndael::GenerateTables()
|
||||
U1[b][0]=U2[b][1]=U3[b][2]=U4[b][3]=T5[I][0]=T6[I][1]=T7[I][2]=T8[I][3]=gmul(b,0xe);
|
||||
}
|
||||
}
|
||||
-
|
||||
+#endif // OPENSSL_AES
|
||||
|
||||
#if 0
|
||||
static void TestRijndael();
|
24
archivers/unrar-iconv/files/patch-rijndael.hpp
Normal file
24
archivers/unrar-iconv/files/patch-rijndael.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
--- rijndael.hpp.orig 2023-01-17 16:25:54 UTC
|
||||
+++ rijndael.hpp
|
||||
@@ -12,6 +12,13 @@
|
||||
class Rijndael
|
||||
{
|
||||
private:
|
||||
+#ifdef OPENSSL_AES
|
||||
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
+ EVP_CIPHER_CTX ctx;
|
||||
+#else
|
||||
+ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
|
||||
+#endif
|
||||
+#else // OPENSSL_AES
|
||||
#ifdef USE_SSE
|
||||
void blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffer);
|
||||
void blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer);
|
||||
@@ -31,6 +38,7 @@ class Rijndael
|
||||
void keySched(byte key[_MAX_KEY_COLUMNS][4]);
|
||||
void keyEncToDec();
|
||||
void GenerateTables();
|
||||
+#endif // OPENSSL_AES
|
||||
|
||||
// RAR always uses CBC, but we may need to turn it off when calling
|
||||
// this code from other archive formats with CTR and other modes.
|
6
archivers/unrar-iconv/pkg-descr
Normal file
6
archivers/unrar-iconv/pkg-descr
Normal file
@ -0,0 +1,6 @@
|
||||
The UnRAR utility is a freeware program, distributed with source code and
|
||||
developed for extracting, testing and viewing the contents of archives created
|
||||
with the RAR archiver, version 1.50 and above.
|
||||
|
||||
The UnRAR utility is a minor part of the RAR archiver and contains RAR
|
||||
uncompression algorithm. UnRAR requires very small volume of memory to operate.
|
Loading…
Reference in New Issue
Block a user