[3774] | 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 | |
---|
| 5 | filename = "/usr/lib/update-watch/reboot.list" |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | -- Function to extract real package name from allow-duplicated packages. |
---|
| 9 | function realname(name) |
---|
| 10 | local s, e, name = string.find(name, "(.+)#") |
---|
| 11 | return name |
---|
| 12 | end |
---|
| 13 | |
---|
| 14 | -- Open list of packages that requires system reboot, |
---|
| 15 | -- Then read it and store package name into local table. |
---|
| 16 | local reboot = {} |
---|
| 17 | |
---|
| 18 | file = io.open(filename, "r") |
---|
| 19 | if not file then |
---|
| 20 | print("error: can't open configuration file at "..filename) |
---|
| 21 | return |
---|
| 22 | else |
---|
| 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 |
---|
| 29 | end |
---|
| 30 | |
---|
[3777] | 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) |
---|
| 34 | if confget("RPM::RootDir", "default") ~= "default" then |
---|
| 35 | return |
---|
| 36 | end |
---|
[3774] | 37 | |
---|
| 38 | -- Check packages that is installed just now, and compare it with |
---|
| 39 | -- extraced list, Then check if reboot is required. |
---|
| 40 | local found = false |
---|
| 41 | |
---|
[3818] | 42 | for 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 |
---|
[3774] | 50 | end |
---|
| 51 | end |
---|
| 52 | end |
---|
| 53 | |
---|
| 54 | if found then |
---|
[3917] | 55 | print ("Reboot required.") |
---|
[3774] | 56 | os.execute("touch /var/run/reboot-required") |
---|
| 57 | end |
---|