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
|
|
|
|
|
|
|
assert(env.GLUON_IMAGEDIR)
|
|
|
|
assert(env.GLUON_PACKAGEDIR)
|
|
|
|
|
|
|
|
|
|
|
|
local target = arg[1]
|
|
|
|
|
|
|
|
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')
|
|
|
|
|
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
lib.include(target)
|
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)
|
|
|
|
local source = string.format('openwrt/bin/targets/%s/openwrt-%s-%s%s%s',
|
|
|
|
bindir, openwrt_target, image.name, image.in_suffix, image.extension)
|
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
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Copy opkg repo
|
2019-06-17 23:33:12 +00:00
|
|
|
if lib.opkg and (env.GLUON_DEVICES or '') == '' then
|
|
|
|
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
|