shared-mime-info: update to 1.4.
This commit is contained in:
parent
707867999b
commit
d8521a4363
|
@ -1,80 +0,0 @@
|
||||||
From fd48920cf82402a95f658cab93db0cf3786c4d6e Mon Sep 17 00:00:00 2001
|
|
||||||
From: Bastien Nocera <hadess@hadess.net>
|
|
||||||
Date: Wed, 25 Jun 2014 17:23:50 +0200
|
|
||||||
Subject: [PATCH 7/8] Split out fdatasync() usage
|
|
||||||
|
|
||||||
---
|
|
||||||
update-mime-database.c | 38 ++++++++++++++++++++++++--------------
|
|
||||||
1 file changed, 24 insertions(+), 14 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/update-mime-database.c b/update-mime-database.c
|
|
||||||
index c043606..c1a6f9f 100644
|
|
||||||
--- update-mime-database.c
|
|
||||||
+++ update-mime-database.c
|
|
||||||
@@ -936,39 +936,49 @@ set_error_from_errno (GError **error)
|
|
||||||
g_strerror(errsv));
|
|
||||||
}
|
|
||||||
|
|
||||||
-/* Renames pathname by removing the .new extension */
|
|
||||||
-static gboolean atomic_update(const gchar *pathname, GError **error)
|
|
||||||
+static int
|
|
||||||
+sync_file(const gchar *pathname, GError **error)
|
|
||||||
{
|
|
||||||
- gboolean ret = FALSE;
|
|
||||||
- gchar *new_name = NULL;
|
|
||||||
- int len;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
- len = strlen(pathname);
|
|
||||||
-
|
|
||||||
- g_return_val_if_fail(strcmp(pathname + len - 4, ".new") == 0, FALSE);
|
|
||||||
-
|
|
||||||
- new_name = g_strndup(pathname, len - 4);
|
|
||||||
-
|
|
||||||
#ifdef HAVE_FDATASYNC
|
|
||||||
fd = open(pathname, O_RDWR);
|
|
||||||
if (fd == -1)
|
|
||||||
{
|
|
||||||
set_error_from_errno(error);
|
|
||||||
- goto out;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
if (fdatasync(fd) == -1)
|
|
||||||
{
|
|
||||||
set_error_from_errno(error);
|
|
||||||
- goto out;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
if (close(fd) == -1)
|
|
||||||
{
|
|
||||||
set_error_from_errno(error);
|
|
||||||
- goto out;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Renames pathname by removing the .new extension */
|
|
||||||
+static gboolean atomic_update(const gchar *pathname, GError **error)
|
|
||||||
+{
|
|
||||||
+ gboolean ret = FALSE;
|
|
||||||
+ gchar *new_name = NULL;
|
|
||||||
+ int len;
|
|
||||||
+
|
|
||||||
+ len = strlen(pathname);
|
|
||||||
+
|
|
||||||
+ g_return_val_if_fail(strcmp(pathname + len - 4, ".new") == 0, FALSE);
|
|
||||||
+
|
|
||||||
+ new_name = g_strndup(pathname, len - 4);
|
|
||||||
+
|
|
||||||
+ if (sync_file(pathname, error) == -1)
|
|
||||||
+ goto out;
|
|
||||||
+
|
|
||||||
#ifdef _WIN32
|
|
||||||
/* we need to remove the old file first! */
|
|
||||||
remove(new_name);
|
|
||||||
--
|
|
||||||
1.9.3
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
From 1f7683bfcbecbeffa802a1c361e1842db2fff4f8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Bastien Nocera <hadess@hadess.net>
|
|
||||||
Date: Wed, 25 Jun 2014 17:25:50 +0200
|
|
||||||
Subject: [PATCH 8/8] Disable fdatasync() usage if PKGSYSTEM_ENABLE_FSYNC is
|
|
||||||
set
|
|
||||||
|
|
||||||
If the PKGSYSTEM_ENABLE_FSYNC envvar is set to a non-zero value,
|
|
||||||
the fdatasync() call will be skipped, at the expense of data integrity.
|
|
||||||
|
|
||||||
https://bugs.freedesktop.org/show_bug.cgi?id=70366
|
|
||||||
---
|
|
||||||
update-mime-database.c | 14 ++++++++++++++
|
|
||||||
1 file changed, 14 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/update-mime-database.c b/update-mime-database.c
|
|
||||||
index c1a6f9f..894ac97 100644
|
|
||||||
--- update-mime-database.c
|
|
||||||
+++ update-mime-database.c
|
|
||||||
@@ -936,11 +936,25 @@ set_error_from_errno (GError **error)
|
|
||||||
g_strerror(errsv));
|
|
||||||
}
|
|
||||||
|
|
||||||
+static gboolean
|
|
||||||
+sync_enabled(void)
|
|
||||||
+{
|
|
||||||
+ const char *env;
|
|
||||||
+
|
|
||||||
+ env = g_getenv("PKGSYSTEM_ENABLE_FSYNC");
|
|
||||||
+ if (!env)
|
|
||||||
+ return TRUE;
|
|
||||||
+ return atoi(env);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int
|
|
||||||
sync_file(const gchar *pathname, GError **error)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
+ if (!sync_enabled())
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
#ifdef HAVE_FDATASYNC
|
|
||||||
fd = open(pathname, O_RDWR);
|
|
||||||
if (fd == -1)
|
|
||||||
--
|
|
||||||
1.9.3
|
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
From 4b3f9f774da8859d4f1f7e991b12832d6c09b63e Mon Sep 17 00:00:00 2001
|
|
||||||
From: Bastien Nocera <hadess@hadess.net>
|
|
||||||
Date: Fri, 27 Jun 2014 16:57:08 +0200
|
|
||||||
Subject: [PATCH 13/14] Skip mime database update if packages are older than
|
|
||||||
cache
|
|
||||||
|
|
||||||
Check for the mtime of the version file, the last one to be created when
|
|
||||||
updating the database to see against the mtime of the newest packages
|
|
||||||
file.
|
|
||||||
|
|
||||||
If one of the files inside the packages directory is newer than the
|
|
||||||
version file, really update the database.
|
|
||||||
---
|
|
||||||
update-mime-database.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 61 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/update-mime-database.c b/update-mime-database.c
|
|
||||||
index 894ac97..d1849a3 100644
|
|
||||||
--- update-mime-database.c
|
|
||||||
+++ update-mime-database.c
|
|
||||||
@@ -10,6 +10,7 @@
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <glib/gprintf.h>
|
|
||||||
+#include <glib/gstdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <libxml/parser.h>
|
|
||||||
@@ -3538,6 +3539,61 @@ fclose_gerror(FILE *f, GError **error)
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static gint64
|
|
||||||
+newest_mtime(const char *packagedir)
|
|
||||||
+{
|
|
||||||
+ GDir *dir;
|
|
||||||
+ GStatBuf statbuf;
|
|
||||||
+ gint64 mtime = G_MININT64;
|
|
||||||
+ const char *name;
|
|
||||||
+ int retval;
|
|
||||||
+
|
|
||||||
+ retval = g_stat(packagedir, &statbuf);
|
|
||||||
+ if (retval < 0)
|
|
||||||
+ return mtime;
|
|
||||||
+ mtime = statbuf.st_mtime;
|
|
||||||
+
|
|
||||||
+ dir = g_dir_open(packagedir, 0, NULL);
|
|
||||||
+ if (!dir)
|
|
||||||
+ return mtime;
|
|
||||||
+
|
|
||||||
+ while ((name = g_dir_read_name(dir))) {
|
|
||||||
+ char *path;
|
|
||||||
+
|
|
||||||
+ path = g_build_filename(packagedir, name, NULL);
|
|
||||||
+ retval = g_stat(path, &statbuf);
|
|
||||||
+ g_free(path);
|
|
||||||
+ if (retval < 0)
|
|
||||||
+ continue;
|
|
||||||
+ if (statbuf.st_mtime > mtime)
|
|
||||||
+ mtime = statbuf.st_mtime;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ g_dir_close(dir);
|
|
||||||
+ return mtime;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static gboolean
|
|
||||||
+is_cache_up_to_date (const char *mimedir, const char *packagedir)
|
|
||||||
+{
|
|
||||||
+ GStatBuf version_stat;
|
|
||||||
+ gint64 package_mtime;
|
|
||||||
+ char *mimeversion;
|
|
||||||
+ int retval;
|
|
||||||
+
|
|
||||||
+ mimeversion = g_build_filename(mimedir, "/version", NULL);
|
|
||||||
+ retval = g_stat(mimeversion, &version_stat);
|
|
||||||
+ g_free(mimeversion);
|
|
||||||
+ if (retval < 0)
|
|
||||||
+ return FALSE;
|
|
||||||
+
|
|
||||||
+ package_mtime = newest_mtime(packagedir);
|
|
||||||
+ if (package_mtime < 0)
|
|
||||||
+ return FALSE;
|
|
||||||
+
|
|
||||||
+ return version_stat.st_mtime >= package_mtime;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
char *mime_dir = NULL;
|
|
||||||
@@ -3610,6 +3666,11 @@ int main(int argc, char **argv)
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (is_cache_up_to_date(mime_dir, package_dir)) {
|
|
||||||
+ g_message ("Skipping mime update as the cache is up-to-date");
|
|
||||||
+ return EXIT_SUCCESS;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
types = g_hash_table_new_full(g_str_hash, g_str_equal,
|
|
||||||
g_free, free_type);
|
|
||||||
globs_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
|
|
||||||
--
|
|
||||||
1.9.3
|
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
From 29a04be6c9cbaf0865c8b57428b7b7c37fbda4c3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Bastien Nocera <hadess@hadess.net>
|
|
||||||
Date: Fri, 27 Jun 2014 18:25:57 +0200
|
|
||||||
Subject: [PATCH 14/14] Add "-n" option to update-mime-database
|
|
||||||
|
|
||||||
When "-n" is passed, the cache will only be updated if
|
|
||||||
$MIME_DIR/packages or one of the files in that directory is newer
|
|
||||||
than $MIME_DIR/version.
|
|
||||||
|
|
||||||
This is useful for package pre- and post-installation scripts.
|
|
||||||
---
|
|
||||||
update-mime-database.1 | 7 +++++++
|
|
||||||
update-mime-database.c | 10 +++++++---
|
|
||||||
2 files changed, 14 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/update-mime-database.1 b/update-mime-database.1
|
|
||||||
index c9164e1..b18eac3 100644
|
|
||||||
--- update-mime-database.1
|
|
||||||
+++ update-mime-database.1
|
|
||||||
@@ -16,6 +16,8 @@ update-mime-database \- a program to build the Shared MIME-Info database cache
|
|
||||||
.B \-v
|
|
||||||
| [
|
|
||||||
.B \-V
|
|
||||||
+|
|
|
||||||
+.B \-n
|
|
||||||
]
|
|
||||||
.I MIME-DIR
|
|
||||||
|
|
||||||
@@ -38,6 +40,11 @@ Print out the version information.
|
|
||||||
.TP
|
|
||||||
\fB\-V\fR
|
|
||||||
Be verbose.
|
|
||||||
+.TP
|
|
||||||
+\fB\-n\fR
|
|
||||||
+Only update if \fBMIME-DIR\fR/packages/ or a file in that directory
|
|
||||||
+is newer than \fBMIME-DIR\fR/version. This is useful for package pre-
|
|
||||||
+and post-installation scripts.
|
|
||||||
|
|
||||||
.SH ARGUMENTS
|
|
||||||
.TP
|
|
||||||
diff --git a/update-mime-database.c b/update-mime-database.c
|
|
||||||
index d1849a3..be4aba2 100644
|
|
||||||
--- update-mime-database.c
|
|
||||||
+++ update-mime-database.c
|
|
||||||
@@ -194,7 +194,7 @@ fatal_gerror (GError *error)
|
|
||||||
|
|
||||||
static void usage(const char *name)
|
|
||||||
{
|
|
||||||
- g_fprintf(stderr, _("Usage: %s [-hvV] MIME-DIR\n"), name);
|
|
||||||
+ g_fprintf(stderr, _("Usage: %s [-hvVn] MIME-DIR\n"), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void free_type(gpointer data)
|
|
||||||
@@ -3601,11 +3601,12 @@ int main(int argc, char **argv)
|
|
||||||
int opt;
|
|
||||||
GError *local_error = NULL;
|
|
||||||
GError **error = &local_error;
|
|
||||||
+ gboolean if_newer = FALSE;
|
|
||||||
|
|
||||||
/* Install the filtering log handler */
|
|
||||||
g_log_set_default_handler(g_log_handler, NULL);
|
|
||||||
|
|
||||||
- while ((opt = getopt(argc, argv, "hvV")) != -1)
|
|
||||||
+ while ((opt = getopt(argc, argv, "hvVn")) != -1)
|
|
||||||
{
|
|
||||||
switch (opt)
|
|
||||||
{
|
|
||||||
@@ -3624,6 +3625,9 @@ int main(int argc, char **argv)
|
|
||||||
enabled_log_levels |= G_LOG_LEVEL_MESSAGE
|
|
||||||
| G_LOG_LEVEL_INFO;
|
|
||||||
break;
|
|
||||||
+ case 'n':
|
|
||||||
+ if_newer = TRUE;
|
|
||||||
+ break;
|
|
||||||
default:
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
@@ -3666,7 +3670,7 @@ int main(int argc, char **argv)
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (is_cache_up_to_date(mime_dir, package_dir)) {
|
|
||||||
+ if (if_newer && is_cache_up_to_date(mime_dir, package_dir)) {
|
|
||||||
g_message ("Skipping mime update as the cache is up-to-date");
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
1.9.3
|
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
# Template build file for 'shared-mime-info'.
|
# Template build file for 'shared-mime-info'.
|
||||||
disable_parallel_build=1
|
|
||||||
|
|
||||||
pkgname=shared-mime-info
|
pkgname=shared-mime-info
|
||||||
version=1.3
|
version=1.4
|
||||||
revision=3
|
revision=1
|
||||||
build_style=gnu-configure
|
build_style=gnu-configure
|
||||||
# XXX disable fsync for now, ETOOSLOW!
|
configure_args="--disable-update-mimedb"
|
||||||
# see: https://bugs.freedesktop.org/show_bug.cgi?id=70366
|
|
||||||
configure_args="--disable-update-mimedb ac_cv_func_fdatasync=no"
|
|
||||||
hostmakedepends="pkg-config intltool"
|
hostmakedepends="pkg-config intltool"
|
||||||
makedepends="libglib-devel libxml2-devel"
|
makedepends="libglib-devel libxml2-devel"
|
||||||
short_desc="Core database of common types"
|
short_desc="Core database of common types"
|
||||||
|
@ -15,4 +11,4 @@ maintainer="Juan RP <xtraeme@gmail.com>"
|
||||||
license="GPL-2"
|
license="GPL-2"
|
||||||
homepage="http://freedesktop.org/Software/shared-mime-info"
|
homepage="http://freedesktop.org/Software/shared-mime-info"
|
||||||
distfiles="http://people.freedesktop.org/~hadess/$pkgname-$version.tar.xz"
|
distfiles="http://people.freedesktop.org/~hadess/$pkgname-$version.tar.xz"
|
||||||
checksum=4fd49c8c7ca9ecb10c59845094a18dbb73b69c72b4bad3db5e864f2111cb323a
|
checksum=bbc0bd023f497dfd75e1ca73441cbbb5a63617d9e14f2790b868361cc055b5b1
|
||||||
|
|
Loading…
Reference in New Issue