Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DEB archive support #332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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