Installer import into contrib (real import this time)
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / backend / lua / install / 450_select_packages.lua
1 -- $Id: 450_select_packages.lua,v 1.4 2005/02/24 23:08:04 cpressey Exp $
2
3 require "package"
4 require "storage_ui"
5
6 return {
7     name = "select_packages",
8     title = "Select Packages",
9     action = function(fsm)
10         local i, j, pkg, regexp
11
12         if not App.state.sel_pkgs then
13                 local pkg_list = Package.list_all("")
14                 local def_pkgs = App.load_conf("def_pkgs") or {}
15
16                 App.state.sel_pkgs = {}
17                 for i, pkg in pkg_list do
18                         App.state.sel_pkgs[pkg] = false -- but present...
19                         for j, regexp in def_pkgs do
20                                 if string.find(pkg, regexp) then
21                                         App.state.sel_pkgs[pkg] = true
22                                 end
23                         end
24                 end
25         end
26
27         local ok, sel_pkgs = StorageUI.select_packages{
28             name = _("Select Packages"),
29             short_desc = _("Select the packages you wish to install from " ..
30                             "the LiveCD onto the HDD."),
31             checkbox_name = _("Install?"),
32             ok_name = _("Accept these Packages"),
33             cancel_name = _("Return to %s", fsm:prev().title),
34             
35             sel_pkgs = App.state.sel_pkgs
36         }
37
38         if ok then
39                 App.state.sel_pkgs = sel_pkgs
40                 return fsm:next()
41         else
42                 return fsm:prev()
43         end
44     end
45 }