-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
453 additions
and
1,102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!entrypoint.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
OUT_ISO_DIR=${CONTAINER_OUT_DIR} | ||
|
||
# build/iso | ||
ISO_NAME=archlinux-cloud | ||
ISO_VERSION=$(date +%Y.%m.%d) | ||
ISO_LABEL=ARCH_$(date +%Y%m%d) | ||
ISO_PUBLISHER='Tatsuya Kitagawa <https://github.com/t13a/archlinux-cloud>' | ||
ISO_APPLICATION='Arch Linux Cloud Installation Image' | ||
ISO_INSTALL_DIR= | ||
|
||
# build/profile | ||
PROFILE_SRC_DIR=/usr/share/archiso/configs/releng | ||
PROFILE_CHECKSUM=${CONTAINER_BUILD_DIR}/profile/checksum | ||
PROFILE_MOD_DIR=${CONTAINER_BUILD_DIR}/profile/mods | ||
|
||
# build/repo | ||
REPO_NAME=custom | ||
REPO_PKGS_FILE=${CONTAINER_BUILD_DIR}/repo/packages | ||
|
||
# test/cidata | ||
CIDATA_TEMPLATE_DIR=${CONTAINER_TEST_DIR}/cidata | ||
|
||
# test/e2e | ||
E2E_CASE_DIR=${CONTAINER_TEST_DIR}/e2e | ||
QEMU_SMP=1 | ||
QEMU_MEM=1024 | ||
BOOT_TIMEOUT_SECS=1200 | ||
CASE_TIMEOUT_SECS=120 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
out | ||
work | ||
.env | ||
/out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM archlinux | ||
|
||
RUN pacman -Syu --noconfirm \ | ||
&& pacman -S --needed --noconfirm \ | ||
base-devel \ | ||
archiso \ | ||
git \ | ||
&& pacman -Scc --noconfirm | ||
|
||
COPY entrypoint.sh / | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,78 @@ | ||
OUT_DIR := out | ||
SRC_DIR := src | ||
PRINT = @echo -e "\e[1;34m"$(1)"\e[0m" | ||
|
||
BUILD_DIR := build | ||
TEST_DIR := test | ||
WORK_DIR := work | ||
OUT_DIR := out | ||
|
||
ISO_NAME := archlinux-cloud | ||
ISO_VERSION := $(shell date +%Y.%m.%d) | ||
export CONTAINER_BUILD_DIR := /build | ||
export CONTAINER_TEST_DIR := /test | ||
export CONTAINER_OUT_DIR := /out | ||
export CONTAINER_DOTENV := /.env | ||
export CONTAINER_DOTENV_SCRIPT := /dotenv.sh | ||
|
||
DOCKER_TAG = archiso-cloud-$(1) | ||
DOCKER_RUN = docker run \ | ||
-e ISO_NAME=$(ISO_NAME) \ | ||
-e ISO_VERSION=$(ISO_VERSION) \ | ||
-e ISO_LABEL=$(ISO_LABEL) \ | ||
-e PUBLISHER=$(PUBLISHER) \ | ||
-e APPLICATION=$(APPLICATION) \ | ||
-e INSTALL_DIR=$(INSTALL_DIR) \ | ||
-e WAIT_TIMEOUT_SECS=$(WAIT_TIMEOUT_SECS) \ | ||
-e TEST_TIMEOUT_SECS=$(TEST_TIMEOUT_SECS) \ | ||
CONTAINER_RUN = docker run \ | ||
-e BUILD_DIR=$(CONTAINER_BUILD_DIR) \ | ||
-e TEST_DIR=$(CONTAINER_TEST_DIR) \ | ||
-e OUT_DIR=$(CONTAINER_OUT_DIR) \ | ||
-e DOTENV=$(CONTAINER_DOTENV) \ | ||
-e DOTENV_SCRIPT=$(CONTAINER_DOTENV_SCRIPT) \ | ||
-e PUID=$(shell id -u) \ | ||
-e PGID=$(shell id -g) \ | ||
-e PUSER=$(1) \ | ||
-i \ | ||
--privileged \ | ||
--rm \ | ||
-t \ | ||
--tmpfs=/run/shm \ | ||
--tmpfs=/tmp:exec \ | ||
-v $(abspath $(2)):$(3) \ | ||
-v $(abspath $(WORK_DIR)):/work \ | ||
-v $(abspath $(OUT_DIR)):/out \ | ||
$(DOCKER_RUN_EXTRA_OPTS) \ | ||
$(call DOCKER_TAG,$(1)) | ||
-v "$(abspath $(DOTENV)):$(CONTAINER_DOTENV)" \ | ||
-v "$(abspath $(DOTENV_SCRIPT)):$(CONTAINER_DOTENV_SCRIPT)" \ | ||
-v "$(abspath $(2)):$(3)" \ | ||
-v "$(abspath $(OUT_DIR)):$(CONTAINER_OUT_DIR)" \ | ||
-w "$(3)" \ | ||
$(call CONTAINER_IMAGE,$(1)) \ | ||
$(CONTAINER_DOTENV_SCRIPT) | ||
|
||
BUILD = $(call DOCKER_RUN,builder,$(SRC_DIR),/src) | ||
RUN = $(call DOCKER_RUN,runner,$(TEST_DIR),/test) | ||
INIT_FILES := | ||
CLEAN_FILES := $(OUT_DIR) | ||
|
||
PRINT = @echo -e "\e[1;34m"$(1)"\e[0m" | ||
include *.mk | ||
|
||
.DEFAULT_GOAL := all | ||
.PHONY: all | ||
all: build | ||
all: init build test | ||
|
||
.PHONY: build | ||
build: build-all | ||
.PHON: init | ||
init: $(INIT_FILES) | ||
|
||
.PHONY: test | ||
test: run-all | ||
.PHONY: build | ||
build: build/all | ||
|
||
.PHONY: build-% | ||
build-exec: DOCKER_RUN_EXTRA_OPTS = -it | ||
build-%: builder $(OUT_DIR) $(WORK_DIR) | ||
$(call PRINT,Starting builder...) | ||
$(BUILD) make $(@:build-%=%) | ||
$(call PRINT,Stopped builder) | ||
.PHONY: build/% | ||
build/%: build-container $(OUT_DIR) | ||
$(call PRINT,Starting build container...) | ||
$(call CONTAINER_RUN,build,$(BUILD_DIR),$(CONTAINER_BUILD_DIR)) make $(MAKEFLAGS) $* | ||
$(call PRINT,Stopped build container) | ||
|
||
.PHONY: run-% | ||
run-exec: DOCKER_RUN_EXTRA_OPTS = -it | ||
run-%: runner $(OUT_DIR) $(WORK_DIR) | ||
$(call PRINT,Starting runner...) | ||
$(RUN) make $(@:run-%=%) | ||
$(call PRINT,Stopped runner) | ||
.PHONY: test | ||
test: test/all | ||
|
||
.PHONY: builder runner | ||
builder runner: | ||
$(call PRINT,Building Docker image $(call DOCKER_TAG,$@)...) | ||
docker build -t $(call DOCKER_TAG,$@) $@ | ||
.PHONY: test/% | ||
test/%: test-container $(OUT_DIR) | ||
$(call PRINT,Starting test container...) | ||
$(call CONTAINER_RUN,test,$(TEST_DIR),$(CONTAINER_TEST_DIR)) make $(MAKEFLAGS) $* | ||
$(call PRINT,Stopped test container) | ||
|
||
$(OUT_DIR) $(WORK_DIR): | ||
$(call PRINT,Creating host directory $(@)...) | ||
mkdir -p $@ | ||
$(OUT_DIR): | ||
$(call PRINT,'Creating directory "$@"...') | ||
mkdir -p $(@) | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(OUT_DIR) $(WORK_DIR) | ||
docker rmi -f $(call DOCKER_TAG,builder) $(call DOCKER_TAG,runner) | ||
$(call PRINT,Cleaning...) | ||
docker run \ | ||
--rm \ | ||
-v "$(abspath .):/work" \ | ||
-w /work \ | ||
archlinux \ | ||
rm -rf $(CLEAN_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
PRINT = @echo -e "\e[1;34m"[build] $(1)"\e[0m" | ||
|
||
CLEAN_FILES := | ||
|
||
include *.mk | ||
|
||
.DEFAULT_GOAL := all | ||
.PHONY: all | ||
all: iso | ||
|
||
.PHONY: clean | ||
clean: | ||
sudo rm -rf $(CLEAN_FILES) | ||
|
||
.PHONY: exec | ||
exec: | ||
bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export OUT_ISO_WORK_DIR := $(OUT_DIR)/iso | ||
export OUT_ISO := $(OUT_ISO_DIR)/$(ISO_NAME)-$(ISO_VERSION)-x86_64.iso | ||
|
||
CLEAN_FILES += \ | ||
$(OUT_ISO_WORK_DIR) \ | ||
$(OUT_ISO) | ||
|
||
.PHONY: iso | ||
iso: $(OUT_ISO) | ||
|
||
$(OUT_ISO): profile repo | ||
$(call PRINT,Building ISO image...) | ||
sudo $(OUT_PROFILE_DIR)/build.sh \ | ||
-N $(ISO_NAME) \ | ||
-V $(ISO_VERSION) \ | ||
$(if $(ISO_LABEL),-L "$(ISO_LABEL)") \ | ||
$(if $(ISO_PUBLISHER),-P "$(ISO_PUBLISHER)") \ | ||
$(if $(ISO_APPLICATION),-A "$(ISO_APPLICATION)") \ | ||
$(if $(ISO_INSTALL_DIR),-D "$(ISO_INSTALL_DIR)") \ | ||
-w $(OUT_ISO_WORK_DIR) \ | ||
-o $(OUT_ISO_DIR) \ | ||
-v | ||
$(call PRINT,Succeessfully built ISO image) | ||
|
Oops, something went wrong.