summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-09-23 17:41:25 +0100
committerRichard Hughes <richard@hughsie.com>2014-09-23 17:41:27 +0100
commit5115cea340aee25735ac05bdc65b134c2b7d0c47 (patch)
treea72f8cc1740b025781362650dabe2b79ebe7ea1e
parentfcc3feb19a1569f39be7e50f80e58be6d72b8c1a (diff)
downloadappstream-glib-5115cea340aee25735ac05bdc65b134c2b7d0c47.tar.gz
Decompress the destination file if soft or hardlinked
This fixes failures such as veusz where the icon is installed into /usr/share/veusz/icons and then symlinked to /usr/share/pixmaps for the desktop file.
-rw-r--r--data/tests/app-1-1.fc21.i686.rpmbin13476 -> 13620 bytes
-rw-r--r--data/tests/app-1-1.fc21.x86_64.rpmbin13440 -> 13584 bytes
-rw-r--r--data/tests/app-console-1-1.fc21.noarch.rpmbin6764 -> 6796 bytes
-rw-r--r--data/tests/app-extra-1-1.fc21.noarch.rpmbin6652 -> 6680 bytes
-rw-r--r--data/tests/app.spec10
-rw-r--r--libappstream-builder/asb-utils.c16
6 files changed, 23 insertions, 3 deletions
diff --git a/data/tests/app-1-1.fc21.i686.rpm b/data/tests/app-1-1.fc21.i686.rpm
index be0aa9f..478333c 100644
--- a/data/tests/app-1-1.fc21.i686.rpm
+++ b/data/tests/app-1-1.fc21.i686.rpm
Binary files differ
diff --git a/data/tests/app-1-1.fc21.x86_64.rpm b/data/tests/app-1-1.fc21.x86_64.rpm
index 60011fb..a85dfda 100644
--- a/data/tests/app-1-1.fc21.x86_64.rpm
+++ b/data/tests/app-1-1.fc21.x86_64.rpm
Binary files differ
diff --git a/data/tests/app-console-1-1.fc21.noarch.rpm b/data/tests/app-console-1-1.fc21.noarch.rpm
index 640d753..e0b6c0d 100644
--- a/data/tests/app-console-1-1.fc21.noarch.rpm
+++ b/data/tests/app-console-1-1.fc21.noarch.rpm
Binary files differ
diff --git a/data/tests/app-extra-1-1.fc21.noarch.rpm b/data/tests/app-extra-1-1.fc21.noarch.rpm
index 6e03922..e8dd104 100644
--- a/data/tests/app-extra-1-1.fc21.noarch.rpm
+++ b/data/tests/app-extra-1-1.fc21.noarch.rpm
Binary files differ
diff --git a/data/tests/app.spec b/data/tests/app.spec
index 349027c..efc3adf 100644
--- a/data/tests/app.spec
+++ b/data/tests/app.spec
@@ -44,7 +44,14 @@ Sub package with console "application".
%install
install -Dp %{SOURCE0} $RPM_BUILD_ROOT/%{_datadir}/%{name}-%{version}/README
install -Dp %{SOURCE1} $RPM_BUILD_ROOT/%{_datadir}/applications/app.desktop
-install -Dp %{SOURCE2} $RPM_BUILD_ROOT/%{_datadir}/pixmaps/app.png
+
+# test decompressing a symlink destination
+install -Dp %{SOURCE2} $RPM_BUILD_ROOT/%{_datadir}/app/app.png
+mkdir -p $RPM_BUILD_ROOT/%{_datadir}/pixmaps
+cd $RPM_BUILD_ROOT
+ln -s %{_datadir}/app/app.png usr/share/pixmaps/app.png
+cd -
+
install -Dp %{SOURCE3} $RPM_BUILD_ROOT/%{_datadir}/appdata/app.appdata.xml
install -Dp %{SOURCE4} $RPM_BUILD_ROOT/%{_datadir}/gnome-shell/search-providers/search-provider.ini
install -Dp %{SOURCE5} $RPM_BUILD_ROOT/%{_datadir}/help/C/app/index.page
@@ -75,6 +82,7 @@ install -Dp %{SOURCE16} $RPM_BUILD_ROOT/%{_datadir}/applications/console2.deskto
%{_datadir}/kde4/apps/app/app.notifyrc
%{_datadir}/locale/en_GB/LC_MESSAGES/app.mo
%{_datadir}/locale/ru/LC_MESSAGES/app.mo
+%{_datadir}/app/app.png
%{_datadir}/pixmaps/app.png
%files extra
diff --git a/libappstream-builder/asb-utils.c b/libappstream-builder/asb-utils.c
index f4544ea..43c425f 100644
--- a/libappstream-builder/asb-utils.c
+++ b/libappstream-builder/asb-utils.c
@@ -181,7 +181,8 @@ asb_utils_ensure_exists_and_empty (const gchar *directory, GError **error)
static gboolean
asb_utils_explode_file (struct archive_entry *entry,
const gchar *dir,
- GPtrArray *glob)
+ GPtrArray *glob,
+ GPtrArray *symlink_glob)
{
const gchar *tmp;
gchar buf[PATH_MAX];
@@ -212,6 +213,7 @@ asb_utils_explode_file (struct archive_entry *entry,
/* update hardlinks */
tmp = archive_entry_hardlink (entry);
if (tmp != NULL) {
+ g_ptr_array_add (symlink_glob, asb_glob_value_new (tmp, ""));
g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp);
archive_entry_update_hardlink_utf8 (entry, buf);
}
@@ -219,6 +221,7 @@ asb_utils_explode_file (struct archive_entry *entry,
/* update symlinks */
tmp = archive_entry_symlink (entry);
if (tmp != NULL) {
+ g_ptr_array_add (symlink_glob, asb_glob_value_new (tmp, ""));
g_snprintf (buf, PATH_MAX, "%s/%s", dir, tmp);
archive_entry_update_symlink_utf8 (entry, buf);
}
@@ -251,6 +254,7 @@ asb_utils_explode (const gchar *filename,
struct archive *arch = NULL;
struct archive_entry *entry;
_cleanup_free_ gchar *data = NULL;
+ _cleanup_ptrarray_unref_ GPtrArray *symlink_glob = NULL;
/* load file at once to avoid seeking */
ret = g_file_get_contents (filename, &data, &len, error);
@@ -273,6 +277,7 @@ asb_utils_explode (const gchar *filename,
}
/* decompress each file */
+ symlink_glob = asb_glob_value_array_new ();
for (;;) {
r = archive_read_next_header (arch, &entry);
if (r == ARCHIVE_EOF)
@@ -288,7 +293,7 @@ asb_utils_explode (const gchar *filename,
}
/* only extract if valid */
- valid = asb_utils_explode_file (entry, dir, glob);
+ valid = asb_utils_explode_file (entry, dir, glob, symlink_glob);
if (!valid)
continue;
r = archive_read_extract (arch, entry, 0);
@@ -302,6 +307,13 @@ asb_utils_explode (const gchar *filename,
goto out;
}
}
+
+ /* there are soft or hard links to explode too */
+ if (symlink_glob->len > 0) {
+ ret = asb_utils_explode (filename, dir, symlink_glob, error);
+ if (!ret)
+ goto out;
+ }
out:
if (arch != NULL) {
archive_read_close (arch);