1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# «oem-config-remove-gtk» - remove-oem-config after completing
#
# Copyright (C) 2010, Mario Limonciello
# Copyright (C) 2010, Sebastian Heinlein
#
#
# Ubiquity is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this application; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import glob
import os
import sys
from aptdaemon import client, enums
from aptdaemon.gtk3widgets import AptProgressDialog
from gi.repository import GLib, Gtk
loop = GLib.MainLoop()
def _on_failure(error):
dia = Gtk.MessageDialog(type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.CLOSE,
message_format=error.message)
dia.run()
dia.hide()
loop.quit()
sys.exit(1)
def _on_finished(dia):
loop.quit()
if dia._transaction.exit == enums.EXIT_SUCCESS:
sys.exit(0)
else:
sys.exit(1)
def _on_transaction(trans):
apt_dialog = AptProgressDialog(trans)
theme = Gtk.IconTheme.get_default()
apt_dialog.set_icon(theme.load_icon("update-manager", 16, 0))
apt_dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
apt_dialog.run()
apt_dialog.connect("finished", _on_finished)
def using_cryptsetup():
if os.path.exists("/home/.ecryptfs"):
return True
try:
with open("/etc/crypttab") as crypttab:
for line in crypttab:
if not line.startswith("#"):
return True
except IOError:
pass
return False
def main():
purge = []
for pkg in ('ubiquity', 'ubiquity-casper',
'ubiquity-ubuntu-artwork', 'ubiquity-slideshow-ubuntu',
'oem-config-slideshow-ubuntu', 'ubiquity-frontend-gtk'):
if glob.glob('/var/lib/dpkg/info/%s.list' % pkg):
purge.append(pkg)
if not using_cryptsetup():
purge.append("cryptsetup")
ac = client.AptClient()
ac.commit_packages(
install=[], reinstall=[], remove=[], purge=purge, upgrade=[],
downgrade=[], error_handler=_on_failure, reply_handler=_on_transaction)
loop.run()
if __name__ == "__main__":
main()
|