Port the 64-bit support to unzip 6.10

Marked as untested on 64-bit because I don't have a 64bit install
currently. If you test and enable it, make sure extracting file and
directory attributes works as expected.
This commit is contained in:
Adrien Destugues
2018-01-07 11:54:40 +01:00
parent 4a6698c36b
commit 864e84b41b
3 changed files with 127 additions and 88 deletions

View File

@@ -1,83 +0,0 @@
From 9f375ee32a8c453386ee463f26604d445fe68dfc Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Tue, 14 Oct 2014 20:22:25 +0200
Subject: Make it build on Haiku again
* Fix installation dir for binaries and docs
* Define UNICODE_SUPPORT
* Fix source dir for docs and manpages
diff --git a/beos/Makefile b/beos/Makefile
index 9e86a3d..7f674ac 100644
--- a/beos/Makefile
+++ b/beos/Makefile
@@ -91,18 +91,18 @@ UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
INSTALL = install
# on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
manext = 1
-prefix = /boot/home/config
-BINDIR = $(prefix)/bin# where to install executables
-MANDIR = $(prefix)/man/man$(manext)# where to install man pages
+prefix ?= /boot/home/config
+BINDIR ?= $(prefix)/bin# where to install executables
+MANDIR ?= $(prefix)/man/ # where to install man pages
INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/zipinfo$E $(BINDIR)/unzipsfx$E \
$(BINDIR)/unzip$E
-INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) \
- $(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
+INSTALLEDMAN = $(MANDIR)/man1/unzip.$(manext) $(MANDIR)/man1/funzip.$(manext) \
+ $(MANDIR)/man1/unzipsfx.$(manext) $(MANDIR)/man1/zipinfo.$(manext)
#
UNZIPS = unzip$E funzip$E unzipsfx$E zipinfo$E
# this is a little ugly...well, no, it's a lot ugly:
-MANS = man/unzip.1 man/unzipsfx.1 man/zipinfo.1 man/funzip.1 man/zipgrep.1
-DOCS = unzip.txt unzipsfx.txt zipinfo.txt funzip.txt zipgrep.txt
+MANS = man/man1/unzip.1 man/man1/unzipsfx.1 man/man1/zipinfo.1 man/man1/funzip.1 man/man1/zipgrep.1
+DOCS = docs/unzip.txt docs/unzipsfx.txt docs/zipinfo.txt docs/funzip.txt docs/zipgrep.txt
######################################################################
# Things that change:
@@ -371,11 +371,11 @@ install: all
$(LN) unzip$E $(BINDIR)/zipinfo$E
$(RM) $(BINDIR)/zipgrep$E
$(INSTALL) -m 755 unix/zipgrep $(BINDIR)/zipgrep$E
- $(INSTALL) -m 644 man/unzip.1 $(MANDIR)/unzip.$(manext)
- $(INSTALL) -m 644 man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
- $(INSTALL) -m 644 man/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
- $(INSTALL) -m 644 man/funzip.1 $(MANDIR)/funzip.$(manext)
- $(INSTALL) -m 644 man/zipgrep.1 $(MANDIR)/zipgrep.$(manext)
+ $(INSTALL) -m 644 man/man1/unzip.1 $(MANDIR)/man1/unzip.$(manext)
+ $(INSTALL) -m 644 man/man1/unzipsfx.1 $(MANDIR)/man1/unzipsfx.$(manext)
+ $(INSTALL) -m 644 man/man1/zipinfo.1 $(MANDIR)/man1/zipinfo.$(manext)
+ $(INSTALL) -m 644 man/man1/funzip.1 $(MANDIR)/man1/funzip.$(manext)
+ $(INSTALL) -m 644 man/man1/zipgrep.1 $(MANDIR)/man1/zipgrep.$(manext)
$(INSTALL) -m 644 $(DOCS) $(MANDIR)
# alternatively, could use zip method: -cd $(BINDIR); rm -f $(UNZIPS) [etc.]
diff --git a/beos/beocfg.h b/beos/beocfg.h
index 68584ed..02744c4 100644
--- a/beos/beocfg.h
+++ b/beos/beocfg.h
@@ -68,6 +68,7 @@
/* ISO/OEM (iconv) character conversion. */
+#define UNICODE_SUPPORT
#define ICONV_MAPPING /* part of vanilla Haiku distribution */
#ifdef ICONV_MAPPING
diff --git a/fileio.c b/fileio.c
index 3884ee2..0e17e54 100644
--- a/fileio.c
+++ b/fileio.c
@@ -62,6 +62,7 @@
#define __FILEIO_C /* identifies this source module */
#define UNZIP_INTERNAL
#include "unzip.h"
+
#ifdef DLL
# include "api.h"
#endif /* def DLL */
--
1.8.3.4

View File

@@ -1,4 +1,4 @@
From 94b89957e5960a284dba79386f39fb64df61c849 Mon Sep 17 00:00:00 2001
From 169b0483a4210ede494b8d132659583781f4e501 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 7 Jan 2018 10:40:16 +0100
Subject: Fix BeOS makefile (not really maintained by upstream)
@@ -70,7 +70,7 @@ index b6b6cf9..73764e0 100644
2.15.0
From 1e9782a77b2f5b070df6e89da2a21c272ffc72ea Mon Sep 17 00:00:00 2001
From d997afacc4a3a061dd1976e2d16b3359aab331bc Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 7 Jan 2018 11:09:04 +0100
Subject: Fix writing directory attributes
@@ -94,3 +94,125 @@ index ecdc2c8..1f03710 100644
--
2.15.0
From d998b4385689b34bdc6a5ca1217d1abb3769747a Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 7 Jan 2018 11:46:19 +0100
Subject: Port over 64-bit support from unzip 6.0 patches
The attr_info struct is larger on 64bit systems (extra padding), so it
cannot be memcpy'ed directly out of the stream. We do not really need
the struct anyway, so use two separate variables.
diff --git a/beos/beos.c b/beos/beos.c
index 1f03710..0f06171 100644
--- a/beos/beos.c
+++ b/beos/beos.c
@@ -994,7 +994,7 @@ void close_outfile(__G) /* GRR: change to return PK-style warning level */
extent ucsize = (extent)G.lrec.ucsize;
unsigned BeOSef_len = 0;
extent slnk_entrysize;
- uch *BeOS_exfld;
+ uch *BeOS_exfld = NULL;
slinkentry *slnk_entry;
if (!uO.J_flag) {
@@ -1035,7 +1035,7 @@ void close_outfile(__G) /* GRR: change to return PK-style warning level */
slnk_entry->target = slnk_entry->buf + BeOSef_len;
slnk_entry->fname = slnk_entry->target + ucsize + 1;
strcpy(slnk_entry->fname, G.filename);
- if (BeOSef_len > 0)
+ if (BeOSef_len > sizeof(unsigned))
memcpy(slnk_entry->buf, BeOS_exfld, BeOSef_len);
/* move back to the start of the file to re-read the "link data" */
@@ -1138,7 +1138,7 @@ int set_symlnk_attribs(__G__ slnk_entry)
__GDEF
slinkentry *slnk_entry;
{
- if (slnk_entry->attriblen > 0)
+ if (slnk_entry->attriblen > sizeof(unsigned))
setBeOSexfield(slnk_entry->fname, (uch *)slnk_entry->buf);
/* currently, no error propagation... */
return PK_OK;
@@ -1339,7 +1339,7 @@ yet, or I'd list a few)
*/
static int set_file_attrs( const char *name,
const unsigned char *attr_buff,
- const off_t attr_size )
+ const off_t total_attr_size )
{
int retval = EOK;
unsigned char *ptr;
@@ -1347,7 +1347,7 @@ static int set_file_attrs( const char *name,
int fd;
ptr = (unsigned char *)attr_buff;
- guard = ptr + attr_size;
+ guard = ptr + total_attr_size;
fd = open(name, O_RDONLY | O_NOTRAVERSE);
if (fd < 0) {
@@ -1356,29 +1356,30 @@ static int set_file_attrs( const char *name,
while (ptr < guard) {
ssize_t wrote_bytes;
- struct attr_info fa_info;
const char *attr_name;
unsigned char *attr_data;
+ uint32 attr_type;
+ int64 attr_size;
attr_name = (char *)&(ptr[0]);
ptr += strlen(attr_name) + 1;
/* The attr_info data is stored in big-endian format because the */
/* PowerPC port was here first. */
- memcpy(&fa_info, ptr, sizeof(struct attr_info));
- fa_info.type = (uint32)B_BENDIAN_TO_HOST_INT32( fa_info.type );
- fa_info.size = (off_t)B_BENDIAN_TO_HOST_INT64( fa_info.size );
- ptr += sizeof(struct attr_info);
+ memcpy(&attr_type, ptr, 4); ptr += 4;
+ memcpy(&attr_size, ptr, 8); ptr += 8;
+ attr_type = (uint32)B_BENDIAN_TO_HOST_INT32(attr_type);
+ attr_size = (uint32)B_BENDIAN_TO_HOST_INT64(attr_size);
- if (fa_info.size < 0LL) {
+ if (attr_size < 0LL) {
Info(slide, 0x201, ((char *)slide,
"warning: skipping attribute with invalid length (%Ld)\n",
- fa_info.size));
+ attr_size));
break;
}
attr_data = ptr;
- ptr += fa_info.size;
+ ptr += attr_size;
if (ptr > guard) {
/* We've got a truncated attribute. */
@@ -1388,15 +1389,15 @@ static int set_file_attrs( const char *name,
}
/* Wave the magic wand... this will swap Be-known types properly. */
- (void)swap_data( fa_info.type, attr_data, fa_info.size,
+ (void)swap_data( attr_type, attr_data, attr_size,
B_SWAP_BENDIAN_TO_HOST );
- wrote_bytes = fs_write_attr(fd, attr_name, fa_info.type, 0,
- attr_data, fa_info.size);
- if (wrote_bytes != fa_info.size) {
+ wrote_bytes = fs_write_attr(fd, attr_name, attr_type, 0,
+ attr_data, attr_size);
+ if (wrote_bytes != attr_size) {
Info(slide, 0x201, ((char *)slide,
"warning: wrote %ld attribute bytes of %ld\n",
- (unsigned long)wrote_bytes,(unsigned long)fa_info.size));
+ (unsigned long)wrote_bytes,(unsigned long)attr_size));
}
}
--
2.15.0

View File

@@ -3,15 +3,15 @@ DESCRIPTION="UnZip is an extraction utility for archives compressed in \
.zip format (zipfiles). UnZip can list or extract files from an archive \
or test its integrity."
HOMEPAGE="http://www.info-zip.org/UnZip.html"
COPYRIGHT="1995-2014 Greg Roelofs"
COPYRIGHT="1990-2017 Info-ZIP"
LICENSE="Info-ZIP"
REVISION="1"
REVISION="2"
SOURCE_URI="http://antinode.info/ftp/info-zip/unzip610c23.zip"
SOURCE_DIR="unzip610c23"
CHECKSUM_SHA256="a9c3f0b4377aa593a77574e2fb69aeab97e66e93d8b110797f7b329e09848b62"
PATCHES="unzip-6.10c23.patchset"
ARCHITECTURES="x86_gcc2"
ARCHITECTURES="x86_gcc2 ?x86_64"
PROVIDES="
unzip = $portVersion