forked from Mirrors/flatpak-builder
archive source: Allow overriding the archive type
This allows unpacking files that would otherwise not be recognised as of a particular type, such as self-extracting files supported by zip, 7z or cabextract.master
parent
8c7bcf08a0
commit
38b6c80a3b
|
@ -644,6 +644,13 @@
|
|||
<term><option>git-init</option> (boolean)</term>
|
||||
<listitem><para>Whether to initialise the repository as a git repository.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>archive-type</option> (string)</term>
|
||||
<listitem><para>
|
||||
The type of archive if it cannot be guessed from the path. Possible values are "rpm", "tar",
|
||||
"tar-gzip", "tar-compress", "tar-bzip2", "tar-lzip", "tar-lzma", "tar-lzop", "tar-xz" and "zip".
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>md5</option> (string)</term>
|
||||
<listitem><para>The md5 checksum of the file, verified after download</para>
|
||||
|
|
|
@ -46,6 +46,7 @@ struct BuilderSourceArchive
|
|||
guint strip_components;
|
||||
char *dest_filename;
|
||||
gboolean git_init;
|
||||
char *archive_type;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -67,6 +68,7 @@ enum {
|
|||
PROP_DEST_FILENAME,
|
||||
PROP_MIRROR_URLS,
|
||||
PROP_GIT_INIT,
|
||||
PROP_ARCHIVE_TYPE,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
@ -135,6 +137,7 @@ builder_source_archive_finalize (GObject *object)
|
|||
g_free (self->sha512);
|
||||
g_free (self->dest_filename);
|
||||
g_strfreev (self->mirror_urls);
|
||||
g_free (self->archive_type);
|
||||
|
||||
G_OBJECT_CLASS (builder_source_archive_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -189,6 +192,10 @@ builder_source_archive_get_property (GObject *object,
|
|||
g_value_set_boolean (value, self->git_init);
|
||||
break;
|
||||
|
||||
case PROP_ARCHIVE_TYPE:
|
||||
g_value_set_string (value, self->archive_type);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -254,6 +261,11 @@ builder_source_archive_set_property (GObject *object,
|
|||
self->git_init = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_ARCHIVE_TYPE:
|
||||
g_free (self->archive_type);
|
||||
self->archive_type = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -629,6 +641,39 @@ init_git (GFile *dir,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static BuilderArchiveType
|
||||
get_type_from_prop (BuilderSourceArchive *self)
|
||||
{
|
||||
struct {
|
||||
const char *id;
|
||||
BuilderArchiveType type;
|
||||
} str_to_types[] = {
|
||||
{ "rpm", RPM },
|
||||
{ "tar", TAR },
|
||||
{ "tar-gzip", TAR_GZIP },
|
||||
{ "tar-compress", TAR_COMPRESS },
|
||||
{ "tar-bzip2", TAR_BZIP2 },
|
||||
{ "tar-lzip", TAR_LZIP },
|
||||
{ "tar-lzma", TAR_LZMA },
|
||||
{ "tar-xz", TAR_XZ },
|
||||
{ "zip", ZIP },
|
||||
};
|
||||
guint i;
|
||||
|
||||
if (self->archive_type == NULL)
|
||||
return UNKNOWN;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(str_to_types); i++)
|
||||
{
|
||||
if (g_strcmp0 (self->archive_type, str_to_types[i].id) == 0)
|
||||
return str_to_types[i].type;
|
||||
}
|
||||
|
||||
g_warning ("Unknown archive-type \"%s\"", self->archive_type);
|
||||
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
builder_source_archive_extract (BuilderSource *source,
|
||||
GFile *dest,
|
||||
|
@ -647,7 +692,9 @@ builder_source_archive_extract (BuilderSource *source,
|
|||
if (archivefile == NULL)
|
||||
return FALSE;
|
||||
|
||||
type = get_type (archivefile);
|
||||
type = get_type_from_prop (self);
|
||||
if (type == UNKNOWN)
|
||||
type = get_type (archivefile);
|
||||
|
||||
archive_path = g_file_get_path (archivefile);
|
||||
|
||||
|
@ -866,6 +913,13 @@ builder_source_archive_class_init (BuilderSourceArchiveClass *klass)
|
|||
"",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_ARCHIVE_TYPE,
|
||||
g_param_spec_string ("archive-type",
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue