source: projects/update-watch/tags/2.0.0/check-reboot.lua @ 3917

Revision 3917, 1.5 KB checked in by kazutaka, 11 years ago (diff)
  • update check-reboot.lua to fix rpm lua segv when apt-get upgrade again (import from 1.2.0-6vl5. Thanks iwamoto-san and daisuke-san)
  • hide column header in list of updates
  • show install/download size in List of updates window
  • 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(pkgs_install) do
43    local name = realname(pkgname(pkg))
44    if not name then
45        name = pkgname(pkg)
46    end
47    for i, name_r in pairs(reboot) do
48        if name == name_r then
49            found = true
50        end
51    end
52end
53
54if found then
55    print ("Reboot required.")
56    os.execute("touch /var/run/reboot-required")
57end
Note: See TracBrowser for help on using the repository browser.