From b8323edbf3d143c098909f4ba9e28b71cce455a7 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 21 Jan 2018 14:16:33 +0100 Subject: [PATCH] Reworked patch Unzip 6.10 now uses the UNIX makefiles, like the 6.0 version. This should help getting it to build on 64bit systems. --- app-arch/unzip/patches/unzip-6.10c23.patchset | 764 +++++++++++++----- app-arch/unzip/unzip-6.10c23.recipe | 18 +- 2 files changed, 584 insertions(+), 198 deletions(-) diff --git a/app-arch/unzip/patches/unzip-6.10c23.patchset b/app-arch/unzip/patches/unzip-6.10c23.patchset index 2bd17d2b7..a84a01699 100644 --- a/app-arch/unzip/patches/unzip-6.10c23.patchset +++ b/app-arch/unzip/patches/unzip-6.10c23.patchset @@ -1,198 +1,596 @@ -From 169b0483a4210ede494b8d132659583781f4e501 Mon Sep 17 00:00:00 2001 +From 5e93b50f6067bc15f4002f4c06d1f769bae7ca47 Mon Sep 17 00:00:00 2001 From: Adrien Destugues -Date: Sun, 7 Jan 2018 10:40:16 +0100 -Subject: Fix BeOS makefile (not really maintained by upstream) +Date: Sun, 21 Jan 2018 13:41:08 +0100 +Subject: Import revised patch from upstream. -* 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..102d847 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) +diff --git a/unix/Makefile b/unix/Makefile +index aa889d0..1dd4989 100644 +--- a/unix/Makefile ++++ b/unix/Makefile +@@ -1,8 +1,8 @@ + #============================================================================== + # unix/Makefile +-# - For UnZip, fUnZip, UnZipSFX, and ZipInfo Revised: 2017-04-28 ++# - For UnZip, fUnZip, UnZipSFX, and ZipInfo Revised: 2018-01-16 # - 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 +-# Copyright (c) 2004-2017 Info-ZIP. All rights reserved. ++# Copyright (c) 2004-2018 Info-ZIP. All rights reserved. + # + # See the accompanying file LICENSE, version 2009-Jan-2 or later (the + # contents of which are also included in zip.h) for terms of use. If, +@@ -129,13 +129,14 @@ MISC_TARGETS = clean clean_bzip2 clean_docs clean_exe dashv + SYS_TARGETS01 = 386i 3Bx 7300 7300_gcc amdahl amdahl_eft apollo aviion + SYS_TARGETS02 = bsd bsdi bsdi_noasm bull coherent convex cray cray_opt + SYS_TARGETS03 = cyber_sgi cygwin dec dnix encore eta freebsd gcc gould +-SYS_TARGETS04 = hk68 hp hpux isc isc_gcc isi linux linux_dos linux_noasm +-SYS_TARGETS05 = lynx macosx macosx_gcc minix mips +-SYS_TARGETS06 = mpeix next next10 next2x next3x nextfat osf1 pixel ptx +-SYS_TARGETS07 = pyramid qnxnto realix regulus sco sco_dos sco_sl sco_x286 +-SYS_TARGETS08 = sequent sgi solaris stardent stellar sunos3 sunos4 +-SYS_TARGETS09 = sysv sysv_gcc sysv6300 tahoe ti_sysv ultrix vax v7 +-SYS_TARGETS10 = xenix xos ++SYS_TARGETS04 = haiku hk68 hp hpux isc isc_gcc isi ++SYS_TARGETS05 = linux linux_dos linux_noasm lynx ++SYS_TARGETS06 = macosx macosx_gcc minix mips mpeix ++SYS_TARGETS07 = next next10 next2x next3x nextfat osf1 ++SYS_TARGETS08 = pixel ptx pyramid qnxnto realix regulus ++SYS_TARGETS09 = sco sco_dos sco_sl sco_x286 sequent sgi solaris ++SYS_TARGETS10 = stardent stellar sunos3 sunos4 sysv sysv_gcc sysv6300 ++SYS_TARGETS11 = tahoe ti_sysv ultrix vax v7 xenix xos - ###################################################################### - # 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) + # By default, print help on which "make" targets to try. - # alternatively, could use zip method: -cd $(BINDIR); rm -f $(UNZIPS) [etc.] -diff --git a/beos/beocfg.h b/beos/beocfg.h -index b6b6cf9..73764e0 100644 ---- a/beos/beocfg.h -+++ b/beos/beocfg.h -@@ -69,6 +69,7 @@ +@@ -258,6 +259,7 @@ list: + @echo " $(SYS_TARGETS08)" + @echo " $(SYS_TARGETS09)" + @echo " $(SYS_TARGETS10)" ++ @echo " $(SYS_TARGETS11)" + @echo '' + @echo 'Miscellaneous targets:' + @echo " $(MISC_TARGETS)" +@@ -1650,6 +1652,17 @@ gcc: unix_make + $(MAKE) $(BINS) CC=gcc LD=gcc CFLAGS="-O3" LF2="" + $(STRIP) $(UNZIP_PPGMS) - /* ISO/OEM (iconv) character conversion. */ ++# Haiku ++haiku: unix_make ++ $(MAKE) $(BINS) \ ++ CC="cc" CFLAGS=" -O3 -DLARGE_FILE_SUPPORT -DUNICODE_SUPPORT \ ++ -DUNICODE_WCHAR -DUNICODE_SUPPORT -DUTF8_MAYBE_NATIVE \ ++ -DNO_LCHMOD -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -D_MBCS \ ++ -DNO_SYSDIR" \ ++ CRCA_O="" AS="cc -c" LFLAGS1="-lbe" LF2="-s" \ ++ CC_BZ="cc" CFLAGS_BZ="-O3" \ ++ IZ_BZIP2="." D_USE_BZ2="" L_BZ2="" LIBBZ2="" ++ + # Heurikon HK68 (68010), UniPlus+ System V 5.0, Green Hills C-68000 + hk68: unix_make + $(MAKE) $(BINS) CC="gcc" LD="gcc" \ +diff --git a/unix/unix.c b/unix/unix.c +index d839c18..ffb997b 100644 +--- a/unix/unix.c ++++ b/unix/unix.c +@@ -54,6 +54,21 @@ + # endif + #endif -+#define UNICODE_SUPPORT - #define ICONV_MAPPING /* part of vanilla Haiku distribution */ - - #ifdef ICONV_MAPPING --- -2.15.0 - - -From d997afacc4a3a061dd1976e2d16b3359aab331bc Mon Sep 17 00:00:00 2001 -From: Adrien Destugues -Date: Sun, 7 Jan 2018 11:09:04 +0100 -Subject: Fix writing directory attributes - -It is not allowed to open a directory in write mode. -Fortunately, fs_write_attr accepts a read-only file descriptor. - -diff --git a/beos/beos.c b/beos/beos.c -index ecdc2c8..1f03710 100644 ---- a/beos/beos.c -+++ b/beos/beos.c -@@ -1349,7 +1349,7 @@ static int set_file_attrs( const char *name, - ptr = (unsigned char *)attr_buff; - guard = ptr + attr_size; - -- fd = open(name, O_RDWR | O_NOTRAVERSE); -+ fd = open(name, O_RDONLY | O_NOTRAVERSE); - if (fd < 0) { - return errno; /* should it be -fd ? */ ++#ifdef __HAIKU__ ++# include ++# include ++# include ++# define EB_BE_FL_BADBITS 0xfe /* bits currently undefined */ ++static uch *scanBeOSexfield OF((const uch *ef_ptr, unsigned ef_len)); ++static void setBeOSexfield OF((const char *path, uch *extra_field)); ++# ifdef BEOS_USE_PRINTEXFIELD ++static void printBeOSexfield OF((int isdir, uch *extra_field)); ++# endif ++# ifdef BEOS_ASSIGN_FILETYPE ++static void assign_MIME( const char * ); ++# endif ++#endif /* def __HAIKU__ */ ++ + #ifdef _POSIX_VERSION + # ifndef DIRENT + # define DIRENT +@@ -690,6 +705,17 @@ int mapname(__G__ renamed) + G.action_msg_str = "creat"; + #endif /* def ENABLE_USER_PROGRESS */ + } ++ ++#ifdef __HAIKU__ ++ if (!uO.J_flag) { /* Handle the BeOS extra field if present. */ ++ void *ptr = scanBeOSexfield(G.extra_field, ++ G.lrec.extra_field_length); ++ if (ptr) { ++ setBeOSexfield(G.filename, ptr); ++ } ++ } ++#endif /* def __HAIKU__ */ ++ + #ifndef NO_CHMOD + # ifdef KFLAG + if (uO.kflag >= 0) +@@ -721,6 +747,20 @@ int mapname(__G__ renamed) + /* set dir time (note trailing '/') */ + return (error & ~MPN_MASK) | MPN_CREATED_DIR; + } ++ ++#ifdef __HAIKU__ ++ /* TODO: should we re-write the BeOS extra field data in case it's ++ * changed? The answer is yes. [Sept 1999 - cjh] ++ */ ++ if (!uO.J_flag) { /* Handle the BeOS extra field if present. */ ++ void *ptr = scanBeOSexfield(G.extra_field, ++ G.lrec.extra_field_length); ++ if (ptr) { ++ setBeOSexfield(G.filename, ptr); ++ } ++ } ++#endif /* def __HAIKU__ */ ++ + /* dir existed already; don't look for data to extract */ + return (error & ~MPN_MASK) | MPN_INF_SKIP; } --- -2.15.0 - - -From d998b4385689b34bdc6a5ca1217d1abb3769747a Mon Sep 17 00:00:00 2001 -From: Adrien Destugues -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; +@@ -1233,14 +1273,29 @@ void close_outfile(__G) /* GRR: change to return PK-style warning level */ + # else + extent attribsize = 0; + # endif ++ extent slnk_entrysize; ++ slinkentry *slnk_entry; ++ ++# ifdef __HAIKU__ ++ uch *BeOS_exfld; ++ ++ if (!uO.J_flag) { ++ /* Symlinks can have attributes, too. */ ++ BeOS_exfld = scanBeOSexfield(G.extra_field, ++ G.lrec.extra_field_length); ++ if (BeOS_exfld) { ++ attribsize = makeword(EB_LEN + BeOS_exfld) + EB_HEADSIZE; ++ } ++ } ++# endif /* def __HAIKU__ */ ++ + /* size of the symlink entry is the sum of + * (struct size (includes 1st '\0') + 1 additional trailing '\0'), + * system specific attribute data size (might be 0), + * and the lengths of name and link target. + */ +- extent slnk_entrysize = (sizeof(slinkentry) + 1) + attribsize + ++ slnk_entrysize = (sizeof(slinkentry) + 1) + attribsize + + ucsize + strlen(G.filename); +- 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; + if (slnk_entrysize < ucsize) { + Info(slide, 0x201, ((char *)slide, +@@ -1261,11 +1316,18 @@ void close_outfile(__G) /* GRR: change to return PK-style warning level */ + slnk_entry->targetlen = ucsize; + slnk_entry->attriblen = attribsize; + # ifdef SET_SYMLINK_ATTRIBS +- memcpy(slnk_entry->buf, &(G.pInfo->file_attr), +- sizeof(unsigned)); ++ ++# ifdef __HAIKU__ ++ if (attribsize > sizeof(unsigned)) ++ memcpy(slnk_entry->buf, BeOS_exfld, attribsize); ++# else ++ memcpy(slnk_entry->buf, &(G.pInfo->file_attr), sizeof(unsigned)); + if (have_uidgid_flg) + memcpy(slnk_entry->buf + 4, z_uidgid, sizeof(z_uidgid)); +-# endif ++# endif /* def __HAIKU__ */ ++ ++# endif /* def SET_SYMLINK_ATTRIBS */ ++ + slnk_entry->target = slnk_entry->buf + slnk_entry->attriblen; 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 +@@ -1452,6 +1514,13 @@ int set_symlnk_attribs(__G__ slnk_entry) 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 ) + if (slnk_entry->attriblen > 0) { ++ ++# ifdef __HAIKU__ ++ if (slnk_entry->attriblen > sizeof(unsigned)) { ++ setBeOSexfield(slnk_entry->fname, (uch *)slnk_entry->buf); ++ } ++# endif ++ + # ifndef NO_LCHOWN + if (slnk_entry->attriblen > sizeof(unsigned)) { + ulg *z_uidgid_p = (zvoid *)(slnk_entry->buf + sizeof(unsigned)); +@@ -2286,6 +2355,287 @@ static void qlfix(__G__ ef_ptr, ef_len) + #endif /* def QLZIP */ + + ++#ifdef __HAIKU__ ++ ++/******************************/ ++/* Extra field functions */ ++/******************************/ ++ ++/* ++ * Scan the extra fields in extra_field, and look for a BeOS EF. ++ * Return a pointer to that EF, or NULL if it's not there. ++ */ ++static uch *scanBeOSexfield(const uch *ef_ptr, unsigned ef_len) ++{ ++ while( ef_ptr != NULL && ef_len >= EB_HEADSIZE ) { ++ unsigned eb_id = makeword(EB_ID + ef_ptr); ++ unsigned eb_len = makeword(EB_LEN + ef_ptr); ++ ++ if (eb_len > (ef_len - EB_HEADSIZE)) { ++ Trace((stderr, ++ "scanBeOSexfield: block length %u > rest ef_size %u\n", eb_len, ++ ef_len - EB_HEADSIZE)); ++ break; ++ } ++ ++ if (eb_id == EF_BEOS && eb_len >= EB_BEOS_HLEN) { ++ return (uch *)ef_ptr; ++ } ++ ++ ef_ptr += (eb_len + EB_HEADSIZE); ++ ef_len -= (eb_len + EB_HEADSIZE); ++ } ++ ++ return NULL; ++} ++ ++/* Used by setBeOSexfield(): ++ * ++ * Set a file/directory's attributes to the attributes passed in. ++ * ++ * If set_file_attrs() fails, an error will be returned: ++ * EOK - no errors occurred ++ * (Other values will be whatever the failed function returned. ++ * No docs yet, or I'd list a few.) ++ */ ++static int set_file_attrs( const char *name, ++ const unsigned char *attr_buff, + 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; ++{ ++ int retval = EOK; ++ unsigned char *ptr; ++ const unsigned char *guard; ++ int fd; ++ ++ ptr = (unsigned char *)attr_buff; + 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) { ++ ++ fd = open(name, O_RDONLY | O_NOTRAVERSE); ++ if (fd < 0) { ++ return errno; /* should it be -fd ? */ ++ } ++ ++ while (ptr < guard) { ++ ssize_t wrote_bytes; ++ 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(&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 = (off_t)B_BENDIAN_TO_HOST_INT64( attr_size ); ++ + if (attr_size < 0LL) { - Info(slide, 0x201, ((char *)slide, - "warning: skipping attribute with invalid length (%Ld)\n", -- fa_info.size)); ++ Info(slide, 0x201, ((char *)slide, ++ "warning: skipping attribute with invalid length (%Ld)\n", + attr_size)); - break; - } - - attr_data = ptr; -- ptr += fa_info.size; ++ break; ++ } ++ ++ attr_data = ptr; + ptr += attr_size; ++ ++ if (ptr > guard) { ++ /* We've got a truncated attribute. */ ++ Info(slide, 0x201, ((char *)slide, ++ "warning: truncated attribute\n")); ++ break; ++ } ++ ++ /* Wave the magic wand... this will swap Be-known types properly. */ ++ (void)swap_data( fa_info.type, attr_data, fa_info.size, ++ B_SWAP_BENDIAN_TO_HOST ); ++ ++ 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)attr_size)); ++ } ++ } ++ ++ close(fd); ++ ++ return retval; ++} ++ ++static void setBeOSexfield(const char *path, uch *extra_field) ++{ ++ uch *ptr = extra_field; ++ ush id = 0; ++ ush size = 0; ++ ulg full_size = 0; ++ uch flags = 0; ++ uch *attrbuff = NULL; ++ int retval; ++ ++ if( extra_field == NULL ) { ++ return; ++ } ++ ++ /* Collect the data from the extra field buffer. */ ++ id = makeword(ptr); ptr += 2; /* we don't use this... */ ++ size = makeword(ptr); ptr += 2; ++ full_size = makelong(ptr); ptr += 4; ++ flags = *ptr; ptr++; ++ ++ /* Do a little sanity checking. */ ++ if (flags & EB_BE_FL_BADBITS) { ++ /* corrupted or unsupported */ ++ Info(slide, 0x201, ((char *)slide, ++ "Unsupported flags set for this BeOS extra field, skipping.\n")); ++ return; ++ } ++ if (size <= EB_BEOS_HLEN) { ++ /* corrupted, unsupported, or truncated */ ++ Info(slide, 0x201, ((char *)slide, ++ "BeOS extra field is %d bytes, should be at least %d.\n", size, ++ EB_BEOS_HLEN)); ++ return; ++ } ++ if (full_size < (size - EB_BEOS_HLEN)) { ++ /* possible old archive? will this screw up on valid archives? */ ++ Info(slide, 0x201, ((char *)slide, ++ "Skipping attributes: BeOS extra field is %d bytes, " ++ "data size is %ld.\n", size - EB_BEOS_HLEN, full_size)); ++ return; ++ } ++ ++ /* Find the BeOS file attribute data. */ ++ if (flags & EB_BE_FL_UNCMPR) { ++ /* Uncompressed data */ ++ attrbuff = ptr; ++ } else { ++ /* Compressed data */ ++ attrbuff = (uch *)malloc( full_size ); ++ if (attrbuff == NULL) { ++ /* No memory to uncompress attributes */ ++ Info(slide, 0x201, ((char *)slide, ++ "Can't allocate memory to uncompress file attributes.\n")); ++ return; ++ } ++ ++ retval = memextract(__G__ attrbuff, full_size, ++ ptr, size - EB_BEOS_HLEN); ++ if( retval != PK_OK ) { ++ /* error uncompressing attributes */ ++ Info(slide, 0x201, ((char *)slide, ++ "Error uncompressing file attributes.\n")); ++ ++ /* Some errors here might not be so bad. We should expect ++ * some truncated data, for example. If the data were ++ * corrupt, we should _not_ attempt to restore the attrs ++ * for this file... there's no way to detect what attrs ++ * are good and which are bad. ++ */ ++ free (attrbuff); ++ return; ++ } ++ } ++ ++ /* Now attempt to set the file attributes on the extracted file. */ ++ retval = set_file_attrs(path, attrbuff, (off_t)full_size); ++ if (retval != EOK) { ++ Info(slide, 0x201, ((char *)slide, ++ "Error writing file attributes.\n")); ++ } ++ ++ /* Clean up, if necessary */ ++ if (attrbuff != ptr) { ++ free(attrbuff); ++ } ++ return; ++} ++ ++# ifdef BEOS_USE_PRINTEXFIELD ++static void printBeOSexfield( int isdir, uch *extra_field ) ++{ ++ uch *ptr = extra_field; ++ ush id = 0; ++ ush size = 0; ++ ulg full_size = 0; ++ uch flags = 0; ++ ++ /* Tell picky compilers to be quiet. */ ++ isdir = isdir; ++ ++ if( extra_field == NULL ) { ++ return; ++ } ++ ++ /* Collect the data from the buffer. */ ++ id = makeword( ptr ); ptr += 2; ++ size = makeword( ptr ); ptr += 2; ++ full_size = makelong( ptr ); ptr += 4; ++ flags = *ptr; ptr++; ++ ++ if( id != EF_BEOS ) { ++ /* not a 'Be' field */ ++ printf("\t*** Unknown field type (0x%04x, '%c%c')\n", id, ++ (char)(id >> 8), (char)id); ++ } ++ ++ if( flags & EB_BE_FL_BADBITS ) { ++ /* corrupted or unsupported */ ++ printf("\t*** Corrupted BeOS extra field:\n"); ++ printf("\t*** unknown bits set in the flags\n"); ++ printf("\t*** (Possibly created by an old version of zip for BeOS.\n"); ++ } ++ ++ if( size <= EB_BEOS_HLEN ) { ++ /* corrupted, unsupported, or truncated */ ++ printf("\t*** Corrupted BeOS extra field:\n"); ++ printf("\t*** size is %d, should be larger than %d\n", size, ++ EB_BEOS_HLEN ); ++ } ++ ++ if( flags & EB_BE_FL_UNCMPR ) { ++ /* Uncompressed data */ ++ printf("\tBeOS extra field data (uncompressed):\n"); ++ printf("\t\t%ld data bytes\n", full_size); ++ } else { ++ /* Compressed data */ ++ printf("\tBeOS extra field data (compressed):\n"); ++ printf("\t\t%d compressed bytes\n", size - EB_BEOS_HLEN); ++ printf("\t\t%ld uncompressed bytes\n", full_size); ++ } ++} ++# endif /* def BEOS_USE_PRINTEXFIELD */ ++ ++# ifdef BEOS_ASSIGN_FILETYPE ++/* Note: This will no longer be necessary in BeOS PR4. ++ * update_mime_info() will be updated to build its own absolute pathname ++ * if it's not given one. ++ */ ++static void assign_MIME( const char *file ) ++{ ++ char *fullname; ++ char buff[PATH_MAX], cwd_buff[PATH_MAX]; ++ int retval; ++ ++ if( file[0] == '/' ) { ++ fullname = (char *)file; ++ } else { ++ sprintf( buff, "%s/%s", getcwd( cwd_buff, PATH_MAX ), file ); ++ fullname = buff; ++ } ++ ++ retval = update_mime_info( fullname, FALSE, TRUE, TRUE ); ++} ++# endif /* def BEOS_ASSIGN_FILETYPE */ ++ ++#endif /* def __HAIKU__ */ ++ ++ + /* ISO/OEM (iconv) character conversion. */ - if (ptr > guard) { - /* We've got a truncated attribute. */ -@@ -1388,15 +1389,15 @@ static int set_file_attrs( const char *name, + #ifdef ICONV_MAPPING +@@ -2452,7 +2802,7 @@ void charset_to_intern(char *string, char *from_charset) + { + /* 2017-11-29 Rene Freingruber, SMS. + * Was using buflen, ignoring last byte. Next strcpy() was +- * strncpy() with a bad maxchar parameter (buflen). ++ * strncpy() with a bad maxchar parameter (buflen). + */ + memset( buf, 0, (buflen+ 1)); + +diff --git a/unzip.c b/unzip.c +index 094c72c..61e8e65 100644 +--- a/unzip.c ++++ b/unzip.c +@@ -3467,7 +3467,7 @@ static void help_extended(__G) + " -I [Unix, with ICONV_MAPPING] ISO code page to use.", + " -i [MacOS] Ignore filenames in MacOS extra field. Instead, use name in", + " standard header.", +- " -J [BeOS] Junk file attributes.", ++ " -J [BeOS, Haiku] Junk file attributes.", + " [MacOS] Ignore MacOS specific info.", + " [MacOSX] No special AppleDouble file handling.", + " -Je [MacOSX] Ignore AppleDouble extended attributes.", +diff --git a/unzpriv.h b/unzpriv.h +index 1361f34..89f3e00 100644 +--- a/unzpriv.h ++++ b/unzpriv.h +@@ -395,13 +395,21 @@ + #endif + + /*--------------------------------------------------------------------------- +- BeOS/Haiku section: ++ BeOS section: + ---------------------------------------------------------------------------*/ + +-#if defined( __BEOS__) || defined( __HAIKU__) ++#ifdef __BEOS__ + # include "beos/beocfg.h" + #endif + ++/*--------------------------------------------------------------------------- ++ Haiku section: ++ ---------------------------------------------------------------------------*/ ++ ++#ifdef __HAIKU__ ++# include ++#endif ++ + /*--------------------------------------------------------------------------- + Human68k/X680x0 section: + ---------------------------------------------------------------------------*/ +@@ -877,7 +885,7 @@ extern void izu_md_check( void); + # define DOS_T20_VMS + #endif + +-#if (defined(__ATHEOS__) || defined(__BEOS__)) ++#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(__HAIKU__)) + # define ATH_BEO + #endif + +-- +2.15.1 + + +From a3246a4c178c7bfb59b0c1b442d20765806067fc Mon Sep 17 00:00:00 2001 +From: Adrien Destugues +Date: Sun, 21 Jan 2018 14:07:25 +0100 +Subject: Fix build and re-enable -DICONV_MAPPING for Haiku + + +diff --git a/unix/Makefile b/unix/Makefile +index 1dd4989..9e2605e 100644 +--- a/unix/Makefile ++++ b/unix/Makefile +@@ -1656,12 +1656,12 @@ gcc: unix_make + haiku: unix_make + $(MAKE) $(BINS) \ + CC="cc" CFLAGS=" -O3 -DLARGE_FILE_SUPPORT -DUNICODE_SUPPORT \ +- -DUNICODE_WCHAR -DUNICODE_SUPPORT -DUTF8_MAYBE_NATIVE \ ++ -DUNICODE_WCHAR -DICONV_MAPPING -DUTF8_MAYBE_NATIVE \ + -DNO_LCHMOD -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -D_MBCS \ + -DNO_SYSDIR" \ +- CRCA_O="" AS="cc -c" LFLAGS1="-lbe" LF2="-s" \ ++ CRCA_O="" AS="cc -c" LF2="-lbe -liconv -s" \ + CC_BZ="cc" CFLAGS_BZ="-O3" \ +- IZ_BZIP2="." D_USE_BZ2="" L_BZ2="" LIBBZ2="" ++ IZ_BZIP2="." D_USE_BZ2="" L_BZ2="" LIBBZ2="" LN="ln -s" + + # Heurikon HK68 (68010), UniPlus+ System V 5.0, Green Hills C-68000 + hk68: unix_make +diff --git a/unix/unix.c b/unix/unix.c +index ffb997b..b6e14fa 100644 +--- a/unix/unix.c ++++ b/unix/unix.c +@@ -56,7 +56,7 @@ + + #ifdef __HAIKU__ + # include +-# include ++# include + # include + # define EB_BE_FL_BADBITS 0xfe /* bits currently undefined */ + static uch *scanBeOSexfield OF((const uch *ef_ptr, unsigned ef_len)); +@@ -2451,7 +2451,7 @@ static int set_file_attrs( const char *name, } /* Wave the magic wand... this will swap Be-known types properly. */ @@ -200,19 +598,7 @@ index 1f03710..0f06171 100644 + (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)); - } - } - + wrote_bytes = fs_write_attr(fd, attr_name, attr_type, 0, -- -2.15.0 +2.15.1 diff --git a/app-arch/unzip/unzip-6.10c23.recipe b/app-arch/unzip/unzip-6.10c23.recipe index 23b9c2716..658a44419 100644 --- a/app-arch/unzip/unzip-6.10c23.recipe +++ b/app-arch/unzip/unzip-6.10c23.recipe @@ -5,11 +5,11 @@ or test its integrity." HOMEPAGE="http://www.info-zip.org/UnZip.html" COPYRIGHT="1990-2017 Info-ZIP" LICENSE="Info-ZIP" -REVISION="2" +REVISION="3" SOURCE_URI="http://antinode.info/ftp/info-zip/unzip610c23.zip" SOURCE_DIR="unzip610c23" CHECKSUM_SHA256="a9c3f0b4377aa593a77574e2fb69aeab97e66e93d8b110797f7b329e09848b62" -PATCHES="unzip-6.10c23.patchset" +PATCHES="unzip-$portVersion.patchset" ARCHITECTURES="x86_gcc2 ?x86_64" @@ -37,15 +37,15 @@ BUILD_PREREQUIRES=" BUILD() { - make -f beos/Makefile \ - prefix=$prefix MANDIR=$manDir BINDIR=$binDir - + make -f unix/Makefile haiku MANDIR=$manDir/man1 } INSTALL() { - mkdir -p $binDir - mkdir -p $manDir/man1 - make -f beos/Makefile install \ - prefix=$prefix MANDIR=$manDir BINDIR=$binDir + make -f unix/Makefile install PREFIX=$prefix MANDIR=$manDir/man1 +} + +TEST() +{ + make test }