Skip to content

Commit

Permalink
*: add pause binary as a build target
Browse files Browse the repository at this point in the history
Take the pause binary's source code (from kubernetes/pause) and make it
part of the build setup for cri-o. This is necessary to remove the
Docker requirement for setting up the pause container, at least until
the storage API is set up so that we can make this far more flexible
(namely that we can pull the image from a registry or other transport,
even from an archive).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
  • Loading branch information
cyphar committed Oct 2, 2016
1 parent 37affbf commit 1313f0d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
/ocic
conmon/conmon
conmon/conmon.o
pause/pause
pause/pause.o
/docs/ocid.8
vendor/src/github.com/kubernetes-incubator/cri-o
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ ${OCID_LINK}:
conmon:
make -C $@

pause:
make -C $@

ocid: ${OCID_LINK}
go build -o ocid ./cmd/server/

Expand All @@ -44,6 +47,7 @@ clean:
rm -f ocic ocid
rm -f ${OCID_LINK}
rm -f conmon/conmon.o conmon/conmon
rm -f pause/pause.o pause/pause
rm -f docs/*.1 docs/*.8
find . -name \*~ -delete
find . -name \#\* -delete
Expand All @@ -64,7 +68,7 @@ integration: ocidimage
localintegration: binaries
./test/test_runner.sh ${TESTFLAGS}

binaries: ${OCID_LINK} ocid ocic conmon
binaries: ${OCID_LINK} ocid ocic conmon pause

MANPAGES_MD = $(wildcard docs/*.md)

Expand All @@ -82,12 +86,13 @@ install: binaries docs
install -D -m 755 ocid ${INSTALLDIR}/ocid
install -D -m 755 ocic ${INSTALLDIR}/ocic
install -D -m 755 conmon/conmon $(PREFIX)/libexec/ocid/conmon
install -D -m 755 pause/pause $(PREFIX)/libexec/ocid/pause
install -d $(PREFIX)/share/man/man8
install -m 644 $(basename $(MANPAGES_MD)) $(PREFIX)/share/man/man8

uninstall:
rm -f ${INSTALLDIR}/{ocid,ocic}
rm -f $(PREFIX)/libexec/ocid/conmon
rm -f $(PREFIX)/libexec/ocid/{conmon,pause}
for i in $(basename $(MANPAGES_MD)); do \
rm -f $(PREFIX)/share/man/man8/$$(basename $${i}); \
done
Expand Down Expand Up @@ -118,13 +123,14 @@ install.tools: .install.gitvalidation .install.gometalinter .install.md2man

.PHONY: \
binaries \
clean \
conmon \
default \
docs \
ocid \
ocic \
clean \
lint \
help \
install \
lint \
ocic \
ocid \
pause \
uninstall
3 changes: 3 additions & 0 deletions pause/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.container-*
/.push-*
/bin
13 changes: 13 additions & 0 deletions pause/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
src = $(wildcard *.c)
obj = $(src:.c=.o)

override LIBS +=
override CFLAGS += -Os -Wall -Wextra -static

pause: $(obj)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
strip $@

.PHONY: clean
clean:
rm -f $(obj) pause
36 changes: 36 additions & 0 deletions pause/pause.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static void sigdown(int signo) {
psignal(signo, "shutting down, got signal");
exit(0);
}

int main() {
if (signal(SIGINT, sigdown) == SIG_ERR)
return 1;
if (signal(SIGTERM, sigdown) == SIG_ERR)
return 2;
signal(SIGKILL, sigdown);
for (;;) pause();
fprintf(stderr, "error: infinite loop terminated\n");
return 42;
}

0 comments on commit 1313f0d

Please sign in to comment.