-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
Makefile
74 lines (64 loc) · 3.92 KB
/
Makefile
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
70
71
72
73
74
SHELL := /bin/bash
CURDIR != pwd
MUNKIPKG := /usr/local/bin/munkipkg
PKG_ROOT := $(CURDIR)/pkg/erase-install/payload
PKG_SCRIPTS := $(CURDIR)/pkg/erase-install/scripts
PKG_BUILD := $(CURDIR)/pkg/erase-install/build
GITHUB_TOKEN_FILE := /Users/Shared/gh_token
all: build
.PHONY : build
build:
@echo
@echo "## Copying erase-install.sh into /Library/Management/erase-install"
mkdir -p "$(PKG_ROOT)/Library/Management/erase-install"
cp "$(CURDIR)/erase-install.sh" "$(PKG_ROOT)/Library/Management/erase-install/erase-install.sh"
chmod 755 "$(PKG_ROOT)/Library/Management/erase-install/erase-install.sh"
@echo
@echo "## Copying icons folder into /Library/Management/erase-install"
cp -r "$(CURDIR)/icons" "$(PKG_ROOT)/Library/Management/erase-install/"
chmod 755 "$(PKG_ROOT)/Library/Management/erase-install/icons"
chmod 644 "$(PKG_ROOT)/Library/Management/erase-install/icons/"*
mkdir -p "$(PKG_SCRIPTS)"
@echo
swiftdialog_tag=$$(awk -F '=' '/swiftdialog_tag_required="v/ {print $$NF}' $(CURDIR)/erase-install.sh | tr -d '"') ;\
echo "## Downloading swiftDialog $$swiftdialog_tag" ;\
github_token=$$(cat $(GITHUB_TOKEN_FILE)) ;\
swiftdialog_api_url="https://api.github.com/repos/swiftDialog/swiftDialog/releases" ;\
swiftdialog_url=$$(/usr/bin/curl -sL -H "Accept: application/json" "$$swiftdialog_api_url/tags/$$swiftdialog_tag" --header "Authorization: Bearer $$github_token" --header "X-GitHub-Api-Version: 2022-11-28" | /usr/bin/plutil -extract 'assets.1.browser_download_url' raw -) ;\
echo "## Downloading swiftDialog from $$swiftdialog_url" ;\
curl -L "$$swiftdialog_url" -o "/private/tmp/swiftDialog.dmg" ;\
echo "## Downloaded swiftDialog $$swiftdialog_tag" ;\
hdiutil attach -quiet -noverify -nobrowse "/private/tmp/swiftDialog.dmg" ;\
cp -r /Volumes/Dialog/Dialog.app "$(PKG_ROOT)/Library/Management/erase-install/Dialog.app"
@echo
swiftdialog_bigsur_tag=$$(awk -F '=' '/swiftdialog_bigsur_tag_required="v/ {print $$NF}' $(CURDIR)/erase-install.sh | tr -d '"') ;\
echo "## Downloading swiftDialog $$swiftdialog_bigsur_tag" ;\
github_token=$$(cat $(GITHUB_TOKEN_FILE)) ;\
swiftdialog_api_url="https://api.github.com/repos/swiftDialog/swiftDialog/releases" ;\
swiftdialog_bigsur_url=$$(/usr/bin/curl -sL -H "Accept: application/json" "$$swiftdialog_api_url/tags/$$swiftdialog_bigsur_tag" --header "Authorization: Bearer $$github_token" --header "X-GitHub-Api-Version: 2022-11-28" | /usr/bin/plutil -extract 'assets.0.browser_download_url' raw -) ;\
echo "## Downloading swiftDialog from $$swiftdialog_bigsur_url" ;\
curl -L "$$swiftdialog_bigsur_url" -o "$(PKG_SCRIPTS)/swiftDialog-bigsur.pkg" ;\
echo "## Downloaded swiftDialog $$swiftdialog_bigsur_tag"
@echo
mist_tag=$$(awk -F '=' '/mist_tag_required=/ {print $$NF}' $(CURDIR)/erase-install.sh | tr -d '"') ;\
echo "## Downloading mist-cli $$mist_tag" ;\
github_token=$$(cat $(GITHUB_TOKEN_FILE)) ;\
mist_api_url="https://api.github.com/repos/ninxsoft/mist-cli/releases" ;\
mist_url=$$(/usr/bin/curl -sL -H "Accept: application/json" "$$mist_api_url/tags/$$mist_tag" --header "Authorization: Bearer $$github_token" --header "X-GitHub-Api-Version: 2022-11-28" | awk -F '"' '/browser_download_url/ { print $$4; exit }') ;\
curl -L "$$mist_url" -o "$(PKG_SCRIPTS)/mist-cli.pkg" ;\
echo "## Downloaded mist-cli $$mist_tag"
@echo
pkg_version=$$(awk -F '=' '/^version=/ {print $$NF}' $(CURDIR)/erase-install.sh | tr -d '"') ;\
echo "## Writing version string $$pkg_version to build-info.plist" ;\
/usr/libexec/PlistBuddy -c "Set :version '$$pkg_version'" $(CURDIR)/pkg/erase-install/build-info.plist
@echo
@echo "## Making package in '$(PKG_ROOT)' directory"
cd $(CURDIR)/pkg && python3 $(MUNKIPKG) erase-install
open $(PKG_BUILD)
.PHONY : clean
clean :
@echo "Cleaning up package root"
rm -Rf "$(PKG_ROOT)/Library/Management/erase-install/"* ||:
rm $(CURDIR)/pkg/erase-install/build/*.pkg ||:
rm -Rf $(CURDIR)/pkg/erase-install/scripts/*.pkg ||:
rm -Rf $(CURDIR)/pkg/erase-install/payload ||: