git: aeb01f3ee1e1 - main - graphics/jbig2dec: Use USES=pathfix to fix .pc installation

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Sun, 09 Jul 2023 10:34:02 UTC
The branch main has been updated by sunpoet:

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

commit aeb01f3ee1e1a0c1cdee67e1c9b0c915561e6855
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2023-07-09 10:17:11 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2023-07-09 10:17:11 +0000

    graphics/jbig2dec: Use USES=pathfix to fix .pc installation
    
    - Update MASTER_SITES
    - Convert REINPLACE_CMD to patch files
---
 graphics/jbig2dec/Makefile                |  6 ++---
 graphics/jbig2dec/files/patch-Makefile.in | 10 +++-----
 graphics/jbig2dec/files/patch-jbig2dec.c  | 11 ++++++++-
 graphics/jbig2dec/files/patch-sha1.c      | 40 +++++++++++++++++++++++++++++--
 4 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/graphics/jbig2dec/Makefile b/graphics/jbig2dec/Makefile
index 4845f33846f0..d60f4d55eb03 100644
--- a/graphics/jbig2dec/Makefile
+++ b/graphics/jbig2dec/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	jbig2dec
 PORTVERSION=	0.19
 CATEGORIES=	graphics devel
-MASTER_SITES=	https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs9531/
+MASTER_SITES=	https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs9533/
 
 MAINTAINER=	sunpoet@FreeBSD.org
 COMMENT=	Decoder implementation of the JBIG2 image compression format
@@ -10,11 +10,12 @@ WWW=		https://github.com/ArtifexSoftware/jbig2dec
 LICENSE=	GPLv3
 LICENSE_FILE=	${WRKSRC}/COPYING
 
-USES=		cpe libtool
+USES=		cpe libtool pathfix
 
 CONFIGURE_ENV=	ac_cv_func_getopt_long=yes
 GNU_CONFIGURE=	yes
 INSTALL_TARGET=	install-strip
+LDFLAGS+=	-lmd
 USE_LDCONFIG=	yes
 
 CPE_VENDOR=	artifex
@@ -27,6 +28,5 @@ PNG_LIB_DEPENDS=	libpng.so:graphics/png
 
 post-patch:
 	@${RM} ${WRKSRC}/getopt* ${WRKSRC}/sha1.h
-	@${REINPLACE_CMD} -E 's|SHA1_Final\( *([^,]+), *([^\)]+)\)|SHA1_Final(\2, \1)|' ${WRKSRC}/jbig2dec.c ${WRKSRC}/sha1.c
 
 .include <bsd.port.mk>
diff --git a/graphics/jbig2dec/files/patch-Makefile.in b/graphics/jbig2dec/files/patch-Makefile.in
index 7eaca1b3943e..dbaf72f05b1f 100644
--- a/graphics/jbig2dec/files/patch-Makefile.in
+++ b/graphics/jbig2dec/files/patch-Makefile.in
@@ -1,6 +1,6 @@
 --- Makefile.in.orig	2020-09-10 16:29:31 UTC
 +++ Makefile.in
-@@ -611,18 +611,19 @@ libjbig2dec_la_SOURCES = jbig2.c \
+@@ -611,8 +611,8 @@ libjbig2dec_la_SOURCES = jbig2.c \
  	jbig2_generic.h jbig2_symbol_dict.h jbig2_text.h \
  	memento.c memento.h
  
@@ -10,17 +10,13 @@
 +	jbig2.h jbig2_image.h \
  	os_types.h config_types.h config_win32.h
  
--jbig2dec_LDADD = libjbig2dec.la @LIBOBJS@ $(PNG_LIBS)
-+jbig2dec_LDADD = libjbig2dec.la @LIBOBJS@ $(PNG_LIBS) -lmd
- pkgconfigdir = $(libdir)/pkgconfig
- pkgconfig_DATA = jbig2dec.pc
+ jbig2dec_LDADD = libjbig2dec.la @LIBOBJS@ $(PNG_LIBS)
+@@ -621,7 +621,7 @@ pkgconfig_DATA = jbig2dec.pc
  dist_man_MANS = jbig2dec.1
  EXTRA_DIST = test_jbig2dec.py msvc.mak LICENSE CHANGES
  MAINTAINERCLEANFILES = config_types.h.in
 -test_sha1_SOURCES = sha1.c sha1.h
 +test_sha1_SOURCES = sha1.c
  test_sha1_CFLAGS = -DTEST
