pull in upstream support for new -n option, re-enable fsync default on (#1052173)
This commit is contained in:
parent
7ecbd4c206
commit
bcb66269ca
105
0013-Skip-mime-database-update-if-packages-are-older-than.patch
Normal file
105
0013-Skip-mime-database-update-if-packages-are-older-than.patch
Normal file
@ -0,0 +1,105 @@
|
||||
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
|
||||
--- a/update-mime-database.c
|
||||
+++ b/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
|
||||
|
89
0014-Add-n-option-to-update-mime-database.patch
Normal file
89
0014-Add-n-option-to-update-mime-database.patch
Normal file
@ -0,0 +1,89 @@
|
||||
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
|
||||
--- a/update-mime-database.1
|
||||
+++ b/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
|
||||
--- a/update-mime-database.c
|
||||
+++ b/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 +0,0 @@
|
||||
diff --git a/update-mime-database.c b/update-mime-database.c
|
||||
index 894ac97..8626702 100644
|
||||
--- a/update-mime-database.c
|
||||
+++ b/update-mime-database.c
|
||||
@@ -943,7 +943,7 @@ sync_enabled(void)
|
||||
|
||||
env = g_getenv("PKGSYSTEM_ENABLE_FSYNC");
|
||||
if (!env)
|
||||
- return TRUE;
|
||||
+ return FALSE;
|
||||
return atoi(env);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
Summary: Shared MIME information database
|
||||
Name: shared-mime-info
|
||||
Version: 1.3
|
||||
Release: 5%{?dist}
|
||||
Release: 6%{?dist}
|
||||
License: GPLv2+
|
||||
Group: System Environment/Base
|
||||
URL: http://freedesktop.org/Software/shared-mime-info
|
||||
@ -24,9 +24,9 @@ Patch0: 0001-Remove-sub-classing-from-OO.o-mime-types.patch
|
||||
# https://bugs.freedesktop.org/show_bug.cgi?id=70366#c30
|
||||
Patch1: 0007-Split-out-fdatasync-usage.patch
|
||||
Patch2: 0008-Disable-fdatasync-usage-if-PKGSYSTEM_ENABLE_FSYNC-is.patch
|
||||
# set PKGSYSTEM_ENABLE_FSYNC default off
|
||||
#https://bugzilla.redhat.com/show_bug.cgi?id=1052173#c14
|
||||
Patch3: PKGSYSTEM_ENABLE_FSYNC-default_off.patch
|
||||
Patch3: 0013-Skip-mime-database-update-if-packages-are-older-than.patch
|
||||
Patch4: 0014-Add-n-option-to-update-mime-database.patch
|
||||
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: libxml2-devel
|
||||
@ -46,19 +46,16 @@ a file. This is generally done by examining the file's name or contents,
|
||||
and looking up the correct MIME type in a database.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .ooo-zip
|
||||
%patch1 -p1 -b .0007
|
||||
%patch2 -p1 -b .0008
|
||||
%patch3 -p1 -b .PKGSYSTEM_ENABLE_FSYNC-default_off
|
||||
%autosetup
|
||||
|
||||
%build
|
||||
|
||||
%configure --disable-silent-rules
|
||||
# make %{?_smp_mflags}
|
||||
# not smp safe, pretty small package anyway
|
||||
make
|
||||
|
||||
%install
|
||||
# speed build a bit
|
||||
PKGSYSTEM_ENABLE_FSYNC=0 \
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
find $RPM_BUILD_ROOT%{_datadir}/mime -type d \
|
||||
@ -76,15 +73,12 @@ cat %SOURCE4 >> $RPM_BUILD_ROOT/%{_datadir}/applications/defaults.list
|
||||
## translations are already in the xml file installed
|
||||
rm -rf $RPM_BUILD_ROOT%{_datadir}/locale/*
|
||||
|
||||
%if 0%{?fedora} < 17
|
||||
# f17+ mozilla-firefox.desktop renamed to firefox.desktop (#736558)
|
||||
# defaults.list fixed, handle this exceptional case separately, if at all
|
||||
%endif
|
||||
|
||||
|
||||
%post
|
||||
# Should fail, as it would mean a problem in the mime database
|
||||
%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
|
||||
touch --no-create %{_datadir}/mime/packages ||:
|
||||
|
||||
%posttrans
|
||||
%{_bindir}/update-mime-database -n %{_datadir}/mime &> /dev/null ||:
|
||||
|
||||
%files -f %{name}.files
|
||||
%defattr(-,root,root,-)
|
||||
@ -98,6 +92,9 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/locale/*
|
||||
%{_mandir}/man*/*
|
||||
|
||||
%changelog
|
||||
* Fri Jun 27 2014 Rex Dieter <rdieter@fedoraproject.org> 1.3-6
|
||||
- pull in upstream support for new -n option, re-enable fsync default on (#1052173)
|
||||
|
||||
* Thu Jun 26 2014 Rex Dieter <rdieter@fedoraproject.org> 1.3-5
|
||||
- include PKGSYSTEM_ENABLE_FSYNC upstream implementation, except default off (#1052173)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user