-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftware.mk
69 lines (68 loc) · 2.54 KB
/
software.mk
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
63
64
65
66
67
68
69
#
# This is a GNU Make include for 'etinker'.
#
# Copyright (C) 2018-2025, Derald D. Woods <[email protected]>
#
# This file is part of the Embedded Tinkerer Sandbox, and is made
# available under the terms of the GNU General Public License version 3.
#
# check for existence of a source tree
define software-check
@printf "\n***** [$(ET_BOARD)][$(ET_BOARD_TYPE)] USING $(ET_SOFTWARE_DIR)/$1 for $2 *****\n\n"
@if ! [ -d $(ET_SOFTWARE_DIR)/$1 ] || [ "fetch" = "$3" ]; then \
mkdir -p $(ET_SOFTWARE_DIR); \
(cd $(ET_SOFTWARE_DIR) && \
export et_url="$(shell $(ET_SCRIPTS_DIR)/software $(ET_BOARD) $2-url)"; \
export et_ref="$(shell $(ET_SCRIPTS_DIR)/software $(ET_BOARD) $2-ref)"; \
printf "***** [$(ET_BOARD)][$(ET_BOARD_TYPE)] et_url=$$et_url *****\n"; \
printf "***** [$(ET_BOARD)][$(ET_BOARD_TYPE)] et_ref=$$et_ref *****\n\n"; \
case $2 in \
toolchain | bootloader* | kernel* | rootfs) \
if [ -d $1 ]; then \
(cd $1 && git restore . && git clean -df && git fetch --all && git fetch --tags); \
else \
git clone $$et_url $1; \
fi; \
if ! [ -d $1 ]; then \
printf "\n***** [$(ET_BOARD)][$(ET_BOARD_TYPE)] ERROR MISSING $(ET_SOFTWARE_DIR)/$1 DIRECTORY *****\n\n"; \
exit 2; \
fi; \
(cd $1 && git checkout $$et_ref && (git status | grep -oq HEAD) || git pull) || exit 2; \
if [ -d $(ET_PATCH_DIR)/$(notdir $1) ]; then \
(cd $1 && \
git branch -D patched -f $(ET_NOERR); \
git switch -c patched; \
for f in $(shell ls $(ET_PATCH_DIR)/$(notdir $1)/*.patch $(ET_NOERR)); do \
patch -p1 -i $$f; \
done && \
git add . && \
git commit -a -m "etinker: patches applied @ $$et_ref") || exit 2; \
fi; \
;; \
*) \
if [ -d $2 ]; then \
(cd $2 && git restore . && git clean -df && git fetch --all && git fetch --tags); \
else \
git clone $$et_url $2; \
fi; \
if ! [ -d $2 ]; then \
printf "\n***** [$(ET_BOARD)][$(ET_BOARD_TYPE)] ERROR MISSING $(ET_SOFTWARE_DIR)/$2 DIRECTORY *****\n\n"; \
exit 2; \
fi; \
(cd $2 && git checkout $$et_ref && (git status | grep -oq HEAD) || git pull) || exit 2; \
if [ -d $(ET_PATCH_DIR)/$(notdir $2) ]; then \
(cd $2 && \
git branch -D patched -f $(ET_NOERR); \
git switch -c patched; \
for f in $(shell ls $(ET_PATCH_DIR)/$(notdir $2)/*.patch $(ET_NOERR)); do \
patch -p1 -i $$f; \
done && \
git add . && \
git commit -a -m "etinker: patches applied @ $$et_ref") || exit 2; \
fi; \
;; \
esac; \
) || exit 2; \
printf "\n"; \
fi
endef