Permalink
Browse files

stage0,stage1: autoconf-based build

This commit migrates rkt build process to autoconf and make toolchain
to provide the following features:

* checking for prerequisites in before the build instead of build time
* adds the following explicit configuration flags:

  --with-stage1=type      type of stage1 build one of 'src', 'coreos', 'none'
  --with-stage1-systemd-src=git-path
                          address to git repository of systemd, used in 'src'
                          build mode
  --with-stage1-systemd-version=version
                          systemd version to build
  --with-stage1-image-path
                          custom stage1 image path

* adds explicit `BUILDDIR` make variable to build outside of the source tree
* adds explicit `make stage0` and `make stage1` targets
* adds makefile macros library `makelib/lib.mk` for common build operations

Build changes
-------------

The build is now changed from the "./build" to 3 phase step:

1. First time only `./autogen.sh` step to generate configure script
2. Requried `./configure` build step to generate Makefile
3. Requried `make` bild step

Test changes
-------------

Stage 0 and stage1 tests can be now run separately.

1. `make stage0-test` executes tests for stage0 binaries
2. `make stage1-test` executes functional stage1 tests
3. `make test` executes all tests

Other changes
-------------

1. remove `aggregate` directory in favor of `BUILDDIR` external directory
2. split `aggregate` contents into individual modules in stage1 directory
3. port tests to Makefiles
4. rebase to latest master (Krzesimir Nowak)
  • Loading branch information...
klizhentas authored and krnowak committed Jun 4, 2015
1 parent 1ea8a0a commit c1f54c8310e73d1b4a66039a8476adcc78dba392
Showing with 1,342 additions and 617 deletions.
  1. +6 −0 .gitignore
  2. +2 −2 .travis.yml
  3. +145 −0 Makefile.in
  4. +2 −0 autogen.sh
  5. +0 −96 build
  6. +145 −0 configure.ac
  7. +527 −0 install-sh
  8. +93 −0 makelib/lib.mk
  9. +0 −1 stage1/.gitignore
  10. +5 −0 stage1/README.md
  11. 0 stage1/{rootfs/aggregate → aci}/aci-manifest
  12. +8 −0 stage1/aci/aci.mk
  13. +20 −0 stage1/aci/install.tpl.sh
  14. +16 −0 stage1/bash/bash.mk
  15. 0 stage1/{rootfs → }/diagexec/diagexec.c
  16. +16 −0 stage1/diagexec/diagexec.mk
  17. 0 stage1/{rootfs → }/diagexec/elf.h
  18. BIN stage1/enter/enter
  19. 0 stage1/{rootfs → }/enter/enter.c
  20. +16 −0 stage1/enter/enter.mk
  21. +12 −0 stage1/gc/gc.mk
  22. +1 −1 stage1/init/init.go
  23. +12 −0 stage1/init/init.mk
  24. +1 −1 stage1/init/pod.go
  25. 0 stage1/{rootfs → }/net-plugins/.gitignore
  26. +15 −0 stage1/net-plugins/net-plugins.mk
  27. 0 stage1/{rootfs/net → net/conf}/99-default-restricted.conf
  28. 0 stage1/{rootfs/net → net/conf}/99-default.conf
  29. +9 −0 stage1/net/net.mk
  30. 0 stage1/{rootfs → }/prepare-app/prepare-app.c
  31. +16 −0 stage1/prepare-app/prepare-app.mk
  32. +9 −0 stage1/reaper/reaper.mk
  33. 0 stage1/{rootfs/aggregate/scripts → reaper}/reaper.sh
  34. +0 −26 stage1/rootfs/Makefile
  35. +0 −12 stage1/rootfs/aggregate/Makefile
  36. +0 −15 stage1/rootfs/aggregate/aggregate.sh
  37. +0 −23 stage1/rootfs/aggregate/install.d/99misc
  38. +0 −13 stage1/rootfs/diagexec/Makefile
  39. +0 −1 stage1/rootfs/diagexec/install
  40. +0 −13 stage1/rootfs/enter/Makefile
  41. +0 −1 stage1/rootfs/enter/install
  42. +0 −9 stage1/rootfs/gc/Makefile
  43. +0 −1 stage1/rootfs/gc/install
  44. +0 −9 stage1/rootfs/init/Makefile
  45. +0 −1 stage1/rootfs/init/install
  46. +0 −11 stage1/rootfs/net-plugins/Makefile
  47. +0 −4 stage1/rootfs/net-plugins/install
  48. +0 −9 stage1/rootfs/net/Makefile
  49. +0 −3 stage1/rootfs/net/install
  50. +0 −13 stage1/rootfs/prepare-app/Makefile
  51. +0 −1 stage1/rootfs/prepare-app/install
  52. +0 −17 stage1/rootfs/usr_from_coreos/Makefile
  53. +0 −5 stage1/rootfs/usr_from_coreos/install
  54. +0 −23 stage1/rootfs/usr_from_host/Makefile
  55. +0 −120 stage1/rootfs/usr_from_src/Makefile
  56. +55 −0 stage1/stage1.mk
  57. +18 −0 stage1/units/install.tpl.sh
  58. +11 −0 stage1/units/units.mk
  59. 0 stage1/{rootfs/aggregate → units}/units/default.target
  60. 0 stage1/{rootfs/aggregate → units}/units/exit-watcher.service
  61. 0 stage1/{rootfs/aggregate → units}/units/halt.target
  62. 0 stage1/{rootfs/aggregate → units}/units/local-fs.target
  63. 0 stage1/{rootfs/aggregate → units}/units/reaper.service
  64. 0 stage1/{rootfs/aggregate → units}/units/sockets.target
  65. +1 −0 stage1/usr_from_coreos/.gitignore
  66. +3 −15 stage1/{rootfs → }/usr_from_coreos/cache.sh
  67. 0 stage1/{rootfs → }/usr_from_coreos/manifest.d/bash
  68. 0 stage1/{rootfs → }/usr_from_coreos/manifest.d/journald
  69. 0 stage1/{rootfs → }/usr_from_coreos/manifest.d/systemd
  70. +11 −17 stage1/{rootfs → }/usr_from_coreos/mkbase.sh
  71. +19 −0 stage1/usr_from_coreos/usr_from_coreos.mk
  72. +8 −0 stage1/usr_from_host/usr_from_host.mk
  73. 0 ...ootfs → }/usr_from_src/patches/v215/0001-nspawn-just-disable-registration-on-non-sysd-hosts.patch
  74. 0 stage1/{rootfs → }/usr_from_src/patches/v215/0002-nspawn-add-keep-fd-support.patch
  75. 0 stage1/{rootfs → }/usr_from_src/patches/v219/0001-nspawn-drop-sd_booted-check.patch
  76. 0 ...tfs → }/usr_from_src/patches/v219/0002-unit-don-t-add-automatic-dependencies-on-device-unit.patch
  77. 0 ...tfs → }/usr_from_src/patches/v219/0003-nspawn-only-mount-the-cgroup-root-if-it-s-not-alread.patch
  78. 0 ...tfs → }/usr_from_src/patches/v219/0004-nspawn-skip-symlink-to-a-combined-cgroup-hierarchy-i.patch
  79. 0 stage1/{rootfs → }/usr_from_src/patches/v219/0005-nspawn-close-extra-fds-before-execing-init.patch
  80. +101 −0 stage1/usr_from_src/usr_from_src.mk
  81. +0 −111 test
  82. +1 −1 tests/README.md
  83. +2 −2 tests/install-deps.sh
  84. +3 −1 tests/run-build.sh
  85. +0 −39 tests/test
  86. +33 −0 tests/tests.mk
