Skip to content
Snippets Groups Projects
Select Git revision
  • cb505a354a3a4ea3e5d10fe925718a80d1ea02b5
  • experimental default protected
  • v2023.2.5-ffs
  • nrb/ex400-remove-wps
  • nrb/airmax-test
  • v2023.2.4-ffs
  • nrb/ar9344-reset-sequence
  • autinerd/experimental-openwrt-24.10
  • v2023.2.3-ffs
  • v2023.2.2-ffs
  • v2023.2-ffs
  • v2023.1-ffs
  • v2022.1.4-ffs
  • feature/addMikrotikwAP
  • v2022.1.3-ffs
  • v2021.1.2-ffs
  • v2022.1.1-ffs
  • master protected
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • experimental-2025-07-04
  • experimental-2025-07-04-base
  • experimental-2025-07-01
  • experimental-2025-07-01-base
  • experimental-2025-06-25
  • experimental-2025-06-25-base
  • experimental-2025-06-24
  • experimental-2025-06-24-base
  • experimental-2025-06-22
  • experimental-2025-06-22-base
  • v2023.2.5-ffs0.1
  • experimental-2025-06-08
  • experimental-2025-06-08-base
  • experimental-2025-06-06
  • experimental-2025-06-06-base
  • experimental-2025-05-27
  • experimental-2025-05-27-base
  • experimental-2025-05-18
  • experimental-2025-05-18-base
  • experimental-2025-05-15
41 results

target_lib.lua

Blame
    • Matthias Schiffer's avatar
      bd0133ad
      scripts/target_lib.lua: print a meaningful error message for missing site_code (#2094) · bd0133ad
      Matthias Schiffer authored
      site_code is evaluated early during config generation, so a site.conf
      without site_code would hit this assertion that just printed 'Assertion
      failed'. Add a proper error message to tell users what went wrong.
      
      The inner assert() is removed, as it should never be hit (as site.conf
      syntax will have already been validated when this script runs), and it
      doesn't add anything (even without the assert, the attempt to index a
      nil value would throw an error).
      scripts/target_lib.lua: print a meaningful error message for missing site_code (#2094)
      Matthias Schiffer authored
      site_code is evaluated early during config generation, so a site.conf
      without site_code would hit this assertion that just printed 'Assertion
      failed'. Add a proper error message to tell users what went wrong.
      
      The inner assert() is removed, as it should never be hit (as site.conf
      syntax will have already been validated when this script runs), and it
      doesn't add anything (even without the assert, the attempt to index a
      nil value would throw an error).
    generate_manifest.lua 1.28 KiB
    local lib = dofile('scripts/target_lib.lua')
    local env = lib.env
    
    assert(env.GLUON_IMAGEDIR)
    
    
    local target = arg[1]
    
    lib.include(target)
    
    
    local function strip(s)
    	return string.gsub(s, '\n$', '')
    end
    
    local function generate_line(model, dir, filename, filesize)
    	local exists = pcall(lib.exec, {'test', '-e', dir..'/'..filename})
    	if not exists then
    		return
    	end
    
    	local file256sum = strip(lib.exec_capture {'scripts/sha256sum.sh', dir..'/'..filename})
    
    	io.stdout:write(string.format('%s %s %s %s %s\n', model, env.GLUON_RELEASE, file256sum, filesize, filename))
    end
    
    local function generate(image)
    	local dir, filename = image:dest_name(image.image)
    	local exists = pcall(lib.exec, {'test', '-e', dir..'/'..filename})
    	if not exists then
    		return
    	end
    
    	local filesize = strip(lib.exec_capture {'scripts/filesize.sh', dir..'/'..filename})
    
    	generate_line(image.image, dir, filename, filesize)
    
    	for _, alias in ipairs(image.aliases) do
    		local aliasdir, aliasname = image:dest_name(alias)
    		generate_line(alias, aliasdir, aliasname, filesize)
    	end
    
    	for _, alias in ipairs(image.manifest_aliases) do
    		generate_line(alias, dir, filename, filesize)
    	end
    end
    
    for _, images in pairs(lib.images) do
    	for _, image in ipairs(images) do
    		if image.subdir == 'sysupgrade' then
    			generate(image)
    		end
    	end
    end