Skip to content

Commit

Permalink
scripts/copy_output.lua: delete images from OpenWrt dir after copying…
Browse files Browse the repository at this point in the history
… 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).
  • Loading branch information
neocturne authored and blocktrron committed Apr 25, 2020
1 parent e993f22 commit aefb0b8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/copy_output.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}

Expand All @@ -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


Expand Down

0 comments on commit aefb0b8

Please sign in to comment.