From ca9627e70852f6b2e835660df870fe3ab405882d Mon Sep 17 00:00:00 2001
From: "Suren A. Chilingaryan" <csa@suren.me>
Date: Sun, 1 Sep 2019 00:00:32 +0200
Subject: Initial import

---
 .../ruszip/files/zip-2.3-unix_configure-pic.patch  |  12 ++
 app-arch/ruszip/files/zip-2.31-exec-stack.patch    |  20 +++
 app-arch/ruszip/files/zip-2.32-build.patch         |  89 +++++++++++
 app-arch/ruszip/files/zip232-ds-recoderus.patch    | 165 +++++++++++++++++++++
 4 files changed, 286 insertions(+)
 create mode 100644 app-arch/ruszip/files/zip-2.3-unix_configure-pic.patch
 create mode 100644 app-arch/ruszip/files/zip-2.31-exec-stack.patch
 create mode 100644 app-arch/ruszip/files/zip-2.32-build.patch
 create mode 100644 app-arch/ruszip/files/zip232-ds-recoderus.patch

(limited to 'app-arch/ruszip/files')

diff --git a/app-arch/ruszip/files/zip-2.3-unix_configure-pic.patch b/app-arch/ruszip/files/zip-2.3-unix_configure-pic.patch
new file mode 100644
index 0000000..45b137b
--- /dev/null
+++ b/app-arch/ruszip/files/zip-2.3-unix_configure-pic.patch
@@ -0,0 +1,12 @@
+--- unix/configure.orig	2004-09-28 06:45:33.000000000 +0000
++++ unix/configure	2004-09-28 06:54:53.000000000 +0000
+@@ -29,6 +29,9 @@
+ 
+ echo Check if we can use asm code
+ OBJA=""
++piclib="$(echo | $CPP -dM $CFLAGS - | grep -i __pic__)"
++echo "Checking if compiler wants to create pic code"
++[ "$piclib" == "" ] && \
+ if eval "$CPP match.S > _match.s 2>/dev/null"; then
+   if test ! -s _match.s || grep error < _match.s > /dev/null; then
+     :
diff --git a/app-arch/ruszip/files/zip-2.31-exec-stack.patch b/app-arch/ruszip/files/zip-2.31-exec-stack.patch
new file mode 100644
index 0000000..d3efbd9
--- /dev/null
+++ b/app-arch/ruszip/files/zip-2.31-exec-stack.patch
@@ -0,0 +1,20 @@
+--- zip-2.31/crc_i386.S
++++ zip-2.31/crc_i386.S
+@@ -238,3 +238,7 @@
+ #endif /* i386 || _i386 || _I386 || __i386 */
+ 
+ #endif /* !USE_ZLIB */
++
++#ifdef __ELF__
++.section .note.GNU-stack,"",@progbits
++#endif
+--- zip-2.31/match.S
++++ zip-2.31/match.S
+@@ -405,3 +405,7 @@
+ #endif /* i386 || _I386 || _i386 || __i386  */
+ 
+ #endif /* !USE_ZLIB */
++
++#ifdef __ELF__
++.section .note.GNU-stack,"",@progbits
++#endif
diff --git a/app-arch/ruszip/files/zip-2.32-build.patch b/app-arch/ruszip/files/zip-2.32-build.patch
new file mode 100644
index 0000000..61a2bae
--- /dev/null
+++ b/app-arch/ruszip/files/zip-2.32-build.patch
@@ -0,0 +1,89 @@
+respect build environment settings
+
+--- zip/unix/Makefile
++++ zip/unix/Makefile
+@@ -12,15 +12,15 @@
+ 
+ list:   all
+ 
+-MAKE = make -f unix/Makefile
++MAKE := $(MAKE) -f unix/Makefile
+ SHELL = /bin/sh
+ LN = ln -s
+ 
+ # (to use the Gnu compiler, change cc to gcc in CC)
+-CC = cc
++CC ?= gcc
+ BIND = $(CC)
+ AS = $(CC) -c
+-CPP = /lib/cpp
++CPP ?= $(CC)
+ EXE =
+ 
+ # probably can change this to 'install' if you have it
+@@ -47,7 +47,7 @@
+ #   LFLAGS1   flags after output file spec, before obj file list
+ #   LFLAGS2   flags after obj file list (libraries, etc)
+ CFLAGS_NOOPT = -I. -DUNIX $(LOCAL_ZIP)
+-CFLAGS = -O2 $(CFLAGS_NOOPT)
++CFLAGS ?= -O2 $(CFLAGS_NOOPT)
+ LFLAGS1 =
+ LFLAGS2 = -s
+ 
+--- zip/unix/configure
++++ zip/unix/configure
+@@ -13,52 +13,13 @@
+ 
+ CC=${1-cc}
+-CFLAGS=${2-"-I. -DUNIX"}
+-LFLAGS1=""
++CFLAGS="${2--I. -DUNIX} ${CFLAGS} ${CPPFLAGS}"
++LFLAGS1="${LDFLAGS}"
+ LN="ln -s"
+-echo "Check C compiler type (optimization option)"
+-cat > conftest.c << _EOF_
+-int main()
+-{
+-#ifndef __SUNPRO_C
+-   bad code
+-#endif
+-   return 0;
+-}
+-_EOF_
+-$CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
+-if test $? -eq 0; then
+-  echo '  Sun C (-xO3)'
+-  CFLAGS="${CFLAGS} -xO3"
+-else
+-  cat > conftest.c << _EOF_
+-int main()
+-{
+-#ifndef __DECC
+-   bad code
+-#endif
+-   return 0;
+-}
+-_EOF_
+-  $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
+-  if test $? -eq 0; then
+-    echo '  DEC C (-O3)'
+-    CFLAGS="${CFLAGS} -O3"
+-  else
+-    echo '  Other (gcc?) (-O2)'
+-    CFLAGS="${CFLAGS} -O2"
+-  fi
+-fi
+ 
+ echo Check for the C preprocessor
+ # on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
+ CPP="${CC} -E"
+ # solaris as(1) needs -P, maybe others as well ?
+-[ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
+-[ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
+-[ -f /lib/cpp ] && CPP=/lib/cpp
+-[ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
+-[ -f /xenix ] && CPP="${CC} -E"
+-[ -f /lynx.os ] && CPP="${CC} -E"
+ 
+ echo "#include <stdio.h>" > conftest.c
+ $CPP conftest.c >/dev/null 2>/dev/null || CPP="${CC} -E"
diff --git a/app-arch/ruszip/files/zip232-ds-recoderus.patch b/app-arch/ruszip/files/zip232-ds-recoderus.patch
new file mode 100644
index 0000000..de3e337
--- /dev/null
+++ b/app-arch/ruszip/files/zip232-ds-recoderus.patch
@@ -0,0 +1,165 @@
+diff -dPNur zip-2.32/unix/dsrecode.h zip-2.32-2/unix/dsrecode.h
+--- zip-2.32/unix/dsrecode.h	1970-01-01 01:00:00.000000000 +0100
++++ zip-2.32-2/unix/dsrecode.h	2008-10-07 11:22:48.000000000 +0200
+@@ -0,0 +1,130 @@
++/******* WARNING: Multi-byte output encodings isn't supported! Comments
++may been striped!!!! 
++I don't close 2 opened iconv descriptors. I think this wouldn't cause any
++problem. *******/
++
++#include <iconv.h>
++#include <errno.h>
++#include <locale.h>
++
++#define CHARSET_MAX_STRING_SIZE 4096
++#define LOCALE_STRING_LENGTH 64
++#define CHARSET_MAX_ERRORS 0
++#define ENV_VARIABLE "LC_CTYPE"
++#define LOCALE_VARIABLE LC_CTYPE
++
++static iconv_t ds_oem = (iconv_t)-1;
++static iconv_t ds_iso = (iconv_t)-1;
++
++extern int errno;
++static char xmms_charset_tmp[CHARSET_MAX_STRING_SIZE];
++static char charset_default[LOCALE_STRING_LENGTH]="";
++
++// Multi-byte strings still unsupported
++static void iconv_copysymbol(char **in_buf, size_t *in_left, char **out_buf, size_t *out_left) {
++    if ((out_left>0)&&(in_left>0)) {
++	(**out_buf)=(**in_buf);
++	(*out_buf)++;
++	(*in_buf)++;
++	(*in_left)--;
++	(*out_left)--;
++    }
++}
++
++static char *ds_recode(iconv_t icnv, char *buf, size_t len, size_t *rlen) {
++    char *in_buf, *out_buf, *res, err;
++    size_t in_left, out_left, olen;
++    int errors=0;
++    
++    if (!len) {
++	len=strlen(buf);
++    } else {
++	olen=strlen(buf);
++	if (olen<len) len=olen;
++    }
++
++    if (iconv(icnv, NULL, NULL, NULL, NULL) == -1) return NULL;
++
++    in_buf = buf;
++    in_left = len;
++    out_buf = xmms_charset_tmp;
++    out_left = CHARSET_MAX_STRING_SIZE;
++
++loop:
++    err=iconv(icnv, &in_buf, &in_left, &out_buf, &out_left);
++    if (err<0) {
++        if (errno==E2BIG) {
++    	    *(int*)(xmms_charset_tmp+(CHARSET_MAX_STRING_SIZE-sizeof(int)))=0;
++	} else if (errno==EILSEQ) {
++	    if (errors<CHARSET_MAX_ERRORS) {
++	        errors++;
++		iconv_copysymbol(&in_buf, &in_left, &out_buf, &out_left);
++		if (in_left>0) goto loop;
++	    } else return NULL;
++	} else return NULL;
++    }
++        
++    olen = CHARSET_MAX_STRING_SIZE - out_left;
++    res = malloc(olen+1);
++    if (!res) return NULL;
++
++    memcpy(res,xmms_charset_tmp,olen);
++    res[olen]=0;
++    if (rlen) *rlen=olen;
++    return res;
++}
++
++
++static void charset_setdefault() {
++    char *str1, *str2;
++    str1 = (char*)setlocale(LOCALE_VARIABLE, NULL);
++    if (str1) { 
++	if (!strcasecmp(str1,"C")) {
++	    setlocale(LC_ALL, ""); 
++	    str1 = setlocale(LOCALE_VARIABLE, NULL);
++	}
++    } else str1 = getenv(ENV_VARIABLE);
++    if (str1) {
++        str2 = strrchr(str1,'.');
++        if (str2) {
++	    strncpy(charset_default,str2+1,LOCALE_STRING_LENGTH);
++	    charset_default[LOCALE_STRING_LENGTH-1]=0;
++	    str2 = strchr(charset_default,'@');
++    	    if (str2) *str2 = 0;
++	} else {
++    	    strcpy(charset_default,"KOI8-R");
++	}
++    } else {
++        strcpy(charset_default,"KOI8-R");
++    }
++}
++
++void ds_ex2in(char *string) {
++    char *str;
++    if (ds_oem == (iconv_t)-1) {
++	if (!charset_default[0]) charset_setdefault();
++	ds_oem = iconv_open("CP866",charset_default);
++	if (!ds_oem) return;
++    }
++    str=ds_recode(ds_oem,string,0,NULL);
++    if (str) {
++	strncpy(string,str,strlen(string)+1);
++	free(str);
++    }
++}
++
++void ds_in2ex(char *dst, char *string) {
++    char *str;
++    if (ds_iso == (iconv_t)-1) {
++	if (!charset_default[0]) charset_setdefault();
++	ds_iso = iconv_open(charset_default, "CP866");
++	if (!ds_iso) return;
++    }
++    str=ds_recode(ds_iso,string,0,NULL);
++    if (str) {
++	strncpy(dst,str,strlen(string)+1);
++	free(str);
++    } else {
++	strncpy(dst,string,strlen(string)+1);
++    }
++}
+diff -dPNur zip-2.32/unix/unix.c zip-2.32-2/unix/unix.c
+--- zip-2.32/unix/unix.c	2006-05-30 00:35:00.000000000 +0200
++++ zip-2.32-2/unix/unix.c	2008-10-07 11:23:45.000000000 +0200
+@@ -219,6 +219,8 @@
+   return ZE_OK;
+ }
+ 
++#include "dsrecode.h"
++
+ char *ex2in(x, isdir, pdosflag)
+ char *x;                /* external file name */
+ int isdir;              /* input: x is a directory */
+@@ -266,6 +268,8 @@
+ 
+ #ifdef EBCDIC
+   strtoasc(n, n);       /* here because msname() needs native coding */
++#else
++  ds_ex2in(n);
+ #endif
+ 
+   /* Returned malloc'ed name */
+@@ -288,7 +292,8 @@
+ #ifdef EBCDIC
+   strtoebc(x, n);
+ #else
+-  strcpy(x, n);
++//  strcpy(x, n);
++    ds_in2ex(x,n);
+ #endif
+   return x;
+ }
-- 
cgit v1.2.3