Skip to content

Commit 308a84e

Browse files
committed
Fix centos image for arm64
1 parent cc139ac commit 308a84e

File tree

3 files changed

+47
-49
lines changed

3 files changed

+47
-49
lines changed

ci/image/Dockerfile

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
FROM centos:7
22

3-
RUN yum update -y \
4-
&& yum install -y epel-release centos-release-scl \
5-
&& yum-config-manager --enable rhel-server-rhscl-7-rpms \
6-
&& yum update -y \
7-
&& yum install -y \
8-
devtoolset-6 \
9-
gcc-c++ \
10-
xz \
11-
ccache \
12-
git \
13-
wget \
14-
openssl \
15-
libxkbfile-devel \
16-
libsecret-devel \
17-
libx11-devel
3+
RUN yum update -y && yum install -y \
4+
devtoolset-6 \
5+
gcc-c++ \
6+
xz \
7+
ccache \
8+
git \
9+
wget \
10+
openssl \
11+
libxkbfile-devel \
12+
libsecret-devel \
13+
libx11-devel
1814

1915
RUN mkdir /usr/share/node && cd /usr/share/node \
20-
&& curl https://nodejs.org/dist/v12.14.0/node-v12.14.0-linux-x64.tar.xz | tar xJ --strip-components=1 --
16+
&& curl "https://nodejs.org/dist/v12.14.0/node-v12.14.0-linux-$(uname -m | sed 's/86_//; s/aarch/arm/').tar.xz" | tar xJ --strip-components=1 --
2117
ENV PATH "$PATH:/usr/share/node/bin"
2218
RUN npm install -g yarn
2319

24-
RUN curl -L https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_linux_amd64 > /usr/local/bin/shfmt \
20+
RUN curl -L "https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_linux_$(uname -m | sed 's/x86_/amd/; s/aarch64/arm/')" > /usr/local/bin/shfmt \
2521
&& chmod +x /usr/local/bin/shfmt
2622

27-
RUN echo 'source /opt/rh/devtoolset-6/enable' >> /root/.bashrc
28-
2923
ENTRYPOINT ["/bin/bash", "-c"]

src/node/app/update.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ export class UpdateHttpProvider extends HttpProvider {
194194
}
195195
}
196196

197-
public async downloadAndApplyUpdate(update: Update, targetPath?: string, target?: string): Promise<void> {
198-
const releaseName = await this.getReleaseName(update, target)
197+
public async downloadAndApplyUpdate(update: Update, targetPath?: string): Promise<void> {
198+
const releaseName = await this.getReleaseName(update)
199199
const url = this.downloadUrl.replace("{{VERSION}}", update.version).replace("{{RELEASE_NAME}}", releaseName)
200200

201201
let downloadPath = path.join(tmpdir, "updates", releaseName)
@@ -298,7 +298,8 @@ export class UpdateHttpProvider extends HttpProvider {
298298
/**
299299
* Given an update return the name for the packaged archived.
300300
*/
301-
private async getReleaseName(update: Update, target: string = os.platform()): Promise<string> {
301+
public async getReleaseName(update: Update): Promise<string> {
302+
let target: string = os.platform()
302303
if (target === "linux") {
303304
const result = await util
304305
.promisify(cp.exec)("ldd --version")

test/update.test.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import zip from "adm-zip"
22
import * as assert from "assert"
33
import * as fs from "fs-extra"
44
import * as http from "http"
5+
import * as os from "os"
56
import * as path from "path"
67
import * as tar from "tar-fs"
78
import * as zlib from "zlib"
@@ -65,7 +66,20 @@ describe("update", () => {
6566
}
6667

6768
before(async () => {
68-
const archiveName = "code-server-9999999.99999.9999-linux-x86_64"
69+
await new Promise((resolve, reject) => {
70+
server.on("error", reject)
71+
server.on("listening", resolve)
72+
server.listen({
73+
port: 0,
74+
host: "localhost",
75+
})
76+
})
77+
78+
const p = provider()
79+
const archiveName = (await p.getReleaseName({ version: "9999999.99999.9999", checked: 0 })).replace(
80+
/.tar.gz$|.zip$/,
81+
"",
82+
)
6983
await fs.remove(path.join(tmpdir, "tests/updates"))
7084
await fs.mkdirp(path.join(archivePath, archiveName))
7185

@@ -74,8 +88,16 @@ describe("update", () => {
7488
fs.writeFile(path.join(archivePath, archiveName, "node"), `NODE BINARY`),
7589
])
7690

77-
await Promise.all([
78-
new Promise((resolve, reject) => {
91+
if (os.platform() === "darwin") {
92+
await new Promise((resolve, reject) => {
93+
const zipFile = new zip()
94+
zipFile.addLocalFolder(archivePath)
95+
zipFile.writeZip(archivePath + ".zip", (error) => {
96+
return error ? reject(error) : resolve(error)
97+
})
98+
})
99+
} else {
100+
await new Promise((resolve, reject) => {
79101
const write = fs.createWriteStream(archivePath + ".tar.gz")
80102
const compress = zlib.createGzip()
81103
compress.pipe(write)
@@ -86,24 +108,8 @@ describe("update", () => {
86108
write.on("finish", () => {
87109
resolve()
88110
})
89-
}),
90-
new Promise((resolve, reject) => {
91-
const zipFile = new zip()
92-
zipFile.addLocalFolder(archivePath)
93-
zipFile.writeZip(archivePath + ".zip", (error) => {
94-
return error ? reject(error) : resolve(error)
95-
})
96-
}),
97-
])
98-
99-
await new Promise((resolve, reject) => {
100-
server.on("error", reject)
101-
server.on("listening", resolve)
102-
server.listen({
103-
port: 0,
104-
host: "localhost",
105111
})
106-
})
112+
}
107113
})
108114

109115
after(() => {
@@ -205,18 +211,15 @@ describe("update", () => {
205211
assert.equal(`console.log("OLD")`, await fs.readFile(entry, "utf8"))
206212

207213
// Updating should replace the existing version.
208-
await p.downloadAndApplyUpdate(update, destination, "linux")
214+
await p.downloadAndApplyUpdate(update, destination)
209215
assert.equal(`console.log("UPDATED")`, await fs.readFile(entry, "utf8"))
210216

211217
// Should still work if there is no existing version somehow.
212218
await fs.remove(destination)
213-
await p.downloadAndApplyUpdate(update, destination, "linux")
219+
await p.downloadAndApplyUpdate(update, destination)
214220
assert.equal(`console.log("UPDATED")`, await fs.readFile(entry, "utf8"))
215221

216-
assert.deepEqual(spy, [
217-
"/latest",
218-
`/download/${version}/code-server-${version}-linux-x86_64.tar.gz`,
219-
`/download/${version}/code-server-${version}-linux-x86_64.tar.gz`,
220-
])
222+
const archiveName = await p.getReleaseName(update)
223+
assert.deepEqual(spy, ["/latest", `/download/${version}/${archiveName}`, `/download/${version}/${archiveName}`])
221224
})
222225
})

0 commit comments

Comments
 (0)