aboutsummaryrefslogtreecommitdiff
blob: e01844b8cb99f254c94588ec61cf8285e1597f16 (plain)
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
#
# gentoo/__init__.py: Gentoo Portage Anaconda install method backend
#
#
# Copyright (C) 2011 wiktor w brodlo <wiktor@brodlo.net>
# Copyright (C) 2011 Gentoo Foundation
#
# This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
#

import os
import sys

class Portage:

	def __init__(self, terminal, root):
		print "Portage init!"
		self.term = terminal
		self.root = root

	# Syncs the Portage tree and updates Portage if an update is available
	def sync(self):
		self.term.run_command("chroot "+self.root+" emerge --sync")
		if self.term.get_child_exit_status() != 0:
			return False
		self.term.run_command("chroot "+self.root+" emerge --update portage")
		if self.term.get_child_exit_status() == 0:
			return True
		return False

	# Installs a package atom
	def install(self, atom):
		self.term.run_command("chroot "+self.root+" emerge "+atom)
		if self.term.get_child_exit_status() == 0:
			return True
		return False

	# Updates world
	def update_world(self):
		self.term.run_command("chroot "+self.root+" emerge --deep --newuse --update world")
		if self.term.get_child_exit_status() == 0:
			return True
		return False

	# Removes a package atom
	def remove(self, atom):
		self.term.run_command("chroot "+self.root+" emerge -C "+atom)
		if self.term.get_child_exit_status() == 0:
			return True
		return False