Skip to content

Commit 5944d4d

Browse files
authored
Merge pull request #516 from vvoland/diff-result
Makefile: extract diff to a separate script
2 parents bedc5d6 + bcfa2f1 commit 5944d4d

2 files changed

Lines changed: 60 additions & 12 deletions

File tree

Makefile

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,11 @@ endif
7171
$(AWS) cloudfront create-invalidation --distribution-id $(CF_DISTRIBUTION_ID) --paths '/*'
7272

7373
.PHONY: diff
74-
diff: TMP_DIR=/tmp
75-
diff: CHANNEL=stable
76-
diff: SUBDOMAIN=$(if $(filter test,$(CHANNEL)),test,$(if $(filter stable,$(CHANNEL)),get,$(error Invalid CHANNEL: $(CHANNEL))))
7774
diff: build/$(CHANNEL)/install.sh build/$(CHANNEL)/rootless-install.sh
78-
curl -sfSL https://$(SUBDOMAIN).docker.com -o $(TMP_DIR)/install.sh
79-
80-
echo "# Diff $(CHANNEL) install.sh"
81-
diff --color=always -u build/$(CHANNEL)/install.sh $(TMP_DIR)/install.sh || true
82-
83-
ifeq ($(CHANNEL),stable)
84-
curl -sfSL https://$(SUBDOMAIN).docker.com/rootless -o $(TMP_DIR)/rootless-install.sh
85-
echo "# Diff $(CHANNEL) rootless-install.sh"
86-
diff --color=always -u build/$(CHANNEL)/rootless-install.sh $(TMP_DIR)/rootless-install.sh || true
75+
ifeq ($(CHANNEL),)
76+
$(error CHANNEL is empty.)
8777
endif
78+
./diff.sh $(CHANNEL) || true
8879

8980
.PHONY: clean
9081
clean:

diff.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ]; then
4+
echo "usage: $0 <stable|test>" >&2
5+
exit 2
6+
fi
7+
8+
CHANNEL="$1"
9+
10+
# Determine subdomain based on channel
11+
case "$CHANNEL" in
12+
test)
13+
SUBDOMAIN="test"
14+
;;
15+
stable)
16+
SUBDOMAIN="get"
17+
;;
18+
*)
19+
echo "Error: Invalid CHANNEL: $CHANNEL" >&2
20+
exit 1
21+
;;
22+
esac
23+
24+
set -euo pipefail
25+
26+
DIFF_FOUND=0
27+
28+
if [[ ! -f "build/$CHANNEL/install.sh" ]]; then
29+
echo "Error: build/$CHANNEL/install.sh not found" >&2
30+
exit 1
31+
fi
32+
33+
if [[ "$CHANNEL" == "stable" ]] && [[ ! -f "build/$CHANNEL/rootless-install.sh" ]]; then
34+
echo "Error: build/$CHANNEL/rootless-install.sh not found" >&2
35+
exit 1
36+
fi
37+
38+
TMP_DIR=$(mktemp -d)
39+
40+
# Download and compare install.sh
41+
curl -sfSL "https://$SUBDOMAIN.docker.com" -o "$TMP_DIR/install.sh"
42+
43+
echo "# Diff $CHANNEL install.sh"
44+
if ! diff --color=always -u "$TMP_DIR/install.sh" "build/$CHANNEL/install.sh"; then
45+
DIFF_FOUND=1
46+
fi
47+
48+
# For stable channel, also compare rootless-install.sh
49+
if [[ "$CHANNEL" == "stable" ]]; then
50+
curl -sfSL "https://$SUBDOMAIN.docker.com/rootless" -o "$TMP_DIR/rootless-install.sh"
51+
echo "# Diff $CHANNEL rootless-install.sh"
52+
if ! diff --color=always -u "$TMP_DIR/rootless-install.sh" "build/$CHANNEL/rootless-install.sh"; then
53+
DIFF_FOUND=1
54+
fi
55+
fi
56+
57+
exit $DIFF_FOUND

0 commit comments

Comments
 (0)