summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-09-04 00:33:03 +0400
committerIgor Pashev <pashev.igor@gmail.com>2013-09-04 00:33:03 +0400
commit484d96bb1e32097689adda0e8162b9c435d1115a (patch)
tree9c8c4f64aa1d219da82153ab079ec0345bc89fbe
parentc025611417b6b355530815e57a86ff5fbcac5b6a (diff)
downloadlive-484d96bb1e32097689adda0e8162b9c435d1115a.tar.gz
Install profiles
-rw-r--r--DysonInstaller/snack/__init__.py83
-rwxr-xr-xinstall52
2 files changed, 123 insertions, 12 deletions
diff --git a/DysonInstaller/snack/__init__.py b/DysonInstaller/snack/__init__.py
index 31cb0f2..580aaba 100644
--- a/DysonInstaller/snack/__init__.py
+++ b/DysonInstaller/snack/__init__.py
@@ -11,6 +11,8 @@ without prior consent from anybody.
from snack import *
import math
+import apt.progress.base
+import os
class ProgressMessage(object):
_text = None
@@ -118,3 +120,84 @@ class ProgressBar(object):
def __del__(self):
self._screen.popWindow()
+
+
+class BaseProgress(object):
+ _progressbar = None
+ _screen = None
+ _title = None
+ _text = ''
+
+ def __init__(self, screen, title, text=''):
+ self._screen = screen
+ self._title = title
+ self._text = text
+
+ def _create_progressbar(self):
+ self._progressbar = ProgressBar(self._screen,
+ title=self._title, text=self._text)
+
+ def _destroy_progressbar(self):
+ del self._progressbar
+ self._progressbar = None
+
+
+class DownloadProgress(apt.progress.base.AcquireProgress, BaseProgress):
+ def pulse(self, acquire):
+ self._progressbar.progress = (
+ ((self.current_bytes + self.current_items) * 100.0) /
+ float(self.total_bytes + self.total_items))
+ return True
+
+ def start(self):
+ self._create_progressbar()
+
+ def stop(self):
+ self._destroy_progressbar()
+
+class OpenProgress(apt.progress.base.OpProgress, BaseProgress):
+ def __init__(self, screen, title, text=''):
+ BaseProgress.__init__(self, screen, title, text)
+
+ def update(self, percent=None):
+ if not self._progressbar:
+ self._create_progressbar()
+ if percent:
+ self._progressbar.progress = percent
+
+ def done(self):
+ self._destroy_progressbar()
+
+class InstallProgress(apt.progress.base.InstallProgress, BaseProgress):
+ _logfile = '/dev/null'
+
+ def __init__(self, screen, title, text='', logfile=None):
+ apt.progress.base.InstallProgress.__init__(self)
+ BaseProgress.__init__(self, screen, title, text)
+ if logfile:
+ self._logfile = logfile
+
+
+ def start_update(self):
+ self._create_progressbar()
+
+ def finish_update(self):
+ self._destroy_progressbar()
+
+ def status_change(self, pkg, percent, status):
+ self._progressbar.progress = percent
+ self._progressbar.text = status
+
+ def dpkg_status_change(self, pkg, status):
+ self._progressbar.progress = percent
+ self._progressbar.text = status + ' ' + pkg
+
+ def fork(self):
+ """ Shut up dpkg """
+ pid = os.fork()
+ if pid == 0:
+ log = os.open(self._logfile, os.O_WRONLY + os.O_CREAT)
+ os.dup2(log, 1)
+ os.dup2(log, 2)
+ return pid
+
diff --git a/install b/install
index 115cc3c..6dafdc6 100755
--- a/install
+++ b/install
@@ -26,6 +26,8 @@ import sys
import math
import shutil
import traceback
+import apt
+import apt_pkg
# Snack screen
screen = None
@@ -88,13 +90,14 @@ profiles = [
{
'name': 'Basic',
'desc' : 'Basic system without X',
- 'packages' : 'locales vim bash-completion mc sudo lynx mutt wget curl openssh-server illumos-grub illumos-kernel',
+ 'packages' : '''locales vim bash-completion mc sudo lynx mutt wget curl openssh-server''',
},
{
'name': 'Desktop',
'desc' : 'Install X, XFCE and some graphical applications',
- 'packages' : 'mc illumos-grub illumos-kernel locales bash-completion vim-gtk xfce4 synaptic abiword dillo gnumeric'
- 'sylpheed geany lightdm pidgin evince sudo',
+ 'packages' : '''mc locales bash-completion vim-gtk synaptic abiword dillo gnumeric
+ sylpheed geany lightdm pidgin evince sudo
+ xorg xfce4 xfce4-terminal dbus curl wget''',
},
]
@@ -769,10 +772,27 @@ def install_minimal():
umount_in_bootenv() # debootstrap mounts required FS for us
call(['zfs', 'rollback', '-r', bootenv + '@empty'])
-def install():
- choose_profile()
- install_minimal()
- install_profile()
+def install_profile():
+ logfile = rootdir + '/root/apt-get.log'
+ apt_pkg.config.set('Dpkg::Chroot-Directory', rootdir)
+ cache = apt.Cache(rootdir=rootdir)
+
+ update_progress = DownloadProgress(screen, title='Please wait', text='Updating APT cache ...')
+ cache.update(update_progress)
+
+ open_progress = OpenProgress(screen, title='Please wait', text='Reading package list ...')
+ cache.open(open_progress)
+
+ download_progress = DownloadProgress(screen, title='Downloading packages', text='Please wait ...')
+ install_progress = InstallProgress(screen,
+ title='Installing packages', text='Please wait ...',
+ logfile=logfile)
+
+ for p in profiles[profile]['packages'].split():
+ cache[p].mark_install()
+
+ cache.commit(download_progress, install_progress)
+
def umount_in_bootenv():
'''unmount all FS mounted in BE on final cleanup.
@@ -958,19 +978,26 @@ def create_user():
def configure_bootenv():
write_vfstab()
mount_in_bootenv()
+
+ if profile != 0:
+ install_profile()
+
in_bootenv(['/usr/sbin/devfsadm'])
open(rootdir + '/reconfigure', 'w').close()
- configure_packages()
- configure_nodename()
+ configure_nodename()
+ set_root_password()
# quick and dirty: if network is configured on livecd, copy config into boot env
try:
shutil.copy2('/etc/ipadm/ipadm.conf',
rootdir+'/etc/ipadm/ipadm.conf')
except:
pass
- set_root_password()
- create_user()
+
+ if profile != 0:
+ create_user()
+ configure_packages()
+
create_bootarchive()
configure_smf()
@@ -1128,7 +1155,8 @@ while True:
find_hdds()
configure_rpool()
configure_zfs()
- install()
+ choose_profile()
+ install_minimal()
configure_bootenv()
configure_grub()
goodbye()