-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
package_linux_reh.sh
executable file
·225 lines (178 loc) · 6.63 KB
/
package_linux_reh.sh
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -ex
if [[ "${CI_BUILD}" == "no" ]]; then
exit 1
fi
APP_NAME_LC="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
mkdir -p assets
tar -xzf ./vscode.tar.gz
cd vscode || { echo "'vscode' dir not found"; exit 1; }
GLIBC_VERSION="2.17"
GLIBCXX_VERSION="3.4.22"
NODE_VERSION="16.20.2"
if [[ "${VSCODE_ARCH}" == "x64" ]]; then
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:centos7-devtoolset8-${VSCODE_ARCH}"
elif [[ "${VSCODE_ARCH}" == "arm64" ]]; then
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:centos7-devtoolset8-${VSCODE_ARCH}"
export VSCODE_SKIP_SYSROOT=1
export USE_GNUPP2A=1
elif [[ "${VSCODE_ARCH}" == "armhf" ]]; then
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-arm32v7"
export VSCODE_SKIP_SYSROOT=1
export USE_GNUPP2A=1
elif [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
GLIBC_VERSION="2.28"
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:bionic-devtoolset-ppc64le"
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export VSCODE_SYSROOT_REPOSITORY='VSCodium/vscode-linux-build-agent'
export VSCODE_SYSROOT_VERSION='20240129-253798'
export USE_GNUPP2A=1
elif [[ "${VSCODE_ARCH}" == "riscv64" ]]; then
# Unofficial RISC-V nodejs builds doesn't provide v16.x
# Node 18 is buggy so use 20 here for now: https://github.com/VSCodium/vscodium/issues/2060
NODE_VERSION="20.16.0"
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:focal-devtoolset-riscv64"
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export VSCODE_SKIP_SETUPENV=1
export VSCODE_NODEJS_SITE='https://unofficial-builds.nodejs.org'
# part of the url before '/v${nodeVersion}/node-v${nodeVersion}-${platform}-${arch}.tar.gz'
export VSCODE_NODEJS_URLROOT='/download/release'
elif [[ "${VSCODE_ARCH}" == "loong64" ]]; then
NODE_VERSION="20.16.0"
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:trixie-devtoolset-loong64"
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export VSCODE_SKIP_SETUPENV=1
export VSCODE_NODEJS_SITE='https://unofficial-builds.nodejs.org'
export VSCODE_NODEJS_URLROOT='/download/release'
elif [[ "${VSCODE_ARCH}" == "s390x" ]]; then
GLIBC_VERSION="2.28"
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:focal-devtoolset-s390x"
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export VSCODE_SYSROOT_REPOSITORY='VSCodium/vscode-linux-build-agent'
export VSCODE_SYSROOT_VERSION='20241108'
fi
export VSCODE_PLATFORM='linux'
export VSCODE_SKIP_NODE_VERSION_CHECK=1
export VSCODE_SYSROOT_PREFIX="-glibc-${GLIBC_VERSION}"
VSCODE_HOST_MOUNT="$( pwd )"
export VSCODE_HOST_MOUNT
export VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME
sed -i "/target/s/\"20.*\"/\"${NODE_VERSION}\"/" remote/.npmrc
if [[ "${NODE_VERSION}" != 16* ]]; then
if [[ -f "../patches/linux/reh/node16.patch" ]]; then
mv "../patches/linux/reh/node16.patch" "../patches/linux/reh/node16.patch.no"
fi
fi
if [[ -d "../patches/linux/reh/" ]]; then
for file in "../patches/linux/reh/"*.patch; do
if [[ -f "${file}" ]]; then
echo applying patch: "${file}";
if ! git apply --ignore-whitespace "${file}"; then
echo failed to apply patch "${file}" >&2
exit 1
fi
fi
done
fi
if [[ -d "../patches/linux/reh/${VSCODE_ARCH}/" ]]; then
for file in "../patches/linux/reh/${VSCODE_ARCH}/"*.patch; do
if [[ -f "${file}" ]]; then
echo applying patch: "${file}";
if ! git apply --ignore-whitespace "${file}"; then
echo failed to apply patch "${file}" >&2
exit 1
fi
fi
done
fi
if [[ -n "${USE_GNUPP2A}" ]]; then
INCLUDES=$(cat <<EOF
{
"target_defaults": {
"conditions": [
["OS=='linux'", {
'cflags_cc!': [ '-std=gnu++20' ],
'cflags_cc': [ '-std=gnu++2a' ],
}]
]
}
}
EOF
)
if [ ! -d "$HOME/.gyp" ]; then
mkdir -p "$HOME/.gyp"
fi
echo "${INCLUDES}" > "$HOME/.gyp/include.gypi"
fi
for i in {1..5}; do # try 5 times
npm ci --prefix build && break
if [[ $i == 3 ]]; then
echo "Npm install failed too many times" >&2
exit 1
fi
echo "Npm install failed $i, trying again..."
done
if [[ -z "${VSCODE_SKIP_SETUPENV}" ]]; then
if [[ -n "${VSCODE_SKIP_SYSROOT}" ]]; then
source ./build/azure-pipelines/linux/setup-env.sh --skip-sysroot
else
source ./build/azure-pipelines/linux/setup-env.sh
fi
fi
for i in {1..5}; do # try 5 times
npm ci && break
if [[ $i == 3 ]]; then
echo "Npm install failed too many times" >&2
exit 1
fi
echo "Npm install failed $i, trying again..."
done
node build/azure-pipelines/distro/mixin-npm
export VSCODE_NODE_GLIBC="-glibc-${GLIBC_VERSION}"
if [[ "${SHOULD_BUILD_REH}" != "no" ]]; then
echo "Building REH"
yarn gulp minify-vscode-reh
yarn gulp "vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
EXPECTED_GLIBC_VERSION="${GLIBC_VERSION}" EXPECTED_GLIBCXX_VERSION="${GLIBCXX_VERSION}" SEARCH_PATH="../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}" ./build/azure-pipelines/linux/verify-glibc-requirements.sh
pushd "../vscode-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
if [[ -f "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" ]]; then
bash "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" "node_modules"
fi
echo "Archiving REH"
tar czf "../assets/${APP_NAME_LC}-reh-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
popd
fi
if [[ "${SHOULD_BUILD_REH_WEB}" != "no" ]]; then
echo "Building REH-web"
yarn gulp minify-vscode-reh-web
yarn gulp "vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-min-ci"
EXPECTED_GLIBC_VERSION="${GLIBC_VERSION}" EXPECTED_GLIBCXX_VERSION="${GLIBCXX_VERSION}" SEARCH_PATH="../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}" ./build/azure-pipelines/linux/verify-glibc-requirements.sh
pushd "../vscode-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}"
if [[ -f "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" ]]; then
bash "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" "node_modules"
fi
echo "Archiving REH-web"
tar czf "../assets/${APP_NAME_LC}-reh-web-${VSCODE_PLATFORM}-${VSCODE_ARCH}-${RELEASE_VERSION}.tar.gz" .
popd
fi
cd ..
npm install -g checksum
sum_file() {
if [[ -f "${1}" ]]; then
echo "Calculating checksum for ${1}"
checksum -a sha256 "${1}" > "${1}".sha256
checksum "${1}" > "${1}".sha1
fi
}
cd assets
for FILE in *; do
if [[ -f "${FILE}" ]]; then
sum_file "${FILE}"
fi
done
cd ..