summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-04-09 16:20:44 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-04-09 16:20:44 +0000
commit6833313d7ac77c3538a1fe0249eb0d06e11ffa27 (patch)
tree80af2a96124cf8d909b7e2b45b5031cd12dee350
parent285a0dca4874332d9605a978567622ae31ce15a7 (diff)
downloadlive-6833313d7ac77c3538a1fe0249eb0d06e11ffa27.tar.gz
Configure APT mirrors
-rwxr-xr-xinstall93
1 files changed, 93 insertions, 0 deletions
diff --git a/install b/install
index e594bbb..fa910e3 100755
--- a/install
+++ b/install
@@ -15,6 +15,7 @@ from snack import *
from subprocess import Popen, PIPE, call
from pprint import pprint
from tempfile import mkstemp
+from urllib2 import urlopen, URLError, HTTPError
import os
import re
import sys
@@ -34,6 +35,15 @@ rslice = None
# Created boot environment
bootenv = None
+# Version to install:
+codename = 'bok'
+
+# Dyson mirrors:
+mirror = None
+mirrors = [
+ ('http://apt.osdyson.org', 'Russia'),
+ ('http://mirror-us.osdyson.org/apt/', 'USA'),
+ ]
class Abort(Exception):
''' User clicked "Cancel" '''
@@ -374,17 +384,100 @@ will be used.'
raise Abort('Partitioning')
return choice
+def get_mirror():
+ if not hasattr(get_mirror, "m"):
+ get_mirror.m=''
+ while True:
+ (choice, entry) = EntryWindow(screen,
+ title='Enter APT repository URL',
+ text='If you want to have line '
+ '"deb ftp://192.168.1.1 bok main" in /etc/apt/sources.list '
+ 'enter "ftp://192.168.1.1" here.\n'
+ 'Remember to add URL protocol.\n',
+ prompts=[('URL', get_mirror.m)],
+ buttons = [ ('Ok', 'ok'), ('Back', 'back'), ('Cancel', 'cancel')],
+ width=70,
+ entryWidth=50,
+ )
+ if choice == 'back':
+ return None
+ if choice in ['ok', None]:
+ get_mirror.m = entry[0]
+ if valid_mirror(get_mirror.m):
+ return get_mirror.m
+ if choice == 'cancel':
+ raise Abort('Entering an APT mirror')
+def valid_mirror(mirror):
+ progress = ProgressMessage(screen, title='Please, wait',
+ text='Checking APT mirror: ' + mirror)
+ try:
+ o = urlopen('{mirror}/dists/{codename}/Release'.format(
+ mirror=mirror, codename=codename), timeout=10)
+ return True
+ except HTTPError as e:
+ ButtonChoiceWindow(screen,
+ title='Error',
+ text='{code} {reason}.\n\nMirror {mirror} is not usable.'.format(
+ mirror=mirror, code=e.code, reason=e.reason),
+ buttons = ['Ok'], width=70)
+ except URLError as e:
+ ButtonChoiceWindow(screen,
+ title='Error',
+ text='{reason}.\n\nMirror {mirror} is not usable.'.format(
+ reason=e.reason,mirror=mirror),
+ buttons = ['Ok'], width=70)
+ except ValueError:
+ ButtonChoiceWindow(screen,
+ title='Failed to check mirror',
+ text='Invalid URL: ' + mirror,
+ buttons = ['Ok'], width=70)
+ except Exception:
+ ButtonChoiceWindow(screen,
+ title='Failed to check mirror',
+ text='Unknown error: ' + mirror,
+ buttons = ['Ok'], width=70)
+ return False
+
+def configure_mirror():
+ global mirror
+ items = map(lambda x: '{url} ({info})'.format(url=x[0], info=x[1]), mirrors)
+ items.append(('Enter another mirror', None))
+ while not mirror:
+ (choice, m) = ListboxChoiceWindow(screen,
+ title='Choose APT mirror',
+ text='Choose APT repository from which Dyson will be installed',
+ items=items,
+ buttons=[('Ok','ok'), ('Cancel', 'cancel')],
+ width=76,
+ scroll=1,
+ default=0,
+ )
+ if choice in ['ok', None]:
+ if m == None:
+ mirror = get_mirror()
+ else:
+ if valid_mirror(mirrors[m][0]):
+ mirror = mirrors[m][0]
+ if choice == 'cancel':
+ raise Abort('Choosing APT mirror')
+
+
+def destroy_bootenv():
+ pass
+
screen = SnackScreen()
screen.pushHelpLine(' ')
try:
welcome()
find_hdds()
configure_rpool()
+ configure_mirror()
configure_zfs()
except Abort as e:
+ destroy_bootenv()
pass
except NoDisks as e:
print (e)