2011-01-12 12:24:04 +00:00
|
|
|
#
|
|
|
|
# BitBake Graphical GTK User Interface
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 Intel Corporation
|
|
|
|
#
|
|
|
|
# Authored by Joshua Lock <josh@linux.intel.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# 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, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gobject
|
2011-07-01 22:58:50 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
class BuildRep(gobject.GObject):
|
|
|
|
|
|
|
|
def __init__(self, userpkgs, allpkgs, base_image=None):
|
|
|
|
gobject.GObject.__init__(self)
|
|
|
|
self.base_image = base_image
|
|
|
|
self.allpkgs = allpkgs
|
|
|
|
self.userpkgs = userpkgs
|
|
|
|
|
|
|
|
def loadRecipe(self, pathname):
|
|
|
|
contents = []
|
|
|
|
packages = ""
|
|
|
|
base_image = ""
|
|
|
|
|
|
|
|
with open(pathname, 'r') as f:
|
|
|
|
contents = f.readlines()
|
|
|
|
|
|
|
|
pkg_pattern = "^\s*(IMAGE_INSTALL)\s*([+=.?]+)\s*(\"\S*\")"
|
|
|
|
img_pattern = "^\s*(require)\s+(\S+.bb)"
|
|
|
|
|
|
|
|
for line in contents:
|
|
|
|
matchpkg = re.search(pkg_pattern, line)
|
|
|
|
matchimg = re.search(img_pattern, line)
|
|
|
|
if matchpkg:
|
|
|
|
packages = packages + matchpkg.group(3).strip('"')
|
|
|
|
if matchimg:
|
|
|
|
base_image = os.path.basename(matchimg.group(2)).split(".")[0]
|
|
|
|
|
|
|
|
self.base_image = base_image
|
|
|
|
self.userpkgs = packages
|
|
|
|
|
|
|
|
def writeRecipe(self, writepath, model):
|
|
|
|
# FIXME: Need a better way to determine meta_path...
|
|
|
|
template = """
|
|
|
|
# Recipe generated by the HOB
|
|
|
|
|
|
|
|
require %s.bb
|
|
|
|
|
|
|
|
IMAGE_INSTALL += "%s"
|
|
|
|
"""
|
|
|
|
meta_path = model.find_image_path(self.base_image)
|
|
|
|
|
|
|
|
recipe = template % (meta_path, self.userpkgs)
|
|
|
|
|
|
|
|
if os.path.exists(writepath):
|
|
|
|
os.rename(writepath, "%s~" % writepath)
|
|
|
|
|
|
|
|
with open(writepath, 'w') as r:
|
|
|
|
r.write(recipe)
|
|
|
|
|
|
|
|
return writepath
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
class TaskListModel(gtk.ListStore):
|
|
|
|
"""
|
|
|
|
This class defines an gtk.ListStore subclass which will convert the output
|
|
|
|
of the bb.event.TargetsTreeGenerated event into a gtk.ListStore whilst also
|
|
|
|
providing convenience functions to access gtk.TreeModel subclasses which
|
|
|
|
provide filtered views of the data.
|
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
(COL_NAME, COL_DESC, COL_LIC, COL_GROUP, COL_DEPS, COL_BINB, COL_TYPE, COL_INC, COL_IMG, COL_PATH) = range(10)
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
__gsignals__ = {
|
|
|
|
"tasklist-populated" : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
2011-07-01 22:58:50 +00:00
|
|
|
()),
|
|
|
|
"contents-changed" : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
|
|
|
(gobject.TYPE_INT,)),
|
|
|
|
"image-changed" : (gobject.SIGNAL_RUN_LAST,
|
|
|
|
gobject.TYPE_NONE,
|
|
|
|
(gobject.TYPE_STRING,)),
|
2011-01-12 12:24:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
|
|
self.contents = None
|
|
|
|
self.tasks = None
|
|
|
|
self.packages = None
|
|
|
|
self.images = None
|
2011-07-01 22:58:50 +00:00
|
|
|
self.selected_image = None
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
gtk.ListStore.__init__ (self,
|
|
|
|
gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING,
|
2011-07-01 22:58:50 +00:00
|
|
|
gobject.TYPE_BOOLEAN,
|
|
|
|
gobject.TYPE_BOOLEAN,
|
|
|
|
gobject.TYPE_STRING)
|
|
|
|
|
|
|
|
def contents_changed_cb(self, tree_model, path, it=None):
|
|
|
|
pkg_cnt = self.contents.iter_n_children(None)
|
|
|
|
self.emit("contents-changed", pkg_cnt)
|
|
|
|
|
|
|
|
def contents_model_filter(self, model, it):
|
|
|
|
if not model.get_value(it, self.COL_INC) or model.get_value(it, self.COL_TYPE) == 'image':
|
|
|
|
return False
|
|
|
|
name = model.get_value(it, self.COL_NAME)
|
|
|
|
if name.endswith('-native') or name.endswith('-cross'):
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
Create, if required, and return a filtered gtk.TreeModel
|
|
|
|
containing only the items which are to be included in the
|
|
|
|
image
|
|
|
|
"""
|
|
|
|
def contents_model(self):
|
|
|
|
if not self.contents:
|
|
|
|
self.contents = self.filter_new()
|
2011-07-01 22:58:50 +00:00
|
|
|
self.contents.set_visible_func(self.contents_model_filter)
|
|
|
|
self.contents.connect("row-inserted", self.contents_changed_cb)
|
|
|
|
self.contents.connect("row-deleted", self.contents_changed_cb)
|
2011-01-12 12:24:04 +00:00
|
|
|
return self.contents
|
|
|
|
|
|
|
|
"""
|
|
|
|
Helper function to determine whether an item is a task
|
|
|
|
"""
|
|
|
|
def task_model_filter(self, model, it):
|
|
|
|
if model.get_value(it, self.COL_TYPE) == 'task':
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
"""
|
|
|
|
Create, if required, and return a filtered gtk.TreeModel
|
|
|
|
containing only the items which are tasks
|
|
|
|
"""
|
|
|
|
def tasks_model(self):
|
|
|
|
if not self.tasks:
|
|
|
|
self.tasks = self.filter_new()
|
|
|
|
self.tasks.set_visible_func(self.task_model_filter)
|
|
|
|
return self.tasks
|
|
|
|
|
|
|
|
"""
|
|
|
|
Helper function to determine whether an item is an image
|
|
|
|
"""
|
|
|
|
def image_model_filter(self, model, it):
|
|
|
|
if model.get_value(it, self.COL_TYPE) == 'image':
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
"""
|
|
|
|
Create, if required, and return a filtered gtk.TreeModel
|
|
|
|
containing only the items which are images
|
|
|
|
"""
|
|
|
|
def images_model(self):
|
|
|
|
if not self.images:
|
|
|
|
self.images = self.filter_new()
|
|
|
|
self.images.set_visible_func(self.image_model_filter)
|
|
|
|
return self.images
|
|
|
|
|
|
|
|
"""
|
|
|
|
Helper function to determine whether an item is a package
|
|
|
|
"""
|
|
|
|
def package_model_filter(self, model, it):
|
2011-07-01 22:58:50 +00:00
|
|
|
if model.get_value(it, self.COL_TYPE) != 'package':
|
2011-01-12 12:24:04 +00:00
|
|
|
return False
|
2011-07-01 22:58:50 +00:00
|
|
|
else:
|
|
|
|
return True
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
Create, if required, and return a filtered gtk.TreeModel
|
|
|
|
containing only the items which are packages
|
|
|
|
"""
|
|
|
|
def packages_model(self):
|
|
|
|
if not self.packages:
|
|
|
|
self.packages = self.filter_new()
|
|
|
|
self.packages.set_visible_func(self.package_model_filter)
|
|
|
|
return self.packages
|
|
|
|
|
|
|
|
"""
|
|
|
|
The populate() function takes as input the data from a
|
|
|
|
bb.event.TargetsTreeGenerated event and populates the TaskList.
|
|
|
|
Once the population is done it emits gsignal tasklist-populated
|
|
|
|
to notify any listeners that the model is ready
|
|
|
|
"""
|
|
|
|
def populate(self, event_model):
|
2011-07-01 22:58:50 +00:00
|
|
|
# First clear the model, in case repopulating
|
|
|
|
self.clear()
|
2011-01-12 12:24:04 +00:00
|
|
|
for item in event_model["pn"]:
|
|
|
|
atype = 'package'
|
|
|
|
name = item
|
|
|
|
summary = event_model["pn"][item]["summary"]
|
2011-07-01 22:58:50 +00:00
|
|
|
lic = event_model["pn"][item]["license"]
|
2011-01-12 12:24:04 +00:00
|
|
|
group = event_model["pn"][item]["section"]
|
2011-07-01 22:58:50 +00:00
|
|
|
filename = event_model["pn"][item]["filename"]
|
|
|
|
depends = event_model["depends"].get(item, "")
|
2011-01-12 12:24:04 +00:00
|
|
|
rdepends = event_model["rdepends-pn"].get(item, "")
|
2011-07-01 22:58:50 +00:00
|
|
|
if rdepends:
|
|
|
|
for rdep in rdepends:
|
|
|
|
if event_model["packages"].get(rdep, ""):
|
|
|
|
pn = event_model["packages"][rdep].get("pn", "")
|
|
|
|
if pn:
|
|
|
|
depends.append(pn)
|
|
|
|
|
2011-01-12 12:24:04 +00:00
|
|
|
self.squish(depends)
|
|
|
|
deps = " ".join(depends)
|
2011-07-01 22:58:50 +00:00
|
|
|
|
2011-01-12 12:24:04 +00:00
|
|
|
if name.count('task-') > 0:
|
|
|
|
atype = 'task'
|
|
|
|
elif name.count('-image-') > 0:
|
|
|
|
atype = 'image'
|
|
|
|
|
|
|
|
self.set(self.append(), self.COL_NAME, name, self.COL_DESC, summary,
|
2011-07-01 22:58:50 +00:00
|
|
|
self.COL_LIC, lic, self.COL_GROUP, group,
|
|
|
|
self.COL_DEPS, deps, self.COL_BINB, "",
|
|
|
|
self.COL_TYPE, atype, self.COL_INC, False,
|
|
|
|
self.COL_IMG, False, self.COL_PATH, filename)
|
|
|
|
|
2011-01-12 12:24:04 +00:00
|
|
|
self.emit("tasklist-populated")
|
|
|
|
|
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
Load a BuildRep into the model
|
|
|
|
"""
|
|
|
|
def load_image_rep(self, rep):
|
|
|
|
# Unset everything
|
|
|
|
it = self.get_iter_first()
|
|
|
|
while it:
|
|
|
|
path = self.get_path(it)
|
|
|
|
self[path][self.COL_INC] = False
|
|
|
|
self[path][self.COL_IMG] = False
|
|
|
|
it = self.iter_next(it)
|
|
|
|
|
|
|
|
# Iterate the images and disable them all
|
|
|
|
it = self.images.get_iter_first()
|
|
|
|
while it:
|
|
|
|
path = self.images.convert_path_to_child_path(self.images.get_path(it))
|
|
|
|
name = self[path][self.COL_NAME]
|
|
|
|
if name == rep.base_image:
|
|
|
|
self.include_item(path, image_contents=True)
|
|
|
|
else:
|
|
|
|
self[path][self.COL_INC] = False
|
|
|
|
it = self.images.iter_next(it)
|
|
|
|
|
|
|
|
# Mark all of the additional packages for inclusion
|
|
|
|
packages = rep.packages.split(" ")
|
|
|
|
it = self.get_iter_first()
|
|
|
|
while it:
|
|
|
|
path = self.get_path(it)
|
|
|
|
name = self[path][self.COL_NAME]
|
|
|
|
if name in packages:
|
|
|
|
self.include_item(path)
|
|
|
|
packages.remove(name)
|
|
|
|
it = self.iter_next(it)
|
|
|
|
|
|
|
|
self.emit("image-changed", rep.base_image)
|
|
|
|
|
|
|
|
"""
|
|
|
|
squish lst so that it doesn't contain any duplicate entries
|
2011-01-12 12:24:04 +00:00
|
|
|
"""
|
|
|
|
def squish(self, lst):
|
|
|
|
seen = {}
|
|
|
|
for l in lst:
|
|
|
|
seen[l] = 1
|
|
|
|
return seen.keys()
|
|
|
|
|
|
|
|
"""
|
|
|
|
Mark the item at path as not included
|
|
|
|
NOTE:
|
|
|
|
path should be a gtk.TreeModelPath into self (not a filtered model)
|
|
|
|
"""
|
|
|
|
def remove_item_path(self, path):
|
|
|
|
self[path][self.COL_BINB] = ""
|
|
|
|
self[path][self.COL_INC] = False
|
|
|
|
|
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
recursively called to mark the item at opath and any package which
|
|
|
|
depends on it for removal
|
2011-01-12 12:24:04 +00:00
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
def mark(self, opath):
|
2011-01-12 12:24:04 +00:00
|
|
|
removals = []
|
2011-07-01 22:58:50 +00:00
|
|
|
it = self.get_iter_first()
|
|
|
|
name = self[opath][self.COL_NAME]
|
2011-01-12 12:24:04 +00:00
|
|
|
|
2011-07-01 22:58:50 +00:00
|
|
|
self.remove_item_path(opath)
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
# Remove all dependent packages, update binb
|
|
|
|
while it:
|
|
|
|
path = self.get_path(it)
|
2011-07-01 22:58:50 +00:00
|
|
|
inc = self[path][self.COL_INC]
|
|
|
|
deps = self[path][self.COL_DEPS]
|
|
|
|
binb = self[path][self.COL_BINB]
|
|
|
|
|
|
|
|
# FIXME: need to ensure partial name matching doesn't happen
|
|
|
|
if inc and deps.count(name):
|
2011-01-12 12:24:04 +00:00
|
|
|
# found a dependency, remove it
|
|
|
|
self.mark(path)
|
2011-07-01 22:58:50 +00:00
|
|
|
if inc and binb.count(name):
|
|
|
|
bib = self.find_alt_dependency(name)
|
|
|
|
self[path][self.COL_BINB] = bib
|
|
|
|
|
2011-01-12 12:24:04 +00:00
|
|
|
it = self.iter_next(it)
|
|
|
|
|
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
Remove items from contents if the have an empty COL_BINB (brought in by)
|
|
|
|
caused by all packages they are a dependency of being removed.
|
|
|
|
If the item isn't a package we leave it included.
|
2011-01-12 12:24:04 +00:00
|
|
|
"""
|
|
|
|
def sweep_up(self):
|
2011-07-01 22:58:50 +00:00
|
|
|
model = self.contents
|
2011-01-12 12:24:04 +00:00
|
|
|
removals = []
|
2011-07-01 22:58:50 +00:00
|
|
|
it = self.contents.get_iter_first()
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
while it:
|
2011-07-01 22:58:50 +00:00
|
|
|
binb = model.get_value(it, self.COL_BINB)
|
|
|
|
itype = model.get_value(it, self.COL_TYPE)
|
|
|
|
|
|
|
|
if itype == 'package' and not binb:
|
|
|
|
opath = model.convert_path_to_child_path(model.get_path(it))
|
|
|
|
if not opath in removals:
|
|
|
|
removals.extend(opath)
|
|
|
|
|
|
|
|
it = model.iter_next(it)
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
while removals:
|
|
|
|
path = removals.pop()
|
|
|
|
self.mark(path)
|
|
|
|
|
|
|
|
"""
|
|
|
|
Find the name of an item in the image contents which depends on the item
|
|
|
|
at contents_path returns either an item name (str) or None
|
|
|
|
NOTE:
|
|
|
|
contents_path must be a path in the self.contents gtk.TreeModel
|
|
|
|
"""
|
|
|
|
def find_alt_dependency(self, name):
|
|
|
|
it = self.get_iter_first()
|
|
|
|
while it:
|
|
|
|
# iterate all items in the model
|
|
|
|
path = self.get_path(it)
|
|
|
|
deps = self[path][self.COL_DEPS]
|
|
|
|
itname = self[path][self.COL_NAME]
|
|
|
|
inc = self[path][self.COL_INC]
|
|
|
|
if itname != name and inc and deps.count(name) > 0:
|
|
|
|
# if this item depends on the item, return this items name
|
|
|
|
return itname
|
|
|
|
it = self.iter_next(it)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
"""
|
|
|
|
Check the self.contents gtk.TreeModel for an item
|
|
|
|
where COL_NAME matches item_name
|
|
|
|
Returns True if a match is found, False otherwise
|
|
|
|
"""
|
|
|
|
def contents_includes_name(self, item_name):
|
|
|
|
it = self.contents.get_iter_first()
|
|
|
|
while it:
|
|
|
|
path = self.contents.get_path(it)
|
|
|
|
if self.contents[path][self.COL_NAME] == item_name:
|
|
|
|
return True
|
|
|
|
it = self.contents.iter_next(it)
|
|
|
|
return False
|
|
|
|
|
|
|
|
"""
|
|
|
|
Add this item, and any of its dependencies, to the image contents
|
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
def include_item(self, item_path, binb="", image_contents=False):
|
2011-01-12 12:24:04 +00:00
|
|
|
name = self[item_path][self.COL_NAME]
|
|
|
|
deps = self[item_path][self.COL_DEPS]
|
|
|
|
cur_inc = self[item_path][self.COL_INC]
|
|
|
|
if not cur_inc:
|
|
|
|
self[item_path][self.COL_INC] = True
|
|
|
|
self[item_path][self.COL_BINB] = binb
|
2011-07-12 21:48:58 +00:00
|
|
|
|
|
|
|
# We want to do some magic with things which are brought in by the
|
|
|
|
# base image so tag them as so
|
2011-07-01 22:58:50 +00:00
|
|
|
if image_contents:
|
|
|
|
self[item_path][self.COL_IMG] = True
|
|
|
|
if self[item_path][self.COL_TYPE] == 'image':
|
|
|
|
self.selected_image = name
|
|
|
|
|
2011-01-12 12:24:04 +00:00
|
|
|
if deps:
|
|
|
|
# add all of the deps and set their binb to this item
|
|
|
|
for dep in deps.split(" "):
|
|
|
|
# If the contents model doesn't already contain dep, add it
|
2011-07-01 22:58:50 +00:00
|
|
|
# We only care to show things which will end up in the
|
|
|
|
# resultant image, so filter cross and native recipes
|
2011-07-12 21:48:58 +00:00
|
|
|
dep_included = self.contents_includes_name(dep)
|
|
|
|
path = self.find_path_for_item(dep)
|
|
|
|
if not dep_included and not dep.endswith("-native") and not dep.endswith("-cross"):
|
2011-01-12 12:24:04 +00:00
|
|
|
if path:
|
2011-07-01 22:58:50 +00:00
|
|
|
self.include_item(path, name, image_contents)
|
2011-01-12 12:24:04 +00:00
|
|
|
else:
|
|
|
|
pass
|
2011-07-12 21:48:58 +00:00
|
|
|
# Set brought in by for any no longer orphan packages
|
|
|
|
elif dep_included and path:
|
|
|
|
if not self[path][self.COL_BINB]:
|
|
|
|
self[path][self.COL_BINB] = name
|
2011-01-12 12:24:04 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
Find the model path for the item_name
|
|
|
|
Returns the path in the model or None
|
|
|
|
"""
|
|
|
|
def find_path_for_item(self, item_name):
|
|
|
|
it = self.get_iter_first()
|
|
|
|
path = None
|
|
|
|
while it:
|
|
|
|
path = self.get_path(it)
|
|
|
|
if (self[path][self.COL_NAME] == item_name):
|
|
|
|
return path
|
|
|
|
else:
|
|
|
|
it = self.iter_next(it)
|
|
|
|
return None
|
|
|
|
|
|
|
|
"""
|
|
|
|
Empty self.contents by setting the include of each entry to None
|
|
|
|
"""
|
|
|
|
def reset(self):
|
2011-07-07 22:43:25 +00:00
|
|
|
# Deselect images - slightly more complex logic so that we don't
|
|
|
|
# have to iterate all of the contents of the main model, instead
|
|
|
|
# just iterate the images model.
|
|
|
|
if self.selected_image:
|
|
|
|
iit = self.images.get_iter_first()
|
|
|
|
while iit:
|
|
|
|
pit = self.images.convert_iter_to_child_iter(iit)
|
|
|
|
self.set(pit, self.COL_INC, False)
|
|
|
|
iit = self.images.iter_next(iit)
|
|
|
|
self.selected_image = None
|
|
|
|
|
2011-01-12 12:24:04 +00:00
|
|
|
it = self.contents.get_iter_first()
|
|
|
|
while it:
|
2011-07-07 22:43:25 +00:00
|
|
|
oit = self.contents.convert_iter_to_child_iter(it)
|
|
|
|
self.set(oit,
|
|
|
|
self.COL_INC, False,
|
|
|
|
self.COL_BINB, "",
|
|
|
|
self.COL_IMG, False)
|
2011-01-12 12:24:04 +00:00
|
|
|
# As we've just removed the first item...
|
|
|
|
it = self.contents.get_iter_first()
|
|
|
|
|
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
Returns two lists. One of user selected packages and the other containing
|
|
|
|
all selected packages
|
2011-01-12 12:24:04 +00:00
|
|
|
"""
|
2011-07-01 22:58:50 +00:00
|
|
|
def get_selected_packages(self):
|
|
|
|
allpkgs = []
|
|
|
|
userpkgs = []
|
|
|
|
|
|
|
|
it = self.contents.get_iter_first()
|
2011-01-12 12:24:04 +00:00
|
|
|
while it:
|
2011-07-01 22:58:50 +00:00
|
|
|
sel = self.contents.get_value(it, self.COL_BINB) == "User Selected"
|
|
|
|
name = self.contents.get_value(it, self.COL_NAME)
|
|
|
|
allpkgs.append(name)
|
|
|
|
if sel:
|
|
|
|
userpkgs.append(name)
|
|
|
|
it = self.contents.iter_next(it)
|
|
|
|
return userpkgs, allpkgs
|
2011-01-12 12:24:04 +00:00
|
|
|
|
2011-07-01 22:58:50 +00:00
|
|
|
def get_build_rep(self):
|
|
|
|
userpkgs, allpkgs = self.get_selected_packages()
|
|
|
|
image = self.selected_image
|
|
|
|
|
|
|
|
return BuildRep(" ".join(userpkgs), " ".join(allpkgs), image)
|
2011-01-12 12:24:04 +00:00
|
|
|
|
2011-07-01 22:58:50 +00:00
|
|
|
def find_reverse_depends(self, pn):
|
|
|
|
revdeps = []
|
2011-01-12 12:24:04 +00:00
|
|
|
it = self.contents.get_iter_first()
|
2011-07-01 22:58:50 +00:00
|
|
|
|
2011-01-12 12:24:04 +00:00
|
|
|
while it:
|
2011-07-01 22:58:50 +00:00
|
|
|
if self.contents.get_value(it, self.COL_DEPS).count(pn) != 0:
|
|
|
|
revdeps.append(self.contents.get_value(it, self.COL_NAME))
|
2011-01-12 12:24:04 +00:00
|
|
|
it = self.contents.iter_next(it)
|
2011-07-01 22:58:50 +00:00
|
|
|
|
|
|
|
if pn in revdeps:
|
|
|
|
revdeps.remove(pn)
|
|
|
|
return revdeps
|
|
|
|
|
|
|
|
def set_selected_image(self, img):
|
|
|
|
self.selected_image = img
|
|
|
|
path = self.find_path_for_item(img)
|
|
|
|
self.include_item(item_path=path,
|
|
|
|
binb="User Selected",
|
|
|
|
image_contents=True)
|
|
|
|
|
|
|
|
self.emit("image-changed", self.selected_image)
|
|
|
|
|
|
|
|
def set_selected_packages(self, pkglist):
|
|
|
|
selected = pkglist
|
|
|
|
it = self.get_iter_first()
|
|
|
|
|
|
|
|
while it:
|
|
|
|
name = self.get_value(it, self.COL_NAME)
|
|
|
|
if name in pkglist:
|
|
|
|
pkglist.remove(name)
|
|
|
|
path = self.get_path(it)
|
|
|
|
self.include_item(item_path=path,
|
|
|
|
binb="User Selected")
|
|
|
|
if len(pkglist) == 0:
|
|
|
|
return
|
|
|
|
it = self.iter_next(it)
|
|
|
|
|
|
|
|
def find_image_path(self, image):
|
|
|
|
it = self.images.get_iter_first()
|
|
|
|
|
|
|
|
while it:
|
|
|
|
image_name = self.images.get_value(it, self.COL_NAME)
|
|
|
|
if image_name == image:
|
|
|
|
path = self.images.get_value(it, self.COL_PATH)
|
|
|
|
meta_pattern = "(\S*)/(meta*/)(\S*)"
|
|
|
|
meta_match = re.search(meta_pattern, path)
|
|
|
|
if meta_match:
|
|
|
|
_, lyr, bbrel = path.partition(meta_match.group(2))
|
|
|
|
if bbrel:
|
|
|
|
path = bbrel
|
|
|
|
return path
|
|
|
|
it = self.images.iter_next(it)
|