Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #159 from marcov/upmakefile
Browse files Browse the repository at this point in the history
Makefile: update targets to better track build artifacts
  • Loading branch information
jodh-intel authored Sep 7, 2018
2 parents 62aab2f + 344a37c commit 93ad049
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
34 changes: 26 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
MK_DIR :=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

DISTRO ?= centos
DISTRO_ROOTFS := "$(PWD)/$(DISTRO)_rootfs"
DISTRO_ROOTFS := $(PWD)/$(DISTRO)_rootfs
DISTRO_ROOTFS_MARKER := .$(shell basename $(DISTRO_ROOTFS)).done
IMAGE := kata-containers.img
INITRD_IMAGE := kata-containers-initrd.img
IMG_SIZE=500
AGENT_INIT ?= no

Expand All @@ -16,28 +19,43 @@ COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
VERSION_COMMIT := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION))

all: rootfs image initrd
rootfs:
.PHONY: all
all: image initrd

.PHONY: rootfs
rootfs: $(DISTRO_ROOTFS_MARKER)

$(DISTRO_ROOTFS_MARKER):
@echo Creating rootfs based on "$(DISTRO)"
"$(MK_DIR)/rootfs-builder/rootfs.sh" -o $(VERSION_COMMIT) -r "$(DISTRO_ROOTFS)" "$(DISTRO)"
"$(MK_DIR)/rootfs-builder/rootfs.sh" -o $(VERSION_COMMIT) -r $(DISTRO_ROOTFS) $(DISTRO)
touch $@

image: rootfs image-only
.PHONY: image
image: $(IMAGE)

image-only:
$(IMAGE): rootfs
@echo Creating image based on "$(DISTRO_ROOTFS)"
"$(MK_DIR)/image-builder/image_builder.sh" -s "$(IMG_SIZE)" "$(DISTRO_ROOTFS)"

initrd: rootfs initrd-only
.PHONY: initrd
initrd: $(INITRD_IMAGE)

initrd-only:
$(INITRD_IMAGE): rootfs
@echo Creating initrd image based on "$(DISTRO_ROOTFS)"
"$(MK_DIR)/initrd-builder/initrd_builder.sh" "$(DISTRO_ROOTFS)"

.PHONY: test
test:
"$(MK_DIR)/tests/test_images.sh" "$(DISTRO)"

.PHONY: test-image-only
test-image-only:
"$(MK_DIR)/tests/test_images.sh" --test-images-only "$(DISTRO)"

.PHONY: test-initrd-only
test-initrd-only:
"$(MK_DIR)/tests/test_images.sh" --test-initrds-only "$(DISTRO)"

.PHONY: clean
clean:
rm -rf $(DISTRO_ROOTFS_MARKER) $(DISTRO_ROOTFS) $(IMAGE) $(INITRD_IMAGE)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,21 @@ further details, see
#### Image with systemd as init

```
$ sudo -E PATH=$PATH make USE_DOCKER=true image-only
$ sudo -E PATH=$PATH make USE_DOCKER=true image
```

#### Image with the agent as init

```
$ sudo -E PATH=$PATH make USE_DOCKER=true AGENT_INIT=yes image-only
$ sudo -E PATH=$PATH make USE_DOCKER=true AGENT_INIT=yes image
```

### Initrd creation

To create an initrd from the already-created rootfs with the agent acting as the init daemon:

```
$ sudo -E PATH=$PATH make AGENT_INIT=yes initrd-only
$ sudo -E PATH=$PATH make AGENT_INIT=yes initrd
```

For further details,
Expand Down

0 comments on commit 93ad049

Please sign in to comment.