-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (50 loc) · 1.92 KB
/
Copy pathMakefile
File metadata and controls
62 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
SHELL := /usr/bin/env bash
.SHELLFLAGS := -euo pipefail -c
ROOT_DIR := $(shell git rev-parse --show-toplevel)
# Default to latest commit if COMMIT is not specified
COMMIT ?= $(shell git ls-remote https://github.com/gardenlinux/gardenlinux.git HEAD | cut -f1)
.PHONY: prepare update clean help ccloud-help
ccloud-help:
@echo
@echo "CCloud Custom targets:"
@echo " prepare Initialize submodules and prepare environment"
@echo " update [COMMIT=<hash>] Update Garden Linux submodule (to specific commit or latest)"
@echo " clean Remove Garden Linux submodule and reset environment"
@echo
help: ccloud-help
-include gardenlinux/Makefile
prepare:
git submodule update --init --recursive
update:
# update gardenlinux submodule to specified or latest commit
cd $(ROOT_DIR)/gardenlinux && git fetch && git checkout $(COMMIT) && cd ..
git add gardenlinux
# update workflow commit references
sed -i -E 's|(gardenlinux/gardenlinux/.github/workflows/[^@]*)@[0-9a-f]{40}|\1@$(COMMIT)|g' $(ROOT_DIR)/.github/workflows/*.y*ml
# update features
mkdir -p $(ROOT_DIR)/features
for feature in $$(ls $(ROOT_DIR)/gardenlinux/features); do \
if [ -L "$(ROOT_DIR)/features/$$feature" ]; then \
rm "$(ROOT_DIR)/features/$$feature"; \
fi; \
if [ ! -e "$(ROOT_DIR)/features/$$feature" ]; then \
cd $(ROOT_DIR)/features && ln -s "../gardenlinux/features/$$feature" "$$feature"; \
fi; \
done
# update symlinks in bin folder
mkdir -p $(ROOT_DIR)/bin
for script in $$(ls -A $(ROOT_DIR)/gardenlinux/bin); do \
if [ "$$script" == "." ] || [ "$$script" == ".." ]; then \
continue; \
fi; \
if [ -L "$(ROOT_DIR)/bin/$$script" ]; then \
rm "$(ROOT_DIR)/bin/$$script"; \
fi; \
if [ ! -e "$(ROOT_DIR)/bin/$$script" ]; then \
cd $(ROOT_DIR)/bin && ln -s "../gardenlinux/bin/$$script" "$$script"; \
fi; \
done
clean:
git reset --soft
rm -rf $(ROOT_DIR)/gardenlinux
git submodule update --init --recursive