From 6d2be8e324381187e9d8e2f73a8acbf8a70bcbb3 Mon Sep 17 00:00:00 2001 From: Leonid Plyushch Date: Sun, 14 Jul 2019 12:52:45 +0300 Subject: [PATCH] new package: runc --- root-packages/runc/build.sh | 24 +++++++++++ ...libcontainer-nsenter-cloned_binary.c.patch | 43 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 root-packages/runc/build.sh create mode 100644 root-packages/runc/libcontainer-nsenter-cloned_binary.c.patch diff --git a/root-packages/runc/build.sh b/root-packages/runc/build.sh new file mode 100644 index 000000000..24808b422 --- /dev/null +++ b/root-packages/runc/build.sh @@ -0,0 +1,24 @@ +TERMUX_PKG_HOMEPAGE=https://www.opencontainers.org/ +TERMUX_PKG_DESCRIPTION="A tool for spawning and running containers according to the OCI specification" +TERMUX_PKG_LICENSE="Apache-2.0" +TERMUX_PKG_MAINTAINER="Leonid Plyushch " +TERMUX_PKG_VERSION=1.0.0-rc8 +TERMUX_PKG_SRCURL=https://github.com/opencontainers/runc/archive/v${TERMUX_PKG_VERSION}.tar.gz +TERMUX_PKG_SHA256=efe4ff9bbe49b19074346d65c914d809c0a3e90d062ea9619fe240f931f0b700 +TERMUX_PKG_DEPENDS="libseccomp" + +termux_step_make() { + termux_setup_golang + + export GOPATH="${PWD}/go" + + mkdir -p "${GOPATH}/src/github.com/opencontainers" + ln -sf "${TERMUX_PKG_SRCDIR}" "${GOPATH}/src/github.com/opencontainers/runc" + + cd "${GOPATH}/src/github.com/opencontainers/runc" && make +} + +termux_step_make_install() { + cd "${GOPATH}/src/github.com/opencontainers/runc" + install -Dm755 runc "${TERMUX_PREFIX}/bin/runc" +} diff --git a/root-packages/runc/libcontainer-nsenter-cloned_binary.c.patch b/root-packages/runc/libcontainer-nsenter-cloned_binary.c.patch new file mode 100644 index 000000000..b40f5e328 --- /dev/null +++ b/root-packages/runc/libcontainer-nsenter-cloned_binary.c.patch @@ -0,0 +1,43 @@ +diff -uNr runc-1.0.0-rc8/libcontainer/nsenter/cloned_binary.c runc-1.0.0-rc8.mod/libcontainer/nsenter/cloned_binary.c +--- runc-1.0.0-rc8/libcontainer/nsenter/cloned_binary.c 2019-04-25 00:48:25.000000000 +0300 ++++ runc-1.0.0-rc8.mod/libcontainer/nsenter/cloned_binary.c 2019-07-13 22:18:07.323813978 +0300 +@@ -489,6 +489,30 @@ + /* Get cheap access to the environment. */ + extern char **environ; + ++// __procfdname implementation from musl libc. ++static void musl_procfdname(char *buf, unsigned fd) ++{ ++ unsigned i, j; ++ for (i=0; (buf[i] = "/proc/self/fd/"[i]); i++); ++ if (!fd) { ++ buf[i] = '0'; ++ buf[i+1] = 0; ++ return; ++ } ++ for (j=fd; j; j/=10, i++); ++ buf[i] = 0; ++ for (; fd; fd/=10) buf[--i] = '0' + fd%10; ++} ++ ++// fexecve implementation based on one from musl libc. ++static int musl_fexecve(int fd, char *const argv[], char *const envp[]) { ++ char buf[15 + 3*sizeof(int)]; ++ musl_procfdname(buf, fd); ++ execve(buf, argv, envp); ++ if (errno == ENOENT) errno = EBADF; ++ return -1; ++} ++ + int ensure_cloned_binary(void) + { + int execfd; +@@ -509,7 +533,7 @@ + if (putenv(CLONED_BINARY_ENV "=1")) + goto error; + +- fexecve(execfd, argv, environ); ++ musl_fexecve(execfd, argv, environ); + error: + close(execfd); + return -ENOEXEC;