git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #21416 from cstrahan/mesos-1.1.0

mesos: 1.0.1 -> 1.1.0

commitd298a961f1db2356495026702dd9bbc396e000af authorCharles Strahan <charles@cstrahan.com> dateSat 21 Jan 2017, 19:05 (10 years ago) parent5b1b0897ebcada
13 files changed+749−372
nixos/modules/services/misc/mesos-master.nix+21 nixos/modules/services/misc/mesos-slave.nix+94−4 nixos/tests/mesos.nix+78−19 nixos/tests/mesos_test.py+72 pkgs/applications/networking/cluster/mesos/default.nix+74−20 pkgs/applications/networking/cluster/mesos/maven_repo.patch−13 pkgs/applications/networking/cluster/mesos/nixos.patch+364−80 pkgs/applications/networking/cluster/mesos/rb36610.patch+4−3 pkgs/applications/networking/cluster/mesos/rb51324.patch−71 pkgs/applications/networking/cluster/mesos/rb51325.patch−157 pkgs/development/interpreters/python/build-python-package-setuptools.nix+1−1 pkgs/development/libraries/protobuf/generic.nix+21−1 pkgs/top-level/python-packages.nix+20−3
nixos/modules/services/misc/mesos-master.nix+21
@@ -16,12 +16,30 @@ in {
1616 type = types.bool;
1717 };
1818
19+ ip = mkOption {
20+ description = "IP address to listen on.";
21+ default = "0.0.0.0";
22+ type = types.str;
23+ };
24+
1925 port = mkOption {
2026 description = "Mesos Master port";
2127 default = 5050;
2228 type = types.int;
2329 };
2430
31+ advertiseIp = mkOption {
32+ description = "IP address advertised to reach this master.";
33+ default = null;
34+ type = types.nullOr types.str;
35+ };
36+
37+ advertisePort = mkOption {
38+ description = "Port advertised to reach this Mesos master.";
39+ default = null;
40+ type = types.nullOr types.int;
41+ };
42+
2543 zk = mkOption {
2644 description = ''
2745 ZooKeeper URL (used for leader election amongst masters).
@@ -84,7 +102,10 @@ in {
84102 serviceConfig = {
85103 ExecStart = ''
86104 ${pkgs.mesos}/bin/mesos-master \
105+ --ip=${cfg.ip} \
87106 --port=${toString cfg.port} \
107+ ${optionalString (cfg.advertiseIp != null) "--advertise_ip=${cfg.advertiseIp}"} \
108+ ${optionalString (cfg.advertisePort != null) "--advertise_port=${toString cfg.advertisePort}"} \
88109 ${if cfg.quorum == 0
89110 then "--registry=in_memory"
90111 else "--zk=${cfg.zk} --registry=replicated_log --quorum=${toString cfg.quorum}"} \
nixos/modules/services/misc/mesos-slave.nix+94−4
@@ -12,7 +12,23 @@ let
1212 attribsArg = optionalString (cfg.attributes != {})
1313 "--attributes=${mkAttributes cfg.attributes}";
1414
15− containerizers = [ "mesos" ] ++ (optional cfg.withDocker "docker");
15+ containerizersArg = concatStringsSep "," (
16+ lib.unique (
17+ cfg.containerizers ++ (optional cfg.withDocker "docker")
18+ )
19+ );
20+
21+ imageProvidersArg = concatStringsSep "," (
22+ lib.unique (
23+ cfg.imageProviders ++ (optional cfg.withDocker "docker")
24+ )
25+ );
26+
27+ isolationArg = concatStringsSep "," (
28+ lib.unique (
29+ cfg.isolation ++ (optionals cfg.withDocker [ "filesystem/linux" "docker/runtime"])
30+ )
31+ );
1632
1733in {
1834
@@ -27,7 +43,7 @@ in {
2743 ip = mkOption {
2844 description = "IP address to listen on.";
2945 default = "0.0.0.0";
30− type = types.string;
46+ type = types.str;
3147 };
3248
3349 port = mkOption {
@@ -36,6 +52,53 @@ in {
3652 type = types.int;
3753 };
3854
55+ advertiseIp = mkOption {
56+ description = "IP address advertised to reach this agent.";
57+ default = null;
58+ type = types.nullOr types.str;
59+ };
60+
61+ advertisePort = mkOption {
62+ description = "Port advertised to reach this agent.";
63+ default = null;
64+ type = types.nullOr types.int;
65+ };
66+
67+ containerizers = mkOption {
68+ description = ''
69+ List of containerizer implementations to compose in order to provide
70+ containerization. Available options are mesos and docker.
71+ The order the containerizers are specified is the order they are tried.
72+ '';
73+ default = [ "mesos" ];
74+ type = types.listOf types.str;
75+ };
76+
77+ imageProviders = mkOption {
78+ description = "List of supported image providers, e.g., APPC,DOCKER.";
79+ default = [ ];
80+ type = types.listOf types.str;
81+ };
82+
83+ imageProvisionerBackend = mkOption {
84+ description = ''
85+ Strategy for provisioning container rootfs from images,
86+ e.g., aufs, bind, copy, overlay.
87+ '';
88+ default = "copy";
89+ type = types.str;
90+ };
91+
92+ isolation = mkOption {
93+ description = ''
94+ Isolation mechanisms to use, e.g., posix/cpu,posix/mem, or
95+ cgroups/cpu,cgroups/mem, or network/port_mapping, or `gpu/nvidia` for nvidia
96+ specific gpu isolation.
97+ '';
98+ default = [ "posix/cpu" "posix/mem" ];
99+ type = types.listOf types.str;
100+ };
101+
39102 master = mkOption {
40103 description = ''
41104 May be one of:
@@ -57,6 +120,16 @@ in {
57120 type = types.bool;
58121 };
59122
123+ dockerRegistry = mkOption {
124+ description = ''
125+ The default url for pulling Docker images.
126+ It could either be a Docker registry server url,
127+ or a local path in which Docker image archives are stored.
128+ '';
129+ default = null;
130+ type = types.nullOr (types.either types.str types.path);
131+ };
132+
60133 workDir = mkOption {
61134 description = "The Mesos work directory.";
62135 default = "/var/lib/mesos/slave";
@@ -96,28 +169,45 @@ in {
96169 host = "aabc123";
97170 os = "nixos"; };
98171 };
172+
173+ executorEnvironmentVariables = mkOption {
174+ description = ''
175+ The environment variables that should be passed to the executor, and thus subsequently task(s).
176+ '';
177+ default = {
178+ PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
179+ };
180+ type = types.attrsOf types.str;
181+ };
99182 };
100183
101184 };
102185
103−
104186 config = mkIf cfg.enable {
105187 systemd.services.mesos-slave = {
106188 description = "Mesos Slave";
107189 wantedBy = [ "multi-user.target" ];
108190 after = [ "network.target" ];
109− environment.MESOS_CONTAINERIZERS = concatStringsSep "," containerizers;
191+ path = [ pkgs.stdenv.shellPackage ];
110192 serviceConfig = {
111193 ExecStart = ''
112194 ${pkgs.mesos}/bin/mesos-slave \
195+ --containerizers=${containerizersArg} \
196+ --image_providers=${imageProvidersArg} \
197+ --image_provisioner_backend=${cfg.imageProvisionerBackend} \
198+ --isolation=${isolationArg} \
113199 --ip=${cfg.ip} \
114200 --port=${toString cfg.port} \
201+ ${optionalString (cfg.advertiseIp != null) "--advertise_ip=${cfg.advertiseIp}"} \
202+ ${optionalString (cfg.advertisePort != null) "--advertise_port=${toString cfg.advertisePort}"} \
115203 --master=${cfg.master} \
116204 --work_dir=${cfg.workDir} \
117205 --logging_level=${cfg.logLevel} \
118206 ${attribsArg} \
119207 ${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \
120208 ${optionalString cfg.withDocker "--docker=${pkgs.docker}/libexec/docker/docker"} \
209+ ${optionalString (cfg.dockerRegistry != null) "--docker_registry=${cfg.dockerRegistry}"} \
210+ --executor_environment_variables=${lib.escapeShellArg (builtins.toJSON cfg.executorEnvironmentVariables)} \
121211 ${toString cfg.extraCmdLineOptions}
122212 '';
123213 PermissionsStartOnly = true;
nixos/tests/mesos.nix+78−19
@@ -1,32 +1,91 @@
1−import ./make-test.nix ({ pkgs, ...} : {
2− name = "simple";
1+import ./make-test.nix ({ pkgs, ...} : rec {
2+ name = "mesos";
33 meta = with pkgs.stdenv.lib.maintainers; {
4− maintainers = [ offline ];
4+ maintainers = [ offline kamilchm cstrahan ];
55 };
66
7− machine = { config, pkgs, ... }: {
8− services.zookeeper.enable = true;
9− virtualisation.docker.enable = true;
10− services.mesos = {
11− slave = {
12− enable = true;
13− master = "zk://localhost:2181/mesos";
14− attributes = {
15− tag1 = "foo";
16− tag2 = "bar";
17− };
7+ nodes = {
8+ master = { config, pkgs, ... }: {
9+ networking.firewall.enable = false;
10+ services.zookeeper.enable = true;
11+ services.mesos.master = {
12+ enable = true;
13+ zk = "zk://master:2181/mesos";
1814 };
19− master = {
20− enable = true;
21− zk = "zk://localhost:2181/mesos";
15+ };
16+
17+ slave = { config, pkgs, ... }: {
18+ networking.firewall.enable = false;
19+ networking.nat.enable = true;
20+ virtualisation.docker.enable = true;
21+ services.mesos = {
22+ slave = {
23+ enable = true;
24+ master = "master:5050";
25+ dockerRegistry = registry;
26+ executorEnvironmentVariables = {
27+ PATH = "/run/current-system/sw/bin";
28+ };
29+ };
2230 };
2331 };
2432 };
2533
34+ simpleDocker = pkgs.dockerTools.buildImage {
35+ name = "echo";
36+ contents = [ pkgs.stdenv.shellPackage pkgs.coreutils ];
37+ config = {
38+ Env = [
39+ # When shell=true, mesos invokes "sh -c '<cmd>'", so make sure "sh" is
40+ # on the PATH.
41+ "PATH=${pkgs.stdenv.shellPackage}/bin:${pkgs.coreutils}/bin"
42+ ];
43+ Entrypoint = [ "echo" ];
44+ };
45+ };
46+
47+ registry = pkgs.runCommand "registry" { } ''
48+ mkdir -p $out
49+ cp ${simpleDocker} $out/echo:latest.tar
50+ '';
51+
52+ testFramework = pkgs.pythonPackages.buildPythonPackage {
53+ name = "mesos-tests";
54+ propagatedBuildInputs = [ pkgs.mesos ];
55+ catchConflicts = false;
56+ src = ./mesos_test.py;
57+ phases = [ "installPhase" "fixupPhase" ];
58+ installPhase = ''
59+ mkdir $out
60+ cp $src $out/mesos_test.py
61+ chmod +x $out/mesos_test.py
62+
63+ echo "done" > test.result
64+ tar czf $out/test.tar.gz test.result
65+ '';
66+ };
67+
2668 testScript =
2769 ''
2870 startAll;
29− $machine->waitForUnit("mesos-master.service");
30− $machine->waitForUnit("mesos-slave.service");
71+ $master->waitForUnit("mesos-master.service");
72+ $slave->waitForUnit("mesos-slave.service");
73+
74+ $master->waitForOpenPort(5050);
75+ $slave->waitForOpenPort(5051);
76+
77+ # is slave registred?
78+ $master->waitUntilSucceeds("curl -s --fail http://master:5050/master/slaves".
79+ " | grep -q \"\\\"hostname\\\":\\\"slave\\\"\"");
80+
81+ # try to run docker image
82+ $master->succeed("${pkgs.mesos}/bin/mesos-execute --master=master:5050".
83+ " --resources=\"cpus:0.1;mem:32\" --name=simple-docker".
84+ " --containerizer=mesos --docker_image=echo:latest".
85+ " --shell=true --command=\"echo done\" | grep -q TASK_FINISHED");
86+
87+ # simple command with .tar.gz uri
88+ $master->succeed("${testFramework}/mesos_test.py master ".
89+ "${testFramework}/test.tar.gz");
3190 '';
3291})
nixos/tests/mesos_test.pynew file+72
@@ -0,0 +1,72 @@
1+#!/usr/bin/env python
2+import uuid
3+import time
4+import subprocess
5+import os
6+
7+import sys
8+
9+from mesos.interface import Scheduler
10+from mesos.native import MesosSchedulerDriver
11+from mesos.interface import mesos_pb2
12+
13+def log(msg):
14+ process = subprocess.Popen("systemd-cat", stdin=subprocess.PIPE)
15+ (out,err) = process.communicate(msg)
16+
17+class NixosTestScheduler(Scheduler):
18+ def __init__(self):
19+ self.master_ip = sys.argv[1]
20+ self.download_uri = sys.argv[2]
21+
22+ def resourceOffers(self, driver, offers):
23+ log("XXX got resource offer")
24+
25+ offer = offers[0]
26+ task = self.new_task(offer)
27+ uri = task.command.uris.add()
28+ uri.value = self.download_uri
29+ task.command.value = "cat test.result"
30+ driver.launchTasks(offer.id, [task])
31+
32+ def statusUpdate(self, driver, update):
33+ log("XXX status update")
34+ if update.state == mesos_pb2.TASK_FAILED:
35+ log("XXX test task failed with message: " + update.message)
36+ driver.stop()
37+ sys.exit(1)
38+ elif update.state == mesos_pb2.TASK_FINISHED:
39+ driver.stop()
40+ sys.exit(0)
41+
42+ def new_task(self, offer):
43+ task = mesos_pb2.TaskInfo()
44+ id = uuid.uuid4()
45+ task.task_id.value = str(id)
46+ task.slave_id.value = offer.slave_id.value
47+ task.name = "task {}".format(str(id))
48+
49+ cpus = task.resources.add()
50+ cpus.name = "cpus"
51+ cpus.type = mesos_pb2.Value.SCALAR
52+ cpus.scalar.value = 0.1
53+
54+ mem = task.resources.add()
55+ mem.name = "mem"
56+ mem.type = mesos_pb2.Value.SCALAR
57+ mem.scalar.value = 32
58+
59+ return task
60+
61+if __name__ == '__main__':
62+ log("XXX framework started")
63+
64+ framework = mesos_pb2.FrameworkInfo()
65+ framework.user = "root"
66+ framework.name = "nixos-test-framework"
67+ driver = MesosSchedulerDriver(
68+ NixosTestScheduler(),
69+ framework,
70+ sys.argv[1] + ":5050"
71+ )
72+ driver.run()
pkgs/applications/networking/cluster/mesos/default.nix+74−20
@@ -2,16 +2,27 @@
22, automake115x, libtool, unzip, gnutar, jdk, maven, python, wrapPython
33, setuptools, boto, pythonProtobuf, apr, subversion, gzip, systemd
44, leveldb, glog, perf, utillinux, libnl, iproute, openssl, libevent
5−, ethtool, coreutils
5+, ethtool, coreutils, which, iptables
66, bash
77}:
88
99let
1010 mavenRepo = import ./mesos-deps.nix { inherit stdenv curl; };
1111 soext = if stdenv.system == "x86_64-darwin" then "dylib" else "so";
12+ # `tar -z` requires gzip on $PATH, so wrap tar.
13+ # At some point, we should try to patch mesos so we add gzip to the PATH when
14+ # tar is invoked. I think that only needs to be done here:
15+ # src/common/command_utils.cpp
16+ # https://github.com/NixOS/nixpkgs/issues/13783
17+ tarWithGzip = lib.overrideDerivation gnutar (oldAttrs: {
18+ buildInputs = (oldAttrs.buildInputs or []) ++ [ makeWrapper ];
19+ postInstall = (oldAttrs.postInstall or "") + ''
20+ wrapProgram $out/bin/tar --prefix PATH ":" "${gzip}/bin"
21+ '';
22+ });
1223
1324in stdenv.mkDerivation rec {
14− version = "1.0.1";
25+ version = "1.1.0";
1526 name = "mesos-${version}";
1627
1728 enableParallelBuilding = true;
@@ -19,17 +30,14 @@ in stdenv.mkDerivation rec {
1930
2031 src = fetchurl {
2132 url = "mirror://apache/mesos/${version}/${name}.tar.gz";
22− sha256 = "1hdh2wh11ck98ycfrxfzgivgk2pjl3638vkyw14xj7faj9qxjlz0";
33+ sha256 = "1hdjd4syyp88l0bnh88bhzvn9466ad2ysfp9pq3kwj3qzwg5jv8g";
2334 };
2435
2536 patches = [
2637 # https://reviews.apache.org/r/36610/
38+ # TODO: is this still needed?
2739 ./rb36610.patch
2840
29− # https://issues.apache.org/jira/browse/MESOS-6013
30− ./rb51324.patch
31− ./rb51325.patch
32−
3341 # see https://github.com/cstrahan/mesos/tree/nixos-${version}
3442 ./nixos.patch
3543 ];
@@ -46,33 +54,55 @@ in stdenv.mkDerivation rec {
4654 pythonProtobuf
4755 ];
4856
57+ # note that we *must* statically link libprotobuf.
58+ # if we dynamically link the lib, we get these errors:
59+ # https://github.com/NixOS/nixpkgs/pull/19064#issuecomment-255082684
4960 preConfigure = ''
50− substituteInPlace 3rdparty/stout/include/stout/os/posix/fork.hpp \
51− --subst-var-by sh ${bash}/bin/bash
61+ substituteInPlace 3rdparty/stout/include/stout/os/posix/chown.hpp \
62+ --subst-var-by chown ${coreutils}/bin/chown
63+
64+ substituteInPlace 3rdparty/stout/Makefile.am \
65+ --replace "-lprotobuf" \
66+ "${pythonProtobuf.protobuf.lib}/lib/libprotobuf.a"
5267
53− substituteInPlace 3rdparty/stout/include/stout/os/posix/shell.hpp \
68+ substituteInPlace 3rdparty/stout/include/stout/os/posix/fork.hpp \
5469 --subst-var-by sh ${bash}/bin/bash
5570
56− substituteInPlace src/Makefile.am \
57− --subst-var-by mavenRepo ${mavenRepo}
71+ substituteInPlace 3rdparty/stout/include/stout/posix/os.hpp \
72+ --subst-var-by tar ${tarWithGzip}/bin/tar
5873
5974 substituteInPlace src/cli/mesos-scp \
6075 --subst-var-by scp ${openssh}/bin/scp
6176
77+ substituteInPlace src/common/command_utils.cpp \
78+ --subst-var-by curl ${curl}/bin/curl \
79+ --subst-var-by gzip ${gzip}/bin/gzip \
80+ --subst-var-by sha512sum ${coreutils}/bin/sha512sum \
81+ --subst-var-by tar ${tarWithGzip}/bin/tar
82+
6283 substituteInPlace src/launcher/fetcher.cpp \
84+ --subst-var-by cp ${coreutils}/bin/cp \
6385 --subst-var-by gzip ${gzip}/bin/gzip \
64− --subst-var-by tar ${gnutar}/bin/tar \
86+ --subst-var-by tar ${tarWithGzip}/bin/tar \
6587 --subst-var-by unzip ${unzip}/bin/unzip
6688
6789 substituteInPlace src/python/cli/src/mesos/cli.py \
6890 --subst-var-by mesos-resolve $out/bin/mesos-resolve
6991
92+ substituteInPlace src/python/native_common/ext_modules.py.in \
93+ --replace "-lprotobuf" \
94+ "${pythonProtobuf.protobuf.lib}/lib/libprotobuf.a"
95+
96+ substituteInPlace src/slave/containerizer/mesos/isolators/gpu/volume.cpp \
97+ --subst-var-by cp ${coreutils}/bin/cp \
98+ --subst-var-by which ${which}/bin/which
99+
70100 substituteInPlace src/slave/containerizer/mesos/isolators/posix/disk.cpp \
71− --subst-var-by du ${coreutils}/bin/du \
72− --subst-var-by cp ${coreutils}/bin/cp
101+ --subst-var-by du ${coreutils}/bin/du
73102
74103 substituteInPlace src/slave/containerizer/mesos/provisioner/backends/copy.cpp \
75− --subst-var-by cp ${coreutils}/bin/cp
104+ --subst-var-by cp ${coreutils}/bin/cp \
105+ --subst-var-by rm ${coreutils}/bin/rm
76106
77107 substituteInPlace src/uri/fetchers/copy.cpp \
78108 --subst-var-by cp ${coreutils}/bin/cp
@@ -83,23 +113,48 @@ in stdenv.mkDerivation rec {
83113 substituteInPlace src/uri/fetchers/docker.cpp \
84114 --subst-var-by curl ${curl}/bin/curl
85115
116+ substituteInPlace src/Makefile.am \
117+ --subst-var-by mavenRepo ${mavenRepo} \
118+ --replace "-lprotobuf" \
119+ "${pythonProtobuf.protobuf.lib}/lib/libprotobuf.a"
120+
86121 '' + lib.optionalString stdenv.isLinux ''
87122
88123 substituteInPlace src/linux/perf.cpp \
89124 --subst-var-by perf ${perf}/bin/perf
90125
126+ substituteInPlace src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp \
127+ --subst-var-by mount ${utillinux}/bin/mount
128+
129+ substituteInPlace src/slave/containerizer/mesos/isolators/filesystem/linux.cpp \
130+ --subst-var-by mount ${utillinux}/bin/mount
131+
91132 substituteInPlace src/slave/containerizer/mesos/isolators/filesystem/shared.cpp \
92133 --subst-var-by mount ${utillinux}/bin/mount
93134
135+ substituteInPlace src/slave/containerizer/mesos/isolators/gpu/isolator.cpp \
136+ --subst-var-by mount ${utillinux}/bin/mount
137+
94138 substituteInPlace src/slave/containerizer/mesos/isolators/namespaces/pid.cpp \
95139 --subst-var-by mount ${utillinux}/bin/mount
96140
141+ substituteInPlace src/slave/containerizer/mesos/isolators/network/cni/cni.cpp \
142+ --subst-var-by mount ${utillinux}/bin/mount
143+
144+ substituteInPlace src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp \
145+ --subst-var-by iptables ${iptables}/bin/iptables
146+
97147 substituteInPlace src/slave/containerizer/mesos/isolators/network/port_mapping.cpp \
98− --subst-var-by tc ${iproute}/bin/tc \
148+ --subst-var-by ethtool ${ethtool}/sbin/ethtool \
99149 --subst-var-by ip ${iproute}/bin/ip \
100150 --subst-var-by mount ${utillinux}/bin/mount \
101− --subst-var-by sh ${stdenv.shell} \
102− --subst-var-by ethtool ${ethtool}/sbin/ethtool
151+ --subst-var-by tc ${iproute}/bin/tc
152+
153+ substituteInPlace src/slave/containerizer/mesos/isolators/volume/image.cpp \
154+ --subst-var-by mount ${utillinux}/bin/mount
155+
156+ substituteInPlace src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp \
157+ --subst-var-by mount ${utillinux}/bin/mount
103158 '';
104159
105160 configureFlags = [
@@ -108,7 +163,6 @@ in stdenv.mkDerivation rec {
108163 "--with-svn=${subversion.dev}"
109164 "--with-leveldb=${leveldb}"
110165 "--with-glog=${glog}"
111− "--with-glog=${glog}"
112166 "--enable-optimize"
113167 "--disable-python-dependency-install"
114168 "--enable-ssl"
pkgs/applications/networking/cluster/mesos/maven_repo.patchdeleted−13
@@ -1,13 +0,0 @@
1−diff --git a/src/Makefile.am b/src/Makefile.am
2−index ae2740a..1df91a7 100644
3−--- a/src/Makefile.am
4−+++ b/src/Makefile.am
5−@@ -1310,7 +1310,7 @@ if HAS_JAVA
6−
7− $(MESOS_JAR): $(MESOS_JAR_SOURCE) $(MESOS_JAR_GENERATED) java/mesos.pom
8− @echo "Building mesos-$(PACKAGE_VERSION).jar ..."
9−- @cd $(abs_top_builddir)/src/java && $(MVN) -f mesos.pom clean package
10−+ @cd $(abs_top_builddir)/src/java && $(MVN) -f mesos.pom -Dmaven.repo.local=@mavenRepo@ clean package
11−
12− # Convenience library for JNI bindings.
13− # TODO(Charles Reiss): We really should be building the Java library
pkgs/applications/networking/cluster/mesos/nixos.patch+364−80
@@ -1,5 +1,18 @@
1+diff --git a/3rdparty/stout/include/stout/os/posix/chown.hpp b/3rdparty/stout/include/stout/os/posix/chown.hpp
2+index c82e2e574..15d332107 100644
3+--- a/3rdparty/stout/include/stout/os/posix/chown.hpp
4++++ b/3rdparty/stout/include/stout/os/posix/chown.hpp
5+@@ -34,7 +34,7 @@ inline Try<Nothing> chown(
6+ // TODO(bmahler): Consider walking the file tree instead. We would need
7+ // to be careful to not miss dotfiles.
8+ std::string command =
9+- "chown -R " + stringify(uid) + ':' + stringify(gid) + " '" + path + "'";
10++ "@chown@ -R " + stringify(uid) + ':' + stringify(gid) + " '" + path + "'";
11+
12+ int status = os::system(command);
13+ if (status != 0) {
114diff --git a/3rdparty/stout/include/stout/os/posix/fork.hpp b/3rdparty/stout/include/stout/os/posix/fork.hpp
2−index a29967d..290b98b 100644
15+index a29967dcb..290b98b50 100644
316--- a/3rdparty/stout/include/stout/os/posix/fork.hpp
417+++ b/3rdparty/stout/include/stout/os/posix/fork.hpp
518@@ -369,7 +369,7 @@ private:
@@ -11,48 +24,97 @@ index a29967d..290b98b 100644
1124 EXIT(EXIT_FAILURE)
1225 << "Failed to execute '" << command << "': " << os::strerror(errno);
1326 } else if (wait.isSome()) {
14−diff --git a/3rdparty/stout/include/stout/os/posix/shell.hpp b/3rdparty/stout/include/stout/os/posix/shell.hpp
15−index 1d73ae5..9bf89b5 100644
16−--- a/3rdparty/stout/include/stout/os/posix/shell.hpp
17−+++ b/3rdparty/stout/include/stout/os/posix/shell.hpp
18−@@ -37,7 +37,7 @@ namespace Shell {
19− // received by the callee, usually the command name and `arg1` is the
20− // second command argument received by the callee.
21−
22−-constexpr const char* name = "sh";
23−+constexpr const char* name = "@sh@";
24− constexpr const char* arg0 = "sh";
25− constexpr const char* arg1 = "-c";
27+diff --git a/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/stout/include/stout/posix/os.hpp
28+index c37e64db6..d3d87b7f0 100644
29+--- a/3rdparty/stout/include/stout/posix/os.hpp
30++++ b/3rdparty/stout/include/stout/posix/os.hpp
31+@@ -375,7 +375,7 @@ inline Option<std::string> getenv(const std::string& key)
32+ inline Try<Nothing> tar(const std::string& path, const std::string& archive)
33+ {
34+ Try<std::string> tarOut =
35+- os::shell("tar %s %s %s", "-czf", archive.c_str(), path.c_str());
36++ os::shell("@tar@ %s %s %s", "-czf", archive.c_str(), path.c_str());
2637
38+ if (tarOut.isError()) {
39+ return Error("Failed to archive " + path + ": " + tarOut.error());
2740diff --git a/src/Makefile.am b/src/Makefile.am
28−index 28dd151..36fc6ec 100644
41+index 3bcc0f2df..e5cbc57e8 100644
2942--- a/src/Makefile.am
3043+++ b/src/Makefile.am
31−@@ -1528,7 +1528,8 @@ if HAS_JAVA
44+@@ -1545,7 +1545,7 @@ if HAS_JAVA
3245
3346 $(MESOS_JAR): $(MESOS_JAR_SOURCE) $(MESOS_JAR_GENERATED) java/mesos.pom
3447 @echo "Building mesos-$(PACKAGE_VERSION).jar ..."
3548- @cd $(abs_top_builddir)/src/java && $(MVN) -B -f mesos.pom clean package
3649+ @cd $(abs_top_builddir)/src/java && $(MVN) -B -f mesos.pom -Dmaven.repo.local=@mavenRepo@ clean package
37−+
3850
3951 # Convenience library for JNI bindings.
4052 # TODO(Charles Reiss): We really should be building the Java library
4153diff --git a/src/cli/mesos-scp b/src/cli/mesos-scp
42−index a71ab07..feed8c4 100755
54+index a71ab0708..1043d1b3c 100755
4355--- a/src/cli/mesos-scp
4456+++ b/src/cli/mesos-scp
45−@@ -19,7 +19,7 @@ if sys.version_info < (2,6,0):
57+@@ -19,7 +19,8 @@ if sys.version_info < (2,6,0):
4658
4759
4860 def scp(host, src, dst):
4961- cmd = 'scp -pr %s %s' % (src, host + ':' + dst)
5062+ cmd = '@scp@ -pr %s %s' % (src, host + ':' + dst)
63++
5164 try:
5265 process = subprocess.Popen(
5366 cmd,
67+diff --git a/src/common/command_utils.cpp b/src/common/command_utils.cpp
68+index 09e805140..90bf65896 100644
69+--- a/src/common/command_utils.cpp
70++++ b/src/common/command_utils.cpp
71+@@ -140,7 +140,7 @@ Future<Nothing> tar(
72+
73+ argv.emplace_back(input);
74+
75+- return launch("tar", argv)
76++ return launch("@tar@", argv)
77+ .then([]() { return Nothing(); });
78+ }
79+
80+@@ -162,7 +162,7 @@ Future<Nothing> untar(
81+ argv.emplace_back(directory.get());
82+ }
83+
84+- return launch("tar", argv)
85++ return launch("@tar@", argv)
86+ .then([]() { return Nothing(); });
87+ }
88+
89+@@ -170,7 +170,7 @@ Future<Nothing> untar(
90+ Future<string> sha512(const Path& input)
91+ {
92+ #ifdef __linux__
93+- const string cmd = "sha512sum";
94++ const string cmd = "@sha512sum@";
95+ vector<string> argv = {
96+ cmd,
97+ input // Input file to compute shasum.
98+@@ -206,7 +206,7 @@ Future<Nothing> gzip(const Path& input)
99+ input
100+ };
101+
102+- return launch("gzip", argv)
103++ return launch("@gzip@", argv)
104+ .then([]() { return Nothing(); });
105+ }
106+
107+@@ -219,7 +219,7 @@ Future<Nothing> decompress(const Path& input)
108+ input
109+ };
110+
111+- return launch("gzip", argv)
112++ return launch("@gzip@", argv)
113+ .then([]() { return Nothing(); });
114+ }
115+
54116diff --git a/src/launcher/fetcher.cpp b/src/launcher/fetcher.cpp
55−index 4456c28..e22c8fc 100644
117+index 4456c2813..e22c8fc03 100644
56118--- a/src/launcher/fetcher.cpp
57119+++ b/src/launcher/fetcher.cpp
58120@@ -68,13 +68,13 @@ static Try<bool> extract(
@@ -82,11 +144,11 @@ index 4456c28..e22c8fc 100644
82144 LOG(INFO) << "Copying resource with command:" << command;
83145
84146diff --git a/src/linux/perf.cpp b/src/linux/perf.cpp
85−index ea823b3..170f54d 100644
147+index aa31982eb..8b5331b17 100644
86148--- a/src/linux/perf.cpp
87149+++ b/src/linux/perf.cpp
88−@@ -125,7 +125,7 @@ private:
89− // NOTE: The watchdog process places perf in its own process group
150+@@ -127,7 +127,7 @@ private:
151+ // NOTE: The supervisor childhook places perf in its own process group
90152 // and will kill the perf process when the parent dies.
91153 Try<Subprocess> _perf = subprocess(
92154- "perf",
@@ -104,37 +166,51 @@ index ea823b3..170f54d 100644
104166 command << " --event " << event;
105167 }
106168diff --git a/src/linux/systemd.cpp b/src/linux/systemd.cpp
107−index 619aa27..c1cbfe4 100644
169+index 6318f48fc..394d88d47 100644
108170--- a/src/linux/systemd.cpp
109171+++ b/src/linux/systemd.cpp
110−@@ -196,12 +196,19 @@ bool exists()
172+@@ -196,13 +196,21 @@ bool exists()
111173 // This is static as the init system should not change while we are running.
112174 static const bool exists = []() -> bool {
113175 // (1) Test whether `/sbin/init` links to systemd.
114176- const Result<string> realpath = os::realpath("/sbin/init");
115177- if (realpath.isError() || realpath.isNone()) {
116178- LOG(WARNING) << "Failed to test /sbin/init for systemd environment: "
117−- << realpath.error();
179+- << (realpath.isError() ? realpath.error()
180+- : "does not exist");
118181-
119182- return false;
120−+ // cstrahan: first assume we're on NixOS, then try non-NixOS
183++ // cstrahan(nixos): first assume we're on NixOS, then try non-NixOS
121184+ Result<string> realpath = os::realpath("/run/current-system/systemd/lib/systemd/systemd");
122185+ Result<string> realpathNixOS = realpath;
123186+ if (realpathNixOS.isError() || realpathNixOS.isNone()) {
124187+ Result<string> realpathNonNixOS = realpath = os::realpath("/sbin/init");
125188+ if (realpathNonNixOS.isError() || realpathNonNixOS.isNone()) {
126189+ LOG(WARNING) << "Failed to test /run/current-system/systemd/lib/systemd/systemd for systemd environment: "
127−+ << realpathNixOS.error();
190++ << (realpathNixOS.isError() ? realpathNixOS.error()
191++ : "does not exist");
128192+ LOG(WARNING) << "Failed to test /sbin/init for systemd environment: "
129−+ << realpathNonNixOS.error();
193++ << (realpathNonNixOS.isError() ? realpathNonNixOS.error()
194++ : "does not exist");
130195+
131196+ return false;
132197+ }
133198 }
134199
135200 CHECK_SOME(realpath);
201+@@ -278,6 +286,10 @@ Path hierarchy()
202+
203+ Try<Nothing> daemonReload()
204+ {
205++ // cstrahan(nixos): should we patch these `systemctl`s?
206++ // probably don't want to hard-code a particular systemd store path here,
207++ // but if we use /run/current-system/sw/bin/systemctl,
208++ // we won't be able to support non-NixOS distros.
209+ Try<string> daemonReload = os::shell("systemctl daemon-reload");
210+ if (daemonReload.isError()) {
211+ return Error("Failed to reload systemd daemon: " + daemonReload.error());
136212diff --git a/src/python/cli/src/mesos/cli.py b/src/python/cli/src/mesos/cli.py
137−index f342992..354abf4 100644
213+index f342992e0..354abf443 100644
138214--- a/src/python/cli/src/mesos/cli.py
139215+++ b/src/python/cli/src/mesos/cli.py
140216@@ -40,7 +40,7 @@ def resolve(master):
@@ -146,11 +222,70 @@ index f342992..354abf4 100644
146222 stdin=None,
147223 stdout=subprocess.PIPE,
148224 stderr=subprocess.PIPE,
225+diff --git a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
226+index af9f3736b..f8554d414 100644
227+--- a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
228++++ b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
229+@@ -499,7 +499,7 @@ Future<Option<ContainerLaunchInfo>> DockerVolumeIsolatorProcess::_prepare(
230+ // unsafe arbitrary commands).
231+ CommandInfo* command = launchInfo.add_pre_exec_commands();
232+ command->set_shell(false);
233+- command->set_value("mount");
234++ command->set_value("@mount@");
235+ command->add_arguments("mount");
236+ command->add_arguments("-n");
237+ command->add_arguments("--rbind");
238+diff --git a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
239+index df16b8fee..4a17475bd 100644
240+--- a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
241++++ b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
242+@@ -159,9 +159,9 @@ Try<Isolator*> LinuxFilesystemIsolatorProcess::create(const Flags& flags)
243+ // here because 'create' will only be invoked during
244+ // initialization.
245+ Try<string> mount = os::shell(
246+- "mount --bind %s %s && "
247+- "mount --make-private %s && "
248+- "mount --make-shared %s",
249++ "@mount@ --bind %s %s && "
250++ "@mount@ --make-private %s && "
251++ "@mount@ --make-shared %s",
252+ workDir->c_str(),
253+ workDir->c_str(),
254+ workDir->c_str(),
255+@@ -180,8 +180,8 @@ Try<Isolator*> LinuxFilesystemIsolatorProcess::create(const Flags& flags)
256+ LOG(INFO) << "Making '" << workDir.get() << "' a shared mount";
257+
258+ Try<string> mount = os::shell(
259+- "mount --make-private %s && "
260+- "mount --make-shared %s",
261++ "@mount@ --make-private %s && "
262++ "@mount@ --make-shared %s",
263+ workDir->c_str(),
264+ workDir->c_str());
265+
266+@@ -404,7 +404,7 @@ Try<vector<CommandInfo>> LinuxFilesystemIsolatorProcess::getPreExecCommands(
267+
268+ CommandInfo command;
269+ command.set_shell(false);
270+- command.set_value("mount");
271++ command.set_value("@mount@");
272+ command.add_arguments("mount");
273+ command.add_arguments("-n");
274+ command.add_arguments("--rbind");
275+@@ -569,7 +569,7 @@ Try<vector<CommandInfo>> LinuxFilesystemIsolatorProcess::getPreExecCommands(
276+ // TODO(jieyu): Consider the mode in the volume.
277+ CommandInfo command;
278+ command.set_shell(false);
279+- command.set_value("mount");
280++ command.set_value("@mount@");
281+ command.add_arguments("mount");
282+ command.add_arguments("-n");
283+ command.add_arguments("--rbind");
149284diff --git a/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp b/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
150−index 51d1518..783adb5 100644
285+index a1283e5ee..a918427bf 100644
151286--- a/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
152287+++ b/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
153−@@ -204,7 +204,7 @@ Future<Option<ContainerLaunchInfo>> SharedFilesystemIsolatorProcess::prepare(
288+@@ -207,7 +207,7 @@ Future<Option<ContainerLaunchInfo>> SharedFilesystemIsolatorProcess::prepare(
154289 }
155290
156291 launchInfo.add_pre_exec_commands()->set_value(
@@ -159,36 +294,148 @@ index 51d1518..783adb5 100644
159294 }
160295
161296 return launchInfo;
297+diff --git a/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp b/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp
298+index e3756c920..cfe458b59 100644
299+--- a/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp
300++++ b/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp
301+@@ -355,7 +355,7 @@ Future<Option<ContainerLaunchInfo>> NvidiaGpuIsolatorProcess::_prepare(
302+ }
303+
304+ launchInfo.add_pre_exec_commands()->set_value(
305+- "mount --no-mtab --rbind --read-only " +
306++ "@mount@ --no-mtab --rbind --read-only " +
307+ volume.HOST_PATH() + " " + target);
308+ }
309+
310+diff --git a/src/slave/containerizer/mesos/isolators/gpu/volume.cpp b/src/slave/containerizer/mesos/isolators/gpu/volume.cpp
311+index 478752f37..ab527f0cd 100644
312+--- a/src/slave/containerizer/mesos/isolators/gpu/volume.cpp
313++++ b/src/slave/containerizer/mesos/isolators/gpu/volume.cpp
314+@@ -281,7 +281,7 @@ Try<NvidiaVolume> NvidiaVolume::create()
315+ string path = path::join(hostPath, "bin", binary);
316+
317+ if (!os::exists(path)) {
318+- string command = "which " + binary;
319++ string command = "@which@ " + binary;
320+ Try<string> which = os::shell(command);
321+
322+ if (which.isSome()) {
323+@@ -295,7 +295,7 @@ Try<NvidiaVolume> NvidiaVolume::create()
324+ : "No such file or directory"));
325+ }
326+
327+- command = "cp " + realpath.get() + " " + path;
328++ command = "@cp@ " + realpath.get() + " " + path;
329+ Try<string> cp = os::shell(command);
330+ if (cp.isError()) {
331+ return Error("Failed to os::shell '" + command + "': " + cp.error());
332+@@ -367,7 +367,7 @@ Try<NvidiaVolume> NvidiaVolume::create()
333+ Path(realpath.get()).basename());
334+
335+ if (!os::exists(libraryPath)) {
336+- string command = "cp " + realpath.get() + " " + libraryPath;
337++ string command = "@cp@ " + realpath.get() + " " + libraryPath;
338+ Try<string> cp = os::shell(command);
339+ if (cp.isError()) {
340+ return Error("Failed to os::shell '" + command + "':"
162341diff --git a/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp b/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
163−index b41e266..e07c163 100644
342+index 0d9ec57d9..a177e4476 100644
164343--- a/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
165344+++ b/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
166−@@ -163,7 +163,7 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
167− // containers cannot see the namespace bind mount of other
168− // containers.
169− launchInfo.add_pre_exec_commands()->set_value(
170−- "mount -n --bind " + string(PID_NS_BIND_MOUNT_MASK_DIR) +
171−+ "@mount@ -n --bind " + string(PID_NS_BIND_MOUNT_MASK_DIR) +
172− " " + string(PID_NS_BIND_MOUNT_ROOT));
173−
174− // Mount /proc for the container's pid namespace to show the
175−@@ -176,9 +176,9 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
176− // -n flag so the mount is not added to the mtab where it will not
177− // be correctly removed with the namespace terminates.
178− launchInfo.add_pre_exec_commands()->set_value(
179−- "mount none /proc --make-private -o rec");
180−+ "@mount@ none /proc --make-private -o rec");
345+@@ -94,7 +94,7 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
346+ //
347+ // TOOD(jieyu): Consider unmount the existing /proc.
181348 launchInfo.add_pre_exec_commands()->set_value(
182349- "mount -n -t proc proc /proc -o nosuid,noexec,nodev");
183350+ "@mount@ -n -t proc proc /proc -o nosuid,noexec,nodev");
184351
185352 return launchInfo;
186353 }
354+diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
355+index c87e6715a..6601cd1b3 100644
356+--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
357++++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
358+@@ -262,9 +262,9 @@ Try<Isolator*> NetworkCniIsolatorProcess::create(const Flags& flags)
359+ // here because 'create' will only be invoked during
360+ // initialization.
361+ Try<string> mount = os::shell(
362+- "mount --bind %s %s && "
363+- "mount --make-private %s && "
364+- "mount --make-shared %s",
365++ "@mount@ --bind %s %s && "
366++ "@mount@ --make-private %s && "
367++ "@mount@ --make-shared %s",
368+ rootDir->c_str(),
369+ rootDir->c_str(),
370+ rootDir->c_str(),
371+@@ -284,8 +284,8 @@ Try<Isolator*> NetworkCniIsolatorProcess::create(const Flags& flags)
372+ LOG(INFO) << "Making '" << rootDir.get() << "' a shared mount";
373+
374+ Try<string> mount = os::shell(
375+- "mount --make-private %s && "
376+- "mount --make-shared %s",
377++ "@mount@ --make-private %s && "
378++ "@mount@ --make-shared %s",
379+ rootDir->c_str(),
380+ rootDir->c_str());
381+
382+diff --git a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
383+index b470f0c82..6110a43ee 100644
384+--- a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
385++++ b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
386+@@ -303,7 +303,7 @@ Try<Nothing> PortMapper::addPortMapping(
387+ # Check if the `chain` exists in the iptable. If it does not
388+ # exist go ahead and install the chain in the iptables NAT
389+ # table.
390+- iptables -w -t nat --list %s
391++ @iptables@ -w -t nat --list %s
392+ if [ $? -ne 0 ]; then
393+ # NOTE: When we create the chain, there is a possibility of a
394+ # race due to which a container launch can fail. This can
395+@@ -317,25 +317,25 @@ Try<Nothing> PortMapper::addPortMapping(
396+ # since it can happen only when the chain is created the first
397+ # time and two commands for creation of the chain are executed
398+ # simultaneously.
399+- (iptables -w -t nat -N %s || exit 1)
400++ (@iptables@ -w -t nat -N %s || exit 1)
401+
402+ # Once the chain has been installed add a rule in the PREROUTING
403+ # chain to jump to this chain for any packets that are
404+ # destined to a local address.
405+- (iptables -w -t nat -A PREROUTING \
406++ (@iptables@ -w -t nat -A PREROUTING \
407+ -m addrtype --dst-type LOCAL -j %s || exit 1)
408+
409+ # For locally generated packets we need a rule in the OUTPUT
410+ # chain as well, since locally generated packets directly hit
411+ # the output CHAIN, bypassing PREROUTING.
412+- (iptables -w -t nat -A OUTPUT \
413++ (@iptables@ -w -t nat -A OUTPUT \
414+ ! -d 127.0.0.0/8 -m addrtype \
415+ --dst-type LOCAL -j %s || exit 1)
416+ fi
417+
418+ # Within the `chain` go ahead and install the DNAT rule, if it
419+ # does not exist.
420+- (iptables -w -t nat -C %s || iptables -t nat -A %s))~",
421++ (@iptables@ -w -t nat -C %s || @iptables@ -t nat -A %s))~",
422+ chain,
423+ chain,
424+ chain,
425+@@ -362,7 +362,7 @@ Try<Nothing> PortMapper::delPortMapping()
426+ # The iptables command searches for the DNAT rules with tag
427+ # "container_id: <CNI_CONTAINERID>", and if it exists goes ahead
428+ # and deletes it.
429+- iptables -w -t nat -S %s | sed "/%s/ s/-A/iptables -w -t nat -D/e")~",
430++ @iptables@ -w -t nat -S %s | sed "/%s/ s/-A/@iptables@ -w -t nat -D/e")~",
431+ chain,
432+ getIptablesRuleTag()).get();
433+
187434diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
188−index 79ee960..d55a353 100644
435+index 20fb6ab35..46c160977 100644
189436--- a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
190437+++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
191−@@ -1392,19 +1392,19 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
438+@@ -1393,19 +1393,19 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
192439 // Check the availability of a few Linux commands that we will use.
193440 // We use the blocking os::shell here because 'create' will only be
194441 // invoked during initialization.
@@ -211,7 +458,7 @@ index 79ee960..d55a353 100644
211458 if (checkCommandIp.isError()) {
212459 return Error("Check command 'ip' failed: " + checkCommandIp.error());
213460 }
214−@@ -1924,9 +1924,9 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
461+@@ -1925,9 +1925,9 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
215462 // visible. It's OK to use the blocking os::shell here because
216463 // 'create' will only be invoked during initialization.
217464 Try<string> mount = os::shell(
@@ -224,7 +471,7 @@ index 79ee960..d55a353 100644
224471 bindMountRoot->c_str(),
225472 bindMountRoot->c_str(),
226473 bindMountRoot->c_str(),
227−@@ -1943,8 +1943,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
474+@@ -1944,8 +1944,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
228475 // shared mount yet (possibly due to slave crash while preparing
229476 // the work directory mount). It's safe to re-do the following.
230477 Try<string> mount = os::shell(
@@ -235,7 +482,7 @@ index 79ee960..d55a353 100644
235482 bindMountRoot->c_str(),
236483 bindMountRoot->c_str());
237484
238−@@ -1963,8 +1963,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
485+@@ -1964,8 +1964,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
239486 // so that they are in different peer groups.
240487 if (entry.shared() == bindMountEntry->shared()) {
241488 Try<string> mount = os::shell(
@@ -246,14 +493,16 @@ index 79ee960..d55a353 100644
246493 bindMountRoot->c_str(),
247494 bindMountRoot->c_str());
248495
249−@@ -3916,13 +3916,13 @@ string PortMappingIsolatorProcess::scripts(Info* info)
496+@@ -3911,6 +3911,8 @@ Try<Nothing> PortMappingIsolatorProcess::removeHostIPFilters(
497+ // TODO(jieyu): Use the Subcommand abstraction to remove most of the
498+ // logic here. Completely remove this function once we can assume a
499+ // newer kernel where 'setns' works for mount namespaces.
500++// cstrahan(nixos): this is executed in the container,
501++// so we don't want to substitute paths here.
502+ string PortMappingIsolatorProcess::scripts(Info* info)
250503 {
251504 ostringstream script;
252−
253−- script << "#!/bin/sh\n";
254−+ script << "#!@sh@\n";
255− script << "set -xe\n";
256−
505+@@ -3921,7 +3923,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
257506 // Mark the mount point PORT_MAPPING_BIND_MOUNT_ROOT() as slave
258507 // mount so that changes in the container will not be propagated to
259508 // the host.
@@ -262,7 +511,7 @@ index 79ee960..d55a353 100644
262511
263512 // Disable IPv6 when IPv6 module is loaded as IPv6 packets won't be
264513 // forwarded anyway.
265−@@ -3930,7 +3930,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
514+@@ -3929,7 +3931,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
266515 << " echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6\n";
267516
268517 // Configure lo and eth0.
@@ -271,7 +520,7 @@ index 79ee960..d55a353 100644
271520 << " mtu " << hostEth0MTU << " up\n";
272521
273522 // NOTE: This is mostly a kernel issue: in veth_xmit() the kernel
274−@@ -3939,12 +3939,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
523+@@ -3938,12 +3940,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
275524 // when we receive a packet with a bad checksum. Disabling rx
276525 // checksum offloading ensures the TCP layer will checksum and drop
277526 // it.
@@ -288,7 +537,7 @@ index 79ee960..d55a353 100644
288537
289538 // Restrict the ephemeral ports that can be used by the container.
290539 script << "echo " << info->ephemeralPorts.lower() << " "
291−@@ -3973,19 +3973,19 @@ string PortMappingIsolatorProcess::scripts(Info* info)
540+@@ -3972,19 +3974,19 @@ string PortMappingIsolatorProcess::scripts(Info* info)
292541 }
293542
294543 // Set up filters on lo and eth0.
@@ -312,7 +561,7 @@ index 79ee960..d55a353 100644
312561 << " protocol ip"
313562 << " prio " << Priority(IP_FILTER_PRIORITY, NORMAL).get() << " u32"
314563 << " flowid ffff:0"
315−@@ -3996,7 +3996,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
564+@@ -3995,7 +3997,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
316565 foreach (const PortRange& range,
317566 getPortRanges(info->nonEphemeralPorts + info->ephemeralPorts)) {
318567 // Local traffic inside a container will not be redirected to eth0.
@@ -321,7 +570,7 @@ index 79ee960..d55a353 100644
321570 << " protocol ip"
322571 << " prio " << Priority(IP_FILTER_PRIORITY, HIGH).get() << " u32"
323572 << " flowid ffff:0"
324−@@ -4005,7 +4005,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
573+@@ -4004,7 +4006,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
325574
326575 // Traffic going to host loopback IP and ports assigned to this
327576 // container will be redirected to lo.
@@ -330,7 +579,7 @@ index 79ee960..d55a353 100644
330579 << " protocol ip"
331580 << " prio " << Priority(IP_FILTER_PRIORITY, NORMAL).get() << " u32"
332581 << " flowid ffff:0"
333−@@ -4017,14 +4017,14 @@ string PortMappingIsolatorProcess::scripts(Info* info)
582+@@ -4016,14 +4018,14 @@ string PortMappingIsolatorProcess::scripts(Info* info)
334583 }
335584
336585 // Do not forward the ICMP packet if the destination IP is self.
@@ -347,7 +596,7 @@ index 79ee960..d55a353 100644
347596 << " protocol ip"
348597 << " prio " << Priority(ICMP_FILTER_PRIORITY, NORMAL).get() << " u32"
349598 << " flowid ffff:0"
350−@@ -4033,9 +4033,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
599+@@ -4032,9 +4034,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
351600 << net::IPNetwork::LOOPBACK_V4().address() << "\n";
352601
353602 // Display the filters created on eth0 and lo.
@@ -359,7 +608,7 @@ index 79ee960..d55a353 100644
359608 << " parent " << ingress::HANDLE << "\n";
360609
361610 // If throughput limit for container egress traffic exists, use HTB
362−@@ -4047,9 +4047,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
611+@@ -4046,9 +4048,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
363612 // throughput. TBF requires other parameters such as 'burst' that
364613 // HTB already has default values for.
365614 if (egressRateLimitPerContainer.isSome()) {
@@ -371,12 +620,12 @@ index 79ee960..d55a353 100644
371620 << CONTAINER_TX_HTB_HANDLE << " classid "
372621 << CONTAINER_TX_HTB_CLASS_ID << " htb rate "
373622 << egressRateLimitPerContainer.get().bytes() * 8 << "bit\n";
374−@@ -4060,12 +4060,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
623+@@ -4059,12 +4061,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
375624 // fq_codel, which has a larger buffer and better control on
376625 // buffer bloat.
377626 // TODO(cwang): Verity that fq_codel qdisc is available.
378627- script << "tc qdisc add dev " << eth0
379−+ script << "@tC@ qdisc add dev " << eth0
628++ script << "@tc@ qdisc add dev " << eth0
380629 << " parent " << CONTAINER_TX_HTB_CLASS_ID << " fq_codel\n";
381630
382631 // Display the htb qdisc and class created on eth0.
@@ -388,11 +637,11 @@ index 79ee960..d55a353 100644
388637
389638 return script.str();
390639diff --git a/src/slave/containerizer/mesos/isolators/posix/disk.cpp b/src/slave/containerizer/mesos/isolators/posix/disk.cpp
391−index 3dfe7ad..4288666 100644
640+index db0583386..542586370 100644
392641--- a/src/slave/containerizer/mesos/isolators/posix/disk.cpp
393642+++ b/src/slave/containerizer/mesos/isolators/posix/disk.cpp
394−@@ -492,7 +492,7 @@ private:
395− // NOTE: The monitor watchdog will watch the parent process and kill
643+@@ -540,7 +540,7 @@ private:
644+ // NOTE: The supervisor childhook will watch the parent process and kill
396645 // the 'du' process in case that the parent die.
397646 Try<Subprocess> s = subprocess(
398647- "du",
@@ -400,11 +649,37 @@ index 3dfe7ad..4288666 100644
400649 command,
401650 Subprocess::PATH("/dev/null"),
402651 Subprocess::PIPE(),
652+diff --git a/src/slave/containerizer/mesos/isolators/volume/image.cpp b/src/slave/containerizer/mesos/isolators/volume/image.cpp
653+index 210e67ad0..60b3a15e4 100644
654+--- a/src/slave/containerizer/mesos/isolators/volume/image.cpp
655++++ b/src/slave/containerizer/mesos/isolators/volume/image.cpp
656+@@ -214,7 +214,7 @@ Future<Option<ContainerLaunchInfo>> VolumeImageIsolatorProcess::_prepare(
657+
658+ CommandInfo* command = launchInfo.add_pre_exec_commands();
659+ command->set_shell(false);
660+- command->set_value("mount");
661++ command->set_value("@mount@");
662+ command->add_arguments("mount");
663+ command->add_arguments("-n");
664+ command->add_arguments("--rbind");
665+diff --git a/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp b/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp
666+index 7b976d292..474dcd486 100644
667+--- a/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp
668++++ b/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp
669+@@ -240,7 +240,7 @@ Future<Option<ContainerLaunchInfo>> VolumeSandboxPathIsolatorProcess::prepare(
670+
671+ CommandInfo* command = launchInfo.add_pre_exec_commands();
672+ command->set_shell(false);
673+- command->set_value("mount");
674++ command->set_value("@mount@");
675+ command->add_arguments("mount");
676+ command->add_arguments("-n");
677+ command->add_arguments("--rbind");
403678diff --git a/src/slave/containerizer/mesos/provisioner/backends/copy.cpp b/src/slave/containerizer/mesos/provisioner/backends/copy.cpp
404−index b9f6d7a..0fcf455 100644
679+index 9c5354e5f..a73a9692e 100644
405680--- a/src/slave/containerizer/mesos/provisioner/backends/copy.cpp
406681+++ b/src/slave/containerizer/mesos/provisioner/backends/copy.cpp
407−@@ -141,7 +141,7 @@ Future<Nothing> CopyBackendProcess::_provision(
682+@@ -147,7 +147,7 @@ Future<Nothing> CopyBackendProcess::_provision(
408683 #endif // __APPLE__ || __FreeBSD__
409684
410685 Try<Subprocess> s = subprocess(
@@ -413,11 +688,20 @@ index b9f6d7a..0fcf455 100644
413688 args,
414689 Subprocess::PATH("/dev/null"),
415690 Subprocess::PATH("/dev/null"),
691+@@ -180,7 +180,7 @@ Future<bool> CopyBackendProcess::destroy(const string& rootfs)
692+ vector<string> argv{"rm", "-rf", rootfs};
693+
694+ Try<Subprocess> s = subprocess(
695+- "rm",
696++ "@rm@",
697+ argv,
698+ Subprocess::PATH("/dev/null"),
699+ Subprocess::FD(STDOUT_FILENO),
416700diff --git a/src/uri/fetchers/copy.cpp b/src/uri/fetchers/copy.cpp
417−index f095ad6..ee0c2a7 100644
701+index 2cfef5ab0..8a62f7699 100644
418702--- a/src/uri/fetchers/copy.cpp
419703+++ b/src/uri/fetchers/copy.cpp
420−@@ -88,7 +88,7 @@ Future<Nothing> CopyFetcherPlugin::fetch(
704+@@ -97,7 +97,7 @@ Future<Nothing> CopyFetcherPlugin::fetch(
421705 const vector<string> argv = {"cp", "-a", uri.path(), directory};
422706
423707 Try<Subprocess> s = subprocess(
@@ -427,10 +711,10 @@ index f095ad6..ee0c2a7 100644
427711 Subprocess::PATH("/dev/null"),
428712 Subprocess::PIPE(),
429713diff --git a/src/uri/fetchers/curl.cpp b/src/uri/fetchers/curl.cpp
430−index cc3f9ee..691d2d9 100644
714+index 7b746d619..12bbb04df 100644
431715--- a/src/uri/fetchers/curl.cpp
432716+++ b/src/uri/fetchers/curl.cpp
433−@@ -98,7 +98,7 @@ Future<Nothing> CurlFetcherPlugin::fetch(
717+@@ -107,7 +107,7 @@ Future<Nothing> CurlFetcherPlugin::fetch(
434718 };
435719
436720 Try<Subprocess> s = subprocess(
@@ -440,10 +724,10 @@ index cc3f9ee..691d2d9 100644
440724 Subprocess::PATH("/dev/null"),
441725 Subprocess::PIPE(),
442726diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp
443−index 211be6f..d7e3771 100644
727+index 3f38dddfb..fd991ee74 100644
444728--- a/src/uri/fetchers/docker.cpp
445729+++ b/src/uri/fetchers/docker.cpp
446−@@ -113,7 +113,7 @@ static Future<http::Response> curl(
730+@@ -114,7 +114,7 @@ static Future<http::Response> curl(
447731
448732 // TODO(jieyu): Kill the process if discard is called.
449733 Try<Subprocess> s = subprocess(
@@ -452,7 +736,7 @@ index 211be6f..d7e3771 100644
452736 argv,
453737 Subprocess::PATH("/dev/null"),
454738 Subprocess::PIPE(),
455−@@ -212,7 +212,7 @@ static Future<int> download(
739+@@ -213,7 +213,7 @@ static Future<int> download(
456740
457741 // TODO(jieyu): Kill the process if discard is called.
458742 Try<Subprocess> s = subprocess(
pkgs/applications/networking/cluster/mesos/rb36610.patch+4−3
@@ -1,11 +1,12 @@
11diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp
2−index ea0891e320154b85a21ed2d138c192821efae9cd..7b24c377c9a28cad91738305c273fb53a4dc7365 100644
2+index 913e233..c2917a6 100644
33--- a/src/linux/fs.cpp
44+++ b/src/linux/fs.cpp
5−@@ -19,6 +19,7 @@
5+@@ -17,6 +17,7 @@
66 #include <errno.h>
77 #include <stdio.h>
88 #include <string.h>
99+#include <syscall.h>
10−
10+
1111 #include <linux/limits.h>
12+ #include <linux/unistd.h>
pkgs/applications/networking/cluster/mesos/rb51324.patchdeleted−71
@@ -1,71 +0,0 @@
1−diff --git a/3rdparty/stout/include/stout/os/ls.hpp b/3rdparty/stout/include/stout/os/ls.hpp
2−index f8da9ef..6d549d3 100644
3−--- a/3rdparty/stout/include/stout/os/ls.hpp
4−+++ b/3rdparty/stout/include/stout/os/ls.hpp
5−@@ -18,6 +18,7 @@
6− #else
7− #include <dirent.h>
8− #endif // __WINDOWS__
9−+
10− #include <stdlib.h>
11−
12− #include <list>
13−@@ -26,8 +27,6 @@
14− #include <stout/error.hpp>
15− #include <stout/try.hpp>
16−
17−-#include <stout/os/direntsize.hpp>
18−-
19−
20− namespace os {
21−
22−@@ -36,36 +35,32 @@ inline Try<std::list<std::string>> ls(const std::string& directory)
23− DIR* dir = opendir(directory.c_str());
24−
25− if (dir == nullptr) {
26−- // Preserve `opendir` error.
27− return ErrnoError("Failed to opendir '" + directory + "'");
28− }
29−
30−- dirent* temp = (dirent*) malloc(os::dirent_size(dir));
31−-
32−- if (temp == nullptr) {
33−- // Preserve `malloc` error.
34−- ErrnoError error("Failed to allocate directory entries");
35−- closedir(dir);
36−- return error;
37−- }
38−-
39− std::list<std::string> result;
40− struct dirent* entry;
41−- int error;
42−
43−- while ((error = readdir_r(dir, temp, &entry)) == 0 && entry != nullptr) {
44−+ // Zero `errno` before starting to call `readdir`. This is necessary
45−+ // to allow us to determine when `readdir` returns an error.
46−+ errno = 0;
47−+
48−+ while ((entry = readdir(dir)) != NULL) {
49− if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
50− continue;
51− }
52− result.push_back(entry->d_name);
53− }
54−
55−- free(temp);
56−- closedir(dir);
57−+ if (errno != 0) {
58−+ // Preserve `readdir` error.
59−+ Error error = ErrnoError("Failed to read directory");
60−+ closedir(dir);
61−+ return error;
62−+ }
63−
64−- if (error != 0) {
65−- // Preserve `readdir_r` error.
66−- return ErrnoError("Failed to read directories");
67−+ if (closedir(dir) == -1) {
68−+ return ErrnoError("Failed to close directory");
69− }
70−
71− return result;
pkgs/applications/networking/cluster/mesos/rb51325.patchdeleted−157
@@ -1,157 +0,0 @@
1−diff --git a/3rdparty/stout/include/Makefile.am b/3rdparty/stout/include/Makefile.am
2−index 1f2ee85..b0b08d8 100644
3−--- a/3rdparty/stout/include/Makefile.am
4−+++ b/3rdparty/stout/include/Makefile.am
5−@@ -64,7 +64,6 @@ nobase_include_HEADERS = \
6− stout/os/chroot.hpp \
7− stout/os/close.hpp \
8− stout/os/constants.hpp \
9−- stout/os/direntsize.hpp \
10− stout/os/environment.hpp \
11− stout/os/exists.hpp \
12− stout/os/fcntl.hpp \
13−@@ -108,7 +107,6 @@ nobase_include_HEADERS = \
14− stout/os/posix/chown.hpp \
15− stout/os/posix/chroot.hpp \
16− stout/os/posix/close.hpp \
17−- stout/os/posix/direntsize.hpp \
18− stout/os/posix/exists.hpp \
19− stout/os/posix/fcntl.hpp \
20− stout/os/posix/fork.hpp \
21−@@ -134,7 +132,6 @@ nobase_include_HEADERS = \
22− stout/os/windows/bootid.hpp \
23− stout/os/windows/chroot.hpp \
24− stout/os/windows/close.hpp \
25−- stout/os/windows/direntsize.hpp \
26− stout/os/windows/exists.hpp \
27− stout/os/windows/fcntl.hpp \
28− stout/os/windows/fork.hpp \
29−diff --git a/3rdparty/stout/include/stout/os/direntsize.hpp b/3rdparty/stout/include/stout/os/direntsize.hpp
30−deleted file mode 100644
31−index 819f99a..0000000
32−--- a/3rdparty/stout/include/stout/os/direntsize.hpp
33−+++ /dev/null
34−@@ -1,26 +0,0 @@
35−-// Licensed under the Apache License, Version 2.0 (the "License");
36−-// you may not use this file except in compliance with the License.
37−-// You may obtain a copy of the License at
38−-//
39−-// http://www.apache.org/licenses/LICENSE-2.0
40−-//
41−-// Unless required by applicable law or agreed to in writing, software
42−-// distributed under the License is distributed on an "AS IS" BASIS,
43−-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44−-// See the License for the specific language governing permissions and
45−-// limitations under the License.
46−-
47−-#ifndef __STOUT_OS_DIRENTSIZE_HPP__
48−-#define __STOUT_OS_DIRENTSIZE_HPP__
49−-
50−-
51−-// For readability, we minimize the number of #ifdef blocks in the code by
52−-// splitting platform specifc system calls into separate directories.
53−-#ifdef __WINDOWS__
54−-#include <stout/os/windows/direntsize.hpp>
55−-#else
56−-#include <stout/os/posix/direntsize.hpp>
57−-#endif // __WINDOWS__
58−-
59−-
60−-#endif // __STOUT_OS_DIRENTSIZE_HPP__
61−diff --git a/3rdparty/stout/include/stout/os/posix/direntsize.hpp b/3rdparty/stout/include/stout/os/posix/direntsize.hpp
62−deleted file mode 100644
63−index 9d8f72e..0000000
64−--- a/3rdparty/stout/include/stout/os/posix/direntsize.hpp
65−+++ /dev/null
66−@@ -1,42 +0,0 @@
67−-// Licensed under the Apache License, Version 2.0 (the "License");
68−-// you may not use this file except in compliance with the License.
69−-// You may obtain a copy of the License at
70−-//
71−-// http://www.apache.org/licenses/LICENSE-2.0
72−-//
73−-// Unless required by applicable law or agreed to in writing, software
74−-// distributed under the License is distributed on an "AS IS" BASIS,
75−-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76−-// See the License for the specific language governing permissions and
77−-// limitations under the License.
78−-
79−-#ifndef __STOUT_OS_POSIX_DIRENTSIZE_HPP__
80−-#define __STOUT_OS_POSIX_DIRENTSIZE_HPP__
81−-
82−-#include <dirent.h>
83−-#include <unistd.h>
84−-
85−-
86−-namespace os {
87−-
88−-inline size_t dirent_size(DIR* dir)
89−-{
90−- // Calculate the size for a "directory entry".
91−- long name_max = fpathconf(dirfd(dir), _PC_NAME_MAX);
92−-
93−- // If we don't get a valid size, check NAME_MAX, but fall back on
94−- // 255 in the worst case ... Danger, Will Robinson!
95−- if (name_max == -1) {
96−- name_max = (NAME_MAX > 255) ? NAME_MAX : 255;
97−- }
98−-
99−- size_t name_end = (size_t) offsetof(dirent, d_name) + name_max + 1;
100−-
101−- size_t size = (name_end > sizeof(dirent) ? name_end : sizeof(dirent));
102−-
103−- return size;
104−-}
105−-
106−-} // namespace os {
107−-
108−-#endif // __STOUT_OS_POSIX_DIRENTSIZE_HPP__
109−diff --git a/3rdparty/stout/include/stout/os/windows/direntsize.hpp b/3rdparty/stout/include/stout/os/windows/direntsize.hpp
110−deleted file mode 100644
111−index 7c8c7a0..0000000
112−--- a/3rdparty/stout/include/stout/os/windows/direntsize.hpp
113−+++ /dev/null
114−@@ -1,43 +0,0 @@
115−-// Licensed under the Apache License, Version 2.0 (the "License");
116−-// you may not use this file except in compliance with the License.
117−-// You may obtain a copy of the License at
118−-//
119−-// http://www.apache.org/licenses/LICENSE-2.0
120−-//
121−-// Unless required by applicable law or agreed to in writing, software
122−-// distributed under the License is distributed on an "AS IS" BASIS,
123−-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124−-// See the License for the specific language governing permissions and
125−-// limitations under the License.
126−-
127−-#ifndef __STOUT_OS_WINDOWS_DIRENTSIZE_HPP__
128−-#define __STOUT_OS_WINDOWS_DIRENTSIZE_HPP__
129−-
130−-#include <stout/internal/windows/dirent.hpp>
131−-
132−-#include <stout/windows.hpp>
133−-
134−-
135−-namespace os {
136−-
137−-inline size_t dirent_size(DIR* dir)
138−-{
139−- // NOTE: Size calculation logic here is much simpler than on POSIX because
140−- // our implementation of `dirent` is constant-sized. In particular, on POSIX,
141−- // we usually have to calculate the maximum name size for a path before we
142−- // can alloc a correctly-size `dirent`, but on Windows, `dirent.d_name` is
143−- // always `MAX_PATH` bytes in size.
144−- //
145−- // This follows closely from the Windows standard API data structures for
146−- // manipulating and querying directories. For example, the structures
147−- // `WIN32_FIND_DATA`[1] (which in many ways is the Windows equivalent of
148−- // `dirent`) has a field `cFileName` (which is much like `d_name`) that is
149−- // also `MAX_PATH` in size.
150−- //
151−- // [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa365740(v=vs.85).aspx
152−- return sizeof(dirent);
153−-}
154−-
155−-} // namespace os {
156−-
157−-#endif // __STOUT_OS_WINDOWS_DIRENTSIZE_HPP__
pkgs/development/interpreters/python/build-python-package-setuptools.nix+1−1
@@ -53,4 +53,4 @@ in attrs // {
5353 fi
5454 ${postShellHook}
5555 '';
56−}
56+}
pkgs/development/libraries/protobuf/generic.nix+21−1
@@ -1,4 +1,4 @@
1−{ stdenv, version, src
1+{ stdenv, lib, version, src
22, autoreconfHook, zlib, gtest
33, ...
44}:
@@ -21,6 +21,26 @@ stdenv.mkDerivation rec {
2121
2222 buildInputs = [ autoreconfHook zlib ];
2323
24+ # The generated C++ code uses static initializers which mutate a global data
25+ # structure. This causes problems for an executable when:
26+ #
27+ # 1) it dynamically links to two libs, both of which contain generated C++ for
28+ # the same proto file, and
29+ # 2) the two aforementioned libs both dynamically link to libprotobuf.
30+ #
31+ # One solution is to statically link libprotobuf, that way the global
32+ # variables are not shared; in fact, this is necessary for the python Mesos
33+ # binding to not crash, as the python lib contains two C extensions which
34+ # both refer to the same proto schema.
35+ #
36+ # See: https://github.com/NixOS/nixpkgs/pull/19064#issuecomment-255082684
37+ # https://github.com/google/protobuf/issues/1489
38+ dontDisableStatic = true;
39+ configureFlags = [
40+ "CFLAGS=-fPIC"
41+ "CXXFLAGS=-fPIC"
42+ ];
43+
2444 doCheck = true;
2545
2646 meta = {
pkgs/top-level/python-packages.nix+20−3
@@ -19307,18 +19307,35 @@ in {
1930719307 '';
1930819308
1930919309 preConfigure = optionalString (versionAtLeast protobuf.version "2.6.0") ''
19310− PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
19311− PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2
19310+ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
19311+ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2
1931219312 '';
1931319313
19314− checkPhase = if versionAtLeast protobuf.version "2.6.0" then ''
19314+ preBuild = optionalString (versionAtLeast protobuf.version "2.6.0") ''
19315+ ${python}/bin/${python.executable} setup.py build_ext --cpp_implementation
19316+ '';
19317+
19318+ checkPhase = ''
19319+ runHook preCheck
19320+ '' + (if versionAtLeast protobuf.version "2.6.0" then ''
1931519321 ${python.executable} setup.py google_test --cpp_implementation
19322+ echo "sanity checking the C extension . . ."
19323+ echo "import google.protobuf.descriptor" | ${python.executable}
1931619324 '' else ''
1931719325 ${python.executable} setup.py test
19326+ '') + ''
19327+ runHook postCheck
1931819328 '';
1931919329
1932019330 installFlags = optional (versionAtLeast protobuf.version "2.6.0") "--install-option='--cpp_implementation'";
1932119331
19332+ # the _message.so isn't installed, so we'll do that manually.
19333+ # if someone can figure out a less hacky way to get the _message.so to
19334+ # install, please do replace this.
19335+ postInstall = optionalString (versionAtLeast protobuf.version "2.6.0") ''
19336+ cp -v $(find build -name "_message*") $out/${python.sitePackages}/google/protobuf/pyext
19337+ '';
19338+
1932219339 doCheck = true;
1932319340
1932419341 meta = {