Skip to content

Commit

Permalink
- Functions.AutoRootSize now accepts a partition mode as an argument,
Browse files Browse the repository at this point in the history
in order to calculate the root partition size for that mode 
(auto and freespace modes, though the free-space mode still needs work)
- Functions.EnoughSpace() created to compare the theoretical root
partition size with the space the packages will ocupy (returns a boolean
value).
  • Loading branch information
easuter committed Aug 9, 2007
1 parent 2a73466 commit 2e5098f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 32 deletions.
12 changes: 6 additions & 6 deletions .lang/.pot
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ msgstr ""
msgid "Cancel"
msgstr ""

#: frmChoice.class:95
#: frmChoice.class:94
msgid ""
"<center><h3><b>You have 3 choices:</b></h3></center>\n"
"\n"
Expand All @@ -47,23 +47,23 @@ msgid ""
"</ul>\n"
msgstr ""

#: frmChoice.class:106
#: frmChoice.class:105
msgid "Choose install type"
msgstr ""

#: frmChoice.class:121
#: frmChoice.class:120
msgid "Install types"
msgstr ""

#: frmChoice.class:126
#: frmChoice.class:125
msgid "Full-automatic"
msgstr ""

#: frmChoice.class:132
#: frmChoice.class:131
msgid "Semi-automatic"
msgstr ""

#: frmChoice.class:138
#: frmChoice.class:137
msgid "Advanced"
msgstr ""

Expand Down
12 changes: 6 additions & 6 deletions .lang/frmChoice.pot
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: frmChoice.class:95
#: frmChoice.class:94
msgid "<center><h3><b>You have 3 choices:</b></h3></center>\n\n<ul>\n<li><b><u>Full-automatic install:</u></b> Our easiest install yet; choose this option if you want to use your entire hard disk for VL. Your system will be automatically set up, partitions and all. <font color=\"#FF0000\">WARNING: this option will DELETE everything on your hard disk, or offer a choice if there are multiple disks.</font> There will of course be a confirmation dialog in case you selected this option by mistake.</li>\n<li><b><u>Semi-automatic install:</u></b> With this option, you manually partition your drives with gparted, but the rest of the setup will be pretty automatic.</li>\n<li><b><u>Advanced install:</u></b> For the technically savvy user that must do everything by hand. You can control most aspects of the install. However, there will be assisted options available all the way through, so this is a very flexible install.</li>\n</ul>\n"
msgstr ""

#: frmChoice.class:106
#: frmChoice.class:105
msgid "Choose install type"
msgstr ""

#: frmChoice.class:121
#: frmChoice.class:120
msgid "Install types"
msgstr ""

#: frmChoice.class:126
#: frmChoice.class:125
msgid "Full-automatic"
msgstr ""

#: frmChoice.class:132
#: frmChoice.class:131
msgid "Semi-automatic"
msgstr ""

#: frmChoice.class:138
#: frmChoice.class:137
msgid "Advanced"
msgstr ""

61 changes: 45 additions & 16 deletions Functions.module
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ IF sysmem < 134217728 THEN
RETURN sysmem * 2.5
ELSE IF sysmem < 268435456 AND sysmem > 134217728 THEN
RETURN sysmem * 2
ELSE
RETURN 536870912 'Don't return swap partition sizes above 512MB
ELSE 'Don't return swap partition sizes above 512MB
RETURN 536870912
ENDIF

END
Expand Down Expand Up @@ -271,26 +271,55 @@ RETURN iSize

END

PUBLIC FUNCTION AutoRootSize() AS Long
'Calculate the size of the theoretical root partition
PUBLIC FUNCTION AutoRootSize(partmode AS Integer) AS Long
'Calculate the size of the theoretical root partition, for the automatic or free-space partitioning modes
DIM iRootSize AS Long
DIM iTotalSize AS Long
DIM sTemp AS String

Utils.GetSysMemory
iTotalSize = 0

IF Global.SimulationMode = TRUE THEN
sTemp = "38000000"
ELSE
SHELL "fdisk -s " & Global.installDrive TO sTemp
IF Global.enumPARTMODE = 0 THEN 'Use entire drive
IF Global.SimulationMode = TRUE THEN
sTemp = "3800000"
ELSE 'Get real value from fdisk
SHELL "fdisk -s " & Global.installDrive TO sTemp
ENDIF

iTotalSize = CLng(Val(Trim$(sTemp))) * 1024 'Convert to long integer and turn value into bytes
iRootSize = iTotalSize - CalcSwap(Global.SysMemory)

ELSE IF Global.enumPARTMODE = 1 'Use only free space
IF Global.SimulationMode = TRUE THEN
sTemp = "3800000"
ELSE
'Do whatever needs to be done to get free space values from available partitions
ENDIF
ELSE
Message.Error("Unacceptable partition mode (" & Global.enumPARTMODE & ") for AutoRootSize function.")
ENDIF

iTotalSize = Val(sTemp)
iTotalSize = iTotalSize * 1024 'Convert to bytes

'Return the size to be used for the root partition, in bytes, with a "safety margin" of 150MB
iRootSize = iTotalSize - CalcSwap(Global.SysMemory) - 157286400
RETURN iRootSize

END

PUBLIC FUNCTION EnoughSpace() AS Boolean
'Check whether the space destined to the package installation is enough (with a 150MB "safety" margin)
DIM iAvailableSpace AS Long

IF Global.enumPARTMODE = 0 THEN
iAvailableSpace = AutoRootSize - CalcSwap(Global.SysMemory) - 157286400
IF iAvailableSpace > CalcPaksSize("all") THEN
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
'Do the same for other partition modes
ELSE IF Global.enumPARTMODE = 1 THEN
ELSE IF Global.enumPARTMODE = 2 THEN
ELSE IF Global.enumPARTMODE = 3 THEN
ELSE IF Global.enumPARTMODE = 4 THEN
ELSE IF Global.enumPARTMODE = 5 THEN
ELSE
Message.Error("Invalid partition mode: " & Global.enumPARTMODE)
ENDIF

END
3 changes: 3 additions & 0 deletions Main.module
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ ELSE
Global.SimulationMode = FALSE
ENDIF

'Get some basic system info processed:
Utils.GetSysMemory

' Initially no buttons being executed:
Global.flagBUTTExec = FALSE

Expand Down
7 changes: 3 additions & 4 deletions frmChoice.class
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ END
PUBLIC SUB btnFullAuto_Click() ' Full-automatic.

Global.enumINSTMODE = 0 ' Full-automatic install mode.
Global.enumPARTMODE = 0 'Full-automatic partitioning
Global.enumPACKS = 0 'All packages selected
Global.enumLILOMODE = 0 'Install lilo to MBR

Utils.DrivePartInfo
IF Global.DiskInfo.Count >= 1 THEN frmDriveSelect.ShowModal
Expand All @@ -33,10 +36,6 @@ frmMain.btnChoice.Enabled = FALSE ' Disable Choices.
frmMain.btnGo.Enabled = TRUE ' Enable Go for it!.
frmMain.btnGo_Click ' Advance to Go for it!.

'Debug
Utils.GetSysMemory
frmGo.TextLabel1.Text = "Swap: " & Functions.AutoUnits(Functions.CalcSwap(Global.SysMemory)) & " Root: " & Functions.AutoUnits(Functions.AutoRootSize()) & " Packages will ocupy: " & Functions.AutoUnits(Functions.CalcPaksSize("all"))

END

PUBLIC SUB btnSemiAuto_Click() ' Semi-automatic.
Expand Down

0 comments on commit 2e5098f

Please sign in to comment.