summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2014-06-27 18:25:57 +0200
committerBastien Nocera <hadess@hadess.net>2014-06-27 18:31:18 +0200
commit29a04be6c9cbaf0865c8b57428b7b7c37fbda4c3 (patch)
tree1497c47fefd269d8d9ddac150868c4b9324426d7
parent4b3f9f774da8859d4f1f7e991b12832d6c09b63e (diff)
downloadshared-mime-info-29a04be6c9cbaf0865c8b57428b7b7c37fbda4c3.tar.gz
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.
-rw-r--r--update-mime-database.17
-rw-r--r--update-mime-database.c10
2 files changed, 14 insertions, 3 deletions
diff --git a/update-mime-database.1 b/update-mime-database.1
index c9164e13..b18eac3b 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 d1849a3c..be4aba25 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;
}