[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit 2f003686fdd46eb524a08715c8a8988c6d13cea3 Author: Guillem Jover guil...@debian.org Date: Sat May 7 12:27:27 2011 +0200 Group Build-Depends lines by purpose Build tools, i18n tools, compression, security and UI libraries, and perl packages for the test suite. diff --git a/debian/control b/debian/control index b9e6d31..d03ac7e 100644 --- a/debian/control +++ b/debian/control @@ -9,10 +9,11 @@ Homepage: http://wiki.debian.org/Teams/Dpkg Vcs-Browser: http://git.debian.org/?p=dpkg/dpkg.git Vcs-Git: git://git.debian.org/git/dpkg/dpkg.git Standards-Version: 3.9.2 -Build-Depends: debhelper (= 7), pkg-config, +Build-Depends: debhelper (= 7), pkg-config, flex, gettext (= 0.18), po4a (= 0.33.1), - libncursesw5-dev, zlib1g-dev (= 1:1.1.3-19.1), libbz2-dev, flex, + zlib1g-dev (= 1:1.1.3-19.1), libbz2-dev, libselinux1-dev (= 1.28-4) [linux-any], + libncursesw5-dev, libtimedate-perl, libio-string-perl Package: libdpkg-dev -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit ec5615cdd134654d0e7049cdd5925aa9a83034ba Author: Guillem Jover guil...@debian.org Date: Sat May 7 11:16:08 2011 +0200 dpkg-deb: Pass the real file descriptors to compression functions Instead of duping them to the stdin and stdout file descriptors, pass them directly. If the compression functions need the file descriptors on stdin and stdout, then they will take care of setting them up. This is only the case when using the external compression binaries. diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index 0e40222..60318db 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -474,8 +474,7 @@ do_build(const char *const *argv) /* And run gzip to compress our control archive. */ c2 = subproc_fork(); if (!c2) { -m_dup2(p1[0],0); m_dup2(gzfd,1); close(p1[0]); close(gzfd); -compress_filter(compressor_gzip, 0, 1, 9, _(control member)); +compress_filter(compressor_gzip, p1[0], gzfd, 9, _(control member)); } close(p1[0]); subproc_wait_check(c2, gzip -9c, 0); @@ -504,12 +503,17 @@ do_build(const char *const *argv) dpkg_ar_member_put_mem(debar, arfd, DEBMAGIC, deb_magic, strlen(deb_magic)); dpkg_ar_member_put_file(debar, arfd, ADMINMEMBER, gzfd, -1); } + close(gzfd); - /* Control is done, now we need to archive the data. Start by creating - * a new temporary file. Immediately unlink the temporary file so others - * can't mess with it. */ - if (!oldformatflag) { -close(gzfd); + /* Control is done, now we need to archive the data. */ + if (oldformatflag) { +/* In old format, the data member is just concatenated after the + * control member, so we do not need a temporary file and can use + * the compression file descriptor. */ +gzfd = arfd; + } else { +/* Start by creating a new temporary file. Immediately unlink the + * temporary file so others can't mess with it. */ tfbuf = path_make_temp_template(dpkg-deb); gzfd = mkstemp(tfbuf); if (gzfd == -1) @@ -538,9 +542,7 @@ do_build(const char *const *argv) c2 = subproc_fork(); if (!c2) { close(p1[1]); -m_dup2(p2[0],0); close(p2[0]); -m_dup2(oldformatflag ? arfd : gzfd, 1); -compress_filter(compressor, 0, 1, compress_level, _(data member)); +compress_filter(compressor, p2[0], gzfd, compress_level, _(data member)); } close(p2[0]); diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c index 659d334..5992bc8 100644 --- a/dpkg-deb/extract.c +++ b/dpkg-deb/extract.c @@ -112,6 +112,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption, int dummy; pid_t c1=0,c2,c3; int p1[2], p2[2]; + int p2_out; int arfd; struct stat stab; char nlc; @@ -269,14 +270,18 @@ extracthalf(const char *debar, const char *dir, const char *taroption, } close(p1[1]); - if (taroption) m_pipe(p2); + if (taroption) { +m_pipe(p2); +p2_out = p2[1]; + } else { +p2_out = 1; + } c2 = subproc_fork(); if (!c2) { -m_dup2(p1[0], 0); -if (admininfo) close(p1[0]); -if (taroption) { m_dup2(p2[1],1); close(p2[0]); close(p2[1]); } -decompress_filter(decompressor, 0, 1, _(data)); +if (taroption) + close(p2[0]); +decompress_filter(decompressor, p1[0], p2_out, _(data)); } close(p1[0]); close(arfd); -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit 269bbee973c46e1be0aaef82cb7e19bbc9a95aa7 Author: Guillem Jover guil...@debian.org Date: Sat May 7 11:27:06 2011 +0200 libdpkg: Switch the compression filter functions to always return This makes the compression and decompression functions be closer to the buffer api, which always return. For non-blocking I/O, the caller has to setup a child process. When using external binaries, we make the filter functions setup that child process transparently so that the API is uniform. diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index 60318db..a88cb0e 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -475,6 +475,7 @@ do_build(const char *const *argv) c2 = subproc_fork(); if (!c2) { compress_filter(compressor_gzip, p1[0], gzfd, 9, _(control member)); +exit(0); } close(p1[0]); subproc_wait_check(c2, gzip -9c, 0); @@ -543,6 +544,7 @@ do_build(const char *const *argv) if (!c2) { close(p1[1]); compress_filter(compressor, p2[0], gzfd, compress_level, _(data member)); +exit(0); } close(p2[0]); diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c index 5992bc8..b458c1f 100644 --- a/dpkg-deb/extract.c +++ b/dpkg-deb/extract.c @@ -282,6 +282,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption, if (taroption) close(p2[0]); decompress_filter(decompressor, p1[0], p2_out, _(data)); +exit(0); } close(p1[0]); close(arfd); diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c index 59c40df..2bf53c5 100644 --- a/lib/dpkg/compress.c +++ b/lib/dpkg/compress.c @@ -42,47 +42,51 @@ #include dpkg/buffer.h #include dpkg/command.h #include dpkg/compress.h +#include dpkg/subproc.h -static void DPKG_ATTR_NORET DPKG_ATTR_SENTINEL +static void DPKG_ATTR_SENTINEL fd_fd_filter(int fd_in, int fd_out, const char *desc, const char *file, ...) { va_list args; struct command cmd; + pid_t pid; - if (fd_in != 0) { - m_dup2(fd_in, 0); - close(fd_in); - } - if (fd_out != 1) { - m_dup2(fd_out, 1); - close(fd_out); - } + pid = subproc_fork(); + if (pid != 0) { + if (fd_in != 0) { + m_dup2(fd_in, 0); + close(fd_in); + } + if (fd_out != 1) { + m_dup2(fd_out, 1); + close(fd_out); + } - command_init(cmd, file, desc); - command_add_arg(cmd, file); - va_start(args, file); - command_add_argv(cmd, args); - va_end(args); + command_init(cmd, file, desc); + command_add_arg(cmd, file); + va_start(args, file); + command_add_argv(cmd, args); + va_end(args); - command_exec(cmd); + command_exec(cmd); + } + subproc_wait_check(pid, desc, 0); } /* * No compressor (pass-through). */ -static void DPKG_ATTR_NORET +static void decompress_none(int fd_in, int fd_out, const char *desc) { fd_fd_copy(fd_in, fd_out, -1, _(%s: decompression), desc); - exit(0); } -static void DPKG_ATTR_NORET +static void compress_none(int fd_in, int fd_out, int compress_level, const char *desc) { fd_fd_copy(fd_in, fd_out, -1, _(%s: compression), desc); - exit(0); } struct compressor compressor_none = { @@ -98,7 +102,7 @@ struct compressor compressor_none = { */ #ifdef WITH_ZLIB -static void DPKG_ATTR_NORET +static void decompress_gzip(int fd_in, int fd_out, const char *desc) { char buffer[4096]; @@ -130,11 +134,9 @@ decompress_gzip(int fd_in, int fd_out, const char *desc) if (close(fd_out)) ohshite(_(%s: internal gzip write error), desc); - - exit(0); } -static void DPKG_ATTR_NORET +static void compress_gzip(int fd_in, int fd_out, int compress_level, const char *desc) { char buffer[4096]; @@ -177,17 +179,15 @@ compress_gzip(int fd_in, int fd_out, int compress_level, const char *desc) errmsg = zError(err); ohshit(_(%s: internal gzip write error: %s), desc, errmsg); } - - exit(0); } #else -static void DPKG_ATTR_NORET +static void decompress_gzip(int fd_in, int fd_out, const char *desc) { fd_fd_filter(fd_in, fd_out, desc, GZIP, -dc, NULL); } -static void DPKG_ATTR_NORET +static void compress_gzip(int fd_in, int fd_out, int compress_level, const char *desc) { char combuf[6]; @@ -210,7 +210,7 @@ struct compressor compressor_gzip = { */ #ifdef WITH_BZ2 -static void DPKG_ATTR_NORET +static void decompress_bzip2(int fd_in, int fd_out, const char *desc) { char buffer[4096]; @@ -242,11 +242,9 @@ decompress_bzip2(int fd_in, int fd_out, const char *desc) if (close(fd_out))
[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit 7e7236f7e19f1b4e238359d887756e7044328891 Author: Guillem Jover guil...@debian.org Date: Tue May 3 10:28:26 2011 +0200 libdpkg: Expand buffer_copy_TYPE macro instances This makes the code easier to debug, as it will be able to track correct code lines, it also allows to more easily see the code duplication explicitly, and makes the code slightly more clear as it's using the real structure member and type names. diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c index 0a6ab19..0ac9e46 100644 --- a/lib/dpkg/buffer.c +++ b/lib/dpkg/buffer.c @@ -204,28 +204,46 @@ buffer_copy(struct buffer_data *read_data, struct buffer_data *write_data, return totalread; } -#define buffer_copy_TYPE(name, type1, name1, type2, name2) \ -off_t \ -buffer_copy_##name(type1 n1, int typeIn, \ - type2 n2, int typeOut, \ - off_t limit, const char *desc, ...) \ -{ \ - va_list args; \ - struct buffer_data read_data = { .arg.name1 = n1, .type = typeIn }; \ - struct buffer_data write_data = { .arg.name2 = n2, .type = typeOut }; \ - struct varbuf v = VARBUF_INIT; \ - off_t ret; \ -\ - va_start(args, desc); \ - varbuf_vprintf(v, desc, args); \ - va_end(args); \ -\ - ret = buffer_copy(read_data, write_data, limit, v.buf); \ -\ - varbuf_destroy(v); \ -\ - return ret; \ +off_t +buffer_copy_IntInt(int Iin, int Tin, + int Iout, int Tout, + off_t limit, const char *desc, ...) +{ + va_list args; + struct buffer_data read_data = { .type = Tin, .arg.i = Iin }; + struct buffer_data write_data = { .type = Tout, .arg.i = Iout }; + struct varbuf v = VARBUF_INIT; + off_t ret; + + va_start(args, desc); + varbuf_vprintf(v, desc, args); + va_end(args); + + ret = buffer_copy(read_data, write_data, limit, v.buf); + + varbuf_destroy(v); + + return ret; } -buffer_copy_TYPE(IntInt, int, i, int, i); -buffer_copy_TYPE(IntPtr, int, i, void *, ptr); +off_t +buffer_copy_IntPtr(int Iin, int Tin, + void *Pout, int Tout, + off_t limit, const char *desc, ...) +{ + va_list args; + struct buffer_data read_data = { .type = Tin, .arg.i = Iin }; + struct buffer_data write_data = { .type = Tout, .arg.ptr = Pout }; + struct varbuf v = VARBUF_INIT; + off_t ret; + + va_start(args, desc); + varbuf_vprintf(v, desc, args); + va_end(args); + + ret = buffer_copy(read_data, write_data, limit, v.buf); + + varbuf_destroy(v); + + return ret; +} -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit fbc930968e396694b293ee35177c9305f407cf30 Author: Guillem Jover guil...@debian.org Date: Mon May 2 21:53:35 2011 +0200 libdpkg: Rename struct buffer_write_md5ctx to buffer_md5_ctx diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c index 0ac9e46..950e1a6 100644 --- a/lib/dpkg/buffer.c +++ b/lib/dpkg/buffer.c @@ -36,7 +36,7 @@ #include dpkg/fdio.h #include dpkg/buffer.h -struct buffer_write_md5ctx { +struct buffer_md5_ctx { struct MD5Context ctx; char *hash; }; @@ -44,9 +44,9 @@ struct buffer_write_md5ctx { static void buffer_md5_init(struct buffer_data *data) { - struct buffer_write_md5ctx *ctx; + struct buffer_md5_ctx *ctx; - ctx = m_malloc(sizeof(struct buffer_write_md5ctx)); + ctx = m_malloc(sizeof(*ctx)); ctx-hash = data-arg.ptr; data-arg.ptr = ctx; MD5Init(ctx-ctx); @@ -66,12 +66,12 @@ buffer_init(struct buffer_data *data) static void buffer_md5_done(struct buffer_data *data) { - struct buffer_write_md5ctx *ctx; + struct buffer_md5_ctx *ctx; unsigned char digest[16], *p = digest; char *hash; int i; - ctx = (struct buffer_write_md5ctx *)data-arg.ptr; + ctx = (struct buffer_md5_ctx *)data-arg.ptr; hash = ctx-hash; MD5Final(digest, ctx-ctx); for (i = 0; i 16; ++i) { @@ -108,7 +108,7 @@ buffer_write(struct buffer_data *data, const void *buf, off_t length) case BUFFER_WRITE_NULL: break; case BUFFER_WRITE_MD5: - MD5Updatestruct buffer_write_md5ctx *)data-arg.ptr)-ctx), buf, length); + MD5Updatestruct buffer_md5_ctx *)data-arg.ptr)-ctx), buf, length); break; default: internerr(unknown data type '%i' in buffer_write, -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit 751c399e50a087fb5c6367cbfd5a551e3ac676c9 Author: Guillem Jover guil...@debian.org Date: Mon May 9 19:59:21 2011 +0200 libdpkg: Remove unneeded checks on buffer_copy loop termination The while loop checks unnecessarily for bytesread and byteswritten being = 0, but that's always going to be true, as in case of read or write error the code breaks out of the loop. diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c index 950e1a6..3654f4f 100644 --- a/lib/dpkg/buffer.c +++ b/lib/dpkg/buffer.c @@ -166,7 +166,7 @@ buffer_copy(struct buffer_data *read_data, struct buffer_data *write_data, buffer_init(write_data); - while (bytesread = 0 byteswritten = 0 bufsize 0) { + while (bufsize 0) { bytesread = buffer_read(read_data, buf, bufsize); if (bytesread 0) break; -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit e8c1a5863572eac719e36b2e409002871e6eee4a Author: Guillem Jover guil...@debian.org Date: Sun May 1 08:06:53 2011 +0200 libdpkg: Add new buffer_skip_Int() and switch fd_null_copy() to it Add a new buffer_skip() function and the externally visible buffer_skip_Int(), this way we hide the implementation details of fd_null_copy(). diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c index 3654f4f..c99af0f 100644 --- a/lib/dpkg/buffer.c +++ b/lib/dpkg/buffer.c @@ -25,6 +25,7 @@ #include sys/types.h +#include errno.h #include string.h #include unistd.h #include stdlib.h @@ -247,3 +248,45 @@ buffer_copy_IntPtr(int Iin, int Tin, return ret; } + +static off_t +buffer_skip(struct buffer_data *input, off_t limit, const char *desc) +{ + struct buffer_data output; + + switch (input-type) { + case BUFFER_READ_FD: + if (lseek(input-arg.i, limit, SEEK_CUR) != -1) + return limit; + if (errno != ESPIPE) + ohshite(_(failed to seek %s), desc); + break; + default: + internerr(unknown data type '%i' in buffer_skip\n, + input-type); + } + + output.type = BUFFER_WRITE_NULL; + output.arg.ptr = NULL; + + return buffer_copy(input, output, limit, desc); +} + +off_t +buffer_skip_Int(int I, int T, off_t limit, const char *desc_fmt, ...) +{ + va_list args; \ + struct buffer_data input = { .type = T, .arg.i = I }; + struct varbuf v = VARBUF_INIT; + off_t ret; + + va_start(args, desc_fmt); + varbuf_vprintf(v, desc_fmt, args); + va_end(args); + + ret = buffer_skip(input, limit, v.buf); + + varbuf_destroy(v); + + return ret; +} diff --git a/lib/dpkg/buffer.h b/lib/dpkg/buffer.h index 071c08e..c81ef1c 100644 --- a/lib/dpkg/buffer.h +++ b/lib/dpkg/buffer.h @@ -26,8 +26,6 @@ #include sys/types.h -#include errno.h - #include dpkg/macros.h DPKG_BEGIN_DECLS @@ -60,13 +58,7 @@ struct buffer_data { buffer_copy_IntPtr(fd, BUFFER_READ_FD, buf, BUFFER_WRITE_VBUF, \ limit, __VA_ARGS__) # define fd_null_copy(fd, limit, ...) \ - if (lseek(fd, limit, SEEK_CUR) == -1) { \ - if (errno != ESPIPE) \ - ohshite(__VA_ARGS__); \ - buffer_copy_IntPtr(fd, BUFFER_READ_FD, \ - NULL, BUFFER_WRITE_NULL, \ - limit, __VA_ARGS__); \ - } + buffer_skip_Int(fd, BUFFER_READ_FD, limit, __VA_ARGS__) off_t buffer_copy_IntPtr(int i, int typeIn, void *p, int typeOut, off_t limit, const char *desc, @@ -74,6 +66,8 @@ off_t buffer_copy_IntPtr(int i, int typeIn, void *p, int typeOut, off_t buffer_copy_IntInt(int i1, int typeIn, int i2, int typeOut, off_t limit, const char *desc, ...) DPKG_ATTR_PRINTF(6); +off_t buffer_skip_Int(int I, int T, off_t limit, const char *desc_fmt, ...) + DPKG_ATTR_PRINTF(4); off_t buffer_hash(const void *buf, void *hash, int typeOut, off_t length); DPKG_END_DECLS -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-75-g0e0f59a
The following commit has been merged in the master branch: commit 0e0f59a882ce329de880d4a75f30787e261e2cb3 Author: Jonathan Nieder jrnie...@gmail.com Date: Sat May 7 11:33:42 2011 +0200 libdpkg: Use new DPKG_BUFFER_SIZE macro instead of hard-coded literal Signed-off-by: Jonathan Nieder jrnie...@gmail.com Signed-off-by: Guillem Jover guil...@debian.org diff --git a/lib/dpkg/buffer.h b/lib/dpkg/buffer.h index c81ef1c..436a22e 100644 --- a/lib/dpkg/buffer.h +++ b/lib/dpkg/buffer.h @@ -30,6 +30,8 @@ DPKG_BEGIN_DECLS +#define DPKG_BUFFER_SIZE 4096 + #define BUFFER_WRITE_VBUF 1 #define BUFFER_WRITE_FD2 #define BUFFER_WRITE_NULL 3 diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c index 2bf53c5..eb01c5e 100644 --- a/lib/dpkg/compress.c +++ b/lib/dpkg/compress.c @@ -105,7 +105,7 @@ struct compressor compressor_none = { static void decompress_gzip(int fd_in, int fd_out, const char *desc) { - char buffer[4096]; + char buffer[DPKG_BUFFER_SIZE]; gzFile gzfile = gzdopen(fd_in, r); if (gzfile == NULL) @@ -139,7 +139,7 @@ decompress_gzip(int fd_in, int fd_out, const char *desc) static void compress_gzip(int fd_in, int fd_out, int compress_level, const char *desc) { - char buffer[4096]; + char buffer[DPKG_BUFFER_SIZE]; char combuf[6]; int err; gzFile gzfile; @@ -213,7 +213,7 @@ struct compressor compressor_gzip = { static void decompress_bzip2(int fd_in, int fd_out, const char *desc) { - char buffer[4096]; + char buffer[DPKG_BUFFER_SIZE]; BZFILE *bzfile = BZ2_bzdopen(fd_in, r); if (bzfile == NULL) @@ -247,7 +247,7 @@ decompress_bzip2(int fd_in, int fd_out, const char *desc) static void compress_bzip2(int fd_in, int fd_out, int compress_level, const char *desc) { - char buffer[4096]; + char buffer[DPKG_BUFFER_SIZE]; char combuf[6]; int err; BZFILE *bzfile; -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org