1 -- $Id: 500_install_os.lua,v 1.39 2005/04/05 07:37:20 cpressey Exp $
4 require "target_system"
13 -- Final confirmation.
16 id = "ready_to_install",
17 name = _("Ready to Install"),
19 "Everything is now ready to install the actual files which " ..
20 "comprise the %s operating system " ..
21 "on the selected partition of the selected disk.\n\n" ..
22 "Note that this process will take quite a while to finish. " ..
23 "You may wish to take a break now and come back to the " ..
24 "computer in a short while.", App.os.name),
28 name = _("Begin Installing Files")
32 name = _("Return to %s", fsm:prev().title)
35 }).action_id ~= "ok" then
40 -- If there is a target system mounted, unmount it before starting.
42 if App.state.target ~= nil and App.state.target:is_mounted() then
43 if not App.state.target:unmount() then
45 _("Warning: already-mounted target system could " ..
46 "not be correctly unmounted first."))
52 -- Create a command chain.
57 -- Activate swap, if there is none activated so far.
59 if App.state.storage:get_activated_swap() == 0 then
60 for spd in App.state.sel_part:get_subparts() do
61 if spd:get_fstype() == "swap" then
63 cmdline = "${root}${SWAPON} ${root}dev/${dev}",
65 dev = spd:get_device_name()
73 -- Mount the target system. This will create the
74 -- mountpoint directories the user asked for and
75 -- will mount their subpartitions on them.
77 App.state.target = TargetSystem.new(App.state.sel_part, "mnt")
78 if not App.state.target:create() then
80 _("Could not create the skeletal target system.")
84 if not App.state.target:mount() then
86 _("Could not mount the skeletal target system.")
92 -- Create the commands which will install the chosen directories
93 -- onto the target system.
95 App.state.target:cmds_install_srcs(cmds, App.load_conf("sources"))
98 -- If we were to copy /usr/local and /usr/X11R6 onto the HDD,
99 -- *all* packages installed on the LiveCD would be copied to
100 -- the HDD. This may not be what the user wants. So instead,
101 -- create an appropriate filesystem hierarchy under /usr/local
102 -- and /usr/X11R6 and populate them with only mandatory packages.
103 -- And first, remove the copied-over package database, as it is
107 "${root}${RM} -rf ${root}mnt/var/db/pkg",
108 "${root}${MKDIR} -p ${root}mnt/var/db/pkg",
109 "${root}${CHMOD} 755 ${root}mnt/var/db/pkg",
110 "${root}${MKDIR} -p ${root}mnt/usr/local",
111 "${root}${MTREE} -deU -f ${root}etc/mtree/BSD.local.dist -p ${root}mnt/usr/local",
112 "${root}${MKDIR} -p ${root}mnt/usr/X11R6",
113 "${root}${MTREE} -deU -f ${root}etc/mtree/BSD.x11-4.dist -p ${root}mnt/usr/X11R6"
121 -- If the user has both /var and /tmp subparitions,
122 -- symlink /var/tmp to /tmp.
124 if App.state.sel_part:get_subpart_by_mountpoint("/tmp") and
125 App.state.sel_part:get_subpart_by_mountpoint("/var") then
127 "${root}${CHMOD} 1777 ${root}mnt/tmp",
128 "${root}${RM} -rf ${root}mnt/var/tmp",
129 "${root}${LN} -s /tmp ${root}mnt/var/tmp"
134 -- If the user has /var, but no /tmp,
135 -- symlink /tmp to /var/tmp.
137 if not App.state.sel_part:get_subpart_by_mountpoint("/tmp") and
138 App.state.sel_part:get_subpart_by_mountpoint("/var") then
140 "${root}${RM} -rf ${root}mnt/tmp",
141 "${root}${LN} -s /var/tmp ${root}mnt/tmp"
146 -- If the user has /usr, but no /home,
147 -- symlink /home to /usr/home.
149 if not App.state.sel_part:get_subpart_by_mountpoint("/home") and
150 App.state.sel_part:get_subpart_by_mountpoint("/usr") then
152 "${root}${RM} -rf ${root}mnt/home",
153 "${root}${MKDIR} ${root}mnt/usr/home",
154 "${root}${LN} -s /usr/home ${root}mnt/home"
159 -- Clean up. In case some file didn't make it, use rm -f
161 if App.os == "DragonFly" then
162 cmds:add("${root}${RM} -f ${root}mnt/boot/loader.conf")
164 cmds:set_replacements{
165 logfile = App.log_filename,
166 part = App.state.sel_part:get_device_name()
168 cmds:add("${root}${RM} -f ${root}mnt/tmp/${logfile}")
171 -- Create missing directories.
174 "${root}${MKDIR} ${root}mnt/proc",
175 "${root}${MKDIR} ${root}mnt/mnt"
181 App.state.sel_part:cmds_write_fstab(cmds, "${root}mnt/etc/fstab")
184 -- If it was enabled and selected, write the crash device
185 -- in the user's new rc.conf file on the HDD.
187 if App.state.crash_device ~= nil then
188 local cv = ConfigVars.new()
190 cv:set("dumpdev", "/dev/" .. App.state.crash_device)
191 cv:set("dumpdir", "/var/crash")
192 cv:write(App.expander:expand("${root}mnt/etc/rc.conf"), "sh")
196 -- Install requested packages.
198 if App.state.sel_pkgs ~= nil then
199 local pkg_name, selected
202 local pr = App.ui:new_progress_bar{
203 title = _("Calculating package dependencies...")
206 for pkg_name, selected in App.state.sel_pkgs do
213 for pkg_name, selected in App.state.sel_pkgs do
216 "mnt/", cmds, pkg_name, pkg_seen
219 pr:set_amount((i * 100) / n)
227 -- Backup the disklabel and the log.
230 "${root}${DISKLABEL} ${part} >${root}mnt/etc/disklabel.${part}",
231 "${root}${CP} ${tmp}${logfile} ${root}mnt/var/log/${logfile}",
232 "${root}${CHMOD} 600 ${root}mnt/var/log/${logfile}"
238 if cmds:execute() then
240 -- If the install went successfully,
241 -- make sure once and for all that the disklabel is bootable.
243 cmds = CmdChain.new()
244 App.state.sel_part:cmds_install_bootstrap(cmds)
245 if not cmds:execute() then
247 _("Failed to make sure that the partition is bootable.")
253 _("%s was not fully installed.", App.os.name)