53690d83be
The precedence of different package lists was broken since #1876, disallowing removal of GLUON_FEATURES packages via GLUON_SITE_PACKAGES. Including all package selections, both implicit defaults and explicit handling in Gluon, the order of precedence is now the following: 1. OpenWrt defaults (including target-specific defaults) 2. Device-specific packages from OpenWrt 3. Generic default packages (from target/generic) 4. Target default packages (target/$(GLUON_TARGET)) 5. Removal of opkg for tiny targets 6. Packages derived from GLUON_FEATURES + GLUON_FEATURES_$(class) 7. GLUON_SITE_PACKAGES 8. GLUON_SITE_PACKAGES_$(class) 9. Device-specific packages from target/$(GLUON_TARGET) 10. Device-specific packages from GLUON_$(device)_SITE_PACKAGES This also contains various pieces of cleanup: - No hardcoded order of device classes for target_config.lua arguments anymore (in fact, the Makefile doesn't know anything about device classes now) - target_conifg_lib.lua only hardcodes the fallback class for x86, no other occurences of specific class names - Feature -> package list mapping is moved from Makefile to the Lua code as well (still implemented in Shell though)
82 lines
1.9 KiB
Lua
Executable File
82 lines
1.9 KiB
Lua
Executable File
local lib = dofile('scripts/target_lib.lua')
|
|
local env = lib.env
|
|
|
|
local target = env.GLUON_TARGET
|
|
|
|
assert(target)
|
|
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)
|
|
lib.exec {'mkdir', '-p', dir}
|
|
end
|
|
|
|
mkdir(env.GLUON_IMAGEDIR..'/factory')
|
|
mkdir(env.GLUON_IMAGEDIR..'/sysupgrade')
|
|
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}
|
|
end
|
|
|
|
for _, images in pairs(lib.images) do
|
|
for _, image in ipairs(images) do
|
|
clean(image, image.image)
|
|
|
|
local destdir, destname = image:dest_name(image.image)
|
|
local source = image_source(image)
|
|
|
|
lib.exec {'cp', source, destdir..'/'..destname}
|
|
|
|
for _, alias in ipairs(image.aliases) do
|
|
clean(image, alias)
|
|
|
|
local _, aliasname = image:dest_name(alias)
|
|
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
|
|
|
|
|
|
-- Copy opkg repo
|
|
if lib.opkg and (env.GLUON_DEVICES or '') == '' then
|
|
local package_prefix = string.format('gluon-%s-%s', lib.site_code, env.GLUON_RELEASE)
|
|
local function dest_dir(prefix)
|
|
return env.GLUON_PACKAGEDIR..'/'..prefix..'/'..bindir
|
|
end
|
|
|
|
lib.exec {'rm', '-f', dest_dir('\0')..'/\0'}
|
|
lib.exec({'rmdir', '-p', dest_dir('\0')}, true, '2>/dev/null')
|
|
mkdir(dest_dir(package_prefix))
|
|
lib.exec {'cp', 'openwrt/bin/targets/'..bindir..'/packages/\0', dest_dir(package_prefix)}
|
|
end
|