Ticket #39018: dpkg_1.16.15.patch
File dpkg_1.16.15.patch, 36.9 KB (added by xeron (Ivan Larionov), 10 years ago) |
---|
-
Portfile
diff --git a/Portfile b/Portfile index c6f72ca..3027fdc 100644
a b 1 # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 1 2 # $Id: Portfile 105815 2013-05-06 14:52:20Z landonf@macports.org $ 2 3 3 PortSystem 1.0 4 5 name dpkg 6 version 1.14.29 7 revision 4 8 platforms darwin freebsd 9 categories sysutils archivers 10 license GPL-2+ 11 maintainers nomaintainer 12 description Debian package maintenance system 13 long_description ${description} 14 homepage http://wiki.debian.org/Teams/Dpkg 15 16 master_sites debian:d/dpkg/ 17 checksums md5 4326172a959b5b6484b4bc126e9f628d \ 18 sha1 15a35dd96dac6a99f24844b2eff85f8fad37ab06 4 PortSystem 1.0 5 PortGroup perl5 1.0 6 7 name dpkg 8 version 1.16.15 9 platforms darwin freebsd 10 categories sysutils archivers 11 license GPL-2+ 12 maintainers gwmail.gwu.edu:egall openmaintainer 13 description Debian package maintenance system 14 long_description ${name} is the basis of the ${description}. 15 16 homepage http://wiki.debian.org/Teams/Dpkg 17 18 master_sites debian:d/${name}/ 19 checksums md5 0e7d105a57839cdab2b0bf5e3612442f \ 20 sha1 c034f88c1ea9d8df7c5a84cc04bb7749e2b3617a \ 21 rmd160 fa7ebed1156cf501bd22ba3e4aab6e2a3a8439d5 \ 22 sha256 92bca9901ba2d9300be42f6de8dbea59b8367a918a2abeeb47d2176c9cf86b55 23 24 use_xz yes 25 extract.asroot yes 26 27 depends_build-append \ 28 port:pkgconfig \ 29 port:autoconf-archive \ 30 port:xorg-util-macros \ 31 port:gnutar \ 32 port:perl${perl5.major} \ 33 bin:git:git-core \ 34 bin:lzma:xz 19 35 20 36 # Use MacPorts versions explicitly 21 depends_lib port:gettext \ 22 port:libiconv \ 23 port:perl5 \ 24 port:coreutils \ 25 port:bzip2 \ 26 port:zlib 27 28 depends_run bin:gnutar:gnutar \ 29 bin:lzma:xz 30 37 depends_lib-append port:gettext \ 38 port:libiconv \ 39 port:perl${perl5.major} \ 40 port:p${perl5.major}-timedate \ 41 port:coreutils \ 42 port:bzip2 \ 43 port:gzip \ 44 port:zlib \ 45 port:ncurses \ 46 port:gnutar \ 47 path:lib/pkgconfig/liblzma.pc:xz 48 49 depends_run-append port:gnutar \ 50 port:gzip \ 51 bin:lzma:xz \ 52 bin:perl5:perl${perl5.major} \ 53 port:debianutils 54 55 # got to do some underscore-to-hyphen twiddling... 56 distname ${name}_${version} 57 worksrcdir ${name}-${version} 58 59 configure.perl ${prefix}/bin/perl5 60 configure.pkg_config ${prefix}/bin/pkg-config 61 configure.env-append TAR=${prefix}/bin/gnutar 62 configure.args-append \ 63 --with-libintl-prefix=${prefix} \ 64 --with-libiconv-prefix=${prefix} \ 65 --with-admindir=${prefix}/var/db/${name} \ 66 --with-logdir=${prefix}/var/log \ 67 --mandir=${prefix}/share/man \ 68 --with-zlib \ 69 --with-bz2 \ 70 --with-liblzma \ 71 --disable-linker-optimisations \ 72 --disable-silent-rules \ 73 --disable-start-stop-daemon 74 # The start-stop-daemon patch now applies again, but now it leads to build 75 # errors, so disabling it with a configure flag again (as done above) 76 77 # ccache is trouble 78 configure.ccache no 79 80 # Older versions of gcc choke with the -Wvla warning flag 81 configure.cflags-delete -Wvla 82 configure.cppflags-delete -Wvla 83 configure.ldflags-delete -Wvla 84 85 post-configure { 86 reinplace "s|-Wvla||" ${worksrcpath}/Makefile 87 eval reinplace "s|-Wvla||" [glob ${worksrcpath}/*/Makefile] 88 eval reinplace "s|-Wvla||" [glob ${worksrcpath}/lib/*/Makefile] 89 reinplace "s|-Wvla||" ${worksrcpath}/lib/dpkg/test/Makefile 90 reinplace "s|-Wmissing-declarations||" ${worksrcpath}/dselect/Makefile 91 } 31 92 32 distname ${name}_${version} 33 worksrcdir ${name}-${version} 93 compiler.blacklist-append cc gcc-3.3 gcc-4.0 apple-gcc-4.0 34 94 35 patchfiles patch-lib_tarfn.c \ 36 patch-main_remove.c \ 37 patch-main_archives.c \ 38 patch-scripts-Makefile \ 39 patch-lib_dpkg.h \ 40 ncurses.diff 95 build.type gnu 41 96 42 configure.env PERL=${prefix}/bin/perl5 43 configure.args --without-sgml-doc --with-libintl-prefix=${prefix} \ 44 --with-libiconv-prefix=${prefix} --with-admindir=${prefix}/var/db/dpkg \ 45 --mandir=${prefix}/share/man \ 46 --with-zlib --with-bz2 \ 47 --disable-linker-optimisations 97 set vardpkg ${destroot}${prefix}/var/db/${name} 98 destroot.keepdirs-append \ 99 ${vardpkg} \ 100 ${vardpkg}/updates \ 101 ${vardpkg}/info \ 102 ${destroot}${prefix}/var/log \ 103 ${destroot}${prefix}/etc/${name} 48 104 49 build.type gnu 105 patchfiles-append patch-configure.ac.diff \ 106 patch-lib_dpkg_dpkg.h.diff \ 107 patch-lib_dpkg_tarfn.c.diff \ 108 patch-src_remove.c.diff \ 109 patch-src_archives.c.diff \ 110 patch-utils_start-stop-daemon.c.diff \ 111 patch-scripts_Dpkg_Source_Archive.pm.diff 50 112 51 set vardpkg ${destroot}${prefix}/var/db/dpkg 52 destroot.keepdirs ${vardpkg} ${vardpkg}/updates ${vardpkg}/info 113 patch.args-append --backup 53 114 54 115 post-patch { 55 set scripts ${worksrcpath}/scripts 56 reinplace s|/etc/dpkg/|${prefix}/etc/dpkg/| \ 57 ${scripts}/dpkg-shlibdeps.pl \ 58 ${scripts}/dpkg-source.pl 59 60 reinplace s|/etc/alternatives|${prefix}/etc/alternatives|g \ 61 ${scripts}/update-alternatives.pl 116 set scripts ${worksrcpath}/scripts 117 reinplace "s|/etc/${name}/|${prefix}/etc/${name}/|" \ 118 ${scripts}/${name}-shlibdeps.pl \ 119 ${scripts}/${name}-source.pl 120 reinplace "s|AC_ERROR|AC_MSG_ERROR|" ${worksrcpath}/m4/dpkg-build.m4 121 file copy ${prefix}/share/aclocal/ax_check_gnu_make.m4 ${worksrcpath}/m4 122 file copy ${prefix}/share/aclocal/xorg-macros.m4 ${worksrcpath}/m4 123 system -W ${worksrcpath} "git init" 62 124 } 63 125 126 use_autoreconf yes 127 autoreconf.args -fvi --warnings=all 128 64 129 pre-destroot { 65 file mkdir ${destroot}${prefix}/share/doc/dpkg 130 file mkdir ${destroot}${prefix}/share/doc/${name} 66 131 } 67 132 68 133 post-destroot { 69 70 71 72 134 file mkdir ${vardpkg} 135 file mkdir ${vardpkg}/updates 136 file mkdir ${vardpkg}/info 137 system "touch ${vardpkg}/available ${vardpkg}/status" 73 138 } 74 139 140 # These platform variants had previously had patches associated 141 # with them... 75 142 platform darwin { 76 depends_build-append bin:gnumake:gmake 77 patchfiles-append patch-utils_start-stop-daemon.c bsd/patch-main_help.c 143 depends_build-append bin:gnumake:gmake 78 144 } 79 145 80 146 platform freebsd { 81 depends_build-append bin:gmake:gmake 82 patchfiles-append patch-utils_start-stop-daemon.c bsd/patch-main_help.c 147 depends_build-append bin:gmake:gmake 148 } 149 150 # This variant sometimes hangs while building... 151 variant docs description {Build documentation (warning: building documentation takes a long time)} { 152 depends_build-append port:doxygen \ 153 path:bin/dot:graphviz \ 154 port:fontconfig \ 155 port:freefont-ttf 156 set docdir ${prefix}/share/doc/${name} 157 configure.args-append --docdir=${docdir} \ 158 --htmldir=${docdir}/html \ 159 --dvidir=${docdir}/dvi \ 160 --pdfdir=${docdir}/pdf \ 161 --psdir=${docdir}/ps 162 build.target-append doc 163 pre-build { 164 elevateToRoot "doxygen" 165 system -W ${worksrcpath}/doc "${prefix}/bin/doxygen -u" 166 } 167 post-build { 168 system -W ${worksrcpath}/doc "${prefix}/bin/doxygen" 169 dropPrivileges 170 set destroot_docdir ${destroot}${prefix}/share/doc/${name} 171 xinstall -d ${destroot_docdir} 172 copy ${worksrcpath}/doc/doc ${destroot_docdir} 173 copy ${worksrcpath}/doc/html ${destroot_docdir} 174 foreach docfile {coding-style.txt triggers.txt README.feature-removal-schedule frontend.txt README.api} { 175 xinstall -m 644 ${worksrcpath}/doc/${docfile} ${destroot_docdir} 176 } 177 } 178 } 179 180 # Tests currently fail, this needs to be fixed eventually: 181 test.run yes 182 test.target check 183 184 pre-test { 185 elevateToRoot "test" 186 } 187 post-test { 188 dropPrivileges 83 189 } 84 190 85 livecheck.type regex 86 livecheck.url http://ftp.debian.org/debian/pool/main/d/dpkg/ 87 livecheck.regex "${name}_(\\d+\\.\\d+(\\.\\d+)*)" 191 # odd-numbered releases are unstable, so ignore them 192 livecheck.type regex 193 livecheck.url http://ftp.debian.org/debian/pool/main/d/${name}/ 194 livecheck.regex "${name}_(\\d+\\.\\d*\[02468\](\\.\\d+)*)" -
deleted file files/bsd/patch-main_help.c
diff --git a/files/bsd/patch-main_help.c b/files/bsd/patch-main_help.c deleted file mode 100644 index e4f4b89..0000000
+ - 1 --- src/help.c.old Thu Dec 9 16:35:16 20042 +++ src/help.c Thu Dec 9 16:35:38 20043 @@ -77,12 +77,11 @@4 5 void checkpath(void) {6 /* Verify that some programs can be found in the PATH. */7 - static const char *const checklist[]= { "ldconfig",8 + static const char *const checklist[]= {9 #if WITH_START_STOP_DAEMON10 "start-stop-daemon",11 #endif12 "install-info",13 - "update-rc.d",14 NULL15 };16 -
deleted file files/ncurses.diff
diff --git a/files/ncurses.diff b/files/ncurses.diff deleted file mode 100644 index 4e49161..0000000
+ - 1 --- dselect/Makefile.in.orig 2010-03-09 07:32:20.000000000 +11002 +++ dselect/Makefile.in 2011-03-11 12:01:25.000000000 +11003 @@ -640,7 +640,7 @@4 5 curkeys.$(OBJEXT): curkeys.h6 curkeys.h: $(srcdir)/keyoverride $(srcdir)/mkcurkeys.pl7 - cursesfile=`echo '#include <ncursesw/curses.h>' | \8 + cursesfile=`echo '#include <curses.h>' | \9 $(CC) -E - | grep 'curses.h' | head -n 1 | \10 sed -e 's/^[^"]*"//; s/".*$$//'`; \11 if [ "$$cursesfile" = "" ]; then \12 --- dselect/dselect.h.orig 2010-03-09 07:27:35.000000000 +110013 +++ dselect/dselect.h 2011-03-11 12:01:43.000000000 +110014 @@ -28,7 +28,7 @@15 16 #include <signal.h>17 #undef ERR18 -#include <ncursesw/curses.h>19 +#include <curses.h>20 21 struct helpmenuentry {22 char key;23 --- dselect/main.cc.orig 2010-03-09 07:27:35.000000000 +110024 +++ dselect/main.cc 2011-03-11 12:01:36.000000000 +110025 @@ -37,7 +37,7 @@ extern "C" {26 #include <ctype.h>27 #include <assert.h>28 29 -#include <ncursesw/term.h>30 +#include <term.h>31 32 extern "C" {33 #include <dpkg.h> -
new file files/patch-configure.ac.diff
diff --git a/files/patch-configure.ac.diff b/files/patch-configure.ac.diff new file mode 100644 index 0000000..5b932c5
- + 1 --- configure.ac.bak 2013-08-17 15:07:59.000000000 -0400 2 +++ configure.ac 2013-08-17 15:27:30.000000000 -0400 3 @@ -1,21 +1,22 @@ 4 +# -*- Autoconf -*- 5 # Process this file with autoconf to produce a configure script. 6 7 m4_pattern_forbid([^_?DPKG_]) 8 9 -AC_PREREQ(2.60) 10 -AC_INIT([dpkg], m4_esyscmd([./get-version]), [debian-dpkg@lists.debian.org]) 11 +AC_PREREQ([2.69]) 12 +AC_INIT([dpkg],[m4_esyscmd([./get-version])],[debian-dpkg@lists.debian.org]) 13 AC_CONFIG_SRCDIR([lib/dpkg/dpkg.h]) 14 AC_CONFIG_MACRO_DIR([m4]) 15 AC_CONFIG_AUX_DIR([build-aux]) 16 17 AC_USE_SYSTEM_EXTENSIONS 18 19 -AM_INIT_AUTOMAKE([1.8 foreign nostdinc no-dist-gzip dist-xz]) 20 +AM_INIT_AUTOMAKE([1.8 dejagnu foreign nostdinc no-dist-gzip dist-xz tar-ustar -Wall]) 21 22 -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], 23 - [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])]) 24 +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])], 25 + [AC_SUBST([AM_DEFAULT_VERBOSITY],[1])]) 26 27 -AM_GNU_GETTEXT_VERSION([0.18]) 28 +AM_GNU_GETTEXT_VERSION([0.18.3]) 29 AM_GNU_GETTEXT([external]) 30 DPKG_DIST_CHECK([test "$GMSGFMT" = ":" && test "$USE_NLS" = "yes"], 31 [gettext required when NLS support enabled]) 32 @@ -27,19 +28,46 @@ 33 DPKG_BUILD_PROG([install-info]) 34 35 # Allow alternate directories 36 -DPKG_WITH_DIR([admindir], [${localstatedir}/lib/${PACKAGE_NAME}], 37 +DPKG_WITH_DIR([admindir],[${localstatedir}/lib/${PACKAGE_NAME}], 38 [dpkg database directory [LOCALSTATEDIR/lib/dpkg]]) 39 -DPKG_WITH_DIR([logdir], [${localstatedir}/log], 40 +DPKG_WITH_DIR([logdir],[${localstatedir}/log], 41 [system logging directory [LOCALSTATEDIR/log]]) 42 43 # Checks for programs. 44 -AC_PROG_CC 45 +AM_PROG_AR 46 +if test "x$CC" = "x"; then 47 + test -z "$CC" 48 + AC_PROG_CC 49 +else 50 + test ! -z "$CC" 51 + export CC 52 + AC_SUBST([CC]) 53 +fi 54 AC_PROG_CXX 55 -AC_PROG_LEX 56 -DPKG_DIST_CHECK([test "$LEX" = ":"], [lex program required]) 57 -AC_PROG_RANLIB 58 -AC_CHECK_PROGS([DOXYGEN], [doxygen]) 59 -AC_CHECK_PROG([HAVE_DOT], [dot], [YES], [NO]) 60 +if test "x$INSTALL" = "x"; then 61 + test -z "$INSTALL" 62 + AC_PROG_INSTALL 63 + AM_PROG_INSTALL_STRIP 64 +else 65 + test ! -z "$INSTALL" 66 + export INSTALL 67 + AC_SUBST([INSTALL]) 68 +fi 69 +AM_PROG_LEX 70 +DPKG_DIST_CHECK([test "$LEX" = ":"],[lex program required]) 71 +if test "x$RANLIB" = "x"; then 72 + test -z "$RANLIB" 73 + AC_PROG_RANLIB 74 +else 75 + test ! -z "$RANLIB" 76 + export RANLIB 77 + AC_SUBST([RANLIB]) 78 +fi 79 +AC_CHECK_PROGS([DOXYGEN],[doxygen]) 80 +AC_CHECK_PROG([HAVE_DOT],[dot],[YES],[NO]) 81 +AX_CHECK_GNU_MAKE 82 +AC_PATH_PROG([TAR],[gnutar gtar tar]) 83 + 84 DPKG_PROG_PO4A 85 DPKG_PROG_PERL 86 DPKG_PROG_POD2MAN 87 @@ -47,6 +75,8 @@ 88 89 # Checks for operating system services and capabilities. 90 AC_SYS_LARGEFILE 91 +AC_OBJEXT 92 +AC_EXEEXT 93 94 # Checks for libraries. 95 DPKG_LIB_ZLIB 96 @@ -61,69 +91,100 @@ 97 fi 98 99 # Checks for header files. 100 -AC_HEADER_STDC 101 -AC_CHECK_HEADERS([stddef.h error.h locale.h libintl.h kvm.h \ 102 - sys/syscall.h linux/fiemap.h]) 103 +AC_CHECK_HEADERS([error.h fcntl.h libintl.h limits.h \ 104 + linux/fiemap.h locale.h kvm.h \ 105 + stddef.h stdio.h sys/file.h sys/ioctl.h \ 106 + sys/time.h sys/syscall.h sys/vfs.h utime.h]) 107 108 # Checks for typedefs, structures, and compiler characteristics. 109 +AC_HEADER_STDBOOL 110 AC_C_BIGENDIAN 111 AC_C_CONST 112 +AC_C_FLEXIBLE_ARRAY_MEMBER 113 AC_C_INLINE 114 +AC_C_PROTOTYPES 115 +AC_C_VARARRAYS 116 AC_C_VOLATILE 117 DPKG_C_C99 118 +AC_TYPE_INT16_T 119 +AC_TYPE_INT32_T 120 +AC_TYPE_INT8_T 121 AC_TYPE_MODE_T 122 +AC_FUNC_OBSTACK 123 +AC_TYPE_OFF_T 124 AC_TYPE_PID_T 125 AC_TYPE_SIZE_T 126 +AC_TYPE_SSIZE_T 127 +AC_CHECK_MEMBERS([struct stat.st_rdev]) 128 +AC_CHECK_DECLS([sys_siglist]) 129 +AC_TYPE_UINT16_T 130 +AC_TYPE_UINT32_T 131 +AC_TYPE_UINT64_T 132 +AC_TYPE_UINT8_T 133 +AC_TYPE_UID_T 134 DPKG_TYPES_U_INT_T 135 DPKG_TYPE_PTRDIFF_T 136 AC_CHECK_SIZEOF([unsigned int]) 137 +AC_CHECK_ALIGNOF([unsigned int]) 138 AC_CHECK_SIZEOF([unsigned long]) 139 +AC_CHECK_ALIGNOF([unsigned long]) 140 DPKG_DECL_SYS_SIGLIST 141 142 # Checks for library functions. 143 DPKG_FUNC_VA_COPY 144 DPKG_FUNC_C99_SNPRINTF 145 -DPKG_CHECK_DECL([offsetof], [stddef.h]) 146 -DPKG_CHECK_DECL([WCOREDUMP], [sys/wait.h]) 147 -DPKG_CHECK_DECL([TIOCNOTTY], [sys/ioctl.h]) 148 -DPKG_CHECK_DECL([O_NOFOLLOW], [fcntl.h]) 149 +DPKG_CHECK_DECL([offsetof],[stddef.h]) 150 +DPKG_CHECK_DECL([WCOREDUMP],[sys/wait.h]) 151 +DPKG_CHECK_DECL([TIOCNOTTY],[sys/ioctl.h]) 152 +DPKG_CHECK_DECL([O_NOFOLLOW],[fcntl.h]) 153 DPKG_CHECK_PROGNAME 154 DPKG_CHECK_COMPAT_FUNCS([getopt getopt_long obstack_free \ 155 strnlen strndup strerror strsignal asprintf \ 156 scandir alphasort unsetenv]) 157 -AC_CHECK_DECLS([strnlen], [[#include <string.h>]]) 158 +AC_FUNC_CHOWN 159 +AC_FUNC_ERROR_AT_LINE 160 +AC_FUNC_FORK 161 +AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK 162 +AC_FUNC_MALLOC 163 +AC_FUNC_MMAP 164 +AC_FUNC_REALLOC 165 +AC_FUNC_STRNLEN 166 +AC_CHECK_DECLS([strnlen],[[#include <string.h>]]) 167 AC_CHECK_FUNCS([memcpy lchown], 168 - [], [AC_ERROR([missing required function])]) 169 -AC_CHECK_FUNCS([strtoimax isascii setsid getdtablesize \ 170 - getprogname getexecname lutimes posix_fadvise]) 171 + [],[AC_MSG_ERROR(missing required function)]) 172 +AC_CHECK_FUNCS([dup2 ftruncate getdtablesize getexecname \ 173 + getprogname gettimeofday isascii lutimes memchr memmove memset mkdir \ 174 + mkfifo munmap posix_fadvise putenv regcomp rmdir select setenv setlocale \ 175 + setsid strcasecmp strchr strcspn strdup strncasecmp \ 176 + strpbrk strrchr strspn strstr strtoimax strtol]) 177 178 DPKG_MMAP 179 180 # Checks for the build machinery. 181 -AC_DEFINE(LIBDPKG_VOLATILE_API, 1, [Acknowledge the volatility of the API.]) 182 +AC_DEFINE([LIBDPKG_VOLATILE_API],[1],[Acknowledge the volatility of the API.]) 183 DPKG_COMPILER_WARNINGS 184 DPKG_COMPILER_OPTIMISATIONS 185 DPKG_LINKER_OPTIMISATIONS 186 DPKG_ARCHITECTURE 187 188 -AC_CONFIG_FILES([ Makefile 189 - dpkg-deb/Makefile 190 - dpkg-split/Makefile 191 - dselect/Makefile 192 - dselect/methods/Makefile 193 - dselect/po/Makefile.in 194 - lib/Makefile 195 - lib/compat/Makefile 196 - lib/dpkg/Makefile 197 - lib/dpkg/libdpkg.pc 198 - lib/dpkg/test/Makefile 199 - doc/Doxyfile 200 - man/Makefile 201 - po/Makefile.in 202 - scripts/Makefile 203 - scripts/mk/Makefile 204 - scripts/po/Makefile.in 205 - src/Makefile 206 - utils/Makefile ]) 207 +AC_CONFIG_FILES([Makefile 208 + dpkg-deb/Makefile 209 + dpkg-split/Makefile 210 + dselect/Makefile 211 + dselect/methods/Makefile 212 + dselect/po/Makefile.in 213 + lib/Makefile 214 + lib/compat/Makefile 215 + lib/dpkg/Makefile 216 + lib/dpkg/libdpkg.pc 217 + lib/dpkg/test/Makefile 218 + doc/Doxyfile 219 + man/Makefile 220 + po/Makefile.in 221 + scripts/Makefile 222 + scripts/mk/Makefile 223 + scripts/po/Makefile.in 224 + src/Makefile 225 + utils/Makefile]) 226 AC_CONFIG_HEADERS([config.h]) 227 AC_OUTPUT -
deleted file files/patch-lib_dpkg.h
diff --git a/files/patch-lib_dpkg.h b/files/patch-lib_dpkg.h deleted file mode 100644 index f683a0c..0000000
+ - 1 --- ./lib/dpkg.h.orig 2010-03-08 21:27:35.000000000 +01002 +++ ./lib/dpkg.h 2011-04-07 09:51:21.000000000 +02003 @@ -147,7 +147,7 @@4 #define DPKG "dpkg"5 #define DEBSIGVERIFY "/usr/bin/debsig-verify"6 7 -#define TAR "tar"8 +#define TAR "gnutar"9 #define GZIP "gzip"10 #define BZIP2 "bzip2"11 #define LZMA "lzma" -
new file files/patch-lib_dpkg_dpkg.h.diff
diff --git a/files/patch-lib_dpkg_dpkg.h.diff b/files/patch-lib_dpkg_dpkg.h.diff new file mode 100644 index 0000000..b1d3d92
- + 1 --- lib/dpkg/dpkg.h.orig 2013-03-08 11:45:46.000000000 -0500 2 +++ lib/dpkg/dpkg.h 2013-05-16 14:32:09.000000000 -0400 3 @@ -108,7 +108,7 @@ 4 #define DPKG "dpkg" 5 #define DEBSIGVERIFY "/usr/bin/debsig-verify" 6 7 -#define TAR "tar" 8 +#define TAR "gnutar" 9 #define RM "rm" 10 #define CAT "cat" 11 #define FIND "find" -
new file files/patch-lib_dpkg_tarfn.c.diff
diff --git a/files/patch-lib_dpkg_tarfn.c.diff b/files/patch-lib_dpkg_tarfn.c.diff new file mode 100644 index 0000000..a2e13c6
- + 1 --- lib/dpkg/tarfn.c.orig 2013-05-16 14:40:14.000000000 -0400 2 +++ lib/dpkg/tarfn.c 2013-05-16 14:40:36.000000000 -0400 3 @@ -40,6 +40,9 @@ 4 #define TAR_MAGIC_USTAR "ustar\0" "00" 5 #define TAR_MAGIC_GNU "ustar " " \0" 6 7 +static const char ustarMagic[] = { 'u', 's', 't', 'a', 'r', '\0', '0', '0', '\0' }; 8 +static const char gnutarMagic[] = { 'u', 's', 't', 'a', 'r', ' ', ' ', '\0' }; 9 + 10 struct tar_header { 11 char name[100]; 12 char mode[8]; 13 @@ -51,6 +54,7 @@ 14 char linkflag; 15 char linkname[100]; 16 char magic[8]; 17 + char MagicNumber[8]; /* POSIX: "ustar\000", GNU: "ustar \0" (blank blank null) */ 18 char user[32]; 19 char group[32]; 20 char devmajor[8]; 21 @@ -58,6 +62,7 @@ 22 23 /* Only valid on ustar. */ 24 char prefix[155]; 25 + char Prefix[155]; /* POSIX ustar header */ 26 }; 27 28 /** -
deleted file files/patch-lib_tarfn.c
diff --git a/files/patch-lib_tarfn.c b/files/patch-lib_tarfn.c deleted file mode 100644 index 1365bb8..0000000
+ - 1 --- lib/tarfn.c.orig Wed Jan 26 18:31:15 20052 +++ lib/tarfn.c Wed Jan 26 19:26:19 20053 @@ -18,6 +18,9 @@4 5 #include "strnlen.h"6 7 +static const char ustarMagic[] = { 'u', 's', 't', 'a', 'r', '\0', '0', '0', '\0' };8 +static const char gnutarMagic[] = { 'u', 's', 't', 'a', 'r', ' ', ' ', '\0' };9 +10 struct TarHeader {11 char Name[100];12 char Mode[8];13 @@ -28,11 +31,12 @@14 char Checksum[8];15 char LinkFlag;16 char LinkName[100];17 - char MagicNumber[8];18 + char MagicNumber[8]; /* POSIX: "ustar\000", GNU: "ustar \0" (blank blank null) */19 char UserName[32];20 char GroupName[32];21 char MajorDevice[8];22 char MinorDevice[8];23 + char Prefix[155]; /* POSIX ustar header */24 };25 typedef struct TarHeader TarHeader;26 27 @@ -78,6 +82,10 @@28 struct passwd * passwd = NULL;29 struct group * group = NULL;30 unsigned int i;31 + char *prefix, *name, *file;32 + size_t prefixLen;33 + size_t nameLen;34 + size_t fileLen;35 long sum;36 long checksum;37 38 @@ -86,7 +94,35 @@39 if ( *h->GroupName )40 group = getgrnam(h->GroupName);41 42 - d->Name = StoC(h->Name, sizeof(h->Name));43 + /*44 + * Is this a ustar archive entry?45 + * Is Prefix in use?46 + */47 + if ((memcmp(h->MagicNumber, ustarMagic, sizeof(h->MagicNumber)) == 0) && h->Prefix[0]) {48 + prefixLen = strnlen(h->Prefix, sizeof(h->Prefix));49 +50 + prefix = StoC(h->Prefix, prefixLen);51 + if (h->Prefix[prefixLen - 1] != '/') {52 + prefixLen++; /* Space for '/' */53 + /* The rest of the code doesn't care if malloc fails, so we won't either */54 + prefix = realloc(prefix, prefixLen + 1); /* prefix + \0 */55 + prefix[prefixLen - 1] = '/';56 + prefix[prefixLen] = '\0';57 + }58 +59 + nameLen = strnlen(h->Name, sizeof(h->Name));60 + name = StoC(h->Name, nameLen);61 +62 + file = realloc(prefix, prefixLen + nameLen + 1); /* prefix + name + \0 */63 + strcat(file, name);64 +65 + free(name);66 +67 + d->Name = file;68 + } else {69 + d->Name = StoC(h->Name, sizeof(h->Name));70 + }71 +72 d->LinkName = StoC(h->LinkName, sizeof(h->LinkName));73 d->Mode = (mode_t)OtoL(h->Mode, sizeof(h->Mode));74 d->Size = (size_t)OtoL(h->Size, sizeof(h->Size)); -
deleted file files/patch-main_archives.c
diff --git a/files/patch-main_archives.c b/files/patch-main_archives.c deleted file mode 100644 index 35dbe56..0000000
+ - 1 --- src/archives.c.orig Thu Nov 11 20:10:03 20042 +++ src/archives.c Fri Dec 17 17:34:55 20043 @@ -373,6 +373,7 @@4 static struct varbuf conffderefn, hardlinkfn, symlinkfn;5 static int fd;6 const char *usename;7 + char *s = NULL;8 9 struct conffile *conff;10 struct tarcontext *tc= (struct tarcontext*)ti->UserData;11 @@ -423,7 +424,15 @@12 }13 }14 15 - usename= namenodetouse(nifd->namenode,tc->pkg)->name + 1; /* Skip the leading `/' */16 + usename= namenodetouse(nifd->namenode,tc->pkg)->name; /* Skip the leading `/' */17 + if (*usename == '.' && *usename + 1 == '/') {18 + usename += 1; /* Skip the leading `.' */19 + } else if (*usename != '/') {20 + s = malloc(strlen(usename) + 2); /* 1 for NULL, one for `/' we're going to add */21 + strcpy(s + 1, usename);22 + *s = '/';23 + usename = s;24 + }25 26 if (nifd->namenode->flags & fnnf_new_conff) {27 /* If it's a conffile we have to extract it next to the installed28 @@ -435,6 +444,10 @@29 }30 31 setupfnamevbs(usename);32 +33 + if (s != NULL) {34 + free(s);35 + }36 37 statr= lstat(fnamevb.buf,&stab);38 if (statr) { -
deleted file files/patch-main_remove.c
diff --git a/files/patch-main_remove.c b/files/patch-main_remove.c deleted file mode 100644 index d9fe787..0000000
+ - 1 --- src/remove.c.orig Fri Dec 10 15:48:16 20042 +++ src/remove.c Fri Dec 10 15:51:29 20043 @@ -266,7 +266,18 @@4 push_leftover(&leftover,namenode);5 continue;6 }7 - if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);8 + if (errno != ENOTDIR) {9 + /* XXX Hack:10 + * dpkg includes /. in the packing list.11 + * rmdir("/.") will return EINVAL. dpkg will12 + * only attempt to remove /. when uninstalling13 + * the last package on the system, which is why14 + * Debian has never run into this issue. */15 + if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0)16 + continue;17 + else18 + ohshite(_("cannot remove `%.250s'"),fnvb.buf);19 + }20 debug(dbg_eachfiledetail, "removal_bulk unlinking `%s'", fnvb.buf);21 {22 /*23 @@ -383,7 +394,18 @@24 push_leftover(&leftover,namenode);25 continue;26 }27 - if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);28 + if (errno != ENOTDIR) {29 + /* XXX Hack:30 + * dpkg includes /. in the packing list.31 + * rmdir("/.") will return EINVAL. dpkg will32 + * only attempt to remove /. when uninstalling33 + * the last package on the system, which is why34 + * Debian has never run into this issue. */35 + if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0)36 + continue;37 + else38 + ohshite(_("cannot remove `%.250s'"),fnvb.buf);39 + }40 41 push_leftover(&leftover,namenode);42 continue; -
deleted file files/patch-scripts-Makefile
diff --git a/files/patch-scripts-Makefile b/files/patch-scripts-Makefile deleted file mode 100644 index 823c12a..0000000
+ - 1 --- scripts/Makefile.am.orig 2010-03-08 21:27:35.000000000 +01002 +++ scripts/Makefile.am 2011-01-03 10:15:37.000000000 +01003 @@ -123,7 +123,7 @@ nobase_dist_perllib_DATA = \4 Dpkg/Source/Patch.pm \5 Dpkg.pm6 7 -do_perl_subst = sed -e "s:^\#![:space:]*/usr/bin/perl:\#!$(PERL):" \8 +do_perl_subst = sed -e "s:^\#![[:space:]]*/usr/bin/perl:\#!$(PERL):" \9 -e "s:\$$dpkglibdir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$dpkglibdir=\"$(pkglibdir)\":" \10 -e "s:\$$pkgdatadir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$pkgdatadir=\"$(pkgdatadir)\":" \11 -e "s:\$$admindir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$admindir=\"$(admindir)\":" \12 --- scripts/Makefile.in.orig 2010-03-08 21:32:20.000000000 +010013 +++ scripts/Makefile.in 2011-01-03 10:15:50.000000000 +010014 @@ -330,7 +330,7 @@ nobase_dist_perllib_DATA = \15 Dpkg/Source/Patch.pm \16 Dpkg.pm17 18 -do_perl_subst = sed -e "s:^\#![:space:]*/usr/bin/perl:\#!$(PERL):" \19 +do_perl_subst = sed -e "s:^\#![[:space:]]*/usr/bin/perl:\#!$(PERL):" \20 -e "s:\$$dpkglibdir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$dpkglibdir=\"$(pkglibdir)\":" \21 -e "s:\$$pkgdatadir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$pkgdatadir=\"$(pkgdatadir)\":" \22 -e "s:\$$admindir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$admindir=\"$(admindir)\":" \ -
new file files/patch-scripts_Dpkg_Source_Archive.pm.diff
diff --git a/files/patch-scripts_Dpkg_Source_Archive.pm.diff b/files/patch-scripts_Dpkg_Source_Archive.pm.diff new file mode 100644 index 0000000..6fb2555
- + 1 --- scripts/Dpkg/Source/Archive.pm.orig 2013-09-30 18:47:57.000000000 +0400 2 +++ scripts/Dpkg/Source/Archive.pm 2014-03-27 19:59:35.000000000 +0400 3 @@ -47,7 +47,7 @@ 4 $spawn_opts{"from_pipe"} = \*$self->{'tar_input'}; 5 # Call tar creation process 6 $spawn_opts{"delete_env"} = [ "TAR_OPTIONS" ]; 7 - $spawn_opts{'exec'} = [ 'tar', '--null', '-T', '-', '--numeric-owner', 8 + $spawn_opts{'exec'} = [ 'gnutar', '--null', '-T', '-', '--numeric-owner', 9 '--owner', '0', '--group', '0', 10 @{$opts{"options"}}, '-cf', '-' ]; 11 *$self->{"pid"} = spawn(%spawn_opts); 12 @@ -122,7 +122,7 @@ 13 14 # Call tar extraction process 15 $spawn_opts{"delete_env"} = [ "TAR_OPTIONS" ]; 16 - $spawn_opts{'exec'} = [ 'tar', '--no-same-owner', '--no-same-permissions', 17 + $spawn_opts{'exec'} = [ 'gnutar', '--no-same-owner', '--no-same-permissions', 18 @{$opts{"options"}}, '-xf', '-' ]; 19 spawn(%spawn_opts); 20 $self->close(); -
new file files/patch-src_archives.c.diff
diff --git a/files/patch-src_archives.c.diff b/files/patch-src_archives.c.diff new file mode 100644 index 0000000..93e7551
- + 1 --- src/archives.c.orig 2013-05-16 14:55:40.000000000 -0400 2 +++ src/archives.c 2013-05-16 14:56:55.000000000 -0400 3 @@ -712,6 +712,7 @@ 4 { 5 static struct varbuf conffderefn, symlinkfn; 6 const char *usename; 7 + char *s = NULL; 8 struct filenamenode *usenode; 9 10 struct conffile *conff; 11 @@ -771,7 +772,15 @@ 12 st = &ti->stat; 13 14 usenode = namenodetouse(nifd->namenode, tc->pkg, &tc->pkg->available); 15 - usename = usenode->name + 1; /* Skip the leading '/'. */ 16 + usename = usenode->name; /* Skip the leading '/' */ 17 + if (*usename == '.' && *usename + 1 == '/') { 18 + usename += 1; /* Skip the leading `.' */ 19 + } else if (*usename != '/') { 20 + s = malloc(strlen(usename) + 2); /* 1 for NULL, one for `/' we're going to add */ 21 + strcpy(s + 1, usename); 22 + *s = '/'; 23 + usename = s; 24 + } 25 26 trig_file_activate(usenode, tc->pkg); 27 28 @@ -784,6 +793,10 @@ 29 } 30 31 setupfnamevbs(usename); 32 + 33 + if (s != NULL) { 34 + free(s); 35 + } 36 37 statr= lstat(fnamevb.buf,&stab); 38 if (statr) { -
new file files/patch-src_remove.c.diff
diff --git a/files/patch-src_remove.c.diff b/files/patch-src_remove.c.diff new file mode 100644 index 0000000..b13d2a3
- + 1 --- src/remove.c.orig 2012-12-21 13:49:40.000000000 -0500 2 +++ src/remove.c 2013-05-16 14:49:50.000000000 -0400 3 @@ -334,7 +334,18 @@ 4 push_leftover(&leftover, namenode); 5 continue; 6 } 7 - if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf); 8 + if (errno != ENOTDIR) { 9 + /* XXX Hack: 10 + * dpkg includes /. in the packing list. 11 + * rmdir("/.") will return EINVAL. dpkg will 12 + * only attempt to remove /. when uninstalling 13 + * the last package on the system, which is why 14 + * Debian has never run into this issue. */ 15 + if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0) 16 + continue; 17 + else 18 + ohshite(_("cannot remove `%.250s'"),fnvb.buf); 19 + } 20 debug(dbg_eachfiledetail, "removal_bulk unlinking '%s'", fnvb.buf); 21 if (secure_unlink(fnvb.buf)) 22 ohshite(_("unable to securely remove '%.250s'"), fnvb.buf); 23 @@ -425,7 +436,18 @@ 24 push_leftover(&leftover, namenode); 25 continue; 26 } 27 - if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf); 28 + if (errno != ENOTDIR) { 29 + /* XXX Hack: 30 + * dpkg includes /. in the packing list. 31 + * rmdir("/.") will return EINVAL. dpkg will 32 + * only attempt to remove /. when uninstalling 33 + * the last package on the system, which is why 34 + * Debian has never run into this issue. */ 35 + if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0) 36 + continue; 37 + else 38 + ohshite(_("cannot remove `%.250s'"),fnvb.buf); 39 + } 40 41 if (lstat(fnvb.buf, &stab) == 0 && S_ISLNK(stab.st_mode)) { 42 debug(dbg_eachfiledetail, "removal_bulk is a symlink to a directory"); -
deleted file files/patch-utils_start-stop-daemon.c
diff --git a/files/patch-utils_start-stop-daemon.c b/files/patch-utils_start-stop-daemon.c deleted file mode 100644 index 608cb53..0000000
+ - 1 --- utils/start-stop-daemon.c.orig Thu Nov 11 12:10:04 20042 +++ utils/start-stop-daemon.c Mon Dec 13 16:02:18 20043 @@ -38,6 +38,8 @@4 # define OSFreeBSD5 #elif defined(__NetBSD__)6 # define OSNetBSD7 +#elif defined(__APPLE__)8 +# define OSDarwin9 #else10 # error Unknown architecture - cannot build start-stop-daemon11 #endif12 @@ -49,7 +51,8 @@13 #include <ps.h>14 #endif15 16 -#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD)17 +#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin)18 +#include <sys/time.h>19 #include <sys/param.h>20 #include <sys/proc.h>21 #include <sys/stat.h>22 @@ -804,7 +807,7 @@23 #if defined(OSLinux) || defined(OShpux)24 if (execname && !pid_is_exec(pid, &exec_stat))25 return;26 -#elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD)27 +#elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin)28 /* Let's try this to see if it works */29 if (execname && !pid_is_cmd(pid, execname))30 return;31 @@ -882,6 +882,7 @@32 }33 #endif /* OSHURD */34 35 +#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD)36 #ifdef HAVE_KVM_H37 static int38 pid_is_cmd(pid_t pid, const char *name)39 @@ -974,6 +975,7 @@40 {41 /* Nothing to do */42 }43 +#endif44 #endif /* OSOpenBSD */45 46 #if defined(OShpux)47 @@ -975,6 +954,80 @@48 /* Nothing to do */49 }50 #endif /* OSOpenBSD */51 +52 +#if defined(OSDarwin)53 +#include <sys/sysctl.h>54 +int55 +pid_is_user(pid_t pid, uid_t uid)56 +{57 + int mib[4];58 + size_t size;59 + struct kinfo_proc ki;60 +61 + size = sizeof(ki);62 + mib[0] = CTL_KERN;63 + mib[1] = KERN_PROC;64 + mib[2] = KERN_PROC_PID;65 + mib[3] = pid;66 + if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0)67 + errx(1, "%s", "Failure calling sysctl");68 + return (uid == ki.kp_eproc.e_pcred.p_ruid);69 +}70 +71 +static int72 +pid_is_cmd(pid_t pid, const char *name)73 +{74 + int mib[4];75 + size_t size;76 + struct kinfo_proc ki;77 +78 + size = sizeof(ki);79 + mib[0] = CTL_KERN;80 + mib[1] = KERN_PROC;81 + mib[2] = KERN_PROC_PID;82 + mib[3] = pid;83 + if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0)84 + errx(1, "%s", "Failure calling sysctl");85 + return (!strncmp(name, ki.kp_proc.p_comm, MAXCOMLEN));86 +}87 +88 +static void89 +do_procinit(void)90 +{91 + int mib[3];92 + size_t size;93 + int nprocs, ret, i;94 + struct kinfo_proc *procs = NULL, *newprocs;95 +96 + mib[0] = CTL_KERN;97 + mib[1] = KERN_PROC;98 + mib[2] = KERN_PROC_ALL;99 + ret = sysctl(mib, 3, NULL, &size, NULL, 0);100 + /* Allocate enough memory for entire process table */101 + do {102 + size += size / 10;103 + newprocs = realloc(procs, size);104 + if (newprocs == NULL) {105 + if (procs)106 + free(procs);107 + errx(1, "%s", "Could not reallocate memory");108 + }109 + procs = newprocs;110 + ret = sysctl(mib, 3, procs, &size, NULL, 0);111 + } while (ret >= 0 && errno == ENOMEM);112 +113 + if (ret < 0)114 + errx(1, "%s", "Failure calling sysctl");115 +116 + /* Verify size of proc structure */117 + if (size % sizeof(struct kinfo_proc) != 0)118 + errx(1, "%s", "proc size mismatch, userland out of sync with kernel");119 + nprocs = size / sizeof(struct kinfo_proc);120 + for (i = 0; i < nprocs; i++) {121 + check(procs[i].kp_proc.p_pid);122 + }123 +}124 +#endif /* OSDarwin */125 126 #if defined(OShpux)127 static int -
new file files/patch-utils_start-stop-daemon.c.diff
diff --git a/files/patch-utils_start-stop-daemon.c.diff b/files/patch-utils_start-stop-daemon.c.diff new file mode 100644 index 0000000..2c2e62b
- + 1 --- utils/start-stop-daemon.c.orig 2013-05-16 15:05:34.000000000 -0400 2 +++ utils/start-stop-daemon.c 2013-05-16 15:08:45.000000000 -0400 3 @@ -39,6 +39,8 @@ 4 # define OSFreeBSD 5 #elif defined(__NetBSD__) 6 # define OSNetBSD 7 +#elif defined(__APPLE__) 8 +# define OSDarwin 9 #else 10 # error Unknown architecture - cannot build start-stop-daemon 11 #endif 12 @@ -54,7 +56,8 @@ 13 #include <ps.h> 14 #endif 15 16 -#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) 17 +#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin) 18 +#include <sys/time.h> 19 #include <sys/param.h> 20 #include <sys/proc.h> 21 22 @@ -1810,3 +1813,78 @@ 23 execv(startas, argv); 24 fatal("unable to start %s", startas); 25 } 26 + 27 + 28 +#if defined(OSDarwin) 29 +#include <sys/sysctl.h> 30 +int 31 +pid_is_user(pid_t pid, uid_t uid) 32 +{ 33 + int mib[4]; 34 + size_t size; 35 + struct kinfo_proc ki; 36 + 37 + size = sizeof(ki); 38 + mib[0] = CTL_KERN; 39 + mib[1] = KERN_PROC; 40 + mib[2] = KERN_PROC_PID; 41 + mib[3] = pid; 42 + if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0) 43 + errx(1, "%s", "Failure calling sysctl"); 44 + return (uid == ki.kp_eproc.e_pcred.p_ruid); 45 +} 46 + 47 +static int 48 +pid_is_cmd(pid_t pid, const char *name) 49 +{ 50 + int mib[4]; 51 + size_t size; 52 + struct kinfo_proc ki; 53 + 54 + size = sizeof(ki); 55 + mib[0] = CTL_KERN; 56 + mib[1] = KERN_PROC; 57 + mib[2] = KERN_PROC_PID; 58 + mib[3] = pid; 59 + if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0) 60 + errx(1, "%s", "Failure calling sysctl"); 61 + return (!strncmp(name, ki.kp_proc.p_comm, MAXCOMLEN)); 62 +} 63 + 64 +static void 65 +do_procinit(void) 66 +{ 67 + int mib[3]; 68 + size_t size; 69 + int nprocs, ret, i; 70 + struct kinfo_proc *procs = NULL, *newprocs; 71 + 72 + mib[0] = CTL_KERN; 73 + mib[1] = KERN_PROC; 74 + mib[2] = KERN_PROC_ALL; 75 + ret = sysctl(mib, 3, NULL, &size, NULL, 0); 76 + /* Allocate enough memory for entire process table */ 77 + do { 78 + size += size / 10; 79 + newprocs = realloc(procs, size); 80 + if (newprocs == NULL) { 81 + if (procs) 82 + free(procs); 83 + errx(1, "%s", "Could not reallocate memory"); 84 + } 85 + procs = newprocs; 86 + ret = sysctl(mib, 3, procs, &size, NULL, 0); 87 + } while (ret >= 0 && errno == ENOMEM); 88 + 89 + if (ret < 0) 90 + errx(1, "%s", "Failure calling sysctl"); 91 + 92 + /* Verify size of proc structure */ 93 + if (size % sizeof(struct kinfo_proc) != 0) 94 + errx(1, "%s", "proc size mismatch, userland out of sync with kernel"); 95 + nprocs = size / sizeof(struct kinfo_proc); 96 + for (i = 0; i < nprocs; i++) { 97 + check(procs[i].kp_proc.p_pid); 98 + } 99 +} 100 +#endif /* OSDarwin */