[142883] trunk/dports/sysutils/dpkg
mojca at macports.org
mojca at macports.org
Sat Dec 12 07:38:25 PST 2015
Revision: 142883
https://trac.macports.org/changeset/142883
Author: mojca at macports.org
Date: 2015-11-25 15:13:17 -0800 (Wed, 25 Nov 2015)
Log Message:
-----------
dpgk: upgrade to 1.18.3 with a major rewrite ([new] maintainers, closes #39018)
Modified Paths:
--------------
trunk/dports/sysutils/dpkg/Portfile
Added Paths:
-----------
trunk/dports/sysutils/dpkg/files/patch-scripts_Dpkg_Source_Archive.pm.diff
Removed Paths:
-------------
trunk/dports/sysutils/dpkg/files/bsd/
trunk/dports/sysutils/dpkg/files/ncurses.diff
trunk/dports/sysutils/dpkg/files/patch-lib_dpkg.h
trunk/dports/sysutils/dpkg/files/patch-lib_tarfn.c
trunk/dports/sysutils/dpkg/files/patch-main_archives.c
trunk/dports/sysutils/dpkg/files/patch-main_remove.c
trunk/dports/sysutils/dpkg/files/patch-scripts-Makefile
trunk/dports/sysutils/dpkg/files/patch-utils_start-stop-daemon.c
Modified: trunk/dports/sysutils/dpkg/Portfile
===================================================================
--- trunk/dports/sysutils/dpkg/Portfile 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/Portfile 2015-11-25 23:13:17 UTC (rev 142883)
@@ -2,71 +2,85 @@
# $Id$
PortSystem 1.0
+PortGroup perl5 1.0
name dpkg
-version 1.14.29
-revision 4
-platforms darwin freebsd
+version 1.18.3
+platforms darwin
categories sysutils archivers
license GPL-2+
-maintainers nomaintainer
+maintainers gwmail.gwu.edu:egall gmail.com:xeron.oskom openmaintainer
description Debian package maintenance system
-long_description ${description}
+long_description ${name} is the basis of the ${description}.
+
homepage http://wiki.debian.org/Teams/Dpkg
+master_sites debian:d/${name}/
+distname ${name}_${version}
+worksrcdir ${name}-${version}
-master_sites debian:d/dpkg/
+use_xz yes
+extract.asroot yes
-checksums md5 4326172a959b5b6484b4bc126e9f628d \
- sha1 15a35dd96dac6a99f24844b2eff85f8fad37ab06
+checksums rmd160 baffcdf3bb72ad535d6aacbcee88202488e4612a \
+ sha256 a40ffe38d7f36d858a752189a306433cfc52c7d15d7b98f61d9f9dd49e0e4807
+perl5.branches 5.22
+
+depends_build-append \
+ port:pkgconfig \
+ port:flex
+
# Use MacPorts versions explicitly
-depends_lib port:gettext \
+depends_lib-append port:bzip2 \
+ port:coreutils \
+ port:gettext \
+ port:gnutar \
+ port:gzip \
port:libiconv \
- port:perl5 \
- port:coreutils \
- port:bzip2 \
+ port:ncurses \
+ port:perl${perl5.major} \
+ port:xz \
port:zlib
-depends_run bin:gnutar:gnutar \
- bin:lzma:xz
+depends_run-append port:debianutils
-distname ${name}_${version}
-worksrcdir ${name}-${version}
-
-patchfiles patch-lib_tarfn.c \
- patch-main_remove.c \
- patch-main_archives.c \
- patch-scripts-Makefile \
- patch-lib_dpkg.h \
- ncurses.diff
-
-configure.env PERL=${prefix}/bin/perl5
-configure.args --with-libintl-prefix=${prefix} \
+configure.perl ${perl5.bin}
+configure.pkg_config \
+ ${prefix}/bin/pkg-config
+configure.env-append \
+ TAR=${prefix}/bin/gnutar
+configure.args-append \
+ --with-libintl-prefix=${prefix} \
--with-libiconv-prefix=${prefix} \
- --with-admindir=${prefix}/var/db/dpkg \
+ --with-admindir=${prefix}/var/db/${name} \
+ --with-logdir=${prefix}/var/log \
--mandir=${prefix}/share/man \
+ --with-zlib \
--with-bz2 \
- --with-zlib \
- --without-sgml-doc \
- --disable-linker-optimisations
+ --with-liblzma \
+ --disable-linker-optimisations \
+ --disable-silent-rules \
+ --disable-start-stop-daemon
+compiler.blacklist-append cc gcc-3.3 gcc-4.0 apple-gcc-4.0
+
build.type gnu
-set vardpkg ${destroot}${prefix}/var/db/dpkg
-destroot.keepdirs ${vardpkg} ${vardpkg}/updates ${vardpkg}/info
+set vardpkg ${destroot}${prefix}/var/db/${name}
+destroot.keepdirs-append \
+ ${vardpkg} \
+ ${vardpkg}/updates \
+ ${vardpkg}/info \
+ ${destroot}${prefix}/var/log \
+ ${destroot}${prefix}/etc/${name}
-post-patch {
- set scripts ${worksrcpath}/scripts
- reinplace s|/etc/dpkg/|${prefix}/etc/dpkg/| \
- ${scripts}/dpkg-shlibdeps.pl \
- ${scripts}/dpkg-source.pl
+patchfiles-append patch-scripts_Dpkg_Source_Archive.pm.diff
- reinplace s|/etc/alternatives|${prefix}/etc/alternatives|g \
- ${scripts}/update-alternatives.pl
-}
+use_autoreconf yes
+autoreconf.args -fvi --warnings=all
pre-destroot {
- file mkdir ${destroot}${prefix}/share/doc/dpkg
+ file mkdir ${destroot}${prefix}/share/doc/${name}
}
post-destroot {
@@ -76,18 +90,51 @@
system "touch ${vardpkg}/available ${vardpkg}/status"
}
-platform darwin {
- depends_build-append bin:gnumake:gmake
- patchfiles-append patch-utils_start-stop-daemon.c \
- bsd/patch-main_help.c
-}
+# This variant sometimes hangs while building...
+variant docs description "Build documentation (warning: building documentation takes a long time)" {
+ depends_build-append port:doxygen \
+ path:bin/dot:graphviz \
+ port:fontconfig \
+ port:freefont-ttf
-platform freebsd {
- depends_build-append bin:gmake:gmake
- patchfiles-append patch-utils_start-stop-daemon.c \
- bsd/patch-main_help.c
+ set docdir ${prefix}/share/doc/${name}
+ configure.args-append --docdir=${docdir} \
+ --htmldir=${docdir}/html \
+ --dvidir=${docdir}/dvi \
+ --pdfdir=${docdir}/pdf \
+ --psdir=${docdir}/ps
+
+ build.target-append doc
+
+ pre-build {
+ elevateToRoot "doxygen"
+ system -W ${worksrcpath}/doc "${prefix}/bin/doxygen -u"
+ }
+
+ post-build {
+ system -W ${worksrcpath}/doc "${prefix}/bin/doxygen"
+ dropPrivileges
+ set destroot_docdir ${destroot}${prefix}/share/doc/${name}
+ xinstall -d ${destroot_docdir}
+ copy ${worksrcpath}/doc/doc ${destroot_docdir}
+ copy ${worksrcpath}/doc/html ${destroot_docdir}
+ foreach docfile {coding-style.txt triggers.txt README.feature-removal-schedule frontend.txt README.api} {
+ xinstall -m 644 ${worksrcpath}/doc/${docfile} ${destroot_docdir}
+ }
+ }
}
+# Tests currently fail, this needs to be fixed eventually:
+test.run yes
+test.target check
+
+#pre-test {
+# elevateToRoot "test"
+#}
+#post-test {
+# dropPrivileges
+#}
+
livecheck.type regex
-livecheck.url http://ftp.debian.org/debian/pool/main/d/dpkg/
+livecheck.url http://ftp.debian.org/debian/pool/main/d/${name}/
livecheck.regex "${name}_(\\d+\\.\\d+(\\.\\d+)*)"
Deleted: trunk/dports/sysutils/dpkg/files/ncurses.diff
===================================================================
--- trunk/dports/sysutils/dpkg/files/ncurses.diff 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/files/ncurses.diff 2015-11-25 23:13:17 UTC (rev 142883)
@@ -1,33 +0,0 @@
---- dselect/Makefile.in.orig 2010-03-09 07:32:20.000000000 +1100
-+++ dselect/Makefile.in 2011-03-11 12:01:25.000000000 +1100
-@@ -640,7 +640,7 @@
-
- curkeys.$(OBJEXT): curkeys.h
- curkeys.h: $(srcdir)/keyoverride $(srcdir)/mkcurkeys.pl
-- cursesfile=`echo '#include <ncursesw/curses.h>' | \
-+ cursesfile=`echo '#include <curses.h>' | \
- $(CC) -E - | grep 'curses.h' | head -n 1 | \
- sed -e 's/^[^"]*"//; s/".*$$//'`; \
- if [ "$$cursesfile" = "" ]; then \
---- dselect/dselect.h.orig 2010-03-09 07:27:35.000000000 +1100
-+++ dselect/dselect.h 2011-03-11 12:01:43.000000000 +1100
-@@ -28,7 +28,7 @@
-
- #include <signal.h>
- #undef ERR
--#include <ncursesw/curses.h>
-+#include <curses.h>
-
- struct helpmenuentry {
- char key;
---- dselect/main.cc.orig 2010-03-09 07:27:35.000000000 +1100
-+++ dselect/main.cc 2011-03-11 12:01:36.000000000 +1100
-@@ -37,7 +37,7 @@ extern "C" {
- #include <ctype.h>
- #include <assert.h>
-
--#include <ncursesw/term.h>
-+#include <term.h>
-
- extern "C" {
- #include <dpkg.h>
Deleted: trunk/dports/sysutils/dpkg/files/patch-lib_dpkg.h
===================================================================
--- trunk/dports/sysutils/dpkg/files/patch-lib_dpkg.h 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/files/patch-lib_dpkg.h 2015-11-25 23:13:17 UTC (rev 142883)
@@ -1,11 +0,0 @@
---- ./lib/dpkg.h.orig 2010-03-08 21:27:35.000000000 +0100
-+++ ./lib/dpkg.h 2011-04-07 09:51:21.000000000 +0200
-@@ -147,7 +147,7 @@
- #define DPKG "dpkg"
- #define DEBSIGVERIFY "/usr/bin/debsig-verify"
-
--#define TAR "tar"
-+#define TAR "gnutar"
- #define GZIP "gzip"
- #define BZIP2 "bzip2"
- #define LZMA "lzma"
Deleted: trunk/dports/sysutils/dpkg/files/patch-lib_tarfn.c
===================================================================
--- trunk/dports/sysutils/dpkg/files/patch-lib_tarfn.c 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/files/patch-lib_tarfn.c 2015-11-25 23:13:17 UTC (rev 142883)
@@ -1,74 +0,0 @@
---- lib/tarfn.c.orig Wed Jan 26 18:31:15 2005
-+++ lib/tarfn.c Wed Jan 26 19:26:19 2005
-@@ -18,6 +18,9 @@
-
- #include "strnlen.h"
-
-+static const char ustarMagic[] = { 'u', 's', 't', 'a', 'r', '\0', '0', '0', '\0' };
-+static const char gnutarMagic[] = { 'u', 's', 't', 'a', 'r', ' ', ' ', '\0' };
-+
- struct TarHeader {
- char Name[100];
- char Mode[8];
-@@ -28,11 +31,12 @@
- char Checksum[8];
- char LinkFlag;
- char LinkName[100];
-- char MagicNumber[8];
-+ char MagicNumber[8]; /* POSIX: "ustar\000", GNU: "ustar \0" (blank blank null) */
- char UserName[32];
- char GroupName[32];
- char MajorDevice[8];
- char MinorDevice[8];
-+ char Prefix[155]; /* POSIX ustar header */
- };
- typedef struct TarHeader TarHeader;
-
-@@ -78,6 +82,10 @@
- struct passwd * passwd = NULL;
- struct group * group = NULL;
- unsigned int i;
-+ char *prefix, *name, *file;
-+ size_t prefixLen;
-+ size_t nameLen;
-+ size_t fileLen;
- long sum;
- long checksum;
-
-@@ -86,7 +94,35 @@
- if ( *h->GroupName )
- group = getgrnam(h->GroupName);
-
-- d->Name = StoC(h->Name, sizeof(h->Name));
-+ /*
-+ * Is this a ustar archive entry?
-+ * Is Prefix in use?
-+ */
-+ if ((memcmp(h->MagicNumber, ustarMagic, sizeof(h->MagicNumber)) == 0) && h->Prefix[0]) {
-+ prefixLen = strnlen(h->Prefix, sizeof(h->Prefix));
-+
-+ prefix = StoC(h->Prefix, prefixLen);
-+ if (h->Prefix[prefixLen - 1] != '/') {
-+ prefixLen++; /* Space for '/' */
-+ /* The rest of the code doesn't care if malloc fails, so we won't either */
-+ prefix = realloc(prefix, prefixLen + 1); /* prefix + \0 */
-+ prefix[prefixLen - 1] = '/';
-+ prefix[prefixLen] = '\0';
-+ }
-+
-+ nameLen = strnlen(h->Name, sizeof(h->Name));
-+ name = StoC(h->Name, nameLen);
-+
-+ file = realloc(prefix, prefixLen + nameLen + 1); /* prefix + name + \0 */
-+ strcat(file, name);
-+
-+ free(name);
-+
-+ d->Name = file;
-+ } else {
-+ d->Name = StoC(h->Name, sizeof(h->Name));
-+ }
-+
- d->LinkName = StoC(h->LinkName, sizeof(h->LinkName));
- d->Mode = (mode_t)OtoL(h->Mode, sizeof(h->Mode));
- d->Size = (size_t)OtoL(h->Size, sizeof(h->Size));
Deleted: trunk/dports/sysutils/dpkg/files/patch-main_archives.c
===================================================================
--- trunk/dports/sysutils/dpkg/files/patch-main_archives.c 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/files/patch-main_archives.c 2015-11-25 23:13:17 UTC (rev 142883)
@@ -1,38 +0,0 @@
---- src/archives.c.orig Thu Nov 11 20:10:03 2004
-+++ src/archives.c Fri Dec 17 17:34:55 2004
-@@ -373,6 +373,7 @@
- static struct varbuf conffderefn, hardlinkfn, symlinkfn;
- static int fd;
- const char *usename;
-+ char *s = NULL;
-
- struct conffile *conff;
- struct tarcontext *tc= (struct tarcontext*)ti->UserData;
-@@ -423,7 +424,15 @@
- }
- }
-
-- usename= namenodetouse(nifd->namenode,tc->pkg)->name + 1; /* Skip the leading `/' */
-+ usename= namenodetouse(nifd->namenode,tc->pkg)->name; /* Skip the leading `/' */
-+ if (*usename == '.' && *usename + 1 == '/') {
-+ usename += 1; /* Skip the leading `.' */
-+ } else if (*usename != '/') {
-+ s = malloc(strlen(usename) + 2); /* 1 for NULL, one for `/' we're going to add */
-+ strcpy(s + 1, usename);
-+ *s = '/';
-+ usename = s;
-+ }
-
- if (nifd->namenode->flags & fnnf_new_conff) {
- /* If it's a conffile we have to extract it next to the installed
-@@ -435,6 +444,10 @@
- }
-
- setupfnamevbs(usename);
-+
-+ if (s != NULL) {
-+ free(s);
-+ }
-
- statr= lstat(fnamevb.buf,&stab);
- if (statr) {
Deleted: trunk/dports/sysutils/dpkg/files/patch-main_remove.c
===================================================================
--- trunk/dports/sysutils/dpkg/files/patch-main_remove.c 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/files/patch-main_remove.c 2015-11-25 23:13:17 UTC (rev 142883)
@@ -1,42 +0,0 @@
---- src/remove.c.orig Fri Dec 10 15:48:16 2004
-+++ src/remove.c Fri Dec 10 15:51:29 2004
-@@ -266,7 +266,18 @@
- push_leftover(&leftover,namenode);
- continue;
- }
-- if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);
-+ if (errno != ENOTDIR) {
-+ /* XXX Hack:
-+ * dpkg includes /. in the packing list.
-+ * rmdir("/.") will return EINVAL. dpkg will
-+ * only attempt to remove /. when uninstalling
-+ * the last package on the system, which is why
-+ * Debian has never run into this issue. */
-+ if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0)
-+ continue;
-+ else
-+ ohshite(_("cannot remove `%.250s'"),fnvb.buf);
-+ }
- debug(dbg_eachfiledetail, "removal_bulk unlinking `%s'", fnvb.buf);
- {
- /*
-@@ -383,7 +394,18 @@
- push_leftover(&leftover,namenode);
- continue;
- }
-- if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);
-+ if (errno != ENOTDIR) {
-+ /* XXX Hack:
-+ * dpkg includes /. in the packing list.
-+ * rmdir("/.") will return EINVAL. dpkg will
-+ * only attempt to remove /. when uninstalling
-+ * the last package on the system, which is why
-+ * Debian has never run into this issue. */
-+ if (errno == EINVAL && strcmp(fnvb.buf, "/.") == 0)
-+ continue;
-+ else
-+ ohshite(_("cannot remove `%.250s'"),fnvb.buf);
-+ }
-
- push_leftover(&leftover,namenode);
- continue;
Deleted: trunk/dports/sysutils/dpkg/files/patch-scripts-Makefile
===================================================================
--- trunk/dports/sysutils/dpkg/files/patch-scripts-Makefile 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/files/patch-scripts-Makefile 2015-11-25 23:13:17 UTC (rev 142883)
@@ -1,22 +0,0 @@
---- scripts/Makefile.am.orig 2010-03-08 21:27:35.000000000 +0100
-+++ scripts/Makefile.am 2011-01-03 10:15:37.000000000 +0100
-@@ -123,7 +123,7 @@ nobase_dist_perllib_DATA = \
- Dpkg/Source/Patch.pm \
- Dpkg.pm
-
--do_perl_subst = sed -e "s:^\#![:space:]*/usr/bin/perl:\#!$(PERL):" \
-+do_perl_subst = sed -e "s:^\#![[:space:]]*/usr/bin/perl:\#!$(PERL):" \
- -e "s:\$$dpkglibdir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$dpkglibdir=\"$(pkglibdir)\":" \
- -e "s:\$$pkgdatadir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$pkgdatadir=\"$(pkgdatadir)\":" \
- -e "s:\$$admindir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$admindir=\"$(admindir)\":" \
---- scripts/Makefile.in.orig 2010-03-08 21:32:20.000000000 +0100
-+++ scripts/Makefile.in 2011-01-03 10:15:50.000000000 +0100
-@@ -330,7 +330,7 @@ nobase_dist_perllib_DATA = \
- Dpkg/Source/Patch.pm \
- Dpkg.pm
-
--do_perl_subst = sed -e "s:^\#![:space:]*/usr/bin/perl:\#!$(PERL):" \
-+do_perl_subst = sed -e "s:^\#![[:space:]]*/usr/bin/perl:\#!$(PERL):" \
- -e "s:\$$dpkglibdir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$dpkglibdir=\"$(pkglibdir)\":" \
- -e "s:\$$pkgdatadir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$pkgdatadir=\"$(pkgdatadir)\":" \
- -e "s:\$$admindir[[:space:]]*=[[:space:]]*['\"][^'\"]*['\"]:\$$admindir=\"$(admindir)\":" \
Added: trunk/dports/sysutils/dpkg/files/patch-scripts_Dpkg_Source_Archive.pm.diff
===================================================================
--- trunk/dports/sysutils/dpkg/files/patch-scripts_Dpkg_Source_Archive.pm.diff (rev 0)
+++ trunk/dports/sysutils/dpkg/files/patch-scripts_Dpkg_Source_Archive.pm.diff 2015-11-25 23:13:17 UTC (rev 142883)
@@ -0,0 +1,29 @@
+--- scripts/Dpkg/Source/Archive.pm.orig 2015-11-19 21:10:57.000000000 -0800
++++ scripts/Dpkg/Source/Archive.pm 2015-11-19 21:18:41.000000000 -0800
+@@ -48,7 +48,7 @@
+ $spawn_opts{from_pipe} = \*$self->{tar_input};
+ # Call tar creation process
+ $spawn_opts{delete_env} = [ 'TAR_OPTIONS' ];
+- $spawn_opts{exec} = [ 'tar', '-cf', '-', '--format=gnu', '--null',
++ $spawn_opts{exec} = [ 'gnutar', '-cf', '-', '--format=gnu', '--null',
+ '--numeric-owner', '--owner=0', '--group=0',
+ @{$opts{options}}, '-T', '-' ];
+ *$self->{pid} = spawn(%spawn_opts);
+@@ -90,7 +90,7 @@
+ my $self = shift;
+
+ close(*$self->{tar_input}) or syserr(g_('close on tar input'));
+- wait_child(*$self->{pid}, cmdline => 'tar -cf -');
++ wait_child(*$self->{pid}, cmdline => 'gnutar -cf -');
+ delete *$self->{pid};
+ delete *$self->{tar_input};
+ delete *$self->{cwd};
+@@ -126,7 +126,7 @@
+
+ # Call tar extraction process
+ $spawn_opts{delete_env} = [ 'TAR_OPTIONS' ];
+- $spawn_opts{exec} = [ 'tar', '-xf', '-', '--no-same-permissions',
++ $spawn_opts{exec} = [ 'gnutar', '-xf', '-', '--no-same-permissions',
+ '--no-same-owner', @{$opts{options}} ];
+ spawn(%spawn_opts);
+ $self->close();
Deleted: trunk/dports/sysutils/dpkg/files/patch-utils_start-stop-daemon.c
===================================================================
--- trunk/dports/sysutils/dpkg/files/patch-utils_start-stop-daemon.c 2015-11-25 20:55:11 UTC (rev 142882)
+++ trunk/dports/sysutils/dpkg/files/patch-utils_start-stop-daemon.c 2015-11-25 23:13:17 UTC (rev 142883)
@@ -1,127 +0,0 @@
---- utils/start-stop-daemon.c.orig Thu Nov 11 12:10:04 2004
-+++ utils/start-stop-daemon.c Mon Dec 13 16:02:18 2004
-@@ -38,6 +38,8 @@
- # define OSFreeBSD
- #elif defined(__NetBSD__)
- # define OSNetBSD
-+#elif defined(__APPLE__)
-+# define OSDarwin
- #else
- # error Unknown architecture - cannot build start-stop-daemon
- #endif
-@@ -49,7 +51,8 @@
- #include <ps.h>
- #endif
-
--#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD)
-+#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin)
-+#include <sys/time.h>
- #include <sys/param.h>
- #include <sys/proc.h>
- #include <sys/stat.h>
-@@ -804,7 +807,7 @@
- #if defined(OSLinux) || defined(OShpux)
- if (execname && !pid_is_exec(pid, &exec_stat))
- return;
--#elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD)
-+#elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin)
- /* Let's try this to see if it works */
- if (execname && !pid_is_cmd(pid, execname))
- return;
-@@ -882,6 +882,7 @@
- }
- #endif /* OSHURD */
-
-+#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD)
- #ifdef HAVE_KVM_H
- static int
- pid_is_cmd(pid_t pid, const char *name)
-@@ -974,6 +975,7 @@
- {
- /* Nothing to do */
- }
-+#endif
- #endif /* OSOpenBSD */
-
- #if defined(OShpux)
-@@ -975,6 +954,80 @@
- /* Nothing to do */
- }
- #endif /* OSOpenBSD */
-+
-+#if defined(OSDarwin)
-+#include <sys/sysctl.h>
-+int
-+pid_is_user(pid_t pid, uid_t uid)
-+{
-+ int mib[4];
-+ size_t size;
-+ struct kinfo_proc ki;
-+
-+ size = sizeof(ki);
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_PID;
-+ mib[3] = pid;
-+ if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0)
-+ errx(1, "%s", "Failure calling sysctl");
-+ return (uid == ki.kp_eproc.e_pcred.p_ruid);
-+}
-+
-+static int
-+pid_is_cmd(pid_t pid, const char *name)
-+{
-+ int mib[4];
-+ size_t size;
-+ struct kinfo_proc ki;
-+
-+ size = sizeof(ki);
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_PID;
-+ mib[3] = pid;
-+ if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0)
-+ errx(1, "%s", "Failure calling sysctl");
-+ return (!strncmp(name, ki.kp_proc.p_comm, MAXCOMLEN));
-+}
-+
-+static void
-+do_procinit(void)
-+{
-+ int mib[3];
-+ size_t size;
-+ int nprocs, ret, i;
-+ struct kinfo_proc *procs = NULL, *newprocs;
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_ALL;
-+ ret = sysctl(mib, 3, NULL, &size, NULL, 0);
-+ /* Allocate enough memory for entire process table */
-+ do {
-+ size += size / 10;
-+ newprocs = realloc(procs, size);
-+ if (newprocs == NULL) {
-+ if (procs)
-+ free(procs);
-+ errx(1, "%s", "Could not reallocate memory");
-+ }
-+ procs = newprocs;
-+ ret = sysctl(mib, 3, procs, &size, NULL, 0);
-+ } while (ret >= 0 && errno == ENOMEM);
-+
-+ if (ret < 0)
-+ errx(1, "%s", "Failure calling sysctl");
-+
-+ /* Verify size of proc structure */
-+ if (size % sizeof(struct kinfo_proc) != 0)
-+ errx(1, "%s", "proc size mismatch, userland out of sync with kernel");
-+ nprocs = size / sizeof(struct kinfo_proc);
-+ for (i = 0; i < nprocs; i++) {
-+ check(procs[i].kp_proc.p_pid);
-+ }
-+}
-+#endif /* OSDarwin */
-
- #if defined(OShpux)
- static int
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20151212/5c378a14/attachment.html>
More information about the macports-changes
mailing list