From: <cod...@go...> - 2009-03-05 22:35:21
|
Author: M0...@gm... Date: Thu Mar 5 14:29:53 2009 New Revision: 510 Added: branches/speedy/Step3a3a.class branches/speedy/Step3a3a.form Modified: branches/speedy/.lang/.pot branches/speedy/.lang/Step3a3.pot branches/speedy/ClsGlobal.class branches/speedy/MdlAutoPartition.module branches/speedy/Step3a3.class branches/speedy/Step3a3.form Log: Began autopartition process based on user input and partition selection Modified: branches/speedy/.lang/.pot ============================================================================== --- branches/speedy/.lang/.pot (original) +++ branches/speedy/.lang/.pot Thu Mar 5 14:29:53 2009 @@ -30,19 +30,19 @@ msgid "Quit" msgstr "" -#: MdlAutoPartition.module:112 +#: MdlAutoPartition.module:190 msgid "MB of free space" msgstr "" -#: MdlAutoPartition.module:182 +#: MdlAutoPartition.module:230 msgid "Existing Data" msgstr "" -#: MdlAutoPartition.module:203 +#: MdlAutoPartition.module:252 msgid "Total space for VectorLinux" msgstr "" -#: MdlAutoPartition.module:294 +#: MdlAutoPartition.module:346 msgid "Select the location to which we will resize" msgstr "" @@ -493,7 +493,7 @@ msgid "Partitioning stage complete. Click" msgstr "" -#: Step3a1a.class:177 Step3a2.class:359 Step5.class:177 +#: Step3a1a.class:177 Step3a2.class:359 Step3a3a.class:69 Step5.class:177 msgid "to continue" msgstr "" @@ -593,12 +593,55 @@ "back and select another partitioning method" msgstr "" -#: Step3a3.class:22 +#: Step3a3.class:23 Step3a3a.class:113 msgid "Claim free space from existing partitions" msgstr "" -#: Step3a3.class:144 -msgid "Select which partition to resize in order to make room for VectorLinux" +#: Step3a3.class:100 +msgid "" +"Select which partition to resize and use the slider below it to adjust the " +"ammount of space to be used by VectorLinux" +msgstr "" + +#: Step3a3a.class:26 +msgid "You are about to shink" +msgstr "" + +#: Step3a3a.class:26 +msgid "to make room for your vectorlinux installation." +msgstr "" + +#: Step3a3a.class:26 +msgid "" +"This is generally a safe procedure, however, you should always consider " +"making copies of your valuable data before making changes such as this one " +"to your system" +msgstr "" + +#: Step3a3a.class:26 +msgid "When you are ready to continue, click the" +msgstr "" + +#: Step3a3a.class:26 +msgid "button." +msgstr "" + +#: Step3a3a.class:64 +msgid "" +"Shrinking partitions and creating new environment for VectorLinux ... Please " +"Wait" +msgstr "" + +#: Step3a3a.class:69 +msgid "Partitions are ready for VectorLinux. Click" +msgstr "" + +#: Step3a3a.class:130 +msgid "Warning" +msgstr "" + +#: Step3a3a.class:160 +msgid "Shrink partitions now" msgstr "" #: Step4.class:23 Modified: branches/speedy/.lang/Step3a3.pot ============================================================================== --- branches/speedy/.lang/Step3a3.pot (original) +++ branches/speedy/.lang/Step3a3.pot Thu Mar 5 14:29:53 2009 @@ -14,11 +14,11 @@ "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: Step3a3.class:22 +#: Step3a3.class:23 msgid "Claim free space from existing partitions" msgstr "" -#: Step3a3.class:144 -msgid "Select which partition to resize in order to make room for VectorLinux" +#: Step3a3.class:100 +msgid "Select which partition to resize and use the slider below it to adjust the ammount of space to be used by VectorLinux" msgstr "" Modified: branches/speedy/ClsGlobal.class ============================================================================== --- branches/speedy/ClsGlobal.class (original) +++ branches/speedy/ClsGlobal.class Thu Mar 5 14:29:53 2009 @@ -68,3 +68,7 @@ STATIC PUBLIC sBulkListToInstall AS String STATIC PUBLIC sPkgListToInstall AS String +' auto partition by shinking existing partitions +STATIC PUBLIC lTotalMBforVL AS Long + + Modified: branches/speedy/MdlAutoPartition.module ============================================================================== --- branches/speedy/MdlAutoPartition.module (original) +++ branches/speedy/MdlAutoPartition.module Thu Mar 5 14:29:53 2009 @@ -24,6 +24,124 @@ PRIVATE picDrive AS Picture PRIVATE myProgs AS Object[] +PUBLIC sPartitionToShrink AS String +PUBLIC lMBAmmountToUseForVL AS Long + + +PUBLIC FUNCTION PERFORM_AUTO_PARTITION_FROM_FREE_SPACE(sPartition AS String) AS Integer + + ' trigger the automatic partitioning process. + DIM hproc AS Process + DIM sPartitionString, sFs, sResizeCommand, sDump, sPartPrefx AS String + DIM sLine, partedDump, sMountDumpArr AS String[] + DIM lCurrentSize AS Long + DIM i, iPart AS Integer + DIM lEndMark AS Long + DIM bSwapNeeded AS Boolean + DIM sSwapPart, sRootPart AS String + + lMBAmmountToUseForVL = ClsGlobal.lTotalMBforVL + + PRINT " --- -> Preparing to allocate " & lMBAmmountToUseForVL & " MB of space for VectorLinux from " & sPartition & " <- ---" + WAIT 1 + iPart = Right(sPartition, Len(sPartition) - Len("/dev/hda")) + IF iPart < 10 THEN + sPartPrefx = " " + ELSE + sPartPrefx = "" + END IF + + ' search for the partition information + FOR i = 0 TO sResizableList.Max + IF Left(Trim(sResizableList[i]), Len("/dev/hda1")) = Trim(sPartition) THEN + sPartitionString = Trim(sResizableList[i]) + END IF + NEXT ' we got the partition string now + + ' Ths string is formatted like this + ' Filesystem Type 1M-blocks Used Available Use% Mounted on + + ' split it in spaces + sLine = Split(sPartitionString, " ") + sFs = Trim(sLine[1]) + lCurrentSize = sLine[2] + + IF lMBAmmountToUseForVL <= 0 THEN + Message.Error("I dont know how much space to use for VL") + RETURN + END IF + + SELECT CASE sFs + CASE "ntfs", "NTFS" + sResizeCommand = "ntfsresize -s " & (lCurrentSize - lMBAmmountToUseForVL) & "m" & Space(1) & sPartition + CASE "ext2", "ext3", "*fat*", "hfsx", "hfs+", "hfs", "linux-swap" + SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print | tr -s \' \',\"\" | grep \"^" & sPartPrefx & iPart & "\"" TO sDump + sDump = Trim(sDump) + 'Number Start End Size Type File system Flags + '1 0.03MB 12256MB 12256MB primary reiserfs + partedDump = Split(sDump, " ") + lEndMark = Trim(partedDump[2]) + sResizeCommand = "parted " & sPartition & " unit mb resize " & iPart & Space(1) & Trim(partedDump[1]) & "m" & Space(1) & lEndMark - lMBAmmountToUseForVL & "m" + CASE "reiserfs" + 'r resize_reiserfs -s -1G /dev/hda8 ( see man resize_reiserfs ) + sResizeCommand = "resize_reiserfs -s -" & lMBAmmountToUseForVL & "M" & Space(1) & sPartition + + CASE ELSE + Message.Error("I dont know how to resize a pertition type " & sFs) + END SELECT + + + 'Message(sResizeCommand) + ' MAKE SURE THE PARTITION IS NOT MOUNTED BEFORE PROCEEDING + SHELL "mount | grep ^" & sPartition TO sDump + sDump = Trim(sDump) + sMountDumpArr = Split(sDump, "\n") + FOR i = 0 TO sMountDumpArr.Max + SHELL "umount -f " & sPartition + NEXT + + ' Just to make sure + SHELL "mount | grep ^" & sPartition TO sDump + sDump = Trim(sDump + IF Len(sDump) > 0 THEN + Message.Error(sPartition & Space(1)("is currently being used. Unable to umount it.") & "<br>" & + ("Try another partitioning method")) + RETURN 1 + END IF + + + ' run the actual command + hproc = SHELL sResizeCommand WAIT + IF hproc.Value > 0 THEN + RETURN hproc.Value + END IF + + ' create new partitions now that we're here ============================================================================================ + ' do we need to create a swap partition? + SHELL "probepart | grep -i \"linux swap\"" TO sDump + sDump = Trim(sDump) + IF sDump THEN + bSwapNeeded = FALSE + sDumparr = Split(sDump, "\n") + sLine = Split(sDumparr[0], " ") + sSwapPart = Trim(sLine[0]) + ELSE + bSwapNeeded = TRUE + END IF + + + + + + + + + + +END + + + PUBLIC SUB DISPLAY_PARTITIONS_WITH_FREE_SPACE(hostContainer AS Container) @@ -51,7 +169,10 @@ picDrive = Picture.Load("images/hdd.png") - + PRINT " ---\\_ Shrink existing partitions to make room for VL" + + WAIT + SHELL "df -Th | grep \"^/dev/\" | cut -f 1 -d \' \'" TO sPreMountList '| tr -s \' \',\"\"" TO sPreMountList 'Message(sPreMountList) sDumparr = Split(sPreMountList, "\n") @@ -105,7 +226,9 @@ lUsedMB = Trim(sLineArr[3]) lFreeMB = Trim(sLineArr[4]) 'Message(sLineArr[0] & Space(1) & "fREE SPACE " & sLineArr[4] & " Mb") + IF lFreeMB >= 10240 THEN ' only if free space is equal to or greater than 10GB + IF Trim(sLineArr[1]) <> "*xfs*" OR Trim(sLineArr[1]) <> "*jfs*" THEN 'only if fs is not xfs or jfs sResizableList.Add(Trim(sResults[i])) rb = NEW RadioButton(hostContainer) AS "PartitionOptions" WITH rb @@ -150,10 +273,11 @@ .BackColor = Color.SelectedBackground .Expand = FALSE .Text = ("Existing Data") - '.Width = .Parent.Width / 2 + .Width = .Parent.Width / 2 '.Width = .Parent.Width - (((lUsedMB + (4 * 1024)) + (lFreeMB / 2) / lFreeMB) / 100) * 100 .Height = .Parent.Height .Alignment = Align.Center + '.Visible = TRUE .tag = .Parent.Tag END WITH myProgs.Add(tl) @@ -161,7 +285,7 @@ WITH tl .Text = ClsGlobal.sDistroName .Height = .Parent.Height - .Width = .Parent.Width * 0.5 + '.Width = .Parent.Width * 0.5 .Expand = TRUE .BackColor = Color.LightBackground .Alignment = Align.Center @@ -211,21 +335,24 @@ ' END WITH END IF + END IF NEXT IF objContainters.count > 0 THEN objContainters[0].visible = TRUE - IF objSliders.Count > 0 THEN - objSliders[0].setfocus - END IF + FOR EACH tl IN myProgs + FOR EACH sl IN objSliders + IF tl.Tag = sl.tag THEN + 'Message(sl.value) + tl.Width = tl.Parent.Width / 2 + END IF + NEXT + NEXT + END -PUBLIC SUB Slider_click() - - - -END + PUBLIC SUB Slider_change() @@ -264,8 +391,10 @@ LAST.tooltip = ("Select the location to which we will resize") & Space(1) & LAST.tag FOR EACH tl IN objTls IF tl.Tag = LAST.tag THEN + tl.Text = ("Total space for VectorLinux") & ":" & Space(1) & (100 - LAST.Value) & "%" & Space(1) & "-" & " ( " & sAllocated & " MB )" - + 'lMBAmmountToUseForVL = sAllocated + ClsGlobal.lTotalMBforVL = sAllocated END IF NEXT Modified: branches/speedy/Step3a3.class ============================================================================== --- branches/speedy/Step3a3.class (original) +++ branches/speedy/Step3a3.class Thu Mar 5 14:29:53 2009 @@ -19,76 +19,32 @@ PUBLIC SUB Form_Open() - ME.tlbanner.Text = "<h2>" & ("Claim free space from existing partitions") & "</h2>" - 'ME.DISPLAY_RESIZABLE_PARTITIONS() - -END - -PUBLIC SUB DISPLAY_RESIZABLE_PARTITIONS() - ' ' - ' ' DIM sDump, sPreMountList, sDfDump, sDrives, sPartition, sPartShort AS String - ' ' DIM sResults, sDumparr AS String[] - ' ' DIM i, n AS Integer - ' ' - ' ' SHELL "df -Th | grep \"/dev\" | tr -s \' \',\"\"" TO sPreMountList - ' ' 'Message(sPreMountList) - ' ' SHELL "probepart | grep \"^/dev\" | tr -s \' \',\"\" | cut -f 1 -d \' \'" TO sDump - ' ' sDump = Trim(sDump) - ' ' sDumparr = Split(sDump, "\n") - ' ' FOR i = 0 TO sDumparr.Max - ' ' sPartition = Trim(sDumparr[i]) - ' ' sPartShort = Right(sPartition, Len(sPartition) - RInStr(sPartition, "/")) - ' ' 'Message(sPartShort) - ' ' sMountedList = sMountedList & sPartition & " " - ' ' IF InStr(sMountedList, sPartition) = FALSE THEN - ' ' SHELL "mkdir -p /mnt" &/ sPartShort & " 2> /dev/null" WAIT - ' ' SHELL "mount -o ro " & sPartition & Space(1) & "/mnt" &/ sPartShort & " 2> /dev/null" WAIT - ' ' END IF - ' ' - ' ' NEXT - ' ' - ' ' ' now that they're all mounted, get the free space on each one of them - ' ' SHELL "df -Th | grep \"^/dev\" | tr -s \' \',\"\"" TO sDfDump - ' ' 'Message(sMountedList) - ' ' sDfDump = Trim(sDfDump) - ' ' Message(sDfDump) - ' ' - ' ' FOR i = 0 TO sDumparr.Max - ' ' sPartition = Trim(sDumparr[i]) - ' ' sPartShort = Right(sPartition, Len(sPartition) - RInStr(sPartition, "/")) - ' ' IF sPartition <> ClsGlobal.sSourceAddr THEN - ' ' SHELL "umount -f /mnt" &/ sPartShort & " 2> /dev/null" WAIT - ' ' END IF - ' ' NEXT - ' ' - - - - ' Filesystem Type Size Used Avail Use% Mounted on - - - + ME.tlbanner.Text = "<h2>" & ("Claim free space from existing partitions") & "</h2>" END - - - PUBLIC FUNCTION GetNExt() AS String - + RETURN "Step3a3a" END PUBLIC SUB StartUp() + WAIT MdlAutoPartition.DISPLAY_PARTITIONS_WITH_FREE_SPACE(ME.ScrollView1) '(ME.ListContainer1) '(ME.ScrollView1) '(ME.HpnlChoices) END PUBLIC SUB OnExit() - + DIM rb AS RadioButton + FOR EACH rb IN MdlAutoPartition.objRbs + IF rb.Value = TRUE THEN + MdlAutoPartition.sPartitionToShrink = rb.Tag + 'MdlAutoPartition.lMBAmmountToUseForVL = + END IF + NEXT END Modified: branches/speedy/Step3a3.form ============================================================================== --- branches/speedy/Step3a3.form (original) +++ branches/speedy/Step3a3.form Thu Mar 5 14:29:53 2009 @@ -22,12 +22,12 @@ Expand = True } { tlExp TextLabel - MoveScaled(1,8,67,4) + MoveScaled(1,8,67,6) Expand = True - Text = ("Select which partition to resize in order to make room for VectorLinux") + Text = ("Select which partition to resize and use the slider below it to adjust the ammount of space to be used by VectorLinux") } { ScrollView1 ScrollView - MoveScaled(1,13,68,33) + MoveScaled(1,16,73,33) Expand = True Arrangement = Arrange.Row Spacing = 2 Added: branches/speedy/Step3a3a.class ============================================================================== --- (empty file) +++ branches/speedy/Step3a3a.class Thu Mar 5 14:29:53 2009 @@ -0,0 +1,82 @@ +' Gambas class file + +' This file is part of vinstall-ng + +' vinstall-ng is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 2 of the License, or +' (at your option) any later version. + +' vinstall-ng is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. + +' You should have received a copy of the GNU General Public License +' along with vinstall-ng. If not, see <http://www.gnu.org/licenses/>. + +PUBLIC SUB Form_Open() + + DIM sText AS String + + ME.tlExp.Text = "<h2>" & ME.tlExp.text & "</h2>" + + sText = ("You are about to shink") & Space(1) & MdlAutoPartition.sPartitionToShrink & Space(1) & ("to make room for your vectorlinux installation.") & Space(1)& + ("This is generally a safe procedure, however, you should always consider making copies of your valuable data before making changes such as this one to your system")& + "<br><br>" & ("When you are ready to continue, click the") & Space(1) & "\"<b>" & btstart.Text & "\" </b>" & Space(1) & ("button.") + ClsGlobal.fRunningMainForm.btnext.enabled = FALSE + ME.tlWarning.Text = sText + ME.tlbanner.Text = "<h2>" & ME.tlbanner.Text & "</h2>" + ME.hbox2.Visible = FALSE + + +END + +PUBLIC SUB OnExit() + + + +END + + +PUBLIC FUNCTION GetNext() AS String + + + +END + +PUBLIC SUB StartUP() + +ME.btStart.Enabled = TRUE +ME.HBox2.Visible = FALSE +ME.tlWarning.Visible = TRUE +ME.MovieBox1.Enabled = TRUE +ClsGlobal.fRunningMainForm.btnext.enabled = FALSE + +END + + +PUBLIC SUB btStart_Click() + + ME.tlWarning.Visible = FALSE + ME.HBox2.Visible = TRUE + ME.MovieBox1.path = "images/throbber.gif" + ME.tlExp.Text = ("Shrinking partitions and creating new environment for VectorLinux ... Please Wait") + ME.MovieBox1.Playing = TRUE + LAST.enabled = FALSE + MdlAutoPartition.PERFORM_AUTO_PARTITION_FROM_FREE_SPACE(MdlAutoPartition.sPartitionToShrink) + + ME.tlExp.Text = ("Partitions are ready for VectorLinux. Click") & Space(1) & "\"" & ClsGlobal.fRunningMainForm.btnext.text & "\"" & Space(1) & ("to continue") + MovieBox1.Playing = FALSE + ME.MovieBox1.Enabled = FALSE + ClsGlobal.fRunningMainForm.btnext.enabled = TRUE + + 'WAIT 10 + + 'ME.MovieBox1.Playing = FALSE + 'ClsGlobal.fRunningMainForm.btnext.enabled = TRUE + + + + +END Added: branches/speedy/Step3a3a.form ============================================================================== --- (empty file) +++ branches/speedy/Step3a3a.form Thu Mar 5 14:29:53 2009 @@ -0,0 +1,54 @@ +# Gambas Form File 2.0 + +{ Form Form + MoveScaled(0,0,80,67) + Text = ("") + Arrangement = Arrange.Row + { HPanel1 HPanel + MoveScaled(0,0,60,5) + Expand = True + { tlbanner TextLabel + MoveScaled(12,0,45,3) + Expand = True + Text = ("Claim free space from existing partitions") + } + { Separator1 Separator + MoveScaled(13,4,25,1) + Expand = True + } + } + { HBox1 HBox + MoveScaled(0,5,10,2) + Expand = True + } + { tlExp TextLabel + MoveScaled(1,8,67,4) + Expand = True + Text = ("Warning") + } + { tlWarning TextLabel + MoveScaled(1,12,62,10) + Expand = True + Padding = 2 + Text = ("") + Border = Border.Etched + } + { HBox2 HBox + MoveScaled(7,22,56,38) + Visible = False + Expand = True + { MovieBox1 MovieBox + MoveScaled(9,3,40,34) + Expand = True + Path = "/home/vluser/devel/speedy/images/throbber.gif" + } + } + { HBox3 HBox + MoveScaled(1,60,6,2) + Expand = True + } + { btStart Button + MoveScaled(1,62,20,3) + Text = ("Shrink partitions now") + } +} |