source: projects/update-watch/tags/1.0.4/check-reboot.lua @ 175

Revision 175, 1.3 KB checked in by kazutaka, 15 years ago (diff)

update-watch をインポート

  • Property svn:executable set to *
Line 
1-- This is a helper script to check installation of reboot-required
2-- packages.
3-- This script runs just after changes are commited to rpm database.
4
5filename = "/usr/lib/update-watch/reboot.list"
6
7
8-- Function to extract real package name from allow-duplicated packages.
9function realname(name)
10    local s, e, name = string.find(name, "(.+)#")
11    return name
12end
13
14-- Open list of packages that requires system reboot,
15-- Then read it and store package name into local table.
16local reboot = {}
17
18file = io.open(filename, "r")
19if not file then
20    print("error: can't open configuration file at "..filename)
21    return
22else
23    for line in io.lines(filename) do
24        local s, e = string.find(line, "reboot:")
25        if e then
26            table.insert(reboot, string.sub(line, e+1))
27        end
28    end
29end
30
31
32-- Check packages that is installed just now, and compare it with
33-- extraced list, Then check if reboot is required.
34local found = false
35
36for i, pkg in pairs(pkglist()) do
37    if statinstall(pkg) then
38        local name = realname(pkgname(pkg))
39        if not name then
40            name = pkgname(pkg)
41        end
42        for i, name_r in pairs(reboot) do
43            if name == name_r then
44                found = true
45            end
46       end
47    end
48end
49
50if found then
51    -- print ("reboot required.")
52    os.execute("touch /var/run/reboot-required")
53end
Note: See TracBrowser for help on using the repository browser.