-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
executable file
·88 lines (73 loc) · 2.47 KB
/
utils.sh
File metadata and controls
executable file
·88 lines (73 loc) · 2.47 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# GRID Builder - Utility Functions and Environment Defaults
# This script provides common functions and sets default environment variables
# for the GRID build system. It works in standalone, GitHub Actions, or any CI/CD system.
# Application identity
APP_NAME="${APP_NAME:-GRID}"
APP_NAME_LC="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
BINARY_NAME="${BINARY_NAME:-GRID}"
# Repository configuration
GH_REPO_PATH="${GH_REPO_PATH:-millsydotdev/GRID-BUILDER}"
ORG_NAME="${ORG_NAME:-GRID-Editor}"
ASSETS_REPOSITORY="${ASSETS_REPOSITORY:-${GITHUB_REPOSITORY_OWNER:-millsydotdev}/binaries}"
VERSIONS_REPOSITORY="${VERSIONS_REPOSITORY:-${GITHUB_REPOSITORY_OWNER:-millsydotdev}/versions}"
# Build configuration defaults
CI_BUILD="${CI_BUILD:-yes}"
DISABLE_UPDATE="${DISABLE_UPDATE:-yes}"
SHOULD_BUILD="${SHOULD_BUILD:-yes}"
# Build toggles (default to yes if not specified)
SHOULD_BUILD_ZIP="${SHOULD_BUILD_ZIP:-yes}"
SHOULD_BUILD_REH="${SHOULD_BUILD_REH:-yes}"
SHOULD_BUILD_REH_WEB="${SHOULD_BUILD_REH_WEB:-yes}"
echo "---------- GRID Builder Utils -----------"
echo "APP_NAME=\"${APP_NAME}\""
echo "APP_NAME_LC=\"${APP_NAME_LC}\""
echo "BINARY_NAME=\"${BINARY_NAME}\""
echo "GH_REPO_PATH=\"${GH_REPO_PATH}\""
echo "ORG_NAME=\"${ORG_NAME}\""
echo "CI_BUILD=\"${CI_BUILD}\""
echo "VSCODE_QUALITY=\"${VSCODE_QUALITY:-stable}\""
echo "OS_NAME=\"${OS_NAME:-linux}\""
echo "VSCODE_ARCH=\"${VSCODE_ARCH:-x64}\""
echo "----------------------------------------"
# All common functions can be added to this file
apply_patch() {
if [[ -z "$2" ]]; then
echo applying patch: "$1";
fi
# grep '^+++' "$1" | sed -e 's#+++ [ab]/#./vscode/#' | while read line; do shasum -a 256 "${line}"; done
cp $1{,.bak}
replace "s|!!APP_NAME!!|${APP_NAME}|g" "$1"
replace "s|!!APP_NAME_LC!!|${APP_NAME_LC}|g" "$1"
replace "s|!!BINARY_NAME!!|${BINARY_NAME}|g" "$1"
replace "s|!!GH_REPO_PATH!!|${GH_REPO_PATH}|g" "$1"
replace "s|!!ORG_NAME!!|${ORG_NAME}|g" "$1"
replace "s|!!RELEASE_VERSION!!|${RELEASE_VERSION}|g" "$1"
if ! git apply --ignore-whitespace "$1"; then
echo failed to apply patch "$1" >&2
exit 1
fi
mv -f $1{.bak,}
}
exists() { type -t "$1" &> /dev/null; }
is_gnu_sed() {
sed --version &> /dev/null
}
replace() {
if is_gnu_sed; then
sed -i -E "${1}" "${2}"
else
sed -i '' -E "${1}" "${2}"
fi
}
if ! exists gsed; then
if is_gnu_sed; then
function gsed() {
sed -i -E "$@"
}
else
function gsed() {
sed -i '' -E "$@"
}
fi
fi