extra/jbigkit to 2.1-7

This commit is contained in:
Kevin Mihelich 2023-09-05 12:41:40 +00:00
parent 661630c3a8
commit 63a28d2263
5 changed files with 373 additions and 34 deletions

View file

@ -1,49 +1,70 @@
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer:
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>
# Contributor: Frank Ickstadt (frank dot ickstadt at gmail dot com)
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# - don't unset CFLAGS, use -fPIC with armv7h and aarch64
# - build with -fPIC
pkgname=jbigkit
pkgver=2.1
pkgrel=6
pkgrel=7
pkgdesc="Data compression library/utilities for bi-level high-resolution images"
arch=('x86_64')
arch=(x86_64)
url="https://www.cl.cam.ac.uk/~mgk25/jbigkit/"
license=('GPL')
depends=()
options=('staticlibs')
source=(http://www.cl.cam.ac.uk/~mgk25/download/jbigkit-$pkgver.tar.gz)
md5sums=('ebcf09bed9f14d7fa188d3bd57349522')
license=(GPL-2.0-or-later)
depends=(glibc)
provides=(
libjbig85.so
libjbig.so
)
source=(
https://www.cl.cam.ac.uk/~mgk25/download/$pkgname-$pkgver.tar.gz
$pkgname-2.1-shared_lib.patch
$pkgname-2.1-build_warnings.patch
$pkgname-2.1-ldflags.patch
$pkgname-2.1-coverity.patch
)
sha512sums=('c4127480470ef90db1ef3bd2caa444df10b50ed8df0bc9997db7612cb48b49278baf44965028f1807a21028eb965d677e015466306b44683c4ec75a23e1922cf'
'9f46ee24f8b5eb57935c9b2cd9bd3d61b422c2352143c59a68adee8880511dd0bba0a057f0ed070dd0111c9eb0504df060343261c824c5a5734c06a1aedb14c8'
'9be32ccec414de5c5de7d508ff14e1f1f3a40f81a2de252ca66e0f2844a8546d353d6a7abe36895ac798816165b2c5d8a9d043ea3f0c832fecdd9170dd6f92bf'
'fb0c1f35ba5469dd4f7f6bd2a933d3484191d2ecd8367ea865fd2396bc99825b3afa7fcd09fbf8e841acbf92ed01cf743a83df7991e7e03f9e6cf8fbe0925ae6'
'10f4f154c4f824c9361266f27bea231b35ed4cac680587c8659b6e12c0c06141f04a22cf72dd847abcb833578d25dfe5142d10d757f8c14c70d943c8eb3d5612')
b2sums=('7bd82f0e10a2d3794739ee85b77c5407d58753a00e014e937735f9af3043347de88a6e567609bc26de488887a6d61b0a162387fb72732b9be7e550e3f9b9539e'
'52c5f7384f499e15a636b8e0089153750ac02da4ac850260a3243ee06d1194133f1264abc3457e52c5a15ee1a4bfad0b31042975d80273bf741b75e634845745'
'6114609e5186e5fae1678de00f8c7336970c18923d3d3c01fbc431e95387bfe5696fe7914947ea3903c972eb54dfd24efe0d9ac3c7f4512de26f6ab138ce590c'
'a8e36381543c0f701a589c115577da2509f02f3002926ab86b62e29e9f8a12db65b5d56387a61aa7a053e49d59e79e968c477ce096c73aa24ad3f94e28dff6b5'
'2650020ba8ef433a3b935917297c034f01f0296a2a7c9c23c47521b823cc79ac32df8a3695f57e885b91604b138fedc1fcfea1cda8d2a79e9fd3c9680f0c06a8')
prepare() {
# instead of a static library, create a shared library
patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-2.1-shared_lib.patch
# fix build warnings
patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-2.1-build_warnings.patch
# apply distribution LDFLAGS
patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-2.1-ldflags.patch
# fix coverity issues
patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-2.1-coverity.patch
}
build() {
cd $srcdir/$pkgname-$pkgver
unset CPPFLAGS LDFLAGS
[ "$CARCH" == "x86_64" ] && export CFLAGS="$CFLAGS -fPIC"
[ "$CARCH" == "armv7h" ] && export CFLAGS="$CFLAGS -fPIC"
[ "$CARCH" == "aarch64" ] && export CFLAGS="$CFLAGS -fPIC"
make CFLAGS="$CFLAGS"
CFLAGS+=" -fPIC"
export EXTRA_CFLAGS="$CFLAGS"
make -C $pkgname-$pkgver
}
check() {
# NOTE: tests can not be parallelized
make test -C $pkgname-$pkgver -j1
}
package() {
cd $srcdir/$pkgname-$pkgver
install -D -m644 libjbig/libjbig.a $pkgdir/usr/lib/libjbig.a
install -D -m644 libjbig/libjbig85.a $pkgdir/usr/lib/libjbig85.a
install -D -m644 libjbig/jbig.h $pkgdir/usr/include/jbig.h
install -D -m644 libjbig/jbig_ar.h $pkgdir/usr/include/jbig_ar.h
install -D -m644 libjbig/jbig85.h $pkgdir/usr/include/jbig85.h
install -d -m755 $pkgdir/usr/share/man/man1
# install -d -m755 $pkgdir/usr/share/man/man5
install -m644 pbmtools/*.1* $pkgdir/usr/share/man/man1
# install -m644 pbmtools/*.5* $pkgdir/usr/share/man/man5
install -D -m755 pbmtools/jbgtopbm $pkgdir/usr/bin/jbgtopbm
install -D -m755 pbmtools/pbmtojbg $pkgdir/usr/bin/pbmtojbg
install -D -m755 pbmtools/jbgtopbm85 $pkgdir/usr/bin/jbgtopbm85
install -D -m755 pbmtools/pbmtojbg85 $pkgdir/usr/bin/pbmtojbg85
rm -f $pkgdir/usr/share/man/man5/p{b,g}m.5*
cd $pkgname-$pkgver
install -vDm 644 libjbig/*.h -t "$pkgdir/usr/include/"
install -vDm 755 libjbig/*.so.* -t "$pkgdir/usr/lib/"
for lib in libjbig.so libjbig85.so; do
ln -sv "$lib.$pkgver" "$pkgdir/usr/lib/$lib"
done
install -vDm 755 pbmtools/{jbgtopbm{,85},pbmtojbg{,85}} -t "$pkgdir/usr/bin/"
install -vDm 644 pbmtools/*.1* -t "$pkgdir/usr/share/man/man1/"
}

View file

@ -0,0 +1,77 @@
diff -up jbigkit-2.1/pbmtools/pbmtojbg85.c.warnings jbigkit-2.1/pbmtools/pbmtojbg85.c
--- jbigkit-2.1/pbmtools/pbmtojbg85.c.warnings 2008-08-26 00:26:39.000000000 +0200
+++ jbigkit-2.1/pbmtools/pbmtojbg85.c 2012-07-17 16:24:56.741332942 +0200
@@ -72,9 +72,12 @@ static unsigned long getint(FILE *f)
while ((c = getc(f)) != EOF && !(c == 13 || c == 10)) ;
if (c != EOF) {
ungetc(c, f);
- fscanf(f, "%lu", &i);
+ if (fscanf(f, "%lu", &i) != 1) {
+ /* should never fail, since c must be a digit */
+ fprintf(stderr, "Unexpected failure reading digit '%c'\n", c);
+ exit(1);
+ }
}
-
return i;
}
@@ -239,7 +242,9 @@ int main (int argc, char **argv)
break;
case '4':
/* PBM raw binary format */
- fread(next_line, bpl, 1, fin);
+ if (fread(next_line, bpl, 1, fin) != 1) {
+ /* silence compiler warnings; ferror/feof checked below */
+ }
break;
default:
fprintf(stderr, "Unsupported PBM type P%c!\n", type);
diff -up jbigkit-2.1/pbmtools/pbmtojbg.c.warnings jbigkit-2.1/pbmtools/pbmtojbg.c
--- jbigkit-2.1/pbmtools/pbmtojbg.c.warnings 2008-07-16 22:59:41.000000000 +0200
+++ jbigkit-2.1/pbmtools/pbmtojbg.c 2012-07-17 16:23:46.584285686 +0200
@@ -88,7 +88,11 @@ static unsigned long getint(FILE *f)
while ((c = getc(f)) != EOF && !(c == 13 || c == 10)) ;
if (c != EOF) {
ungetc(c, f);
- fscanf(f, "%lu", &i);
+ if (fscanf(f, "%lu", &i) != 1) {
+ /* should never fail, since c must be a digit */
+ fprintf(stderr, "Unexpected failure reading digit '%c'\n", c);
+ exit(1);
+ }
}
return i;
@@ -302,7 +306,9 @@ int main (int argc, char **argv)
break;
case '4':
/* PBM raw binary format */
- fread(bitmap[0], bitmap_size, 1, fin);
+ if (fread(bitmap[0], bitmap_size, 1, fin) != 1) {
+ /* silence compiler warnings; ferror/feof checked below */
+ }
break;
case '2':
case '5':
@@ -314,8 +320,18 @@ int main (int argc, char **argv)
for (j = 0; j < bpp; j++)
image[x * bpp + (bpp - 1) - j] = v >> (j * 8);
}
- } else
- fread(image, width * height, bpp, fin);
+ } else {
+ if (fread(image, width * height, bpp, fin) != (size_t) bpp) {
+ if (ferror(fin)) {
+ fprintf(stderr, "Problem while reading input file '%s", fnin);
+ perror("'");
+ exit(1);
+ } else {
+ fprintf(stderr, "Unexpected end of input file '%s'!\n", fnin);
+ exit(1);
+ }
+ }
+ }
jbg_split_planes(width, height, planes, encode_planes, image, bitmap,
use_graycode);
free(image);

