commit: 771d65724085a595bfc9027335773447c6e86151 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Sat Mar 1 07:02:16 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Sat Mar 1 07:03:25 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=771d6572
net-misc/zsync: drop bundled zlib Using a patch from Debian. Bug: https://bugs.gentoo.org/208660 Signed-off-by: Sam James <sam <AT> gentoo.org> .../zsync/files/zsync-0.6.2-unbundle-zlib.patch | 124 ++++++++++++++++ .../zsync/files/zsync-0.6.2-warning-fixes.patch | 157 +++++++++++++++++++++ net-misc/zsync/zsync-0.6.2-r5.ebuild | 41 ++++++ 3 files changed, 322 insertions(+) diff --git a/net-misc/zsync/files/zsync-0.6.2-unbundle-zlib.patch b/net-misc/zsync/files/zsync-0.6.2-unbundle-zlib.patch new file mode 100644 index 000000000000..4b78ba85683d --- /dev/null +++ b/net-misc/zsync/files/zsync-0.6.2-unbundle-zlib.patch @@ -0,0 +1,124 @@ +https://sources.debian.org/data/main/z/zsync/0.6.2-7/debian/patches/devendor-zlib.patch + +Description: De-vendor zlib + Use the zlib as it is in the archive, not an embedded copy +Author: Simon Quigley <[email protected]> +Origin: vendor +Forwarded: not-needed +Last-Update: 2025-02-26 +--- a/configure.ac ++++ b/configure.ac +@@ -38,6 +38,9 @@ X_DECL_H_ERRNO + dnl Solaris needs -lsocket - and we need this for the getaddrinfo test + AC_CHECK_LIB(socket,socket) + ++AC_CHECK_LIB([z], [inflate], [], [AC_MSG_ERROR([zlib library not found])]) ++AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib headers not found])]) ++ + AC_REPLACE_FUNCS(getaddrinfo) + + dnl - Large file support if available +@@ -65,6 +68,6 @@ X_C_COMPILE_FLAGS($ZS_CFLAGS -g -Wall -W + dnl --- output + AC_SUBST(ac_aux_dir) + AC_CONFIG_HEADERS([config.h]) +-AC_CONFIG_FILES([Makefile librcksum/Makefile zlib/Makefile libzsync/Makefile doc/Makefile]) ++AC_CONFIG_FILES([Makefile librcksum/Makefile libzsync/Makefile doc/Makefile]) + AC_OUTPUT + +--- a/Makefile.am ++++ b/Makefile.am +@@ -2,15 +2,15 @@ + AUTOMAKE_OPTIONS = check-news + ACLOCAL_AMFLAGS = -I autotools + +-SUBDIRS = librcksum zlib libzsync doc ++SUBDIRS = librcksum libzsync doc + + bin_PROGRAMS = zsyncmake zsync + + zsyncmake_SOURCES = make.c makegz.c makegz.h format_string.h +-zsyncmake_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a zlib/libdeflate.a -lm ++zsyncmake_LDADD = libzsync/libzsync.a librcksum/librcksum.a -lz -lm + + zsync_SOURCES = client.c http.c http.h url.c url.h progress.c progress.h base64.c format_string.h zsglobal.h +-zsync_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a $(LIBOBJS) ++zsync_LDADD = libzsync/libzsync.a librcksum/librcksum.a -lz $(LIBOBJS) + + EXTRA_zsync_SOURCES = getaddrinfo.h + +--- a/Makefile.in ++++ b/Makefile.in +@@ -61,11 +61,10 @@ am_zsync_OBJECTS = client.$(OBJEXT) http + progress.$(OBJEXT) base64.$(OBJEXT) + zsync_OBJECTS = $(am_zsync_OBJECTS) + zsync_DEPENDENCIES = libzsync/libzsync.a librcksum/librcksum.a \ +- zlib/libinflate.a $(LIBOBJS) ++ $(LIBOBJS) + am_zsyncmake_OBJECTS = make.$(OBJEXT) makegz.$(OBJEXT) + zsyncmake_OBJECTS = $(am_zsyncmake_OBJECTS) +-zsyncmake_DEPENDENCIES = libzsync/libzsync.a librcksum/librcksum.a \ +- zlib/libinflate.a zlib/libdeflate.a ++zsyncmake_DEPENDENCIES = libzsync/libzsync.a librcksum/librcksum.a + DEFAULT_INCLUDES = -I.@am__isrc@ + depcomp = $(SHELL) $(top_srcdir)/autotools/depcomp + am__depfiles_maybe = depfiles +@@ -252,11 +251,11 @@ top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + AUTOMAKE_OPTIONS = check-news + ACLOCAL_AMFLAGS = -I autotools +-SUBDIRS = librcksum zlib libzsync doc ++SUBDIRS = librcksum libzsync doc + zsyncmake_SOURCES = make.c makegz.c makegz.h format_string.h +-zsyncmake_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a zlib/libdeflate.a -lm ++zsyncmake_LDADD = libzsync/libzsync.a librcksum/librcksum.a -lz -lm + zsync_SOURCES = client.c http.c http.h url.c url.h progress.c progress.h base64.c format_string.h zsglobal.h +-zsync_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a $(LIBOBJS) ++zsync_LDADD = libzsync/libzsync.a librcksum/librcksum.a -lz $(LIBOBJS) + EXTRA_zsync_SOURCES = getaddrinfo.h + + # From "GNU autoconf, automake and libtool" Vaughan, Elliston, +--- a/libzsync/zmap.c ++++ b/libzsync/zmap.c +@@ -287,7 +287,7 @@ off_t *zmap_to_compressed_ranges(const s + return consolidate_byteranges(zbyterange, num); + } + +-#include "zlib/zlib.h" ++#include <zlib.h> + /* zmap_search(self, offset) + * Find this offset in the Z-Map */ + int zmap_search(const struct zmap* zm, long zoffset) { +--- a/libzsync/zsync.c ++++ b/libzsync/zsync.c +@@ -48,7 +48,7 @@ + # include <dmalloc.h> + #endif + +-#include "zlib/zlib.h" ++#include <zlib.h> + + #include "librcksum/rcksum.h" + #include "zsync.h" +--- a/make.c ++++ b/make.c +@@ -43,7 +43,7 @@ + #include "librcksum/rcksum.h" + #include "libzsync/zmap.h" + #include "libzsync/sha1.h" +-#include "zlib/zlib.h" ++#include <zlib.h> + #include "format_string.h" + + /* We're only doing one file per run, so these are global state for the current +--- a/makegz.c ++++ b/makegz.c +@@ -20,7 +20,7 @@ + #include <unistd.h> + #include <stdlib.h> + +-#include "zlib/zlib.h" ++#include <zlib.h> + + #include <sys/types.h> + #include <sys/stat.h> diff --git a/net-misc/zsync/files/zsync-0.6.2-warning-fixes.patch b/net-misc/zsync/files/zsync-0.6.2-warning-fixes.patch new file mode 100644 index 000000000000..c15783604010 --- /dev/null +++ b/net-misc/zsync/files/zsync-0.6.2-warning-fixes.patch @@ -0,0 +1,157 @@ +(Note that despite the Debian description, it really seems largely about +warning fixes instead with one zlib modernisation fix as well.) + +https://sources.debian.org/data/main/z/zsync/0.6.2-7/debian/patches/update-zlib-functions.patch + +Description: Update functions for zlib de-vendoring +Author: Simon Quigley <[email protected]> +Origin: vendor +Forwarded: not-needed +Last-Update: 2025-02-26 +--- a/libzsync/zsync.c ++++ b/libzsync/zsync.c +@@ -151,7 +151,7 @@ struct zsync_state *zsync_begin(FILE * f + char *safelines = NULL; + + /* Allocate memory for the object */ +- struct zsync_state *zs = calloc(sizeof *zs, 1); ++ struct zsync_state *zs = calloc(1, sizeof *zs); + + if (!zs) + return NULL; +@@ -210,7 +210,7 @@ struct zsync_state *zsync_begin(FILE * f + } + else if (!strcmp(buf, "Blocksize")) { + zs->blocksize = atol(p); +- if (zs->blocksize < 0 || (zs->blocksize & (zs->blocksize - 1))) { ++ if (zs->blocksize & (zs->blocksize - 1)) { + fprintf(stderr, "nonsensical blocksize %ld\n", zs->blocksize); + free(zs); + return NULL; +@@ -240,7 +240,8 @@ struct zsync_state *zsync_begin(FILE * f + + zblock = malloc(nzblocks * sizeof *zblock); + if (zblock) { +- if (fread(zblock, sizeof *zblock, nzblocks, f) < nzblocks) { ++ size_t nread = fread(zblock, sizeof *zblock, nzblocks, f); ++ if (nread < (size_t)nzblocks) { + fprintf(stderr, "premature EOF after Z-Map\n"); + free(zs); + return NULL; +@@ -701,7 +702,8 @@ static int zsync_recompress(struct zsync + p = skip_zhead(buf); + skip = 0; + } +- if (fwrite(p, 1, r - (p - buf), zout) != r - (p - buf)) { ++ size_t out_len = r - (p - buf); ++ if (fwrite(p, 1, out_len, zout) != out_len) { + perror("fwrite"); + rc = -1; + goto leave_it; +@@ -714,8 +716,8 @@ static int zsync_recompress(struct zsync + rc = -1; + } + } +- if (fclose(g) != 0) { +- perror("close"); ++ if (pclose(g) == -1) { ++ perror("pclose failed"); + rc = -1; + } + +@@ -782,7 +784,7 @@ void zsync_configure_zstream_for_zdata(c + /* Fake an output buffer of 32k filled with data to zlib */ + zstrm->next_out = wbuf + lookback; + zstrm->avail_out = 0; +- updatewindow(zstrm, lookback); ++ inflateSetDictionary(zstrm, wbuf, lookback); + } + } + +@@ -922,10 +924,10 @@ static int zsync_receive_data_compressed + return 0; + + /* Now set up for the downloaded block */ +- zr->strm.next_in = buf; ++ zr->strm.next_in = (Bytef *)buf; + zr->strm.avail_in = len; + +- if (zr->strm.total_in == 0 || offset != zr->strm.total_in) { ++ if (zr->strm.total_in == 0 || (uLong)offset != zr->strm.total_in) { + zsync_configure_zstream_for_zdata(zr->zs, &(zr->strm), offset, + &(zr->outoffset)); + +@@ -939,7 +941,7 @@ static int zsync_receive_data_compressed + "data didn't align with block boundary in compressed stream\n"); + return 1; + } +- zr->strm.next_in = buf; ++ zr->strm.next_in = (Bytef *)buf; + zr->strm.avail_in = len; + } + +@@ -952,6 +954,7 @@ static int zsync_receive_data_compressed + switch (rc) { + case Z_STREAM_END: + eoz = 1; ++ [[fallthrough]]; + case Z_BUF_ERROR: + case Z_OK: + if (zr->strm.avail_out == 0 || eoz) { +--- a/libzsync/zmap.c ++++ b/libzsync/zmap.c +@@ -359,5 +359,8 @@ void configure_zstream_for_zdata(const s + *poutoffset = zm->e[i].outbytes; + + /* Align with the bitstream */ +- inflate_advance(zs, zoffset, zm->e[i].inbits % 8, !zm->e[i].blockcount); ++ int ret; ++ do { ++ ret = inflate(zs, Z_SYNC_FLUSH); ++ } while (ret == Z_OK); + } +--- a/make.c ++++ b/make.c +@@ -316,7 +316,7 @@ void do_zstream(FILE * fin, FILE * fout, + /* If we passed a block boundary in the uncompressed data, record the + * next available point at which we could stop or start decompression. + * Write a zmap delta with the 1st when we see the 2nd, etc */ +- if (want_zdelta && inflateSafePoint(&zs)) { ++ if (want_zdelta && inflateSyncPoint(&zs)) { + long long cur_in = header_bits + in_position(&zs); + if (midblock_in) { + write_zmap_delta(&prev_in, &prev_out, midblock_in, +@@ -718,7 +718,7 @@ int main(int argc, char **argv) { + read_stream_write_blocksums(instream, tf); + + { /* Decide how long a rsum hash and checksum hash per block we need for this file */ +- seq_matches = len > blocksize ? 2 : 1; ++ seq_matches = ((off_t)len > (off_t)blocksize) ? 2 : 1; + rsum_len = ceil(((log(len) + log(blocksize)) / log(2) - 8.6) / seq_matches / 8); + + /* min and max lengths of rsums to store */ +@@ -836,7 +836,7 @@ int main(int argc, char **argv) { + fprintf(fout, "MTime: %s\n", buf); + } + else { +- fprintf(stderr, "error converting %d to struct tm\n", mtime); ++ fprintf(stderr, "error converting %ld to struct tm\n", (long)mtime); + } + } + } +--- a/http.c ++++ b/http.c +@@ -554,9 +554,10 @@ static int range_fetch_set_url(struct ra + if (rf->authh) free(rf->authh); + + /* Get host:port for Host: header */ +- if (strcmp(cport, "http") != 0) +- snprintf(rf->hosth, sizeof(rf->hosth), "%s:%s", hostn, cport); +- else ++ if (strcmp(cport, "http") != 0) { ++ strncpy(rf->hosth, hostn, sizeof(rf->hosth) - 1); ++ rf->hosth[sizeof(rf->hosth) - 1] = '\0'; ++ } else + snprintf(rf->hosth, sizeof(rf->hosth), "%s", hostn); + + if (proxy) { diff --git a/net-misc/zsync/zsync-0.6.2-r5.ebuild b/net-misc/zsync/zsync-0.6.2-r5.ebuild new file mode 100644 index 000000000000..9e28818bb6ce --- /dev/null +++ b/net-misc/zsync/zsync-0.6.2-r5.ebuild @@ -0,0 +1,41 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools + +DESCRIPTION="Partial/differential file download client over HTTP using the rsync algorithm" +HOMEPAGE="http://zsync.moria.org.uk/" +SRC_URI=" + http://zsync.moria.org.uk/download/${P}.tar.bz2 +" + +LICENSE="Artistic-2" +SLOT="0" +KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86" + +RDEPEND="sys-libs/zlib" +DEPEND="${RDEPEND}" + +PATCHES=( + "${FILESDIR}"/${PN}-0.6.2-musl-off_t-fix.patch + "${FILESDIR}"/${PN}-0.6.2-c99.patch + "${FILESDIR}"/${PN}-0.6.2-unbundle-zlib.patch + "${FILESDIR}"/${PN}-0.6.2-warning-fixes.patch +) + +src_prepare() { + default + + # Drop bundled zlib + rm -r zlib || die + + eautoreconf +} + +src_install() { + dobin zsync zsyncmake + dodoc NEWS README + doman doc/zsync.1 doc/zsyncmake.1 +}