-+test_sha1_LDADD = -lmd
  test_arith_SOURCES = jbig2_arith.c
  test_arith_CFLAGS = -DTEST
- test_arith_LDADD = libjbig2dec.la
diff --git a/graphics/jbig2dec/files/patch-jbig2dec.c b/graphics/jbig2dec/files/patch-jbig2dec.c
index aa6c5c14b29e..bee9aa6ff1fd 100644
--- a/graphics/jbig2dec/files/patch-jbig2dec.c
+++ b/graphics/jbig2dec/files/patch-jbig2dec.c
@@ -1,4 +1,4 @@
---- jbig2dec.c.orig	2020-02-11 16:28:00 UTC
+--- jbig2dec.c.orig	2020-09-10 15:14:14 UTC
 +++ jbig2dec.c
 @@ -33,7 +33,10 @@
  #endif
@@ -12,3 +12,12 @@
  
  #ifdef JBIG_EXTERNAL_MEMENTO_H
  #include JBIG_EXTERNAL_MEMENTO_H
+@@ -217,7 +220,7 @@ hash_print(jbig2dec_params_t *params, FILE *out)
+     char digest[2 * SHA1_DIGEST_SIZE + 1];
+     int i;
+ 
+-    SHA1_Final(params->hash_ctx, md);
++    SHA1_Final(md, params->hash_ctx);
+     for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
+         snprintf(&(digest[2 * i]), 3, "%02x", md[i]);
+     }
diff --git a/graphics/jbig2dec/files/patch-sha1.c b/graphics/jbig2dec/files/patch-sha1.c
index 8bf5fbc99ce6..2765753e2500 100644
--- a/graphics/jbig2dec/files/patch-sha1.c
+++ b/graphics/jbig2dec/files/patch-sha1.c
@@ -1,4 +1,4 @@
---- sha1.c.orig	2014-10-31 13:30:04 UTC
+--- sha1.c.orig	2020-09-10 15:14:14 UTC
 +++ sha1.c
 @@ -86,6 +86,13 @@ A million repetitions of "a"
  #include <string.h>
@@ -14,7 +14,16 @@
  #include "sha1.h"
  
  void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]);
-@@ -258,7 +265,6 @@ SHA1_Final(SHA1_CTX *context, uint8_t di
+@@ -225,7 +232,7 @@ SHA1_Update(SHA1_CTX *context, const uint8_t *data, co
+ 
+ /* Add padding and return the message digest. */
+ void
+-SHA1_Final(SHA1_CTX *context, uint8_t digest[SHA1_DIGEST_SIZE])
++SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX *context)
+ {
+     uint32_t i;
+     uint8_t finalcount[8];
+@@ -258,7 +265,6 @@ SHA1_Final(SHA1_CTX *context, uint8_t digest[SHA1_DIGE
  
  /*************************************************************/
  
@@ -22,3 +31,30 @@
  int
  main(int argc, char **argv)
  {
+@@ -286,7 +292,7 @@ main(int argc, char **argv)
+         i = fread(buffer, 1, 16384, file);
+         SHA1_Update(&context, buffer, i);
+     }
+-    SHA1_Final(&context, digest);
++    SHA1_Final(digest, &context);
+     fclose(file);
+     for (i = 0; i < SHA1_DIGEST_SIZE / 4; i++) {
+         for (j = 0; j < 4; j++) {
+@@ -344,7 +350,7 @@ main(int argc, char **argv)
+     for (k = 0; k < 2; k++) {
+         SHA1_Init(&context);
+         SHA1_Update(&context, (uint8_t *) test_data[k], strlen(test_data[k]));
+-        SHA1_Final(&context, digest);
++        SHA1_Final(digest, &context);
+         digest_to_hex(digest, output);
+ 
+         if (strcmp(output, test_results[k])) {
+@@ -359,7 +365,7 @@ main(int argc, char **argv)
+     SHA1_Init(&context);
+     for (k = 0; k < 1000000; k++)
+         SHA1_Update(&context, (uint8_t *) "a", 1);
+-    SHA1_Final(&context, digest);
++    SHA1_Final(digest, &context);
+     digest_to_hex(digest, output);
+     if (strcmp(output, test_results[2])) {
+         fprintf(stdout, "FAIL\n");