[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#618592: zfsutils misses zdb, zinject and ztest (with patch)



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Package: zfsutils
Version: 8.1-4
Severity: normal
Tags: patch, kfreebsd

The currently shipped version of zfsutils lacks the commands `zdb',
`ztest' and `zinject'.

Upstream does ship those utilities, so I tried to patch the current
package to include them. My patch fixes this issue and provides binaries
ready to provides packages:


root@kfreebsd:~/testbuild/zfsutils-8.1#
LD_PRELOAD="./cddl/lib/libumem/libumem.so
./cddl/lib/libzpool/libzpool.so ./cddl/lib/libavl/libavl.so"
./cddl/usr.sbin/zdb/zdb
zfs_pool
    version=14
    name='zfs_pool'
    state=0
    txg=4
    pool_guid=10142712129494363932
    hostname='kfreebsd'
...


However packages do not build (but compiling and usage of them succeeds
when using the proper libraries) because dpkg-shlibdeps fails to resolve
the dependency for libavl, as I did not provide a binary for this
package, it is included in the source though and builds fine. Problem
is, there is a non ABI and API compatible libavl package in Debian
already (http://packages.debian.org/source/squeeze/libavl) which clashes
with the implementation those utilities use.

You, as developer might choose how to resolve this conflict finally,
maybe it is necessary to rename the "libavl" zfsutils expect for kfreebsd.

I attached a patch for the debian directory which solves the original
problem though, i.e. it provides a `zdb' enabled zfustils and provides
some new binary packages required by those. It is not entirely
straightforward to apply the patch, since the source package is, ...
well, ... needs some time to get used to. You need a new orig.tar.gz to
build the new package, I used r219701 from upstream's SVN. To apply the
patch do:

root@kfreebsd:~/testbuild# apt-get source zfsutils
root@kfreebsd:~/testbuild# rm zfsutils_8.1.orig.tar.gz
root@kfreebsd:~/testbuild# cd zfsutils-8.1/
root@kfreebsd:~/testbuild/zfsutils-8.1# patch -p0  <
../debian-diff/debian-diff.patch
root@kfreebsd:~/testbuild/zfsutils-8.1# make -f debian/rules get-orig-source
root@kfreebsd:~/testbuild# mv zfsutils-8.1/debian .
root@kfreebsd:~/testbuild# rm -rf zfsutils-8.1
root@kfreebsd:~/testbuild# tar zxf zfsutils_8.1.orig.tar.gz
root@kfreebsd:~/testbuild# cd zfsutils-8.1
root@kfreebsd:~/testbuild/zfsutils-8.1# mv ../debian .

build as usual from here on. Please note I neither changed
debian/changelog nor did I increase the version number.

- -- 
with kind regards,
Arno Töll
GnuPG Key-ID: 0x8408D4C4
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNgQY4AAoJELBdpXvEXpo9xZ0P/0za/cgC37JfuBM7yWNRaWPR
QdyorS+lCBsi+yboCdJ28tk8pil3nd39cWbu9D7MlFKdkNb3tW+rRYHqHz0zOV9v
5LXTWofQezIqqUnlInfT3LXKe6MBknFx3q4UnmU4Yc1pvrwCKvOVVPVNsmvmMCIs
h9an6Ag+6bqf+QhtAZ4kqz12pvq5jOfyrXFRNLSsNenxG7FRmH/29QClp8epX5wO
mktTDvt1wbFRKgJXqL2c4MFyVvbej7tv1RtXQ0DCOq7UYbUBdh6F4dAk6v3CQval
/3YMJ97zV0TpLN8GBmoztDoL9AbBL42GAMiXE2xEEjICpVchY7UEdlZJszltcH7L
J2qV+lASGXjoqn6cpXvSzDEiEKIt+cUJusVVKe3hC3cH8ZeWS8++JB1/SeaoamqY
u08PSCsru4FiDFA9Qz5FMf+1/NePdR1ykvFQLj1mcQCMU6jLuqSXXZr53O2j+6cz
alC8UU02hk/vlYkQ/xHvsoIky9R7pMMDOKK4LjcEDRZefp8N9ftMBQAtkdRloYur
OeWbCjUt1qljOegwuuracoXbfRwxjhAQZVjOIKpV6MH4eQIWTGx51vbZOB44xeJy
tPYsW6iDUMoe23KJF9jJp7kctlsgohSQDv5Cn4Q3A6KDUChEeqrfCt2b8G1bt8PK
EzSoiLnZxGNiLenRljnv
=vmvZ
-----END PGP SIGNATURE-----
diff -ruN debian.orig/control debian/control
--- debian.orig/control	2011-03-16 14:57:19.000000000 -0400
+++ debian/control	2011-03-16 15:00:42.000000000 -0400
@@ -4,7 +4,8 @@
 Maintainer: GNU/kFreeBSD Maintainers <debian-bsd@lists.debian.org>
 Uploaders: Aurelien Jarno <aurel32@debian.org>
 Build-Depends: debhelper (>= 7), quilt, freebsd-buildutils, libbsd-dev (>= 0.1.4),
- libc0.1-dev (>= 2.10), kfreebsd-kernel-headers (>= 0.51), libgeom-dev, libsbuf-dev
+ libc0.1-dev (>= 2.10), kfreebsd-kernel-headers (>= 0.51), libgeom-dev, libsbuf-dev,
+ zlib1g-dev
 Vcs-Browser: http://svn.debian.org/wsvn/glibc-bsd/trunk/zfsutils/
 Vcs-Svn: svn://svn.debian.org/glibc-bsd/trunk/zfsutils/
 Standards-Version: 3.9.1
@@ -116,3 +117,36 @@
  ZFS filesystems.
  .
  This is a minimal package for use in debian-installer.
+
+
+Package: libumem0
+Section: libs
+Architecture: kfreebsd-any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: OpenSolaris name-value pair library
+ This package contains the OpenSolaris libumem library, to detect 
+ memory management bugs in applications
+
+Package: libumem-dev
+Section: libdevel
+Architecture: kfreebsd-any
+Depends: libumem0 (= ${binary:Version}), ${misc:Depends}, libc0.1-dev | libc-dev
+Description: Development files for libnvpair
+ This package contains the header files and static library needed to
+ compile applications that use libumem.
+
+Package: libzpool0
+Section: libs
+Architecture: kfreebsd-any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: OpenSolaris name-value pair library
+ This package contains the OpenSolaris libzpool library.
+
+Package: libzpool-dev
+Section: libdevel
+Architecture: kfreebsd-any
+Depends: libzpool0 (= ${binary:Version}), ${misc:Depends}, libc0.1-dev | libc-dev
+Description: Development files for libnvpair
+ This package contains the header files and static library needed to
+ compile applications that use libzpool.
+
diff -ruN debian.orig/libumem0.install debian/libumem0.install
--- debian.orig/libumem0.install	1969-12-31 19:00:00.000000000 -0500
+++ debian/libumem0.install	2011-03-16 15:00:42.000000000 -0400
@@ -0,0 +1 @@
+cddl/lib/libumem/libumem.so.0	lib
diff -ruN debian.orig/libumem-dev.install debian/libumem-dev.install
--- debian.orig/libumem-dev.install	1969-12-31 19:00:00.000000000 -0500
+++ debian/libumem-dev.install	2011-03-16 15:00:42.000000000 -0400
@@ -0,0 +1 @@
+cddl/lib/libumem/libumem.a	usr/lib
diff -ruN debian.orig/libumem-dev.links debian/libumem-dev.links
--- debian.orig/libumem-dev.links	1969-12-31 19:00:00.000000000 -0500
+++ debian/libumem-dev.links	2011-03-16 15:00:42.000000000 -0400
@@ -0,0 +1 @@
+lib/libumem.so.0                 usr/lib/libumem.so
diff -ruN debian.orig/libzpool0.install debian/libzpool0.install
--- debian.orig/libzpool0.install	1969-12-31 19:00:00.000000000 -0500
+++ debian/libzpool0.install	2011-03-16 15:00:42.000000000 -0400
@@ -0,0 +1 @@
+cddl/lib/libzpool/libzpool.so.0	lib
diff -ruN debian.orig/libzpool-dev.install debian/libzpool-dev.install
--- debian.orig/libzpool-dev.install	1969-12-31 19:00:00.000000000 -0500
+++ debian/libzpool-dev.install	2011-03-16 15:00:42.000000000 -0400
@@ -0,0 +1 @@
+cddl/lib/libzpool/libzpool.a	usr/lib
diff -ruN debian.orig/libzpool-dev.links debian/libzpool-dev.links
--- debian.orig/libzpool-dev.links	1969-12-31 19:00:00.000000000 -0500
+++ debian/libzpool-dev.links	2011-03-16 15:00:42.000000000 -0400
@@ -0,0 +1 @@
+lib/libzpool.so.0                 usr/lib/libzpool.so
diff -ruN debian.orig/patches/13_zpool.diff debian/patches/13_zpool.diff
--- debian.orig/patches/13_zpool.diff	1969-12-31 19:00:00.000000000 -0500
+++ debian/patches/13_zpool.diff	2011-03-16 15:00:42.000000000 -0400
@@ -0,0 +1,163 @@
+Index: zfsutils-8.1/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+===================================================================
+--- zfsutils-8.1.orig/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	2011-03-14 21:47:32.000000000 -0400
++++ zfsutils-8.1/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	2011-03-14 21:49:19.000000000 -0400
+@@ -141,6 +141,13 @@
+ extern uint64_t zfs_write_limit_max;
+ extern kmutex_t zfs_write_limit_lock;
+ 
++
++#ifndef alloca
++#define alloca(x) __builtin_alloca(x)
++#endif
++
++#define __unused __attribute__((unused))
++
+ #define	ARC_REDUCE_DNLC_PERCENT	3
+ uint_t arc_reduce_dnlc_percent = ARC_REDUCE_DNLC_PERCENT;
+ 
+Index: zfsutils-8.1/cddl/usr.sbin/zdb/Makefile
+===================================================================
+--- zfsutils-8.1.orig/cddl/usr.sbin/zdb/Makefile	2011-03-14 21:47:32.000000000 -0400
++++ zfsutils-8.1/cddl/usr.sbin/zdb/Makefile	2011-03-14 21:49:19.000000000 -0400
+@@ -21,7 +21,10 @@
+ 
+ DPADD=	${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ 	${LIBUUTIL} ${LIBZ} ${LIBZFS} ${LIBZPOOL}
++
+ LDADD=	-lavl -lgeom -lm -lnvpair -lpthread -lumem -luutil -lz -lzfs -lzpool
++LDADD+= -L${.CURDIR}/../../../cddl/lib/libumem
++LDADD+= -L${.CURDIR}/../../../cddl/lib/libzpool
+ 
+ CSTD=	c99
+ 
+Index: zfsutils-8.1/cddl/usr.bin/zinject/Makefile
+===================================================================
+--- zfsutils-8.1.orig/cddl/usr.bin/zinject/Makefile	2011-03-14 21:47:32.000000000 -0400
++++ zfsutils-8.1/cddl/usr.bin/zinject/Makefile	2011-03-14 21:49:19.000000000 -0400
+@@ -21,5 +21,7 @@
+ DPADD=	${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ 	${LIBZFS} ${LIBZPOOL} ${LIBUUTIL}
+ LDADD=	-lavl -lgeom -lm -lnvpair -lumem -luutil -lzfs -lzpool
++LDADD+= -L${.CURDIR}/../../../cddl/lib/libzpool
++LDADD+= -L${.CURDIR}/../../../cddl/lib/libumem
+ 
+ .include <bsd.prog.mk>
+Index: zfsutils-8.1/cddl/usr.bin/ztest/Makefile
+===================================================================
+--- zfsutils-8.1.orig/cddl/usr.bin/ztest/Makefile	2011-03-14 21:47:32.000000000 -0400
++++ zfsutils-8.1/cddl/usr.bin/ztest/Makefile	2011-03-14 22:03:39.000000000 -0400
+@@ -17,7 +17,10 @@
+ 
+ DPADD=	${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ 	${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+-LDADD=	-lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
++LDADD=	-lm -lnvpair -lumem -lzpool -lpthread -lz -lavl -lrt -ldl
++LDADD+= -L${.CURDIR}/../../../cddl/lib/libzpool
++LDADD+= -L${.CURDIR}/../../../cddl/lib/libumem
++LDADD+= -L${.CURDIR}/../../../cddl/lib/libavl
+ 
+ CSTD=	c99
+ 
+Index: zfsutils-8.1/cddl/contrib/opensolaris/cmd/zdb/zdb.c
+===================================================================
+--- zfsutils-8.1.orig/cddl/contrib/opensolaris/cmd/zdb/zdb.c	2011-03-14 21:47:32.000000000 -0400
++++ zfsutils-8.1/cddl/contrib/opensolaris/cmd/zdb/zdb.c	2011-03-14 21:49:19.000000000 -0400
+@@ -67,6 +67,11 @@
+ boolean_t zdb_sig_user_data = B_TRUE;
+ int zdb_sig_cksumalg = ZIO_CHECKSUM_SHA256;
+ 
++#ifndef alloca
++#define alloca(x) __builtin_alloca(x)
++#endif
++
++
+ /*
+  * These libumem hooks provide a reasonable set of defaults for the allocator's
+  * debugging facilities.
+Index: zfsutils-8.1/cddl/contrib/opensolaris/cmd/zdb/zdb_il.c
+===================================================================
+--- zfsutils-8.1.orig/cddl/contrib/opensolaris/cmd/zdb/zdb_il.c	2011-03-14 21:47:32.000000000 -0400
++++ zfsutils-8.1/cddl/contrib/opensolaris/cmd/zdb/zdb_il.c	2011-03-14 21:49:19.000000000 -0400
+@@ -40,6 +40,11 @@
+ 
+ extern uint8_t dump_opt[256];
+ 
++#ifndef alloca
++#define alloca(x) __builtin_alloca(x)
++#endif
++
++
+ static void
+ print_log_bp(const blkptr_t *bp, const char *prefix)
+ {
+Index: zfsutils-8.1/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
+===================================================================
+--- zfsutils-8.1.orig/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h	2011-03-14 21:49:18.000000000 -0400
++++ zfsutils-8.1/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h	2011-03-14 21:49:19.000000000 -0400
+@@ -85,6 +85,12 @@
+ 
+ #define	ZFS_EXPORTS_PATH	"/etc/zfs/exports"
+ 
++
++#ifndef alloca
++#define alloca(x) __builtin_alloca(x)
++#endif
++
++
+ /*
+  * Debugging
+  */
+Index: zfsutils-8.1/cddl/contrib/opensolaris/lib/libzpool/common/util.c
+===================================================================
+--- zfsutils-8.1.orig/cddl/contrib/opensolaris/lib/libzpool/common/util.c	2011-03-14 22:02:01.000000000 -0400
++++ zfsutils-8.1/cddl/contrib/opensolaris/lib/libzpool/common/util.c	2011-03-14 22:02:56.000000000 -0400
+@@ -32,11 +32,48 @@
+ #include <sys/spa.h>
+ #include <sys/fs/zfs.h>
+ #include <sys/refcount.h>
++#include <sys/types.h>
+ 
+ /*
+  * Routines needed by more than one client of libzpool.
+  */
+ 
++
++
++/* strlcpy based on OpenBSDs strlcpy */
++size_t strlcpy(char *, const char *, size_t);
++
++/*
++ * Copy src to string dst of size siz.  At most siz-1 characters
++ * will be copied.  Always NUL terminates (unless siz == 0).
++ * Returns strlen(src); if retval >= siz, truncation occurred.
++ */
++size_t
++strlcpy(char *dst, const char *src, size_t siz)
++{
++        char *d = dst;
++        const char *s = src;
++        size_t n = siz;
++
++        /* Copy as many bytes as will fit */
++        if (n != 0 && --n != 0) {
++                do {
++                        if ((*d++ = *s++) == 0)
++                                break;
++                } while (--n != 0);
++        }
++
++        /* Not enough room in dst, add NUL and traverse rest of src */
++        if (n == 0) {
++                if (siz != 0)
++                        *d = '\0';                /* NUL-terminate dst */
++                while (*s++)
++                        ;
++        }
++
++        return(s - src - 1);        /* count does not include NUL */
++}
++
+ void
+ nicenum(uint64_t num, char *buf)
+ {
diff -ruN debian.orig/patches/series debian/patches/series
--- debian.orig/patches/series	2011-03-16 14:57:19.000000000 -0400
+++ debian/patches/series	2011-03-16 15:00:42.000000000 -0400
@@ -10,3 +10,4 @@
 10_zpool_import.diff
 11_endian.diff
 12_freebsd.diff
+13_zpool.diff
diff -ruN debian.orig/rules debian/rules
--- debian.orig/rules	2011-03-16 14:57:19.000000000 -0400
+++ debian/rules	2011-03-16 15:00:42.000000000 -0400
@@ -4,7 +4,7 @@
 SHELL=bash
 
 # Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
+export DH_VERBOSE=1
 
 # This has to be exported to make some magic below work.
 export DH_OPTIONS
@@ -42,8 +42,11 @@
 	         cddl/contrib/opensolaris/lib/libzpool \
 	         sys/cddl/compat/opensolaris \
 	         sys/cddl/contrib/opensolaris \
-	         cddl/lib/libnvpair \
+	         cddl/lib/libavl \
+                 cddl/lib/libnvpair \
 	         cddl/lib/libuutil \
+	         cddl/lib/libzpool \
+	         cddl/lib/libumem \
 	         cddl/lib/libzfs \
 	         cddl/sbin/zpool \
 	         cddl/sbin/zfs \
@@ -63,7 +66,7 @@
 	QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2
 	touch $@
 
-build: build-libuutil build-libnvpair build-libzfs build-zfsutils
+build: build-libuutil build-libnvpair build-libzfs build-libumem build-libzpool build-zfsutils build-libavl
 
 build-libuutil: build-libuutil-stamp
 build-libuutil-stamp: patch
@@ -80,10 +83,35 @@
 	$(PMAKE) -C $(CURDIR)/cddl/lib/libzfs
 	touch $@
 
+build-libumem: build-libumem-stamp
+build-libumem-stamp: patch
+	$(PMAKE) -C $(CURDIR)/cddl/lib/libumem
+	touch $@
+
+
+build-libzpool: build-libzpool-stamp
+build-libzpool-stamp: patch
+	$(PMAKE) -C $(CURDIR)/cddl/lib/libzpool
+	touch $@
+
+build-libzfs: build-libzfs-stamp
+build-libzfs-stamp: patch build-libnvpair-stamp build-libuutil-stamp
+	$(PMAKE) -C $(CURDIR)/cddl/lib/libzfs
+	touch $@
+
+build-libavl: build-libavl-stamp
+build-libavl-stamp: patch
+	$(PMAKE) -C $(CURDIR)/cddl/lib/libavl
+	touch $@
+
 build-zfsutils: build-zfsutils-stamp
-build-zfsutils-stamp: patch build-libzfs-stamp build-libnvpair-stamp build-libuutil-stamp
+build-zfsutils-stamp: patch build-libzfs-stamp build-libnvpair-stamp build-libuutil-stamp build-libumem build-libzpool build-libavl
 	$(PMAKE) -C $(CURDIR)/cddl/sbin/zpool
 	$(PMAKE) -C $(CURDIR)/cddl/sbin/zfs
+
+	$(PMAKE) -C $(CURDIR)/cddl/usr.sbin/zdb
+	$(PMAKE) -C $(CURDIR)/cddl/usr.bin/zinject 
+	$(PMAKE) -C $(CURDIR)/cddl/usr.bin/ztest/   
 	touch $@
 
 clean:
@@ -98,6 +126,14 @@
 	$(PMAKE) -C $(CURDIR)/cddl/sbin/zpool clean
 	$(PMAKE) -C $(CURDIR)/cddl/sbin/zfs clean
 	
+	
+	$(PMAKE) -C $(CURDIR)/cddl/lib/libumem clean
+	$(PMAKE) -C $(CURDIR)/cddl/lib/libzpool clean
+	$(PMAKE) -C $(CURDIR)/cddl/lib/libavl clean
+	$(PMAKE) -C $(CURDIR)/cddl/usr.sbin/zdb clean
+	$(PMAKE) -C $(CURDIR)/cddl/usr.bin/ztest clean
+	$(PMAKE) -C $(CURDIR)/cddl/usr.bin/zinject clean
+
 	QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2
 	rm -rf .pc
 	rm -f *stamp
@@ -108,7 +144,7 @@
 	dh_testroot
 	dh_prep -s
 	dh_installdirs -s
-	dh_install -s
+	dh_install -s --fail-missing
 
 # Build architecture-independent files here.
 binary-indep: build install
diff -ruN debian.orig/zfsutils.install debian/zfsutils.install
--- debian.orig/zfsutils.install	2011-03-16 14:57:19.000000000 -0400
+++ debian/zfsutils.install	2011-03-16 15:00:42.000000000 -0400
@@ -1,2 +1,5 @@
 cddl/sbin/zpool/zpool	/sbin
 cddl/sbin/zfs/zfs	/sbin
+cddl/usr.bin/zinject  	/usr/bin
+cddl/usr.bin/ztest	/usr/bin
+cddl/usr.sbin/zdb	/usr/sbin

Reply to: