From 0a8e028e8f33efa61628de4ba3d8d4e5c2586c7a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 19 Jan 2017 13:10:57 +0100 Subject: [PATCH] gluon-core: upgrade: don't print an error message on systems without opkg --- .../luasrc/lib/gluon/upgrade/500-opkg | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg b/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg index 9acd3b14..353cf8d8 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg @@ -24,35 +24,37 @@ end local prefix = subst['%%n'] .. '_' -local distfeeds = {} -for line in io.lines('/etc/opkg/distfeeds.conf') do - table.insert(distfeeds, line) -end - -local f = io.open('/etc/opkg/distfeeds.conf', 'w') - -for _, line in ipairs(distfeeds) do - local name = line:match('^src/gz%s' .. prefix .. '(%S+)%s') - if name == 'core' then - f:write('# ' .. line .. '\n') - elseif name and site.opkg and site.opkg.lede then - f:write(string.format('src/gz %s %s/%s\n', prefix .. name, replace_patterns(site.opkg.lede), name)) - else - f:write(line .. '\n') +if fs.access('/etc/opkg/distfeeds.conf') then + local distfeeds = {} + for line in io.lines('/etc/opkg/distfeeds.conf') do + table.insert(distfeeds, line) end -end -f:close() + local f = io.open('/etc/opkg/distfeeds.conf', 'w') -if site.opkg and site.opkg.extra and next(site.opkg.extra) then - local f = io.open('/etc/opkg/gluon.conf', 'w') - - for k, v in pairs(site.opkg.extra) do - f:write(string.format('src/gz %s %s\n', k, replace_patterns(v))) + for _, line in ipairs(distfeeds) do + local name = line:match('^src/gz%s' .. prefix .. '(%S+)%s') + if name == 'core' then + f:write('# ' .. line .. '\n') + elseif name and site.opkg and site.opkg.lede then + f:write(string.format('src/gz %s %s/%s\n', prefix .. name, replace_patterns(site.opkg.lede), name)) + else + f:write(line .. '\n') + end end f:close() -else - os.remove('/etc/opkg/gluon.conf') + if site.opkg and site.opkg.extra and next(site.opkg.extra) then + local f = io.open('/etc/opkg/gluon.conf', 'w') + + for k, v in pairs(site.opkg.extra) do + f:write(string.format('src/gz %s %s\n', k, replace_patterns(v))) + end + + f:close() + + else + os.remove('/etc/opkg/gluon.conf') + end end