264
264
self.apt_clone_restore()
266
syslog.syslog(syslog.LOG_WARNING,
267
268
'Could not restore packages from the previous install:')
268
269
for line in traceback.format_exc().split('\n'):
269
270
syslog.syslog(syslog.LOG_WARNING, line)
273
274
self.copy_network_config()
275
syslog.syslog(syslog.LOG_WARNING,
276
278
'Could not copy the network configuration:')
277
279
for line in traceback.format_exc().split('\n'):
278
280
syslog.syslog(syslog.LOG_WARNING, line)
282
284
self.copy_bluetooth_config()
284
syslog.syslog(syslog.LOG_WARNING,
285
288
'Could not copy the bluetooth configuration:')
286
289
for line in traceback.format_exc().split('\n'):
287
290
syslog.syslog(syslog.LOG_WARNING, line)
291
294
self.recache_apparmor()
293
syslog.syslog(syslog.LOG_WARNING,
294
'Could not create an Apparmor cache:')
297
syslog.LOG_WARNING, 'Could not create an Apparmor cache:')
295
298
for line in traceback.format_exc().split('\n'):
296
299
syslog.syslog(syslog.LOG_WARNING, line)
298
301
self.copy_wallpaper_cache()
300
syslog.syslog(syslog.LOG_WARNING,
301
'Could not copy wallpaper cache:')
304
syslog.LOG_WARNING, 'Could not copy wallpaper cache:')
302
305
for line in traceback.format_exc().split('\n'):
303
306
syslog.syslog(syslog.LOG_WARNING, line)
342
345
# Python standard library.
343
346
re_minimal = re.compile('^python\d+\.\d+-minimal$')
344
python_installed = sorted(
345
[pkg[:-8] for pkg in cache.keys()
346
if re_minimal.match(pkg) and cache[pkg].is_installed])
347
python_installed = sorted([
348
pkg[:-8] for pkg in cache.keys()
349
if re_minimal.match(pkg) and cache[pkg].is_installed])
347
350
for python in python_installed:
348
351
re_file = re.compile('^/usr/lib/%s/.*\.py$' % python)
349
files = [f for f in cache['%s-minimal' % python].installed_files
350
if re_file.match(f) and
351
not os.path.exists(self.target_file('%sc' % f[1:]))]
353
f for f in cache['%s-minimal' % python].installed_files
354
if (re_file.match(f) and
355
not os.path.exists(self.target_file('%sc' % f[1:])))]
352
356
install_misc.chrex(self.target, python,
353
357
'/usr/lib/%s/py_compile.py' % python, *files)
354
files = [f for f in cache[python].installed_files
355
if re_file.match(f) and
356
not os.path.exists(self.target_file('%sc' % f[1:]))]
359
f for f in cache[python].installed_files
360
if (re_file.match(f) and
361
not os.path.exists(self.target_file('%sc' % f[1:])))]
357
362
install_misc.chrex(self.target, python,
358
363
'/usr/lib/%s/py_compile.py' % python, *files)
503
508
sock = socket.socket(socket.SOCK_DGRAM)
504
509
interfaces = install_misc.get_all_interfaces()
505
510
for i in range(len(interfaces)):
506
if_names[interfaces[i]] = struct.unpack('H6s',
507
fcntl.ioctl(sock.fileno(), SIOCGIFHWADDR,
509
interfaces[i].encode()))[16:24])
511
if_names[interfaces[i]] = struct.unpack(
513
sock.fileno(), SIOCGIFHWADDR,
514
struct.pack('256s', interfaces[i].encode()))[16:24])
512
517
with open(self.target_file('etc/iftab'), 'w') as iftab:
558
563
language_plugin = [
559
564
plugin for plugin in self.plugins
560
if plugin_manager.get_mod_string(plugin, "NAME") ==
565
if (plugin_manager.get_mod_string(plugin, "NAME") ==
562
567
except IndexError:
564
569
self.run_plugin(language_plugin)
586
591
if self.db.get('base-installer/install-recommends') == 'false':
587
with open(self.target_file(
588
'etc/apt/apt.conf.d/00InstallRecommends'),
592
tf = self.target_file('etc/apt/apt.conf.d/00InstallRecommends')
593
with open(tf, 'w') as apt_conf_ir:
590
594
print('APT::Install-Recommends "false";', file=apt_conf_ir)
591
595
except debconf.DebconfError:
594
598
# Make apt trust CDs. This is not on by default (we think).
595
599
# This will be left in place on the installed system.
596
with open(self.target_file(
597
'etc/apt/apt.conf.d/00trustcdrom'), 'w') as apt_conf_tc:
600
tf = self.target_file('etc/apt/apt.conf.d/00trustcdrom')
601
with open(tf, 'w') as apt_conf_tc:
598
602
print('APT::Authentication::TrustCDROM "true";', file=apt_conf_tc)
600
604
# Avoid clock skew causing gpg verification issues.
601
605
# This file will be left in place until the end of the install.
602
with open(self.target_file(
603
'etc/apt/apt.conf.d/00IgnoreTimeConflict'), 'w') as apt_conf_itc:
606
tf = self.target_file('etc/apt/apt.conf.d/00IgnoreTimeConflict')
607
with open(tf, 'w') as apt_conf_itc:
604
608
print('Acquire::gpgv::Options { "--ignore-time-conflict"; };',
605
609
file=apt_conf_itc)
608
612
if self.db.get('debian-installer/allow_unauthenticated') == 'true':
609
with open(self.target_file(
610
'etc/apt/apt.conf.d/00AllowUnauthenticated'),
613
tf = self.target_file(
614
'etc/apt/apt.conf.d/00AllowUnauthenticated')
615
with open(tf, 'w') as apt_conf_au:
612
616
print('APT::Get::AllowUnauthenticated "true";',
613
617
file=apt_conf_au)
614
618
print('Aptitude::CmdLine::Ignore-Trust-Violations "true";',
629
633
# Make apt-cdrom and apt not unmount/mount CD-ROMs.
630
634
# This file will be left in place until the end of the install.
631
with open(self.target_file(
632
'etc/apt/apt.conf.d/00NoMountCDROM'), 'w') as apt_conf_nmc:
635
tf = self.target_file('etc/apt/apt.conf.d/00NoMountCDROM')
636
with open(tf, 'w') as apt_conf_nmc:
633
637
print(textwrap.dedent("""\
634
638
APT::CDROM::NoMount "true";
894
898
if configdir is not None:
895
with open(os.path.join(
896
configdir, 'resume'), 'w') as configfile:
899
resume_path = os.path.join(configdir, 'resume')
900
with open(resume_path, 'w') as configfile:
897
901
print("RESUME=%s" % resume, file=configfile)
899
903
osextras.unlink_force(self.target_file('etc/popularity-contest.conf'))
1006
1010
'/usr/share/locale-langpack/%s/LC_MESSAGES/grub.mo' % lang)
1007
1011
if (os.path.exists(source) and
1008
os.path.isdir('/boot/grub/locale')):
1012
os.path.isdir('/boot/grub/locale')):
1009
1013
shutil.copy(source, '/boot/grub/locale/%s.mo' % lang)
1233
1237
# We only ever install these packages from the CD.
1234
1238
sources_list = self.target_file('etc/apt/sources.list')
1235
1239
os.rename(sources_list, "%s.apt-setup" % sources_list)
1236
with open("%s.apt-setup" % sources_list) as old_sources, \
1237
open(sources_list, 'w') as new_sources:
1239
for line in old_sources:
1240
if 'cdrom:' in line:
1241
print(line, end="", file=new_sources)
1240
with open("%s.apt-setup" % sources_list) as old_sources:
1241
with open(sources_list, 'w') as new_sources:
1243
for line in old_sources:
1244
if 'cdrom:' in line:
1245
print(line, end="", file=new_sources)
1243
1247
if not found_cdrom:
1244
1248
os.rename("%s.apt-setup" % sources_list, sources_list)
1261
1265
apps_dir = 'usr/share/applications'
1262
1266
for desktop_file in (
1263
apps_dir + '/oem-config-prepare-gtk.desktop',
1264
apps_dir + '/kde4/oem-config-prepare-kde.desktop'):
1267
apps_dir + '/oem-config-prepare-gtk.desktop',
1268
apps_dir + '/kde4/oem-config-prepare-kde.desktop'):
1265
1269
if os.path.exists(self.target_file(desktop_file)):
1266
1270
desktop_base = os.path.basename(desktop_file)
1267
1271
install_misc.chrex(
1286
1290
installable_lang = self.db.get(
1287
1291
'ubiquity/only-show-installable-languages')
1288
1292
if installable_lang:
1289
install_misc.set_debconf(self.target,
1293
install_misc.set_debconf(
1290
1295
'ubiquity/only-show-installable-languages',
1291
1296
installable_lang, self.db)
1292
1297
except debconf.DebconfError:
1517
1522
for bind in binds:
1518
1523
misc.execute('mount', '--bind', bind, self.target + bind)
1519
subprocess.check_call(['apt-clone', 'restore-new-distro',
1520
working, codename, '--destination', self.target],
1521
preexec_fn=install_misc.debconf_disconnect)
1525
'apt-clone', 'restore-new-distro',
1526
working, codename, '--destination', self.target]
1527
subprocess.check_call(
1528
restore_cmd, preexec_fn=install_misc.debconf_disconnect)
1523
1530
install_misc.chroot_cleanup(self.target)
1524
1531
for bind in binds:
1615
1622
target_user_cache_dir = self.target_file('home', target_user, '.cache')
1616
1623
target_user_wallpaper_cache_dir = os.path.join(target_user_cache_dir,
1618
if not os.path.isdir(target_user_wallpaper_cache_dir) and \
1619
os.path.isfile('/usr/lib/gnome-settings-daemon/'
1620
'gnome-update-wallpaper-cache'):
1625
if (not os.path.isdir(target_user_wallpaper_cache_dir) and
1626
os.path.isfile('/usr/lib/gnome-settings-daemon/'
1627
'gnome-update-wallpaper-cache')):
1621
1628
# installer mode (else, g-s-d created it)
1622
1629
if not os.path.isdir(casper_user_wallpaper_cache_dir):
1623
1630
subprocess.call(['sudo', '-u', casper_user, '-i', 'DISPLAY=:0',
1695
1702
if self.db.get('oem-config/enable') == 'true':
1696
1703
oem_id = self.db.get('oem-config/id')
1698
self.target_file('var/log/installer/oem-id'),
1699
'w') as oem_id_file:
1704
tf = self.target_file('var/log/installer/oem-id')
1705
with open(tf, 'w') as oem_id_file:
1700
1706
print(oem_id, file=oem_id_file)
1701
1707
except (debconf.DebconfError, IOError):