Merge pull request #1020 from balena-io/1019-fix-qemu

Fix the architecture string used when downloading qemu versions
This commit is contained in:
CameronDiver 2018-11-12 17:15:49 +01:00 committed by GitHub
commit e2ebac27ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,7 +34,9 @@ exports.copyQemu = (context, arch) ->
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
read = fs.createReadStream(qemu) read = fs.createReadStream(qemu)
write = fs.createWriteStream(binPath) write = fs.createWriteStream(binPath)
read read
.on('error', reject)
.pipe(write) .pipe(write)
.on('error', reject) .on('error', reject)
.on('finish', resolve) .on('finish', resolve)
@ -77,15 +79,19 @@ installQemu = (arch) ->
.then (qemuPath) -> .then (qemuPath) ->
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
installStream = fs.createWriteStream(qemuPath) installStream = fs.createWriteStream(qemuPath)
downloadArchiveName = "qemu-3.0.0+resin-#{arch}.tar.gz"
qemuArch = balenaArchToQemuArch(arch)
downloadArchiveName = "qemu-3.0.0+resin-#{qemuArch}.tar.gz"
qemuUrl = "https://github.com/balena-io/qemu/releases/download/#{QEMU_VERSION}/#{downloadArchiveName}" qemuUrl = "https://github.com/balena-io/qemu/releases/download/#{QEMU_VERSION}/#{downloadArchiveName}"
extract = tar.extract() extract = tar.extract()
extract.on 'entry', (header, stream, next) -> extract.on 'entry', (header, stream, next) ->
stream.on('end', next) stream.on('end', next)
if header.name.includes("qemu-#{arch}-static") if header.name.includes("qemu-#{qemuArch}-static")
stream.pipe(installStream) stream.pipe(installStream)
else else
stream.resume() stream.resume()
request(qemuUrl) request(qemuUrl)
.on('error', reject) .on('error', reject)
.pipe(zlib.createGunzip()) .pipe(zlib.createGunzip())
@ -93,6 +99,10 @@ installQemu = (arch) ->
.pipe(extract) .pipe(extract)
.on('error', reject) .on('error', reject)
.on 'finish', -> .on 'finish', ->
# make qemu binary executable
fs.chmodSync(qemuPath, '755') fs.chmodSync(qemuPath, '755')
resolve() resolve()
balenaArchToQemuArch = (arch) ->
switch arch
when 'armv7hf', 'rpi' then 'arm'
else arch