adds a configure option so "/etc/opkg" can be
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Sun, 14 Jun 2009 05:43:35 +0000 (05:43 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Sun, 14 Jun 2009 05:43:35 +0000 (05:43 +0000)
changed when opkg is configured and built.
fix issue due to an error of opkg_conf.c

Thanks to jlc <jlcster@gmail.com>
http://groups.google.com/group/opkg-devel/browse_thread/thread/5c6e55832a7168aa

git-svn-id: http://opkg.googlecode.com/svn/trunk@213 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

configure.ac
libopkg/Makefile.am
libopkg/args.c
libopkg/args.h
libopkg/opkg_conf.c

index 315e13974d114ea62fc66050b0a032739ee1fd8e..4346373e3561b7876fb917031ac6b7c8e3df32eb 100644 (file)
@@ -127,8 +127,9 @@ opkglibdir=
 AC_ARG_WITH(opkglibdir,
 [  --with-opkglibdir=DIR   specifies directory to put status and info files.
                           "/opkg" is always added so if you want your files 
-                          to be in /usr/lib/opkg you should indicate 
-                          --with-opkglibdir=/usr/lib ],
+                          to be in /var/lib/opkg instead of /usr/lib/opkg
+                          you should indicate 
+                          --with-opkglibdir=/var/lib ],
 [case "${withval}" in
 yes)    AC_MSG_ERROR(bad value ${withval} given for opkg libs directories ) ;;
 no)     ;;
@@ -140,7 +141,27 @@ if test x$opkglibdir = x; then
         opkglibdir=/usr/lib
 fi
 
+ipkgetcdir=
+AC_ARG_WITH(opkgetcdir,
+[  --with-ipkgetcdir=DIR   specifies directory for opkg.conf file,
+                           "/opkg" is always added so if you want your files
+                           to be in /usr/etc/opkg instead of /etc/opkg
+                           you should indicate
+                           --with-ipkgetcdir=/usr/etc ],
+[case "${withval}" in
+yes)    AC_MSG_ERROR(bad value ${withval} given for opkg.conf directory ) ;;
+no)     ;;
+*)      opkgetcdir=$with_opkgetcdir ;;
+esac])
+
+# Default local prefix if it is empty
+if test x$opkgetcdir = x; then
+        opkgetcdir=/etc
+fi
+
+
 AC_SUBST(opkglibdir)
+AC_SUBST(opkgetcdir)
 
 AC_OUTPUT(
     Makefile
index 8783f15a1166064272f467686d22ff96991102af..0e9d3a93b369a6f9f786476e2112d20e353e5df0 100644 (file)
@@ -1,5 +1,5 @@
 
-AM_CFLAGS=-Wall -Werror -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS)
+AM_CFLAGS=-Wall -Werror -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS)
 
 libopkg_includedir=$(includedir)/libopkg
 libopkg_include_HEADERS= opkg.h
index 71692f0f928f55163a59e57b890707d717d74f84..ef2b4960e227e389b69b34dbbb3c1a51bf1c74ed 100644 (file)
@@ -47,10 +47,10 @@ enum long_args_opt
      ARGS_OPT_CACHE,
 };
 
+char *conf_file_dir;
+
 int args_init(args_t *args)
 {
-     char *conf_file_dir;
-
      if (!args) {
          return EFAULT;
      }
index b05bab19ad4be1ee913f77bb0d7b240fdab4b7f8..e8bb78bcd2c108c30e3acc26bf9ed3b0fddc4144 100644 (file)
@@ -48,7 +48,7 @@ struct args
 };
 typedef struct args args_t;
 
-#define ARGS_DEFAULT_CONF_FILE_DIR "/etc/opkg"
+#define ARGS_DEFAULT_CONF_FILE_DIR OPKGETCDIR"/opkg"
 #define ARGS_DEFAULT_CONF_FILE_NAME "opkg.conf"
 #define ARGS_DEFAULT_DEST NULL
 #define ARGS_DEFAULT_FORCE_DEFAULTS 0
index 0479b8a364b9b9d26747ee7370085396777fe2c1..fbbd2b2c43945924d46cd2e643618d4832a3a172 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "xregex.h"
 #include "sprintf_alloc.h"
-#include "opkg_conf.h"
+#include "args.h"
 #include "opkg_message.h"
 #include "file_util.h"
 #include "str_util.h"
@@ -33,6 +33,8 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
+extern char *conf_file_dir;
+
 static int opkg_conf_parse_file(opkg_conf_t *conf, const char *filename,
                                pkg_src_list_t *pkg_src_list,
                                nv_pair_list_t *tmp_dest_nv_pair_list,
@@ -110,7 +112,7 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
      nv_pair_list_t tmp_dest_nv_pair_list;
      char *lists_dir = NULL, *lock_file = NULL;
      glob_t globbuf;
-     char *etc_opkg_conf_pattern = "/etc/opkg/*.conf";
+     char *etc_opkg_conf_pattern;
      char *pending_dir = NULL;
 
      memset(conf, 0, sizeof(opkg_conf_t));
@@ -192,10 +194,11 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
 
      if (args->offline_root) 
          sprintf_alloc(&etc_opkg_conf_pattern, "%s/etc/opkg/*.conf", args->offline_root);
+     else
+         sprintf_alloc(&etc_opkg_conf_pattern, "%s/*.conf", conf_file_dir);
      memset(&globbuf, 0, sizeof(globbuf));
      err = glob(etc_opkg_conf_pattern, 0, NULL, &globbuf);
-     if (args->offline_root)
-          free (etc_opkg_conf_pattern);
+     free (etc_opkg_conf_pattern);
      if (!err) {
          int i;
          for (i = 0; i < globbuf.gl_pathc; i++) {