gnome-user-share r338 - in trunk: . data src
- From: fpeters svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-user-share r338 - in trunk: . data src
- Date: Mon, 2 Feb 2009 11:35:19 +0000 (UTC)
Author: fpeters
Date: Mon Feb 2 11:35:19 2009
New Revision: 338
URL: http://svn.gnome.org/viewvc/gnome-user-share?rev=338&view=rev
Log:
* configure.in: remove buildtime checks for Apache.
* src/Makefile.am:
* src/http.c: (get_httpd_program), (get_httpd_modules_path),
(get_httpd_config), (spawn_httpd): lookup Apache at runtime, with
checks for its version number and mod_dnssd.
* data/Makefile.am:
* data/dav_user_2.2.conf.in: no longer generate dav_user_2.2.conf at
build time.
(Closes: #569669)
Added:
trunk/data/dav_user_2.2.conf (props changed)
- copied unchanged from r337, /trunk/data/dav_user_2.2.conf.in
Removed:
trunk/data/dav_user_2.2.conf.in
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/data/Makefile.am
trunk/src/Makefile.am
trunk/src/http.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Mon Feb 2 11:35:19 2009
@@ -27,17 +27,9 @@
AC_TYPE_SIZE_T
AC_TYPE_UID_T
-I_KNOW=no
-AC_ARG_WITH([i-know-i-need-apache-httpd-installed-to-make-this-work],
- [AS_HELP_STRING([--with-i-know-i-need-apache-httpd-installed-to-make-this-work],[Don't require httpd and mod_dnssd at build-time (default: no)])],
- I_KNOW="$withval", I_KNOW="no")
-
AC_ARG_WITH([httpd],
[AS_HELP_STRING([--with-httpd],[Specify the binary used for the Apache httpd binary (default: httpd)])],
[HTTPD=$withval])
-if test -z "$HTTPD" && test "x$I_KNOW" != "xno" ; then
- AC_MSG_ERROR([You need to provide the httpd binary name when building without httpd installed])
-fi
if test -z "$HTTPD" ; then
AC_PATH_PROG([HTTPD], [httpd],,
[$PATH:/usr/sbin])
@@ -53,26 +45,8 @@
fi
fi
-if test "x$I_KNOW" = "xno" ; then
- default_httpd_version=`$HTTPD -v | head -1 | sed "s#^.*Apache/\([^ ]*\).*#\1#" | cut -f 1-2 -d .`
-else
- default_httpd_version="unknown"
-fi
-AC_ARG_WITH(httpd-version, [ --with-httpd-version=VERSION Httpd version used.],
- HTTPD_VERSION="$withval", HTTPD_VERSION="$default_httpd_version")
-
-if test "x$HTTPD_VERSION" != "x2.2" ; then
- AC_MSG_ERROR([Could not detect a supported HTTPD version (2.2)])
-fi
-
-AC_SUBST(HTTPD_VERSION)
+AC_SUBST(HTTPD)
-# FIXME disabled for now, as the configuration for 2.0 hasn't been ported to
-# use mod_dnssd
-#if test "x$HTTPD_VERSION" != "x2.0" && test "x$HTTPD_VERSION" != "x2.2" ; then
-# AC_MSG_ERROR([Could not detect a supported HTTPD version (2.0 or 2.2)])
-#fi
-
PKG_CHECK_EXISTS(dbus-1 >= 1.1.1, have_dbus_1_1=true, have_dbus_1_1=false)
if $have_dbus_1_1 ; then
DBUS_MODULES=dbus-1
@@ -146,23 +120,11 @@
AC_ARG_WITH([modules-path],
[AS_HELP_STRING([--with-modules-path],[Path where the httpd modules are located (default: /etc/httpd/modules/)])],
[with_modules_path=$withval])
-if test "x$with_modules_path" = "x" ; then
- with_modules_path=/etc/httpd/modules/
-fi
MODULES_PATH=$with_modules_path
AC_SUBST(MODULES_PATH)
dnl ==========================================================================
-dnl Check for mod_dnssd
-
-if test "x$I_KNOW" = "xno" && test ! -f $with_modules_path/mod_dnssd.so ; then
- AC_MSG_ERROR([mod_dnssd 0.6 is required to use gnome-user-share])
-else
- grep -q DNSSDServiceTxtRecord $with_modules_path/mod_dnssd.so || AC_MSG_ERROR([mod_dnssd 0.6 is required to use gnome-user-share])
-fi
-
-dnl ==========================================================================
dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.
@@ -221,6 +183,5 @@
])
echo "
- httpd version: $HTTPD_VERSION
- httpd modules path: $MODULES_PATH
+Do note Apache 2.2 and mod_dnssd 0.6 are required to use gnome-user-share.
"
Modified: trunk/data/Makefile.am
==============================================================================
--- trunk/data/Makefile.am (original)
+++ trunk/data/Makefile.am Mon Feb 2 11:35:19 2009
@@ -15,21 +15,13 @@
autostart_in_files = gnome-user-share.desktop.in
appdir = $(datadir)/gnome-user-share
-app_DATA=dav_user_2.0.conf dav_groupfile file-share-properties.ui
-
-appconfdir = $(datadir)/gnome-user-share
-appconf_DATA = dav_user_2.2.conf
-
-dav_user_2.2.conf: dav_user_2.2.conf.in
- sed "s,@DATADIR@,$(datadir)," dav_user_2.2.conf.in | \
- sed "s,@HTTP_MODULES_PATH@,$(MODULES_PATH)," > $@
+app_DATA=dav_user_2.0.conf dav_user_2.2.conf dav_groupfile file-share-properties.ui
install-data-local:
if GCONF_SCHEMAS_INSTALL
-GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
$(GCONFTOOL) --makefile-install-rule $(schema_DATA)
endif
- ln -sf dav_user_$(HTTPD_VERSION).conf $(DESTDIR)$(appdir)/dav_user.conf
if GCONF_SCHEMAS_INSTALL
uninstall-local:
@@ -40,10 +32,9 @@
EXTRA_DIST = $(schema_in_files) \
$(app_DATA) \
$(desktop_in_files) \
- dav_user_2.2.conf.in \
gnome-user-share.desktop.in.in \
file-share-properties.ui
-CLEANFILES = $(desktop_DATA) $(autostart_DATA) dav_user_2.2.conf
+CLEANFILES = $(desktop_DATA) $(autostart_DATA)
-DISTCLEANFILES = $(schema_DATA) dav_user_2.2.conf
+DISTCLEANFILES = $(schema_DATA)
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Feb 2 11:35:19 2009
@@ -21,8 +21,9 @@
-DUSER_SHARE_PROGRAM=\""$(libexecdir)/gnome-user-share"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\""$(datadir)/gnome-user-share/"\" \
- -DHTTPD_CONFIG=\""$(datadir)/gnome-user-share/dav_user.conf"\" \
+ -DHTTPD_CONFIG_TEMPLATE=\""$(datadir)/gnome-user-share/dav_user_%s.conf"\" \
-DHTTPD_PROGRAM=\""$(HTTPD)"\" \
+ -DHTTPD_MODULES_PATH=\""$(MODULES_PATH)"\" \
-I$(top_srcdir) \
-I$(top_builddir) \
$(USER_SHARE_CFLAGS) \
Modified: trunk/src/http.c
==============================================================================
--- trunk/src/http.c (original)
+++ trunk/src/http.c Mon Feb 2 11:35:19 2009
@@ -196,10 +196,106 @@
#endif
}
+static const char *known_httpd_locations [] = {
+ HTTPD_PROGRAM,
+ "/usr/sbin/httpd",
+ "/usr/sbin/httpd2",
+ "/usr/sbin/apache2",
+ NULL
+};
+
+static char*
+get_httpd_program ()
+{
+ int i;
+
+ for (i = 0; known_httpd_locations[i]; i++) {
+ if (known_httpd_locations[i][0] == '\0') {
+ /* empty string as first element, happens when
+ * configured --with-httpd=auto */
+ continue;
+ }
+ if (g_file_test (known_httpd_locations[i], G_FILE_TEST_IS_EXECUTABLE)
+ && ! g_file_test (known_httpd_locations[i], G_FILE_TEST_IS_DIR)) {
+ return g_strdup (known_httpd_locations[i]);
+ }
+ }
+ return NULL;
+}
+
+static const char *known_httpd_modules_locations [] = {
+ HTTPD_MODULES_PATH,
+ "/etc/httpd/modules",
+ "/usr/lib/apache2/modules",
+ NULL
+};
+
+static gchar*
+get_httpd_modules_path ()
+{
+ int i;
+
+ for (i = 0; known_httpd_modules_locations[i]; i++) {
+ if (known_httpd_modules_locations[i][0] == '\0') {
+ /* empty string as first element, happens when
+ * configured --with-httpd=auto */
+ continue;
+ }
+ if (g_file_test (known_httpd_modules_locations[i], G_FILE_TEST_IS_EXECUTABLE)
+ && g_file_test (known_httpd_modules_locations[i], G_FILE_TEST_IS_DIR)) {
+ return g_strdup (known_httpd_modules_locations[i]);
+ }
+ }
+ return NULL;
+}
+
+static GRegex *version_regex = NULL;
+
+static char*
+get_httpd_config (const char *httpd_program)
+{
+ gchar *standard_output;
+ gchar *cmd_line;
+ GMatchInfo *match_info;
+ gchar *version_number = NULL;
+ gchar *config;
+
+ cmd_line = g_strdup_printf ("%s -v", httpd_program);
+ if (! g_spawn_command_line_sync (cmd_line, &standard_output, NULL, NULL, NULL)) {
+ g_free (cmd_line);
+ return NULL;
+ }
+ g_free (cmd_line);
+
+ if (version_regex == NULL) {
+ version_regex = g_regex_new ("\\d\\.\\d", 0, 0, NULL);
+ }
+
+ if (g_regex_match (version_regex, standard_output, 0, &match_info)) {
+ while (g_match_info_matches (match_info)) {
+ version_number = g_match_info_fetch (match_info, 0);
+ break;
+ }
+ g_match_info_free (match_info);
+ g_free (standard_output);
+ } else {
+ /* Failed to parse httpd version number */
+ g_warning ("Could not parse '%s' as a version for httpd", standard_output);
+ g_free (standard_output);
+ /* assume it is 2.2 */
+ version_number = g_strdup ("2.2");
+ }
+
+ config = g_strdup_printf (HTTPD_CONFIG_TEMPLATE, version_number);
+ g_free (version_number);
+
+ return config;
+}
+
static gboolean
spawn_httpd (int port, pid_t *pid_out)
{
- char *free1, *free2, *free3, *free4, *free5, *free6;
+ char *free1, *free2, *free3, *free4, *free5, *free6, *free7, *free8, *free9;
gboolean res;
char *argv[10];
char *env[10];
@@ -217,11 +313,16 @@
ensure_conf_dir ();
i = 0;
- argv[i++] = HTTPD_PROGRAM;
+ free1 = argv[i++] = get_httpd_program ();
+ if (argv[0] == NULL) {
+ fprintf (stderr, "error finding httpd server\n");
+ return FALSE;
+ }
+
argv[i++] = "-f";
- argv[i++] = HTTPD_CONFIG;
+ free2 = argv[i++] = get_httpd_config (argv[0]);
argv[i++] = "-C";
- free1 = argv[i++] = g_strdup_printf ("Listen %d", port);
+ free3 = argv[i++] = g_strdup_printf ("Listen %d", port);
client = gconf_client_get_default ();
str = gconf_client_get_string (client,
@@ -243,11 +344,12 @@
argv[i] = NULL;
i = 0;
- free2 = env[i++] = g_strdup_printf ("HOME=%s", g_get_home_dir());
- free3 = env[i++] = g_strdup_printf ("XDG_PUBLICSHARE_DIR=%s", public_dir);
- free4 = env[i++] = g_strdup_printf ("XDG_CONFIG_HOME=%s", g_get_user_config_dir ());
- free5 = env[i++] = g_strdup_printf ("GUS_SHARE_NAME=%s", get_share_name ());
- free6 = env[i++] = g_strdup_printf ("GUS_LOGIN_LABEL=%s", _("Please log in as the user guest"));
+ free4 = env[i++] = g_strdup_printf ("HOME=%s", g_get_home_dir());
+ free5 = env[i++] = g_strdup_printf ("XDG_PUBLICSHARE_DIR=%s", public_dir);
+ free6 = env[i++] = g_strdup_printf ("XDG_CONFIG_HOME=%s", g_get_user_config_dir ());
+ free7 = env[i++] = g_strdup_printf ("GUS_SHARE_NAME=%s", get_share_name ());
+ free8 = env[i++] = g_strdup_printf ("GUS_LOGIN_LABEL=%s", _("Please log in as the user guest"));
+ free9 = env[i++] = g_strdup_printf ("HTTP_MODULES_PATH=%s",get_httpd_modules_path ());
env[i++] = "LANG=C";
env[i] = NULL;
@@ -269,6 +371,9 @@
g_free (free4);
g_free (free5);
g_free (free6);
+ g_free (free7);
+ g_free (free8);
+ g_free (free9);
g_free (public_dir);
if (!res) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]