Skip to content

Commit

Permalink
source-archive: Add DEB support
Browse files Browse the repository at this point in the history
  • Loading branch information
gasinvein committed Mar 18, 2020
1 parent 8c7bcf0 commit 11a7f3e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/builder-source-archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum {
typedef enum {
UNKNOWN,
RPM,
DEB,
TAR,
TAR_GZIP,
TAR_COMPRESS,
Expand Down Expand Up @@ -467,6 +468,21 @@ unrpm (GFile *dir,
return res;
}

static gboolean
dpkg_deb_extract (GFile *dir,
const char *deb_path,
GError **error)
{
g_autofree char *dir_path = g_file_get_path (dir);

gboolean res;
const gchar *argv[] = { "dpkg-deb", "-x", deb_path, dir_path, NULL };

res = flatpak_spawnv (dir, NULL, 0, error, argv);

return res;
}

static BuilderArchiveType
get_type (GFile *archivefile)
{
Expand Down Expand Up @@ -514,6 +530,9 @@ get_type (GFile *archivefile)
if (g_str_has_suffix (lower, ".rpm"))
return RPM;

if (g_str_has_suffix (lower, ".deb"))
return DEB;

return UNKNOWN;
}

Expand Down Expand Up @@ -692,6 +711,23 @@ builder_source_archive_extract (BuilderSource *source,
return FALSE;
}
}
else if (type == DEB)
{
g_autoptr(GFile) deb_dest = NULL;

deb_dest = create_uncompress_directory (self, dest, error);
if (deb_dest == NULL)
return FALSE;

if (!dpkg_deb_extract (deb_dest, archive_path, error))
return FALSE;

if (self->strip_components > 0)
{
if (!strip_components_into (dest, deb_dest, self->strip_components, error))
return FALSE;
}
}
else
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown archive format of '%s'", archive_path);
Expand Down

0 comments on commit 11a7f3e

Please sign in to comment.