diff --git a/toolchains/riscos/Dockerfile.m4 b/toolchains/riscos/Dockerfile.m4 index bb7ce92..377e354 100644 --- a/toolchains/riscos/Dockerfile.m4 +++ b/toolchains/riscos/Dockerfile.m4 @@ -49,7 +49,7 @@ local_package(bindhelp) local_package(tokenize) -# TODO: http://www.riscos.info/websvn/listing.php?repname=gccsdk&path=%2Ftrunk%2Fautobuilder%2Fsupport%2Fnative-zip%2F +local_package(zip) ENV \ def_binaries(`${GCCSDK_INSTALL_CROSSBIN}/${HOST}-', `ar, as, c++filt, ld, nm, objcopy, objdump, ranlib, readelf, strings, strip') \ diff --git a/toolchains/riscos/packages/zip/build.sh b/toolchains/riscos/packages/zip/build.sh new file mode 100755 index 0000000..79c739b --- /dev/null +++ b/toolchains/riscos/packages/zip/build.sh @@ -0,0 +1,14 @@ +#! /bin/sh + +PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +HELPERS_DIR=$PACKAGE_DIR/../.. +. $HELPERS_DIR/functions.sh + +do_make_bdir + +do_pkg_fetch zip + +do_make -f unix/Makefile generic LOCAL_ZIP=-DFORRISCOS +cp zip /usr/local/bin/ + +do_clean_bdir diff --git a/toolchains/riscos/packages/zip/patches/globals.patch b/toolchains/riscos/packages/zip/patches/globals.patch new file mode 100644 index 0000000..66dc22e --- /dev/null +++ b/toolchains/riscos/packages/zip/patches/globals.patch @@ -0,0 +1,13 @@ +--- a/globals.c.orig 2005-03-20 12:32:02.000000000 -0800 ++++ b/globals.c 2008-01-12 22:45:07.000000000 -0800 +@@ -28,6 +28,10 @@ + int pathput = 1; /* 1=store path with name */ + #ifdef RISCOS + int scanimage = 1; /* 1=scan through image files */ ++#else ++#ifdef FORRISCOS ++int decomma = 0; ++#endif + #endif + int method = BEST; /* one of BEST, DEFLATE (only), or STORE (only) */ + int dosify = 0; /* 1=make new entries look like MSDOS */ diff --git a/toolchains/riscos/packages/zip/patches/zip.patch b/toolchains/riscos/packages/zip/patches/zip.patch new file mode 100644 index 0000000..cc054f5 --- /dev/null +++ b/toolchains/riscos/packages/zip/patches/zip.patch @@ -0,0 +1,58 @@ +--- a/zip.c.orig 2009-05-07 11:54:09.000000000 +0100 ++++ b/zip.c 2009-05-07 11:53:08.000000000 +0100 +@@ -668,6 +668,9 @@ + ," -h2 show more help -I don't scan thru Image files" + #else + ," -h2 show more help" ++#ifdef FORRISCOS ++," -, strip ,xxx from filename and convert to RISCOS filetype encoding" ++#endif + #endif + #endif /* ?MACOS */ + #ifdef VMS +@@ -1144,6 +1147,9 @@ + #if CRYPT && defined(PASSWD_FROM_STDIN) + "PASSWD_FROM_STDIN", + #endif /* CRYPT & PASSWD_FROM_STDIN */ ++#ifdef FORRISCOS ++ "FORRISCOS", ++#endif + NULL + }; + +@@ -2109,6 +2115,9 @@ + #ifdef RISCOS + {"/", "exts-to-swap", o_REQUIRED_VALUE, o_NOT_NEGATABLE, '/', "override Zip$Exts"}, + #endif ++#ifdef FORRISCOS ++ {",", "strip-type", o_NO_VALUE, o_NOT_NEGATABLE, ',', "strip ,xxx extension"}, ++#endif + /* the end of the list */ + {NULL, NULL, o_NO_VALUE, o_NOT_NEGATABLE, 0, NULL} /* end has option_ID = 0 */ + }; +@@ -2847,6 +2856,12 @@ + case 'I': /* Don't scan through Image files */ + scanimage = 0; + break; ++#else ++#ifdef FORRISCOS ++ case ',': /* Convert ,xxx to RISC OS extended filetype info */ ++ decomma = 1; ++ break; ++#endif + #endif + #ifdef MACOS + case o_jj: /* store absolute path including volname */ +--- a/zip.h.org 2008-01-12 22:56:51.000000000 -0800 ++++ b/zip.h 2008-01-12 23:00:05.000000000 -0800 +@@ -256,6 +256,10 @@ + + #ifdef RISCOS + extern int scanimage; /* Scan through image files */ ++#else ++#ifdef FORRISCOS ++extern int decomma; /* Convert ,xxx filename to RISC OS filetype info */ ++#endif + #endif + + #define BEST -1 /* Use best method (deflation or store) */ diff --git a/toolchains/riscos/packages/zip/patches/zipup.patch b/toolchains/riscos/packages/zip/patches/zipup.patch new file mode 100644 index 0000000..18f9ae2 --- /dev/null +++ b/toolchains/riscos/packages/zip/patches/zipup.patch @@ -0,0 +1,162 @@ +--- a/zipup.c.orig 2008-01-12 22:29:14.000000000 -0800 ++++ b/zipup.c 2008-01-12 22:36:00.000000000 -0800 +@@ -118,6 +118,9 @@ + #else + local int filetypes OF((char *, char *)); + #endif ++#ifdef FORRISCOS ++ local int set_extra_field_forriscos OF((struct zlist far *z, iztimes *z_utim)); ++#endif + local unsigned file_read OF((char *buf, unsigned size)); + #ifdef USE_ZLIB + local int zl_deflate_init OF((int pack_level)); +@@ -276,7 +279,133 @@ + } + #endif /* ?RISCOS */ + ++#ifdef FORRISCOS ++ ++int set_extra_field_forriscos(z, z_utim) ++ struct zlist far *z; ++ iztimes *z_utim; ++{ ++#ifdef USE_EF_UT_TIME ++ char *eb_ptr; ++#endif /* USE_EF_UT_TIME */ ++ char *cptr; ++ char *extra_block; ++ unsigned int addr; ++ unsigned int ftype = 0xfff; /* Untyped files default to 'text' */ ++ unsigned timlo; /* 3 lower bytes of acorn file-time plus carry byte */ ++ unsigned timhi; /* 2 high bytes of acorn file-time */ ++ ++#define EB_SPARK_LEN 20 ++#define EB_SPARK_SIZE (EB_HEADSIZE+EB_SPARK_LEN) ++#ifdef USE_EF_UT_TIME ++# ifdef IZ_CHECK_TZ ++# define EB_UTTIME_SIZE (zp_tz_is_valid ? EB_HEADSIZE+EB_UT_LEN(1) : 0) ++# else ++# define EB_UTTIME_SIZE (EB_HEADSIZE+EB_UT_LEN(1)) ++# endif ++#else ++# define EB_UTTIME_SIZE 0 ++#endif ++#define EF_SPARK_TOTALSIZE (EB_SPARK_SIZE + EB_UTTIME_SIZE) ++ ++ cptr=strrchr(z->iname, (int) ','); ++ if (cptr) ++ if ((cptr - z->iname) != (int)(strlen(z->iname)-4)) ++ cptr = NULL; /* There was a comma, but it wasn't a ,xxx at the end! */ ++ ++ if (cptr) ++ { ++ *cptr='\0'; /* Chop the filename at the comma */ ++ ++ ftype = strtol(cptr+1, NULL, 16); /* read the ,xxx as hex filetype */ ++ } ++ else ++ { ++ /* When there is no given filetype, but there is a full stop in the name, ++ then it is better to let the unzip utility in RISC OS do a MimeMap lookup ++ instead, and therefore do nothing here */ ++ if (strchr(z->iname, '.')) ++ return ZE_OK; ++ } ++ ++ z->extra=(char *)malloc(EF_SPARK_TOTALSIZE); ++ if (z->extra==NULL) { ++ fprintf(stderr," set_extra_field_forriscos: not enough memory\n"); ++ return ZE_MEM; ++ } ++ z->cextra = z->extra; ++ z->cext = z->ext = EF_SPARK_TOTALSIZE; ++ ++ timlo = ((unsigned)z_utim->mtime & 0x00ffffffU) * 100 + 0x00996a00U; ++ timhi = ((unsigned)z_utim->mtime >> 24); ++ timhi = timhi * 100 + 0x0000336eU + (timlo >> 24); ++ ++ extra_block=z->extra; ++ /* ID */ ++ extra_block[0]='A'; ++ extra_block[1]='C'; ++ ++ /* size */ ++ extra_block[2]=(char)(EB_SPARK_LEN); ++ extra_block[3]=(char)(EB_SPARK_LEN)>>8; ++ ++ /* ID_2 */ ++ extra_block[4]='A'; ++ extra_block[5]='R'; ++ extra_block[6]='C'; ++ extra_block[7]='0'; ++ ++ /* Load address */ ++ addr=0xfff00000 | (ftype << 8); /* This file is typed, and has filetype 'ftype' */ ++ addr|= ((timhi >> 8) & 0xffU); ++ extra_block[8]=(char)(addr); ++ extra_block[9]=(char)(addr>>8); ++ extra_block[10]=(char)(addr>>16); ++ extra_block[11]=(char)(addr>>24); ++ ++ /* Exec address */ ++ addr=(timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24); ++ extra_block[12]=(char)(addr); ++ extra_block[13]=(char)(addr>>8); ++ extra_block[14]=(char)(addr>>16); ++ extra_block[15]=(char)(addr>>24); ++ ++ /* Attributes */ ++ extra_block[16]=0x13; /* Private read/write, no public access, unlocked */ ++ extra_block[17]=0; ++ extra_block[18]=0; ++ extra_block[19]=0; ++ ++ /* Zero */ ++ extra_block[20]=0; ++ extra_block[21]=0; ++ extra_block[22]=0; ++ extra_block[23]=0; ++ ++#ifdef USE_EF_UT_TIME ++# ifdef IZ_CHECK_TZ ++ if (zp_tz_is_valid) { ++# endif ++ eb_ptr = z->extra + EB_SPARK_SIZE; ++ ++ eb_ptr[0] = 'U'; ++ eb_ptr[1] = 'T'; ++ eb_ptr[2] = EB_UT_LEN(1); /* length of data part of e.f. */ ++ eb_ptr[3] = 0; ++ eb_ptr[4] = EB_UT_FL_MTIME; ++ eb_ptr[5] = (char)(z_utim->mtime); ++ eb_ptr[6] = (char)(z_utim->mtime >> 8); ++ eb_ptr[7] = (char)(z_utim->mtime >> 16); ++ eb_ptr[8] = (char)(z_utim->mtime >> 24); ++# ifdef IZ_CHECK_TZ ++ } ++# endif ++#endif /* USE_EF_UT_TIME */ ++ ++ return ZE_OK; ++} + ++#endif /* FORRISCOS */ + + /* Note: a zip "entry" includes a local header (which includes the file + name), an encryption header if encrypting, the compressed data +@@ -360,6 +489,15 @@ + #if !(defined(VMS) && defined(VMS_PK_EXTRA)) + if (extra_fields) { + /* create extra field and change z->att and z->atx if desired */ ++#ifdef FORRISCOS ++ if (decomma) ++ { ++ /* If we're making a zip for RISC OS, we don't bother with any other */ ++ /* OS-Specific info (although we could - but there's no point!) */ ++ set_extra_field_forriscos(z, &f_utim); ++ } ++ else ++#endif + set_extra_field(z, &f_utim); + #ifdef QLZIP + if(qlflag)