summaryrefslogtreecommitdiff
path: root/converters/pstotext
diff options
context:
space:
mode:
authorobache <obache>2010-04-25 12:46:19 +0000
committerobache <obache>2010-04-25 12:46:19 +0000
commitac8fa06eaf208bae3a3e4f68a547824b6e3b39fd (patch)
treec75ed9abf1ea08206780468bebaee5340c6dec8c /converters/pstotext
parent3216676a9ab8d27b366bfdd7defe2a421355a7c4 (diff)
downloadpkgsrc-ac8fa06eaf208bae3a3e4f68a547824b6e3b39fd.tar.gz
Import pstotext-1.9 as converters/pstotext.
Packaged by Stefan Schaeckeler in pkgsrc-wip. Pstotext extracts plain-text from postscript files (and somewhat less reliable from pdf files).
Diffstat (limited to 'converters/pstotext')
-rw-r--r--converters/pstotext/DESCR2
-rw-r--r--converters/pstotext/Makefile32
-rw-r--r--converters/pstotext/PLIST5
-rw-r--r--converters/pstotext/distinfo7
-rw-r--r--converters/pstotext/hacks.mk20
-rw-r--r--converters/pstotext/patches/patch-aa38
-rw-r--r--converters/pstotext/patches/patch-ab147
7 files changed, 251 insertions, 0 deletions
diff --git a/converters/pstotext/DESCR b/converters/pstotext/DESCR
new file mode 100644
index 00000000000..3b355519d24
--- /dev/null
+++ b/converters/pstotext/DESCR
@@ -0,0 +1,2 @@
+Pstotext extracts plain-text from postscript files (and somewhat less
+reliable from pdf files).
diff --git a/converters/pstotext/Makefile b/converters/pstotext/Makefile
new file mode 100644
index 00000000000..b2e4b047806
--- /dev/null
+++ b/converters/pstotext/Makefile
@@ -0,0 +1,32 @@
+# $NetBSD: Makefile,v 1.1.1.1 2010/04/25 12:46:19 obache Exp $
+#
+
+DISTNAME= pstotext-1.9
+CATEGORIES= converters print
+MASTER_SITES= ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/contrib/
+
+MAINTAINER= schaecsn@gmx.net
+HOMEPAGE= http://pages.cs.wisc.edu/~ghost/doc/pstotext.htm
+COMMENT= Postscript to text converter
+#LICENSE= see the end of pstotext.txt.
+
+PKG_DESTDIR_SUPPORT= user-destdir
+
+USE_TOOLS+= gs:run
+USE_TOOLS+= gmake
+
+SUBST_CLASSES+= gs
+SUBST_STAGE.gs= do-configure
+SUBST_FILES.gs= main.c
+SUBST_SED.gs= -e 's|@GS_CMD@|${TOOLS_PATH.gs}|'
+
+INSTALLATION_DIRS= bin ${PKGMANDIR}/man1 share/doc/${PKGBASE}
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/pstotext ${DESTDIR}${PREFIX}/bin
+ ${INSTALL_DATA} ${WRKSRC}/pstotext.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+ ${INSTALL_DATA} ${WRKSRC}/pstotext.hlp ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}
+ ${INSTALL_DATA} ${WRKSRC}/pstotext.txt ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}
+
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/converters/pstotext/PLIST b/converters/pstotext/PLIST
new file mode 100644
index 00000000000..1fce18043d4
--- /dev/null
+++ b/converters/pstotext/PLIST
@@ -0,0 +1,5 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2010/04/25 12:46:19 obache Exp $
+bin/pstotext
+man/man1/pstotext.1
+share/doc/pstotext/pstotext.hlp
+share/doc/pstotext/pstotext.txt
diff --git a/converters/pstotext/distinfo b/converters/pstotext/distinfo
new file mode 100644
index 00000000000..f65497b832b
--- /dev/null
+++ b/converters/pstotext/distinfo
@@ -0,0 +1,7 @@
+$NetBSD: distinfo,v 1.1.1.1 2010/04/25 12:46:19 obache Exp $
+
+SHA1 (pstotext-1.9.tar.gz) = d84732ba42301a8905f6b14f37d8b57ff8b42a3e
+RMD160 (pstotext-1.9.tar.gz) = 16dc199d19df64280184d11ccbced7a32770ddad
+Size (pstotext-1.9.tar.gz) = 37461 bytes
+SHA1 (patch-aa) = ea34c276a605580e9a80427c9f5588c98f8778a0
+SHA1 (patch-ab) = 862d995d54d6962e7e5264674344671fa6308fb1
diff --git a/converters/pstotext/hacks.mk b/converters/pstotext/hacks.mk
new file mode 100644
index 00000000000..b3be7df84b4
--- /dev/null
+++ b/converters/pstotext/hacks.mk
@@ -0,0 +1,20 @@
+# $NetBSD: hacks.mk,v 1.1.1.1 2010/04/25 12:46:19 obache Exp $
+
+.if !defined(PSTOTEXT_HACKS_MK)
+PSTOTEXT_HACKS_MK= defined
+
+.include "../../mk/compiler.mk"
+
+###
+### With debian's security patch patch-ab, pstotext miscompiles under several
+### versions of gcc-4.x when -O2 is used. It compiles fine with the
+### -fno-strict-aliasing option.
+### For the time being, pstotext will be compiled with -fno-strict-aliasing
+### on any platform when gcc-4 is used independent of the compiler options.
+###
+.if !empty(CC_VERSION:Mgcc-4.*)
+PKG_HACKS+= optimisation
+CFLAGS+= -fno-strict-aliasing # must come at the end of CFLAGs.
+.endif
+
+.endif # PSTOTEXT_HACKS_MK
diff --git a/converters/pstotext/patches/patch-aa b/converters/pstotext/patches/patch-aa
new file mode 100644
index 00000000000..8aba02d7179
--- /dev/null
+++ b/converters/pstotext/patches/patch-aa
@@ -0,0 +1,38 @@
+$NetBSD: patch-aa,v 1.1.1.1 2010/04/25 12:46:19 obache Exp $
+
+Fix CC and CFLAGS. They are now set from mk.conf.
+
+--- Makefile.orig 2010-04-17 19:54:01.000000000 -0700
++++ Makefile 2010-04-17 19:54:40.000000000 -0700
+@@ -9,7 +9,7 @@
+ # commenting out the includes of ptotdll.h in ptotdll.c and main.c.
+ # PMcJ 6 Sep 96
+
+-CC=gcc
++#CC=gcc
+ #CC=cc -std
+
+ BUNDLE = ocr.h rot270.h rot90.h
+@@ -17,18 +17,18 @@
+ all: pstotext
+
+ main.o: main.c ptotdll.h bundle.h ocr.h rot270.h rot90.h
+- $(CC) -c $*.c
++ $(CC) $(CFLAGS) -c $*.c
+
+ ptotdll.o: ptotdll.c ptotdll.h
+- $(CC) -c $*.c
++ $(CC) $(CFLAGS) -c $*.c
+
+ pstotext: bundle.o main.o ptotdll.o
+- $(CC) -o pstotext main.o bundle.o ptotdll.o -lm
++ $(CC) $(CFLAGS) -o pstotext main.o bundle.o ptotdll.o -lm
+
+ .SUFFIXES: .ps
+
+ .c.o:
+- $(CC) -c $*.c
++ $(CC) $(CFLAGS) -c $*.c
+
+ # "Bundle" an Ascii file.
+ .ps.h:
diff --git a/converters/pstotext/patches/patch-ab b/converters/pstotext/patches/patch-ab
new file mode 100644
index 00000000000..0ca60b4176e
--- /dev/null
+++ b/converters/pstotext/patches/patch-ab
@@ -0,0 +1,147 @@
+$NetBSD: patch-ab,v 1.1.1.1 2010/04/25 12:46:19 obache Exp $
+
+* Set absolute path for GS cmmand.
+* Fixes CVE-2005-2536 and SA20012
+ Debian's security patch (also used in FreeBSD).
+
+--- main.c.orig 2004-01-09 10:17:38.000000000 +0000
++++ main.c
+@@ -48,7 +48,7 @@ extern BUNDLE ocr, rot270, rot90;
+
+ static BOOLEAN cork = FALSE;
+ static BOOLEAN debug = FALSE;
+-static const char *gs_cmd = "gs";
++static const char *gs_cmd = "@GS_CMD@";
+ static const char *outfile = "";
+
+ static char *cmd; /* = argv[0] */
+@@ -126,12 +126,14 @@ static char *cmdfile = NULL, *gsoutfile
+ static int cleanup(void) {
+ int gsstatus, status = 0;
+ pstotextExit(instance);
+- if (gs!=NULL) {
+ #ifdef VMS
++ if (gs!=NULL) {
+ gsstatus = fclose(gs);
++ }
+ #else
+- gsstatus = pclose(gs);
++ waitpid(-1, &gsstatus, 0);
+ #endif
++ if (gsstatus) {
+ if (WIFEXITED(gsstatus)) {
+ if (WEXITSTATUS(gsstatus)!=0) status = 3;
+ else if (WIFSIGNALED(gsstatus)) status = 4;
+@@ -166,8 +168,13 @@ static void handler(int x) {
+
+ static int do_it(char *path) {
+ /* If "path" is NULL, then "stdin" should be processed. */
+- char *gs_cmdline;
+- char *input;
++ char *gs_argv[32];
++ int gs_argc=0;
++#ifdef DEBUG
++ int i;
++#endif
++ int fd[2];
++ pid_t p;
+ int status;
+ char norotate[] = "";
+ FILE *fileout;
+@@ -201,47 +208,31 @@ static int do_it(char *path) {
+ exit(1);
+ }
+
+- if (path==NULL) {
+- input = (char*)malloc(2);
+- if (input == NULL) {
+- fprintf(stderr,"No memory available\n");
+- cleanup();
+- exit(1);
++ gs_argv[gs_argc++] = "gs";
++ gs_argv[gs_argc++] = "-r72";
++ gs_argv[gs_argc++] = "-dNODISPLAY";
++ gs_argv[gs_argc++] = "-dFIXEDMEDIA";
++ gs_argv[gs_argc++] = "-dDELAYBIND";
++ gs_argv[gs_argc++] = "-dWRITESYSTEMDICT";
++ if (!debug) {
++ gs_argv[gs_argc++] = "-q";
++ }
++ gs_argv[gs_argc++] = "-dNOPAUSE";
++ gs_argv[gs_argc++] = "-dSAFER";
++ if (rotate_path && strcmp(rotate_path, "")) {
++ gs_argv[gs_argc++] = rotate_path;
+ }
+- strcpy(input, "-");
+- } else {
+- input = (char*)malloc(strlen(path) + 6);
+- if (input == NULL) {
+- fprintf(stderr,"No memory available\n");
+- cleanup();
+- exit(1);
++ if (ocr_path && strcmp(ocr_path, "")) {
++ gs_argv[gs_argc++] = ocr_path;
+ }
+- strcpy(input, "-- '"); strcat(input, path); strcat(input, "'");
++ if (path == NULL ) {
++ gs_argv[gs_argc++] = "-";
+ }
+-
+- gs_cmdline = (char*)malloc(strlen(gs_cmd)+strlen(rotate_path)+
+- strlen(ocr_path) + strlen(input) + 128);
+-
+- if (gs_cmdline == NULL) {
+- fprintf(stderr, "No memory available\n");
+- cleanup();
+- exit(1);
++ else {
++ gs_argv[gs_argc++] = "--";
++ gs_argv[gs_argc++] = path;
+ }
+-
+- sprintf(
+- gs_cmdline,
+-#ifdef VMS
+- "%s -r72 \"-dNODISPLAY\" \"-dFIXEDMEDIA\" \"-dDELAYBIND\" \"-dWRITESYSTEMDICT\" %s \"-dNOPAUSE\" %s %s %s",
+-#else
+- "%s -r72 -dNODISPLAY -dFIXEDMEDIA -dDELAYBIND -dWRITESYSTEMDICT %s -dNOPAUSE %s %s %s",
+-#endif
+- gs_cmd,
+- (debug ? "" : "-q"),
+- rotate_path,
+- ocr_path,
+- input
+- );
+- if (debug) fprintf(stderr, "%s\n", gs_cmdline);
++ gs_argv[gs_argc++] = NULL;
+ #ifdef VMS
+ cmdfile = tempnam("SYS$SCRATCH:","PS2TGS");
+ gsoutfile = tempnam("SYS$SCRATCH:","GSRES");
+@@ -259,8 +250,25 @@ static int do_it(char *path) {
+ exit(1);
+ }
+ #else
+- gs = popen(gs_cmdline, "r");
+- if (gs==0) {perror(cmd); exit(1);}
++ if (pipe(fd)) {
++ perror("pipe failed: "); exit(1);
++ };
++ p = fork();
++ if (p == -1) {
++ perror("fork failed: "); exit(1);
++ }
++ if (p == 0) { /* child */
++ close(fd[0]);
++ dup2(fd[1], 1); /* Redirect stdout into pipe to parent */
++ execvp("gs", gs_argv);
++ perror("execvp: "); status=cleanup(); exit(1);
++ } else { /* parent */
++ close(fd[1]);
++ gs = fdopen(fd[0], "r");
++ if (gs == NULL) {
++ perror("fdopen: "); status=cleanup(); exit(1);
++ }
++ }
+ #endif
+ status = pstotextInit(&instance);
+ if (status!=0) {