Junk

Junk Commit Details

Date:2019-02-17 20:45:07 (9 months 10 hours ago)
Author:Nicola Fontana
Branch:master
Commit:f7e26d7bc73a10d35d4b0d4ce98a359a46c0934c
Parents: db3eec868eedfbfecf8eb515c1dbd703d6a65687
Message:listuserpackages.lua: first implementation

Changes:
Alua/listuserpackages.lua (full)

File differences

lua/listuserpackages.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/lua
--[[
A script for OpenWRT/LEDE that gets the list of user installed packages.
Differently from other scripts it leverages the Installed-Time field.
The (hopefully) improvements are a much shorter list in time ascending
order, likely resembling the ideal list.
Example:
./listuserpackages.lua > /etc/config/opkg.installed
References:
* https://github.com/richb-hanover/OpenWrtScripts/blob/master/opkgscript.sh
* https://openwrt.org/docs/guide-user/installation/generic.sysupgrade#other_options
--]]
local capture, pkg, timestamp
local k, v = {}, {}
for l in io.lines('/usr/lib/opkg/status') do
function match(pattern)
capture = l:match(pattern)
return capture
end
if match 'Package: (.+)' then
pkg = capture
elseif match 'Installed%-Time: (.+)' then
timestamp = capture
elseif match 'Auto%-Installed: yes' then
pkg = nil
elseif l == '' and pkg and timestamp then
if not v[timestamp] then
table.insert(k, timestamp)
v[timestamp] = {}
end
table.insert(v[timestamp], pkg)
end
end
table.sort(k)
-- Skip the oldest timestamp, i.e. when system packages have been installed
for n = 2, #k do
for _,pkg in pairs(v[k[n]]) do print(pkg) end
end

Archive Download the corresponding diff file

Branches