From ebfbc042e7e37217250e20ffda064e926de88309 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Mar 15 2016 16:48:49 +0000 Subject: Properly handle systemd presets in Lua scripts - convert-to-edition: Remove call to grub2-mkconfig Signed-off-by: Dennis Gilmore --- diff --git a/convert-to-edition.lua b/convert-to-edition.lua index f10c3cc..d52a471 100644 --- a/convert-to-edition.lua +++ b/convert-to-edition.lua @@ -7,7 +7,7 @@ local VARIANT_FILE = "/usr/lib/variant" -- Read in /usr/lib/variant and determine the edition local function read_variant() local variant - local f = io.open("/usr/lib/variant", "r") + local f = io.open(VARIANT_FILE, "r") if f ~= nil then while true do local line = f:read() @@ -19,6 +19,7 @@ local function read_variant() variant = m end end + f:close() end return variant end @@ -85,8 +86,8 @@ local function read_presets(path) if cmd == "enable" or cmd == "disable" then result[#result + 1] = arg end - f:close() end + f:close() end return result end @@ -115,20 +116,23 @@ local variants = { } -- Call out to systemctl to enable or disable presets -local function set_presets(edition) +local function set_presets(edition, apply_presets) if variants[edition].presets then local target = "/usr/lib/systemd/system-preset/80-" .. edition .. ".preset" - symlink("../../os.edition.d/presets/80-" .. edition .. ".preset", target) - local presets = read_presets(target) - local systemctl = "/usr/bin/systemctl" - if posix.access(systemctl, "x") then - os.execute(systemctl, "preset", "-q", - table.unpack(presets)) - end + symlink("../../os.release.d/presets/80-" .. edition .. ".preset", target) + + if apply_presets then + local presets = read_presets(target) + local systemctl = "/usr/bin/systemctl" + if posix.access(systemctl, "x") then + os.execute(systemctl, "preset", "-q", + table.unpack(presets)) + end + end end end -local function convert_to_edition(edition, do_presets) +local function convert_to_edition(edition, apply_presets) local variant = variants[edition] if variant == nil then error("undefined edition: " .. edition) @@ -137,14 +141,7 @@ local function convert_to_edition(edition, do_presets) set_issue(variant.issue) clear_presets() - if do_presets then - set_presets(edition) - end - - local grub = "/usr/sbin/grub2-mkconfig" - if posix.access(grub, "x") then - execute(grub, "-o", "/boot/grub2/grub.cfg") - end + set_presets(edition, apply_presets) end local function install_edition(edition) @@ -160,7 +157,7 @@ local function install_edition(edition) -- added -- On upgrades, do not enable or disable presets to avoid -- surprising the user - local initial_install = arg[2] == "1" + local initial_install = arg[2] == 1 convert_to_edition(edition, initial_install) end end @@ -171,8 +168,9 @@ local function uninstall_edition(edition) -- in %%preun so that we don't have any time where the os-release -- symlink is dangling (since in %%postun, the os-release-$EDITION -- file will have already been removed) - if arg[2] == "0" then + if arg[2] == 0 then if read_variant() == edition then + set_variant("nonproduct") convert_to_edition("nonproduct", false) end end diff --git a/fedora-release.spec b/fedora-release.spec index 92d0f05..624c43e 100644 --- a/fedora-release.spec +++ b/fedora-release.spec @@ -5,7 +5,7 @@ Summary: Fedora release files Name: fedora-release Version: 24 -Release: 0.14 +Release: 0.15 License: MIT Group: System Environment/Base URL: http://fedoraproject.org @@ -333,6 +333,10 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %config %attr(0644,root,root) /usr/lib/os.release.d/presets/80-workstation.preset %changelog +* Tue Mar 15 2016 Dennis Gilmore - 24-0.15 +- Properly handle systemd presets in Lua scripts +- convert-to-edition: Remove call to grub2-mkconfig + * Tue Mar 08 2016 Stephen Gallagher - 24-0.14 - Add a subpackage for Atomic Host to provide /usr/lib/os-release differences diff --git a/sources b/sources index 9f61351..3c242ca 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -a70a33c67000cc205045fc7e16ec3e3e fedora-release-24.tar.bz2 +cce2da6dccb1f78d2990f76a3788c156 fedora-release-24.tar.bz2