From 2592348a31fbccb18b5cc00c7bf37e13c577a009 Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Nov 16 2016 13:56:40 +0000 Subject: Improve comps group support, fix bytecompiling - Improve comps group support (patch submitted upstream) - Fix missing bytecompiled Python files --- diff --git a/dnfdragora/0001-Improve-comps-group-support.patch b/dnfdragora/0001-Improve-comps-group-support.patch new file mode 100644 index 0000000..42efb92 --- /dev/null +++ b/dnfdragora/0001-Improve-comps-group-support.patch @@ -0,0 +1,288 @@ +From 7e7d903d8091ffcfad0c356bd5b08a04321851d1 Mon Sep 17 00:00:00 2001 +Message-Id: <7e7d903d8091ffcfad0c356bd5b08a04321851d1.1479273239.git.kevin.kofler@chello.at> +From: Kevin Kofler +Date: Wed, 16 Nov 2016 05:03:26 +0100 +Subject: [PATCH] Improve comps group support + +New file dnfdragora/compsicons.py, similar to groupicons.py, but for +comps. + +New tool tools/gen-comps-category-list.sh: Generates a map from category +name to ID for dnfdragora/compsicons.py, as a workaround for +timlau/dnf-daemon#9. + +dnfdragora/ui.py (mainGui._getAllGroupIDList): Remember the UI names for + each ID in an + id_to_name_map. + (mainGui._fillGroupTree): Handle comps separately, use + compsicons.py to get the + icons (#2) and use the + id_to_name_map to get the UI + name (#3). + +Fixes #2. +Fixes #3. + +The only remaining issue is that the UI names are not translated, which +I filed as timlau/dnf-daemon#10 because Yumex-DNF is also affected (and +thus it is clearly dnfdaemon's fault). +--- + dnfdragora/compsicons.py | 48 ++++++++++++++ + dnfdragora/ui.py | 136 +++++++++++++++++++++++++-------------- + tools/gen-comps-category-list.sh | 4 ++ + 3 files changed, 139 insertions(+), 49 deletions(-) + +diff --git a/dnfdragora/compsicons.py b/dnfdragora/compsicons.py +new file mode 100644 +index 0000000..4305c6f +--- /dev/null ++++ b/dnfdragora/compsicons.py +@@ -0,0 +1,48 @@ ++from gettext import gettext as _ ++import os.path ++ ++class CompsIcons: ++ ''' ++ This class manages the access to group name and icons ++ ''' ++ def __init__(self, icon_path=None): ++ ++ if icon_path: ++ self.icon_path = icon_path if icon_path.endswith("/") else icon_path + "/" ++ else: ++ self.icon_path = "/usr/share/pixmaps/comps/" ++ ++ self.default_icon = self.icon_path + "uncategorized.png" ++ ++ # workaround for https://github.com/timlau/dnf-daemon/issues/9 ++ # generated using tools/gen-comps-category-list.sh ++ self.name_to_id_map = { ++ "KDE Desktop": "kde-desktop-environment", ++ "Xfce Desktop": "xfce-desktop-environment", ++ "Applications": "apps", ++ "LXDE Desktop": "lxde-desktop-environment", ++ "LXQt Desktop": "lxqt-desktop-environment", ++ "Cinnamon Desktop": "cinnamon-desktop-environment", ++ "MATE Desktop": "mate-desktop-environment", ++ "Hawaii Desktop": "hawaii-desktop-environment", ++ "Sugar Desktop Environment": "sugar-desktop-environment", ++ "GNOME Desktop": "gnome-desktop-environment", ++ "Development": "development", ++ "Servers": "servers", ++ "Base System": "base-system", ++ "Content": "content", ++ } ++ ++ def icon(self, group_path): ++ group_names = group_path.split("/") ++ for group_name in reversed(group_names): ++ if group_name in self.name_to_id_map: ++ group_id = self.name_to_id_map[group_name] ++ else: ++ group_id = group_name ++ ++ icon_name = self.icon_path + group_id + ".png" ++ if os.path.exists(icon_name): ++ return icon_name ++ ++ return self.default_icon +diff --git a/dnfdragora/ui.py b/dnfdragora/ui.py +index 27b434f..b933872 100644 +--- a/dnfdragora/ui.py ++++ b/dnfdragora/ui.py +@@ -17,6 +17,7 @@ import platform + import yui + + import dnfdragora.basedragora ++import dnfdragora.compsicons as compsicons + import dnfdragora.groupicons as groupicons + import dnfdragora.progress_ui as progress_ui + from dnfdragora import const +@@ -438,7 +439,7 @@ class mainGui(dnfdragora.basedragora.BaseDragora): + + return None + +- def _getAllGroupIDList(self, groups, new_groups, g_id=None) : ++ def _getAllGroupIDList(self, groups, new_groups, id_to_name_map, g_id=None) : + ''' + return a list of group ID as pathnames + ''' +@@ -446,11 +447,13 @@ class mainGui(dnfdragora.basedragora.BaseDragora): + for gl in groups: + if (isinstance(gl, list)): + if (type(gl[0]) is str) : ++ if not gl[0] in id_to_name_map: ++ id_to_name_map[gl[0]] = gl[1] + new_groups.append(gid + "/" + gl[0] if (gid) else gl[0]) + if not gid : + gid = gl[0] + else : +- self._getAllGroupIDList(gl, new_groups, gid) ++ self._getAllGroupIDList(gl, new_groups, id_to_name_map, gid) + + def _fillGroupTree(self) : + ''' +@@ -466,68 +469,103 @@ class mainGui(dnfdragora.basedragora.BaseDragora): + # get group comps + rpm_groups = self.backend.get_groups() + if rpm_groups : ++ # using comps + groups = [] +- self._getAllGroupIDList(rpm_groups, groups) ++ id_to_name_map = {} ++ self._getAllGroupIDList(rpm_groups, groups, id_to_name_map) + rpm_groups = groups +- else: +- #don't have comps try tags +- rpm_groups = self.backend.get_groups_from_packages() + +- print ("End found %d groups" %len(rpm_groups)) +- +- rpm_groups = sorted(rpm_groups) +- icon_path = self.options['icon_path'] if 'icon_path' in self.options.keys() else None +- gIcons = groupicons.GroupIcons(icon_path) +- groups = gIcons.groups() +- +- for g in rpm_groups: +- #X/Y/Z/... +- currG = groups +- currT = self.groupList +- subGroups = g.split("/") +- currItem = None +- parentItem = None +- groupName = None +- +- for sg in subGroups: +- if groupName: +- groupName += "/%s"%(sg) +- else: +- groupName = sg +- icon = gIcons.icon(groupName) ++ rpm_groups = sorted(rpm_groups) ++ icon_path = self.options['comps_icon_path'] if 'comps_icon_path' in self.options.keys() else '/usr/share/pixmaps/comps/' ++ gIcons = compsicons.CompsIcons(icon_path) ++ ++ for g in rpm_groups: ++ #X/Y/Z/... ++ currT = self.groupList ++ subGroups = g.split("/") ++ currItem = None ++ parentItem = None ++ groupName = None ++ ++ for sg in subGroups: ++ if groupName: ++ groupName += "/%s"%(sg) ++ else: ++ groupName = sg ++ icon = gIcons.icon(groupName) + +- if sg in currG: +- currG = currG[sg] +- if currG["title"] in currT : +- currT = currT[currG["title"]] +- parentItem = currT["item"] +- else : +- # create the item +- item = None +- if parentItem: +- item = yui.YTreeItem(parentItem, currG["title"], icon) +- else : +- item = yui.YTreeItem(currG["title"], icon) +- item.this.own(False) +- currT[currG["title"]] = { "item" : item, "name" : groupName } +- currT = currT[currG["title"]] +- parentItem = item +- else: +- # group is not in our group definition, but it's into the repository +- # we just use it + if sg in currT : + currT = currT[sg] + parentItem = currT["item"] + else : + item = None + if parentItem: +- item = yui.YTreeItem(parentItem, sg, icon) ++ item = yui.YTreeItem(parentItem, id_to_name_map[sg], icon) + else : +- item = yui.YTreeItem(sg, icon) ++ item = yui.YTreeItem(id_to_name_map[sg], icon) + item.this.own(False) + currT[sg] = { "item" : item, "name": groupName } + currT = currT[sg] + parentItem = item ++ else: ++ #don't have comps try tags ++ rpm_groups = self.backend.get_groups_from_packages() ++ ++ rpm_groups = sorted(rpm_groups) ++ icon_path = self.options['icon_path'] if 'icon_path' in self.options.keys() else None ++ gIcons = groupicons.GroupIcons(icon_path) ++ groups = gIcons.groups() ++ ++ for g in rpm_groups: ++ #X/Y/Z/... ++ currG = groups ++ currT = self.groupList ++ subGroups = g.split("/") ++ currItem = None ++ parentItem = None ++ groupName = None ++ ++ for sg in subGroups: ++ if groupName: ++ groupName += "/%s"%(sg) ++ else: ++ groupName = sg ++ icon = gIcons.icon(groupName) ++ ++ if sg in currG: ++ currG = currG[sg] ++ if currG["title"] in currT : ++ currT = currT[currG["title"]] ++ parentItem = currT["item"] ++ else : ++ # create the item ++ item = None ++ if parentItem: ++ item = yui.YTreeItem(parentItem, currG["title"], icon) ++ else : ++ item = yui.YTreeItem(currG["title"], icon) ++ item.this.own(False) ++ currT[currG["title"]] = { "item" : item, "name" : groupName } ++ currT = currT[currG["title"]] ++ parentItem = item ++ else: ++ # group is not in our group definition, but it's into the repository ++ # we just use it ++ if sg in currT : ++ currT = currT[sg] ++ parentItem = currT["item"] ++ else : ++ item = None ++ if parentItem: ++ item = yui.YTreeItem(parentItem, sg, icon) ++ else : ++ item = yui.YTreeItem(sg, icon) ++ item.this.own(False) ++ currT[sg] = { "item" : item, "name": groupName } ++ currT = currT[sg] ++ parentItem = item ++ ++ print ("End found %d groups" %len(rpm_groups)) + + keylist = sorted(self.groupList.keys()) + v = [] +diff --git a/tools/gen-comps-category-list.sh b/tools/gen-comps-category-list.sh +new file mode 100755 +index 0000000..10c8f33 +--- /dev/null ++++ b/tools/gen-comps-category-list.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++# Generate the map from category name to ID for dnfdragora/compsicons.py ++# Workaround for https://github.com/timlau/dnf-daemon/issues/9 ++wget https://pagure.io/fedora-comps/raw/master/f/comps-f26.xml.in -q -O - | tr '\n' '#' | sed -e 's!.*!!g' -e 's!.*!!g' | tr '#' '\n' | grep '<_name>\|' | tr '\n' '#' | sed -e 's!\([^<]*\)# *<_name>\([^<]*\)!"\2": "\1",!g' | tr '#' '\n' | sed -e 's/^ */ /g' +-- +2.7.4 + diff --git a/dnfdragora/dnfdragora.spec b/dnfdragora/dnfdragora.spec index e1a52bb..546d444 100644 --- a/dnfdragora/dnfdragora.spec +++ b/dnfdragora/dnfdragora.spec @@ -3,18 +3,22 @@ Name: dnfdragora Version: 0 -Release: 0.2.%{snapdate}git%(echo %{githash} | cut -c -13)%{?dist} +Release: 0.3.%{snapdate}git%(echo %{githash} | cut -c -13)%{?dist} Summary: Software package manager License: GPLv3 URL: https://github.com/anaselli/%{name} Source0: %{url}/archive/%{githash}/%{name}-%{githash}.tar.gz Source1: %{name}.desktop +# https://github.com/anaselli/dnfdragora/pull/7/commits/7e7d903d8091ffcfad0c356bd5b08a04321851d1 +Patch0: 0001-Improve-comps-group-support.patch BuildArch: noarch BuildRequires: desktop-file-utils BuildRequires: python3-devel +# bytecompile with Python 3 +%global __python %{__python3} BuildRequires: gettext Requires: python3 @@ -33,6 +37,7 @@ supporting Qt, GTK+ and ncurses through libyui. %prep %setup -q -n %{name}-%{githash} +%patch0 -p1 %build tools/po-compile.sh @@ -55,6 +60,10 @@ cp -pr share/locale %{buildroot}%{_datadir}/ %{_datadir}/applications/%{name}.desktop %changelog +* Wed Nov 16 2016 Kevin Kofler - 0-0.3.20161023gitbb6edcf85175a +- Improve comps group support (patch submitted upstream) +- Fix missing bytecompiled Python files + * Tue Nov 15 2016 Kevin Kofler - 0-0.2.20161023gitbb6edcf85175a - Requires: python3-dnfdaemon rather than just dnfdaemon (need dnfdaemon.client)