View file

@ -0,0 +1,30 @@
diff --git a/libjbig/jbig.c b/libjbig/jbig.c
index 751ceff..3c76e07 100644
--- a/libjbig/jbig.c
+++ b/libjbig/jbig.c
@@ -889,7 +889,7 @@ void jbg_enc_options(struct jbg_enc_state *s, int order, int options,
if (order >= 0 && order <= 0x0f) s->order = order;
if (options >= 0) s->options = options;
if (l0 > 0) s->l0 = l0;
- if (mx >= 0 && my < 128) s->mx = mx;
+ if (mx >= 0 && mx < 128) s->mx = mx;
if (my >= 0 && my < 256) s->my = my;
return;
diff --git a/pbmtools/Makefile b/pbmtools/Makefile
index 85e1783..6ae2d33 100644
--- a/pbmtools/Makefile
+++ b/pbmtools/Makefile
@@ -56,9 +56,9 @@ test82: pbmtojbg jbgtopbm
make IMG=sandra "OPTIONSP=-o 2" OPTIONSJ= dotest2g
make IMG=multi OPTIONSP= OPTIONSJ= dotest2g
make IMG=multi OPTIONSP=-b OPTIONSJ=-b dotest2g
- make IMG=mx "OPTIONSP=-q -s 3 -m 128" dotest1
- make IMG=mx "OPTIONSP=-q -s 3 -m 128" dotest2b
- make IMG=mx "OPTIONSP=-q -s 3 -m 128 -p 92" dotest2b
+ make IMG=mx "OPTIONSP=-q -s 3 -m 127" dotest1
+ make IMG=mx "OPTIONSP=-q -s 3 -m 127" dotest2b
+ make IMG=mx "OPTIONSP=-q -s 3 -m 127 -p 92" dotest2b
make IMG=mx "OPTIONSP=-q -Y -1" dotest2b
make IMG=mx "OPTIONSP=-Y -1" dotest2b
rm -f test-*.jbg test-*.pbm test-*.pgm

View file

@ -0,0 +1,51 @@
diff -up jbigkit-2.1/libjbig/Makefile.ldflags jbigkit-2.1/libjbig/Makefile
--- jbigkit-2.1/libjbig/Makefile.ldflags 2018-02-27 17:50:15.786038149 +0100
+++ jbigkit-2.1/libjbig/Makefile 2018-02-27 17:55:44.042093437 +0100
@@ -10,19 +10,19 @@ PICFLAGS := -fPIC -DPIC
all: libjbig.so.$(VERSION) tstcodec tstcodec85
tstcodec: tstcodec.o libjbig.so
- $(CC) $(CFLAGS) -o tstcodec $< -L. -ljbig
+ $(CC) $(CFLAGS) -o tstcodec $< -L. -ljbig $(LDFLAGS)
tstcodec85: tstcodec85.o libjbig85.so
- $(CC) $(CFLAGS) -o tstcodec85 $< -L. -ljbig85
+ $(CC) $(CFLAGS) -o tstcodec85 $< -L. -ljbig85 $(LDFLAGS)
%.so: %.so.$(VERSION)
ln -sf $< $@
libjbig.so.$(VERSION): jbig.o jbig_ar.o
- $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
libjbig85.so.$(VERSION): jbig85.o jbig_ar.o
- $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
jbig.o jbig85.o jbig_ar.o: CFLAGS += $(PICFLAGS)
diff -up jbigkit-2.1/pbmtools/Makefile.ldflags jbigkit-2.1/pbmtools/Makefile
--- jbigkit-2.1/pbmtools/Makefile.ldflags 2018-02-27 17:50:35.902857687 +0100
+++ jbigkit-2.1/pbmtools/Makefile 2018-02-27 17:57:09.296328639 +0100
@@ -15,16 +15,16 @@ all: pbmtojbg jbgtopbm pbmtojbg85 jbgtop
txt: pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt
pbmtojbg: pbmtojbg.o ../libjbig/libjbig.so
- $(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig
+ $(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig $(LDFLAGS)
jbgtopbm: jbgtopbm.o ../libjbig/libjbig.so
- $(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig
+ $(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig $(LDFLAGS)
pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.so
- $(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85
+ $(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85 $(LDFLAGS)
jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.so
- $(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85
+ $(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85 $(LDFLAGS)
jbgtopbm.o: jbgtopbm.c ../libjbig/jbig.h
pbmtojbg.o: pbmtojbg.c ../libjbig/jbig.h

View file

@ -0,0 +1,160 @@
diff -Naur jbigkit-2.1.old/libjbig/Makefile jbigkit-2.1/libjbig/Makefile
--- jbigkit-2.1.old/libjbig/Makefile 2014-03-27 19:47:15.000000000 +0100
+++ jbigkit-2.1/libjbig/Makefile 2014-08-04 10:45:31.865773710 +0200
@@ -4,25 +4,27 @@
CC = gcc
# Options for the compiler: A high optimization level is suggested
-CFLAGS = -g -O -W -Wall -ansi -pedantic # --coverage
+CFLAGS = $(EXTRA_CFLAGS) -W -Wall -ansi -pedantic # --coverage
+PICFLAGS := -fPIC -DPIC
-all: libjbig.a libjbig85.a tstcodec tstcodec85
+all: libjbig.so.$(VERSION) tstcodec tstcodec85
-tstcodec: tstcodec.o jbig.o jbig_ar.o
- $(CC) $(CFLAGS) -o tstcodec tstcodec.o jbig.o jbig_ar.o
+tstcodec: tstcodec.o libjbig.so
+ $(CC) $(CFLAGS) -o tstcodec $< -L. -ljbig
-tstcodec85: tstcodec85.o jbig85.o jbig_ar.o
- $(CC) $(CFLAGS) -o tstcodec85 tstcodec85.o jbig85.o jbig_ar.o
+tstcodec85: tstcodec85.o libjbig85.so
+ $(CC) $(CFLAGS) -o tstcodec85 $< -L. -ljbig85
-libjbig.a: jbig.o jbig_ar.o
- rm -f libjbig.a
- ar rc libjbig.a jbig.o jbig_ar.o
- -ranlib libjbig.a
+%.so: %.so.$(VERSION)
+ ln -sf $< $@
-libjbig85.a: jbig85.o jbig_ar.o
- rm -f libjbig85.a
- ar rc libjbig85.a jbig85.o jbig_ar.o
- -ranlib libjbig85.a
+libjbig.so.$(VERSION): jbig.o jbig_ar.o
+ $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+
+libjbig85.so.$(VERSION): jbig85.o jbig_ar.o
+ $(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+
+jbig.o jbig85.o jbig_ar.o: CFLAGS += $(PICFLAGS)
jbig.o: jbig.c jbig.h jbig_ar.h
jbig85.o: jbig85.c jbig85.h jbig_ar.h
@@ -43,11 +45,11 @@
clang --analyze *.c
test: tstcodec tstcodec85
- ./tstcodec
- ./tstcodec85
+ LD_LIBRARY_PATH=`pwd` ./tstcodec
+ LD_LIBRARY_PATH=`pwd` ./tstcodec85
t82test.pbm: tstcodec
- ./tstcodec $@
+ LD_LIBRARY_PATH=`pwd` ./tstcodec $@
clean:
rm -f *.o *.gcda *.gcno *.gcov *.plist *~ core gmon.out dbg_d\=??.pbm
diff -Naur jbigkit-2.1.old/Makefile jbigkit-2.1/Makefile
--- jbigkit-2.1.old/Makefile 2014-03-27 19:47:15.000000000 +0100
+++ jbigkit-2.1/Makefile 2014-08-04 10:52:09.242027746 +0200
@@ -4,25 +4,26 @@
CC = gcc
# Options for the compiler: A high optimization level is suggested
-CFLAGS = -O2 -W -Wno-unused-result
+CFLAGS = $(EXTRA_CFLAGS) -W -Wno-unused-result
# CFLAGS = -O -g -W -Wall -Wno-unused-result -ansi -pedantic # -DDEBUG
export CC CFLAGS
VERSION=2.1
+export VERSION
all: lib pbm
@echo "Enter 'make test' in order to start some automatic tests."
lib:
- cd libjbig && $(MAKE) -e
+ make -C libjbig
pbm: lib
- cd pbmtools && $(MAKE) -e
+ make -C pbmtools
test: lib pbm
- cd libjbig && $(MAKE) test
- cd pbmtools && $(MAKE) test
+ LD_LIBRARY_PATH=`pwd`/libjbig make -C libjbig test
+ LD_LIBRARY_PATH=`pwd`/libjbig make -C pbmtools test
analyze:
cd libjbig && $(MAKE) analyze
@@ -30,8 +31,8 @@
clean:
rm -f *~ core
- cd libjbig && $(MAKE) clean
- cd pbmtools && $(MAKE) clean
+ make -C libjbig clean
+ make -C pbmtools clean
distribution:
rm -rf jbigkit-$(VERSION)
diff -Naur jbigkit-2.1.old/pbmtools/Makefile jbigkit-2.1/pbmtools/Makefile
--- jbigkit-2.1.old/pbmtools/Makefile 2014-03-27 19:47:15.000000000 +0100
+++ jbigkit-2.1/pbmtools/Makefile 2014-08-04 10:49:47.694581174 +0200
@@ -4,26 +4,26 @@
CC = gcc
# Options for the compiler
-CFLAGS = -g -O -W -Wall -Wno-unused-result -ansi -pedantic # --coverage
+CFLAGS = $(EXTRA_CFLAGS) -W -Wall -Wno-unused-result -ansi -pedantic # --coverage
CPPFLAGS = -I../libjbig
.SUFFIXES: .1 .5 .txt $(SUFFIXES)
.PHONY: txt test test82 test85 clean
-all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 txt
+all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 # txt
txt: pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt
-pbmtojbg: pbmtojbg.o ../libjbig/libjbig.a
+pbmtojbg: pbmtojbg.o ../libjbig/libjbig.so
$(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig
-jbgtopbm: jbgtopbm.o ../libjbig/libjbig.a
+jbgtopbm: jbgtopbm.o ../libjbig/libjbig.so
$(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig
-pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.a
+pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.so
$(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85
-jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.a
+jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.so
$(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85
jbgtopbm.o: jbgtopbm.c ../libjbig/jbig.h
@@ -31,13 +31,13 @@
jbgtopbm85.o: jbgtopbm85.c ../libjbig/jbig85.h
pbmtojbg85.o: pbmtojbg85.c ../libjbig/jbig85.h
-../libjbig/libjbig.a: ../libjbig/jbig.c ../libjbig/jbig.h \
+../libjbig/libjbig.so: ../libjbig/jbig.c ../libjbig/jbig.h \
../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
- make -C ../libjbig libjbig.a
+ make -C ../libjbig libjbig.so
-../libjbig/libjbig85.a: ../libjbig/jbig85.c ../libjbig/jbig85.h \
+../libjbig/libjbig85.so: ../libjbig/jbig85.c ../libjbig/jbig85.h \
../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
- make -C ../libjbig libjbig85.a
+ make -C ../libjbig libjbig85.so
analyze:
clang $(CPPFLAGS) --analyze *.c