forked from Lainports/opnsense-ports
opnsense/bsdinstaller: prune the swap obsession
This commit is contained in:
parent
989ea88f4b
commit
d6fcf59ae9
7 changed files with 8 additions and 155 deletions
|
|
@ -1,6 +1,6 @@
|
|||
PORTNAME= bsdinstaller
|
||||
PORTVERSION= 2.1.1
|
||||
PORTREVISION= 11
|
||||
PORTREVISION= 12
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= # empty
|
||||
DISTFILES= # none
|
||||
|
|
|
|||
|
|
@ -412,7 +412,6 @@ cmd_names = {
|
|||
MOUNT = "sbin/mount -o async",
|
||||
MOUNT_MFS = "sbin/mount_mfs",
|
||||
UMOUNT = "sbin/umount",
|
||||
SWAPON = "sbin/swapon",
|
||||
DISKLABEL = "sbin/disklabel",
|
||||
MBRLABEL = "sbin/mbrlabel",
|
||||
NEWFS = "sbin/newfs",
|
||||
|
|
|
|||
|
|
@ -25,35 +25,6 @@ return {
|
|||
return step
|
||||
end
|
||||
|
||||
if pd:get_activated_swap():in_units("K") > 0 then
|
||||
local response = App.ui:present{
|
||||
name = _("Cannot swapoff; reboot?"),
|
||||
short_desc = _(
|
||||
"Some subpartitions on the selected primary " ..
|
||||
"partition are already activated as swap. " ..
|
||||
"Since there is no way to deactivate swap in " ..
|
||||
"%s once it is activated, in order " ..
|
||||
"to edit the subpartition layout of this " ..
|
||||
"primary partition, you must first reboot.",
|
||||
App.conf.product.name
|
||||
),
|
||||
actions = {
|
||||
{
|
||||
id = "reboot",
|
||||
name = _("Reboot"),
|
||||
effect = function() return "reboot" end
|
||||
},
|
||||
{
|
||||
id = "cancel",
|
||||
name = _("Return to %s", step:get_prev_name()),
|
||||
accelerator = "ESC",
|
||||
effect = function() return step:prev() end
|
||||
}
|
||||
}
|
||||
}
|
||||
return response.result
|
||||
end
|
||||
|
||||
App.state.sel_part = pd
|
||||
|
||||
local part_min_capacity = Storage.Capacity.new(
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
--
|
||||
-- Actually install the OS.
|
||||
-- XXX this could probably be split up into further steps:
|
||||
--
|
||||
-- 2) activate swap
|
||||
-- 3) create and mount the target system
|
||||
-- 4) copy the files
|
||||
-- 5) clean up
|
||||
-- 1) create and mount the target system
|
||||
-- 2) copy the files
|
||||
-- 3) clean up
|
||||
--
|
||||
|
||||
return {
|
||||
|
|
@ -34,22 +32,6 @@ return {
|
|||
--
|
||||
cmds = CmdChain.new()
|
||||
|
||||
--
|
||||
-- Activate swap, if there is none activated so far.
|
||||
--
|
||||
if App.state.storage:get_activated_swap():in_units("K") == 0 then
|
||||
for spd in App.state.sel_part:get_subparts() do
|
||||
if spd:get_fstype() == "swap" then
|
||||
cmds:add{
|
||||
cmdline = "${root}${SWAPON} ${root}dev/${dev}",
|
||||
replacements = {
|
||||
dev = spd:get_device_name()
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Initialize the target system, create the mountpoint directories
|
||||
-- configured for the selected partition (presumably set up by the
|
||||
|
|
|
|||
|
|
@ -36,35 +36,6 @@ return {
|
|||
return step
|
||||
end
|
||||
|
||||
if pd:get_activated_swap():in_units("K") > 0 then
|
||||
local response = App.ui:present{
|
||||
name = _("Cannot swapoff; reboot?"),
|
||||
short_desc = _(
|
||||
"Some subpartitions on the selected primary " ..
|
||||
"partition are already activated as swap. " ..
|
||||
"Since there is no way to deactivate swap in " ..
|
||||
"%s once it is activated, in order " ..
|
||||
"to edit the subpartition layout of this " ..
|
||||
"primary partition, you must first reboot.",
|
||||
App.conf.product.name
|
||||
),
|
||||
actions = {
|
||||
{
|
||||
id = "reboot",
|
||||
name = _("Reboot"),
|
||||
effect = function() return "reboot" end
|
||||
},
|
||||
{
|
||||
id = "cancel",
|
||||
name = _("Return to %s", step:get_prev_name()),
|
||||
accelerator = "ESC",
|
||||
effect = function() return step:prev() end
|
||||
}
|
||||
}
|
||||
}
|
||||
return response.result
|
||||
end
|
||||
|
||||
App.state.sel_part = pd
|
||||
|
||||
local part_min_capacity = Storage.Capacity.new(
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
--
|
||||
-- Actually install the OS.
|
||||
-- XXX this could probably be split up into further steps:
|
||||
--
|
||||
-- 2) activate swap
|
||||
-- 3) create and mount the target system
|
||||
-- 4) copy the files
|
||||
-- 5) clean up
|
||||
-- 1) create and mount the target system
|
||||
-- 2) copy the files
|
||||
-- 3) clean up
|
||||
--
|
||||
|
||||
return {
|
||||
|
|
@ -34,22 +32,6 @@ return {
|
|||
--
|
||||
cmds = CmdChain.new()
|
||||
|
||||
--
|
||||
-- Activate swap, if there is none activated so far.
|
||||
--
|
||||
if App.state.storage:get_activated_swap():in_units("K") == 0 then
|
||||
for spd in App.state.sel_part:get_subparts() do
|
||||
if spd:get_fstype() == "swap" then
|
||||
cmds:add{
|
||||
cmdline = "${root}${SWAPON} ${root}dev/${dev}",
|
||||
replacements = {
|
||||
dev = spd:get_device_name()
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Initialize the target system, create the mountpoint directories
|
||||
-- configured for the selected partition (presumably set up by the
|
||||
|
|
|
|||
|
|
@ -539,32 +539,6 @@ Storage.System.new = function()
|
|||
return Storage.Capacity.new(ram, "M")
|
||||
end
|
||||
|
||||
--
|
||||
-- Return the total amount of swap (virtual) memory,
|
||||
-- as a Storage.Capacity object, activated on all disks
|
||||
-- on this system.
|
||||
--
|
||||
method.get_activated_swap = function(self)
|
||||
local pty, line
|
||||
local swap = 0
|
||||
local found, len, devname, amount
|
||||
|
||||
local cmd = App.expand("${root}${SWAPINFO} -k")
|
||||
local pty = Pty.Logged.open(cmd, App.log_string)
|
||||
line = pty:readline()
|
||||
while line do
|
||||
if not string.find(line, "^Device") then
|
||||
found, len, devname, amount =
|
||||
string.find(line, "^([^%s]+)%s+(%d+)")
|
||||
swap = swap + tonumber(amount)
|
||||
end
|
||||
line = pty:readline()
|
||||
end
|
||||
pty:close()
|
||||
|
||||
return Storage.Capacity.new(swap, "K")
|
||||
end
|
||||
|
||||
--
|
||||
-- Print the contents this Storage.System, for debugging purposes.
|
||||
--
|
||||
|
|
@ -1656,32 +1630,6 @@ Storage.Partition.new = function(params)
|
|||
return parent.get_name() .. "s" .. number -- .. "c"
|
||||
end
|
||||
|
||||
--
|
||||
-- Return the total amount of swap (virtual) memory,
|
||||
-- as a Storage.Capacity object, activated on this partition.
|
||||
--
|
||||
method.get_activated_swap = function(self)
|
||||
local swap = 0
|
||||
local found, len, devname, amount
|
||||
|
||||
local cmd = App.expand("${root}${SWAPINFO} -k")
|
||||
local pty = Pty.Logged.open(cmd, App.log_string)
|
||||
local line = pty:readline()
|
||||
while line do
|
||||
if not string.find(line, "^Device") then
|
||||
found, len, devname, amount =
|
||||
string.find(line, "^([^%s]+)%s+(%d+)")
|
||||
if string.find(devname, self:get_device_name()) then
|
||||
swap = swap + tonumber(amount)
|
||||
end
|
||||
end
|
||||
line = pty:readline()
|
||||
end
|
||||
pty:close()
|
||||
|
||||
return Storage.Capacity.new(swap, "K")
|
||||
end
|
||||
|
||||
--
|
||||
-- Return an iterator which yields the next Storage.Partition
|
||||
-- object in this Storage.Disk each time it is called (typically
|
||||
|
|
@ -2430,4 +2378,4 @@ end
|
|||
|
||||
return Storage
|
||||
|
||||
-- END of lib/storage.lua --
|
||||
-- END of lib/storage.lua --
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue