-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge apps with overlapping IDs from the same pkgname
This should work for a lot of fonts and also applications where there are things like level editors and different runtime versions.
- Loading branch information
Showing
8 changed files
with
235 additions
and
44 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Summary: A test application | ||
Name: composite | ||
Version: 1 | ||
Release: 1%{?dist} | ||
URL: http://people.freedesktop.org/ | ||
License: GPLv2+ | ||
Source1: valid1.desktop | ||
Source2: valid2.desktop | ||
|
||
%description | ||
This is a composite application shipping multiple valid apps in one package. | ||
|
||
%install | ||
install -Dp %{SOURCE1} $RPM_BUILD_ROOT/%{_datadir}/applications/valid1.desktop | ||
install -Dp %{SOURCE2} $RPM_BUILD_ROOT/%{_datadir}/applications/valid2.desktop | ||
|
||
%files | ||
%defattr(-,root,root) | ||
%{_datadir}/applications/valid1.desktop | ||
%{_datadir}/applications/valid2.desktop | ||
|
||
%changelog | ||
* Tue Aug 12 2014 Richard Hughes <richard@hughsie.com> - 1-1 | ||
- Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
msgfmt ru.po -o ru.mo | ||
msgfmt en_GB.po -o en_GB.mo | ||
gcc -o app.bin app.c `pkg-config --cflags --libs gtk+-3.0` | ||
cp * ~/rpmbuild/SOURCES/ && rpmbuild -ba ../app.spec && cp ~/rpmbuild/RPMS/app*.rpm ../ | ||
cp * ~/rpmbuild/SOURCES/ | ||
rpmbuild -ba ../app.spec | ||
rpmbuild -ba ../composite.spec | ||
cp ~/rpmbuild/RPMS/app*.rpm ../ | ||
cp ~/rpmbuild/RPMS/composite*.rpm ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Desktop Entry] | ||
Name=Frobnicator | ||
Comment=Frobnicator | ||
Icon=computer | ||
Exec=app | ||
Terminal=false | ||
Type=Application | ||
Categories=Profiling; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Desktop Entry] | ||
Name=Frobnicator Example | ||
Comment=Frobnicator Example Program | ||
Icon=computer | ||
Exec=app --example | ||
Terminal=false | ||
Type=Application | ||
Categories=Profiling; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- | ||
* | ||
* Copyright (C) 2014 Richard Hughes <richard@hughsie.com> | ||
* | ||
* Licensed under the GNU Lesser General Public License Version 2.1 | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <config.h> | ||
#include <string.h> | ||
|
||
#include <asb-plugin.h> | ||
|
||
/** | ||
* asb_plugin_get_name: | ||
*/ | ||
const gchar * | ||
asb_plugin_get_name (void) | ||
{ | ||
return "composite"; | ||
} | ||
|
||
/** | ||
* asb_plugin_composite_app: | ||
*/ | ||
static gboolean | ||
asb_plugin_composite_app (AsApp *app, AsApp *donor, GError **error) | ||
{ | ||
AsApp *tmp; | ||
gint rc; | ||
_cleanup_free_ gchar *id = NULL; | ||
|
||
/* check this makes sense */ | ||
if (as_app_get_id_kind (app) != as_app_get_id_kind (donor)) { | ||
g_set_error (error, | ||
AS_APP_ERROR, | ||
AS_APP_ERROR_INVALID_TYPE, | ||
"Cannot composite apps %s:%s of different id kind", | ||
as_app_get_id (app), | ||
as_app_get_id (donor)); | ||
return FALSE; | ||
} | ||
|
||
/* the ID, name with the shortest length wins */ | ||
rc = strlen (as_app_get_id (app)) - strlen (as_app_get_id (donor)); | ||
if (rc == 0) { | ||
rc = strlen (as_app_get_name (app, "C")) - | ||
strlen (as_app_get_name (donor, "C")); | ||
} | ||
if (rc > 0) { | ||
tmp = app; | ||
app = donor; | ||
donor = tmp; | ||
} | ||
|
||
/* set the new composite string */ | ||
id = as_utils_get_string_overlap (as_app_get_id (app), as_app_get_id (donor)); | ||
if (id == NULL || strlen (id) < 12) { | ||
g_set_error (error, | ||
AS_APP_ERROR, | ||
AS_APP_ERROR_INVALID_TYPE, | ||
"Cannot composite apps %s:%s as no ID overlap", | ||
as_app_get_id (app), | ||
as_app_get_id (donor)); | ||
return FALSE; | ||
} | ||
as_app_set_id (app, id, -1); | ||
|
||
/* add some easily merged properties */ | ||
as_app_subsume_full (app, donor, AS_APP_SUBSUME_FLAG_PARTIAL); | ||
as_app_add_veto (donor, "absorbed into %s", as_app_get_id (app)); | ||
return TRUE; | ||
} | ||
|
||
/** | ||
* asb_plugin_merge: | ||
*/ | ||
void | ||
asb_plugin_merge (AsbPlugin *plugin, GList *list) | ||
{ | ||
AsApp *app; | ||
AsApp *found; | ||
GList *l; | ||
_cleanup_hashtable_unref_ GHashTable *hash = NULL; | ||
|
||
/* add all packages to the hash */ | ||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, | ||
g_free, (GDestroyNotify) g_object_unref); | ||
for (l = list; l != NULL; l = l->next) { | ||
app = AS_APP (l->data); | ||
if (as_app_get_vetos (app)->len > 0) | ||
continue; | ||
found = g_hash_table_lookup (hash, as_app_get_pkgname_default (app)); | ||
if (found != NULL) { | ||
_cleanup_error_free_ GError *error = NULL; | ||
if (!asb_plugin_composite_app (app, found, &error)) { | ||
g_warning ("Failed to composite %s:%s", | ||
as_app_get_id (app), | ||
as_app_get_id (found)); | ||
continue; | ||
} | ||
continue; | ||
} | ||
g_hash_table_insert (hash, | ||
g_strdup (as_app_get_pkgname_default (app)), | ||
g_object_ref (app)); | ||
} | ||
} |