View
@@ -7,3 +7,9 @@ tests/image/rootfs/
tests/inspect/inspect
tests/*.aci
tests/*.log
autom4te.cache
Makefile
config.log
config.status
build-*
*.test
View
@@ -14,5 +14,5 @@ install:
- go get golang.org/x/tools/cmd/vet
script:
- ./test
- ./configure
- make stage0-test SHELL="/bin/bash -v"
View
@@ -0,0 +1,145 @@
# These variables are set by configure script
# Please check configure.ac instead of modifying these manually
# package specific substitution names
package := @PACKAGE_NAME@
version := @PACKAGE_VERSION@
tarname := @PACKAGE_TARNAME@
distdir := $(tarname)-$(version)
# prefix-specific substitution names
prefix := @prefix@
exec_prefix := @exec_prefix@
bindir := @bindir@
# Setup install scripts for portability
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
# these are rkt-build specific variables
# binaries we need to build things
GO := @GOBINARY@
GOFMT := @GOFMTBINARY@
GIT := @GIT@
BASH := @BASH@
# path to rkt source code distro
ORG_PATH := github.com/coreos
REPO_PATH := $(ORG_PATH)/rkt
# [STAGE1] build settings
# selinux tags for rkt and functional tests
RKT_TAGS := -tags selinux
# stage1 build mode
RKT_STAGE1_USR_FROM := @RKT_STAGE1_USR_FROM@
# git path to systemd
RKT_STAGE1_SYSTEMD_SRC := @RKT_STAGE1_SYSTEMD_SRC@
# systemd build version
RKT_STAGE1_SYSTEMD_VER := @RKT_STAGE1_SYSTEMD_VER@
# stage1 image flags (the optional custom path linked into binary set by user)
RKT_STAGE1_IMAGE_FLAGS := @RKT_STAGE1_IMAGE_FLAGS@
# build-related directories and binaries
BUILDDIR ?= $(shell pwd)/build-$(distdir)
BUILDDIR := $(abspath $(BUILDDIR))
BINDIR := $(BUILDDIR)$(bindir)
GOPATH := $(BUILDDIR)/gopath
GOBIN := $(BUILDDIR)/bin
ACTOOL := $(GOBIN)/actool
ROOT = $(BUILDDIR)/aci/rootfs
ACI = $(BUILDDIR)/aci
# test-related variables
GO_TEST_COVER := -cover
GO_TEST_PACKAGES ?= ./...
GO_TEST_SKIP_DIRS := tests builds
GO_TEST_FUNC_ARGS ?=
# runtime variables
OSTYPE := $(shell uname)
CORES := $(shell grep -c ^processor /proc/cpuinfo)
# export variables to inner makefiles
export
# include standard librares
include makelib/*.mk
.PHONY: clean stage0 stage1 stage1-tools stage1-deps stage0-test stage1-test test
# create directories and symlinks needed to for build in advance so we should not worry about them
$(call make-dirs,$(BINDIR) $(GOPATH)/src/$(ORG_PATH) $(GOBIN) $(BUILDDIR)/src $(BUILDDIR)/install.d $(BUILDDIR)/cache $(ROOT))
$(call make-dir-symlink,$(shell pwd),$(GOPATH)/src/$(REPO_PATH))
all: stage0 stage1
# stage0 builds rkt binary
stage0:
$(info [STAGE0] building rkt binary...)
$(GO) build -o $(GOBIN)/rkt $(RKT_STAGE1_IMAGE_FLAGS) $(RKT_TAGS) $(REPO_PATH)/rkt
# stage1 builds stage1 image and associated toolset
ifneq ($(RKT_STAGE1_USR_FROM),none)
stage1: stage1-tools stage1-rootfs
else
stage1:
@echo [STAGE1] skiping stage 1 build as configured by user
endif
stage1-tools:
@echo [STAGE1] building stage1 build tools...
go build -o $(GOBIN)/actool github.com/coreos/rkt/Godeps/_workspace/src/github.com/appc/spec/actool
stage1-rootfs:
$(if $(filter-out Linux,$(OSTYPE)),$(error unsupported OS: $(OSTYPE)),@echo building on $(OSTYPE))
@echo [STAGE1] building stage1 rootfs using $(CORES) cores...
$(MAKE) -C stage1 -j $(CORES) -f stage1.mk
test: stage0-test stage1-test
@echo "[STAGE0] [STAGE1] executing tests"
stage0-test: GO_PACKAGES_WITH_TESTS := $(call go-find-packages-with-tests,$(GO_TEST_PACKAGES),$(GO_TEST_SKIP_DIRS))
stage0-test: GO_PACKAGES_ALL := $(call go-find-packages,$(GO_TEST_PACKAGES),$(GO_TEST_SKIP_DIRS))
stage0-test:
@echo [STAGE0] checking for gofmt verdict...
@set -e; \
cd $(GOPATH)/src ;\
NEED_FORMATTING="$$(GOPATH=$(GOPATH) $(GOFMT) -l $(GO_PACKAGES_WITH_TESTS))"; \
if [ -n "$$NEED_FORMATTING" ] ; then \
echo "[STAGE0] ERROR: these packages need formatting: $$NEED_FORMATTING"; \
exit 255; \
fi;
@echo [STAGE0] checking for go vet verdict...
@set -e; $(GO) vet $(GO_PACKAGES_ALL)
@set -e; echo [STAGE0] checking license headers...; \
licRes=$$( \
for file in $$(find . -type f -iname '*.go' ! -path './Godeps/*'); do \
head -n1 "$${file}" | grep -Eq "(Copyright|generated)" || echo -e " $${file}"; \
done; \
); \
if [ -n "${licRes}" ]; then \
echo -e "license header checking failed:\n${licRes}"; \
exit 255; \
fi
@echo [STAGE0] executing tests...
@$(GO) test -timeout 60s $(RKT_TAGS) $(GO_TEST_COVER) $(GO_PACKAGES_WITH_TESTS) --race
ifeq ($(filter true,$(RKT_ENABLE_FUNCTIONAL_TESTS)$(GO_TEST_STAGE1_FORCE)),true)
stage1-test: stage0 stage1
$(if $(filter-out Linux,$(OSTYPE)),$(error unsupported OS: $(OSTYPE)),@echo building on $(OSTYPE))
$(MAKE) -C tests -f tests.mk SHELL="/bin/bash -v"
else
stage1-test:
@echo [STAGE1] skipping tests in unsupported environment...
endif
clean:
rm -rf $(BUILDDIR)
View
@@ -0,0 +1,2 @@
#!/bin/bash -e
autoreconf --install
View
96 build

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit c1f54c8

Please sign in to comment.