2019-06-17 23:33:12 +00:00
|
|
|
local lib = dofile('scripts/target_lib.lua')
|
|
|
|
local env = lib.env
|
2019-06-14 17:20:15 +00:00
|
|
|
|
2020-05-03 19:35:01 +00:00
|
|
|
local target = env.GLUON_TARGET
|
|
|
|
|
|
|
|
assert(target)
|
2019-06-14 17:20:15 +00:00
|
|
|
assert(env.GLUON_IMAGEDIR)
|
|
|
|
assert(env.GLUON_PACKAGEDIR)
|
|
|
|
|
|
|
|
|
|
|
|
local openwrt_target
|
|
|
|
local subtarget = env.SUBTARGET
|
|
|
|
if subtarget ~= '' then
|
|
|
|
openwrt_target = env.BOARD .. '-' .. subtarget
|
|
|
|
else
|
|
|
|
openwrt_target = env.BOARD
|
|
|
|
subtarget = 'generic'
|
|
|
|
end
|
|
|
|
|
|
|
|
local bindir = env.BOARD .. '/' .. subtarget
|
|
|
|
|
|
|
|
|
|
|
|
local function mkdir(dir)
|
2019-06-17 23:33:12 +00:00
|
|
|
lib.exec {'mkdir', '-p', dir}
|
2019-06-14 17:20:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
mkdir(env.GLUON_IMAGEDIR..'/factory')
|
|
|
|
mkdir(env.GLUON_IMAGEDIR..'/sysupgrade')
|
|
|
|
mkdir(env.GLUON_IMAGEDIR..'/other')
|
2020-06-04 20:35:58 +00:00
|
|
|
mkdir(env.GLUON_DEBUGDIR)
|
2019-06-14 17:20:15 +00:00
|
|
|
|
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
lib.include(target)
|
2019-06-14 17:20:15 +00:00
|
|
|
|
|
|
|
|
2020-04-24 21:22:11 +00:00
|
|
|
local function image_source(image)
|
|
|
|
return string.format(
|
2023-01-30 22:25:02 +00:00
|
|
|
'openwrt/bin/targets/%s/' .. (env.GLUON_PREFIX or 'openwrt') .. '-%s-%s%s%s',
|
2020-04-24 21:22:11 +00:00
|
|
|
bindir, openwrt_target, image.name, image.in_suffix, image.extension)
|
|
|
|
end
|
|
|
|
|
2019-06-14 17:20:15 +00:00
|
|
|
local function clean(image, name)
|
|
|
|
local dir, file = image:dest_name(name, '\0', '\0')
|
2019-06-17 23:33:12 +00:00
|
|
|
lib.exec {'rm', '-f', dir..'/'..file}
|
2019-06-14 17:20:15 +00:00
|
|
|
end
|
|
|
|
|
2020-04-24 21:09:05 +00:00
|
|
|
for _, images in pairs(lib.images) do
|
|
|
|
for _, image in ipairs(images) do
|
|
|
|
clean(image, image.image)
|
2019-06-14 17:20:15 +00:00
|
|
|
|
2020-04-24 21:09:05 +00:00
|
|
|
local destdir, destname = image:dest_name(image.image)
|
2020-04-24 21:22:11 +00:00
|
|
|
local source = image_source(image)
|
2019-06-14 17:20:15 +00:00
|
|
|
|
2020-04-24 21:09:05 +00:00
|
|
|
lib.exec {'cp', source, destdir..'/'..destname}
|
2019-06-14 17:20:15 +00:00
|
|
|
|
2020-04-24 21:09:05 +00:00
|
|
|
for _, alias in ipairs(image.aliases) do
|
|
|
|
clean(image, alias)
|
2019-06-14 17:20:15 +00:00
|
|
|
|
2020-04-24 21:09:05 +00:00
|
|
|
local _, aliasname = image:dest_name(alias)
|
|
|
|
lib.exec {'ln', '-s', destname, destdir..'/'..aliasname}
|
|
|
|
end
|
2019-06-14 17:20:15 +00:00
|
|
|
end
|
2020-04-24 21:22:11 +00:00
|
|
|
|
|
|
|
for _, image in ipairs(images) do
|
|
|
|
local source = image_source(image)
|
|
|
|
lib.exec {'rm', '-f', source}
|
|
|
|
end
|
2019-06-14 17:20:15 +00:00
|
|
|
end
|
|
|
|
|
2020-06-04 20:35:58 +00:00
|
|
|
-- copy kernel image with debug symbols
|
|
|
|
local kernel_debug_glob = string.format('%s/gluon-\0-%s-kernel-debug.tar.zst',
|
2020-09-13 17:21:15 +00:00
|
|
|
env.GLUON_DEBUGDIR,
|
|
|
|
target)
|
2020-06-04 20:35:58 +00:00
|
|
|
lib.exec {'rm', '-f', kernel_debug_glob}
|
|
|
|
local kernel_debug_source = string.format('openwrt/bin/targets/%s/kernel-debug.tar.zst',
|
2020-09-13 17:21:15 +00:00
|
|
|
bindir)
|
2020-06-04 20:35:58 +00:00
|
|
|
local kernel_debug_dest = string.format('%s/gluon-%s-%s-%s-kernel-debug.tar.zst',
|
2020-09-13 17:21:15 +00:00
|
|
|
env.GLUON_DEBUGDIR,
|
|
|
|
lib.site_code,
|
|
|
|
env.GLUON_RELEASE,
|
|
|
|
target)
|
2020-06-04 20:35:58 +00:00
|
|
|
lib.exec {'cp', kernel_debug_source, kernel_debug_dest}
|
|
|
|
|
2019-06-14 17:20:15 +00:00
|
|
|
|
|
|
|
-- Copy opkg repo
|
2021-07-11 20:48:07 +00:00
|
|
|
if (env.GLUON_DEVICES or '') == '' then
|
2019-06-17 23:33:12 +00:00
|
|
|
local package_prefix = string.format('gluon-%s-%s', lib.site_code, env.GLUON_RELEASE)
|
2019-06-14 17:20:15 +00:00
|
|
|
local function dest_dir(prefix)
|
|
|
|
return env.GLUON_PACKAGEDIR..'/'..prefix..'/'..bindir
|
|
|
|
end
|
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
lib.exec {'rm', '-f', dest_dir('\0')..'/\0'}
|
|
|
|
lib.exec({'rmdir', '-p', dest_dir('\0')}, true, '2>/dev/null')
|
2019-06-14 17:20:15 +00:00
|
|
|
mkdir(dest_dir(package_prefix))
|
2019-06-17 23:33:12 +00:00
|
|
|
lib.exec {'cp', 'openwrt/bin/targets/'..bindir..'/packages/\0', dest_dir(package_prefix)}
|
2019-06-14 17:20:15 +00:00
|
|
|
end
|