Premessa: ho cercato nella documentazione e in questo forum ma non sono riuscito a trovare una soluzione.
Ho un wizard con 8 schermate e ho necessità di far partire uno script shell tra una schermata e l'altra, precisamente tra la n°2 e la n°3, una volta premuto il pulsante di avanzamento. Posto l'intero codice
' Gambas class file
PUBLIC SUB Form_Open()
ME.Center
ME.Caption = ("Wizard")
SHELL "mkdir -p ubuntu-builder/configs/wizard" WAIT
SHELL "mkdir -p ubuntu-builder/configs/wizard/debs" WAIT
SHELL "cd ubuntu-builder/configs/wizard && touch APPS AUTOCOMMANDS BUILDISO DISTRO ISOFILE ISOSAVE" WAIT
TextBox_DistName.MaxLength = 32
TextBox_HostName.MaxLength = 32
TextBox_LiveCD_User.MaxLength = 32
Preset_Box.Add(("Select..."))
Preset_Box.Add("GNOME")
Preset_Box.Add("KDE")
Preset_Box.Add("XFCE4")
Preset_Box.Add("LXDE")
Preset_Box.Add("OpenBox")
Preset_Box.Add("FluxBox")
Preset_Box.Add("BlackBox")
Preset_Box.Add("IceWM")
END
' Seleziona file ISO
PUBLIC SUB ISO_FileChooser_Change()
ISO_FileChooser.Filter = ["*.iso", ("ISO Images")]
SHELL "echo " & ISO_FileChooser.Value & " > ~/ubuntu-builder/configs/wizard/ISOFILE"
END
' Informazioni sul sistema
PUBLIC SUB TextBox_DistName_Change()
File.Save("~/ubuntu-builder/configs/DIST", TextBox_DistName.Text)
END
PUBLIC SUB TextBox_HostName_Change()
File.Save("~/ubuntu-builder/configs/HNAME", TextBox_HostName.Text)
END
PUBLIC SUB TextBox_LiveCD_User_Change()
TextBox_LiveCD_User.Text = (Trim(LCase(TextBox_LiveCD_User.Text)))
File.Save("~/ubuntu-builder/configs/LIVEUSER", TextBox_LiveCD_User.Text)
END
PUBLIC SUB TextBox_ReleaseNotes_Change()
Trim(TextBox_ReleaseNotes.Text)
File.Save("~/ubuntu-builder/ISO/.disk/release_notes_url", TextBox_ReleaseNotes.Text)
END
PUBLIC SUB TextBox_DistName_KeyPress()
SELECT Key.text
CASE "@", "#", "!", "~", "(", ")", "{", "}", "[", "]"
STOP EVENT
END SELECT
END
PUBLIC SUB TextBox_HostName_KeyPress()
SELECT Key.text
CASE "@", "#", "!", "~", "(", ")", "{", "}", "[", "]"
STOP EVENT
END SELECT
END
PUBLIC SUB TextBox_LiveCD_User_KeyPress()
SELECT Key.text
CASE "@", "#", "!", "~", "(", ")", "{", "}", "[", "]"
STOP EVENT
END SELECT
END
' Lista dei presets da installare
PUBLIC SUB Install_Packages_Click()
SELECT CASE Preset_Box.Text
CASE "GNOME"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "gnome-core xserver-xorg")
CASE "KDE"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "kde-standard xserver-xorg")
CASE "XFCE4"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "xfce4 xserver-xorg")
CASE "LXDE"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "lxde-core xserver-xorg")
CASE "OpenBox"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "menu openbox obconf xserver-xorg")
CASE "FluxBox"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "menu fluxbox xserver-xorg")
CASE "BlackBox"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "menu blackbox xserver-xorg")
CASE "IceWM"
File.Save("~/ubuntu-builder/configs/wizard/APPS", "icewm xserver-xorg")
END SELECT
END
PUBLIC SUB Chroot_Commands_TextArea_Change()
File.Save("~/ubuntu-builder/configs/wizard/AUTOCOMMANDS", Chroot_Commands_TextArea.Text)
END
' Schermata aggiungi/rimuovi file .deb
PUBLIC SUB Add_DEB_Click()
DIM i AS Integer
DIM deb AS String[30]
DIM deb2 AS String[30]
DIM list AS String
Dialog.Title = ("Please select a DEB package")
Dialog.Filter = ["*.deb", ("Debian Packages")]
Dialog.Path = "/var/cache/apt/archives"
IF Dialog.OpenFile(TRUE) THEN RETURN
FOR EACH list IN Dialog.Paths
SHELL "echo " & list & " >> ~/ubuntu-builder/configs/wizard/DEBS"
NEXT
FOR i = 0 TO 29
SHELL "cat ~/ubuntu-builder/configs/wizard/DEBS | sed -n '" & Str(i + 1) & "p'" TO deb[i]
deb[i] = Replace(deb[i], "\n", "")
SHELL "cp " & deb[i] & " ~/ubuntu-builder/configs/wizard/debs/"
NEXT
FOR i = 0 TO 29
SHELL "ls ~/ubuntu-builder/configs/wizard/debs/ | sed -n '" & Str(i + 1) & "p'" TO deb2[i]
deb2[i] = Replace(deb2[i], "\n", "")
IF (deb2[i]) THEN DEBs_ListBox.Add(deb2[i])
NEXT
END
PUBLIC SUB DEBs_ListBox_KeyPress()
DIM i AS Integer
IF Key.Code = Key.Delete THEN
i = 0
WHILE i < DEBs_ListBox.Count
IF DEBs_ListBox[i].Selected THEN
SHELL "rm ~/ubuntu-builder/configs/wizard/debs/" & DEBs_ListBox[i].Text
DEBs_ListBox.Remove(i)
DEC i
ENDIF
INC i
WEND
ENDIF
END
PUBLIC SUB Remove_All_DEB_Click()
DEBs_ListBox.Clear
SHELL "rm ~/ubuntu-builder/configs/wizard/debs/*"
END
PUBLIC SUB Edit_Sources_Click()
FEdit.Show
END
PUBLIC SUB Start_Synaptic_Click()
SHELL "x-terminal-emulator -e sudo /usr/share/ubuntu-builder/extras/Synaptic"
END
PUBLIC SUB Wizard_Cancel()
SHELL "rm ~/ubuntu-builder/configs/wizard/debs/*"
FWizard.Close
FMain.Show
END
PUBLIC SUB Wizard_Close()
FWizard.Close
SHELL "x-terminal-emulator -e sudo /usr/share/ubuntu-builder/extras/Wizard"
FMain.Show
END
# Gambas Form File 2.0
{ Form Form
MoveScaled(0,0,78,53)
Text = ("Wizard")
Icon = Picture["ubuntu-builder.png"]
Border = Window.Fixed
{ Wizard Wizard
MoveScaled(1,1,76,51)
Count = 9
Index = 0
Text = ("# Welcome")
{ TextLabel5 TextLabel
MoveScaled(1,1,73,9)
Text = ("Welcome to Ubuntu Builder. This wizard will guide you during the creation of your customized distribuzion. Just follow the various steps and you can enjoy your new operating system.")
}
Index = 1
Text = ("# Select an ISO image")
{ ISO_FileChooser FileChooser
MoveScaled(1,1,73,38)
Filter = []
}
Index = 2
Text = ("# System informations")
{ TextLabel6 TextLabel
MoveScaled(1,1,73,9)
Text = ("Type the distribution name, the user name used for the live cd and the computer name in the fields below. If you want, you can also type the URL of the release notes of your distribution.")
}
{ TextBox_DistName TextBox
MoveScaled(38,16,29,3)
Text = ("")
}
{ TextBox_LiveCD_User TextBox
MoveScaled(38,22,29,3)
Text = ("")
}
{ TextBox_HostName TextBox
MoveScaled(38,28,29,3)
Text = ("")
}
{ TextBox_ReleaseNotes TextBox
MoveScaled(38,34,29,3)
Text = ("")
}
{ Label1 Label
MoveScaled(1,16,29,3)
Text = ("Distribution Name")
Alignment = Align.Left
}
{ Label2 Label
MoveScaled(1,22,29,3)
Text = ("LiveCD User Name")
Alignment = Align.Left
}
{ Label3 Label
MoveScaled(1,28,29,3)
Text = ("Computer Name")
Alignment = Align.Left
}
{ Label4 Label
MoveScaled(1,34,29,3)
Text = ("Release Notes")
Alignment = Align.Left
}
Index = 3
Text = ("# Repository and GUI")
{ Preset_Box ComboBox
MoveScaled(28,29,17,3)
ReadOnly = True
Text = ("")
}
{ TextLabel4 TextLabel
MoveScaled(1,17,73,9)
Text = ("You can add a desktop environment or a window manager to your distribution by selecting one of the presets below.\n\nIf you don't choose anyone of them, anything will be automatically installed on your distribution.")
}
{ Edit_Sources Button
MoveScaled(28,10,17,3)
Text = ("Edit sources")
}
{ TextLabel7 TextLabel
MoveScaled(1,1,73,9)
Text = ("Edit the software sources to increase the availability of packages you can install.")
}
Index = 4
Text = ("# Install DEB packages")
{ TextLabel3 TextLabel
MoveScaled(1,1,73,9)
Text = ("Add the DEB packages you want to install. The wizard will check all the required dependencies to install them. You can remove one package by pressing the CANC button on your keyboard of pressing \"Remove all\" to clear the packages list.")
}
{ DEBs_ListBox ListBox
MoveScaled(1,11,73,21)
Mode = Select.Multiple
Sorted = True
}
{ Add_DEB Button
MoveScaled(6,34,17,3)
Text = ("Add")
}
{ Remove_All_DEB Button
MoveScaled(52,34,17,3)
Text = ("Remove all")
}
Index = 5
Text = ("# Execute commands via chroot")
{ TextLabel2 TextLabel
MoveScaled(1,1,73,9)
Text = ("Here you can enter the commands which will be executed via chroot. Be careful to type the commands correctly; otherwise, the building process may fail.")
}
{ Chroot_Commands_TextArea TextArea
MoveScaled(1,11,73,21)
Text = ("")
Wrap = True
}
Index = 6
Text = ("# Choose where the ISO should be saved")
{ ISO_DirChooser DirChooser
MoveScaled(1,1,73,38)
ShowDetailed = True
}
Index = 7
Text = ("# Do you need more?")
{ Start_Synaptic Button
MoveScaled(28,10,17,3)
Text = ("Start Synaptic")
}
{ TextLabel9 TextLabel
MoveScaled(1,1,73,9)
Text = ("You can use Synaptic to install whatever you need or remove whatever you don't.")
}
{ TextLabel8 TextLabel
MoveScaled(1,17,73,9)
Text = ("Do you need more options? Customize your distribution via textual or graphical chroot. Suggested for advanced users.")
}
{ GUI_chroot Button
MoveScaled(45,29,17,3)
Text = ("Desktop")
}
{ CLI_chroot Button
MoveScaled(12,29,17,3)
Text = ("Console")
}
Index = 8
Text = ("# Ready to build")
{ TextLabel1 TextLabel
MoveScaled(1,1,73,9)
Text = ("All of the preparation has been done. Hit the OK button to start the automated proccess.")
}
Index = 0
}
}
- una volta terminata l'operazione, il wizard riappare e posso continuare con le altre schermate