scripts/copy_output.lua: delete images from OpenWrt dir after copying them

We don't move the images directly, as multiple images of the same device
may have the same source image (on x86), but only delete them after a
whole device has been handled (multiple devices using the same images
must be handled using aliases or manifest aliases instead).
This commit is contained in:
Matthias Schiffer 2020-04-24 23:22:11 +02:00 committed by David Bauer
parent e993f22233
commit aefb0b8c35
1 changed files with 12 additions and 2 deletions

View File

@ -31,6 +31,12 @@ mkdir(env.GLUON_IMAGEDIR..'/other')
lib.include(target)
local function image_source(image)
return string.format(
'openwrt/bin/targets/%s/openwrt-%s-%s%s%s',
bindir, openwrt_target, image.name, image.in_suffix, image.extension)
end
local function clean(image, name)
local dir, file = image:dest_name(name, '\0', '\0')
lib.exec {'rm', '-f', dir..'/'..file}
@ -41,8 +47,7 @@ for _, images in pairs(lib.images) do
clean(image, image.image)
local destdir, destname = image:dest_name(image.image)
local source = string.format('openwrt/bin/targets/%s/openwrt-%s-%s%s%s',
bindir, openwrt_target, image.name, image.in_suffix, image.extension)
local source = image_source(image)
lib.exec {'cp', source, destdir..'/'..destname}
@ -53,6 +58,11 @@ for _, images in pairs(lib.images) do
lib.exec {'ln', '-s', destname, destdir..'/'..aliasname}
end
end
for _, image in ipairs(images) do
local source = image_source(image)
lib.exec {'rm', '-f', source}
end
end