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 Apr 4, 2021
1 parent 2b24480 commit 7b7fe37
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/builder-source-archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ enum {
typedef enum {
UNKNOWN,
RPM,
DEB,
TAR,
TAR_GZIP,
TAR_COMPRESS,
Expand Down Expand Up @@ -493,6 +494,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 @@ -540,6 +556,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 @@ -663,6 +682,7 @@ get_type_from_prop (BuilderSourceArchive *self)
BuilderArchiveType type;
} str_to_types[] = {
{ "rpm", RPM },
{ "deb", DEB },
{ "tar", TAR },
{ "tar-gzip", TAR_GZIP },
{ "tar-compress", TAR_COMPRESS },
Expand Down Expand Up @@ -771,6 +791,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 7b7fe37

Please sign in to comment.