source: projects/update-watch/trunk/check-reboot.lua @ 3777

Revision 3777, 1.6 KB checked in by kazutaka, 13 years ago (diff)

Vine 6向けに更新開始

  • 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-- Check configuration string RPM::RootDir:: to stop miss detection
32-- of reboot-required packages under vbootstrap/vbuilder chroot.
33-- (this string is usually blank, but vbootstrap set it)
34if confget("RPM::RootDir", "default") ~= "default" then
35   return
36end
37
38-- Check packages that is installed just now, and compare it with
39-- extraced list, Then check if reboot is required.
40local found = false
41
42for i, pkg in pairs(pkglist()) do
43    if statinstall(pkg) then
44        local name = realname(pkgname(pkg))
45        if not name then
46            name = pkgname(pkg)
47        end
48        for i, name_r in pairs(reboot) do
49            if name == name_r then
50                found = true
51            end
52       end
53    end
54end
55
56if found then
57    -- print ("reboot required.")
58    os.execute("touch /var/run/reboot-required")
59end
Note: See TracBrowser for help on using the repository browser.