summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:29:02 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:29:02 (EST)
commit1475a6802f47230c01cf4a37ee5a6686a4718f79 (patch)
treebfc156c15ecfc5e98fd507fdaaba0ead85d14a8d
parent2858b18db8d4cbbf5b76fee3abd734c2fc773e12 (diff)
opkg: add a simple way to pass a path environment for pre/post scription execution when in offline mode.
Thanks for Christopher Hall <hsw@openmoko.com> git-svn-id: http://opkg.googlecode.com/svn/trunk@155 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r--configure.ac6
-rw-r--r--libopkg/args.c15
-rw-r--r--libopkg/args.h2
-rw-r--r--libopkg/opkg_conf.c4
-rw-r--r--libopkg/opkg_conf.h1
-rw-r--r--libopkg/pkg.c19
6 files changed, 42 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 0397078..45e7b07 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,10 @@
# Process this file with autoconf to produce a configure script
AC_INIT(libopkg/libopkg.c)
-AM_INIT_AUTOMAKE([opkg], [0.1.5])
+
+AC_CONFIG_AUX_DIR([conf])
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE([opkg], [0.1.6])
AM_CONFIG_HEADER(libopkg/config.h)
AC_CANONICAL_HOST
diff --git a/libopkg/args.c b/libopkg/args.c
index df02eef..d767bfb 100644
--- a/libopkg/args.c
+++ b/libopkg/args.c
@@ -76,6 +76,7 @@ int args_init(args_t *args)
args->nodeps = ARGS_DEFAULT_NODEPS;
args->verbosity = ARGS_DEFAULT_VERBOSITY;
args->offline_root = ARGS_DEFAULT_OFFLINE_ROOT;
+ args->offline_root_path = ARGS_DEFAULT_OFFLINE_ROOT_PATH;
args->offline_root_pre_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_PRE_SCRIPT_CMD;
args->offline_root_post_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_POST_SCRIPT_CMD;
args->multiple_providers = 0;
@@ -88,6 +89,7 @@ int args_init(args_t *args)
void args_deinit(args_t *args)
{
free (args->offline_root);
+ free (args->offline_root_path);
free (args->offline_root_pre_script_cmd);
free (args->offline_root_post_script_cmd);
@@ -138,6 +140,8 @@ int args_parse(args_t *args, int argc, char *argv[])
{"nodeps", 0, 0, ARGS_OPT_NODEPS},
{"offline", 1, 0, 'o'},
{"offline-root", 1, 0, 'o'},
+ {"offline-path", 1, 0, 'p'},
+ {"offline-root-path", 1, 0, 'p'},
{"test", 0, 0, ARGS_OPT_NOACTION},
{"tmp-dir", 1, 0, 't'},
{"verbosity", 2, 0, 'V'},
@@ -146,7 +150,7 @@ int args_parse(args_t *args, int argc, char *argv[])
};
while (1) {
- c = getopt_long_only(argc, argv, "Ad:f:no:t:vV:", long_options, &option_index);
+ c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV:", long_options, &option_index);
if (c == -1)
break;
@@ -164,6 +168,9 @@ int args_parse(args_t *args, int argc, char *argv[])
case 'o':
args->offline_root = strdup (optarg);
break;
+ case 'p':
+ args->offline_root_path = strdup (optarg);
+ break;
case 'n':
args->noaction = 1;
break;
@@ -294,8 +301,10 @@ void args_usage(char *complaint)
printf(" directory name in a pinch).\n");
printf("\t-o <offline_root> Use <offline_root> as the root directory for\n");
printf("\t-offline <offline_root> offline installation of packages.\n");
-
- printf("\tForce Options (use when opkg is too smart for its own good):\n");
+ printf("\t-p <path> Path to utilities for runing postinst\n");
+ printf("\t-offline-path <path> script in offline mode.\n");
+
+ printf("\nForce Options (use when opkg is too smart for its own good):\n");
printf("\t-force-depends Make dependency checks warnings instead of errors\n");
printf("\t Install/remove package in spite of failed dependences\n");
printf("\t-force-defaults Use default options for questions asked by opkg.\n");
diff --git a/libopkg/args.h b/libopkg/args.h
index 395e332..61f32bc 100644
--- a/libopkg/args.h
+++ b/libopkg/args.h
@@ -40,6 +40,7 @@ struct args
int noreadfeedsfile;
int autoremove;
char *offline_root;
+ char *offline_root_path;
char *offline_root_pre_script_cmd;
char *offline_root_post_script_cmd;
char *cache;
@@ -58,6 +59,7 @@ typedef struct args args_t;
#define ARGS_DEFAULT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES 0
#define ARGS_DEFAULT_FORCE_SPACE 0
#define ARGS_DEFAULT_OFFLINE_ROOT NULL
+#define ARGS_DEFAULT_OFFLINE_ROOT_PATH NULL
#define ARGS_DEFAULT_OFFLINE_ROOT_PRE_SCRIPT_CMD NULL
#define ARGS_DEFAULT_OFFLINE_ROOT_POST_SCRIPT_CMD NULL
#define ARGS_DEFAULT_NOACTION 0
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index b61fa3e..99db505 100644
--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -63,6 +63,7 @@ int opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options)
{ "noaction", OPKG_OPT_TYPE_INT, &conf->noaction },
{ "nodeps", OPKG_OPT_TYPE_BOOL, &conf->nodeps },
{ "offline_root", OPKG_OPT_TYPE_STRING, &conf->offline_root },
+ { "offline_root_path", OPKG_OPT_TYPE_STRING, &conf->offline_root_path },
{ "offline_root_post_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd },
{ "offline_root_pre_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd },
{ "proxy_passwd", OPKG_OPT_TYPE_STRING, &conf->proxy_passwd },
@@ -266,6 +267,8 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
opkg_conf_override_string(&conf->offline_root,
args->offline_root);
+ opkg_conf_override_string(&conf->offline_root_path,
+ args->offline_root_path);
opkg_conf_override_string(&conf->offline_root_pre_script_cmd,
args->offline_root_pre_script_cmd);
opkg_conf_override_string(&conf->offline_root_post_script_cmd,
@@ -338,6 +341,7 @@ void opkg_conf_deinit(opkg_conf_t *conf)
hash_table_deinit(&conf->obs_file_hash);
opkg_conf_free_string(&conf->offline_root);
+ opkg_conf_free_string(&conf->offline_root_path);
opkg_conf_free_string(&conf->offline_root_pre_script_cmd);
opkg_conf_free_string(&conf->offline_root_post_script_cmd);
diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h
index 4ca513c..407c8de 100644
--- a/libopkg/opkg_conf.h
+++ b/libopkg/opkg_conf.h
@@ -65,6 +65,7 @@ struct opkg_conf
int force_removal_of_essential_packages;
int nodeps; /* do not follow dependences */
char *offline_root;
+ char *offline_root_path;
char *offline_root_pre_script_cmd;
char *offline_root_post_script_cmd;
int query_all;
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index d9e478d..4bbecb9 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -18,6 +18,7 @@
#include "includes.h"
#include <ctype.h>
#include <string.h>
+#include <stdbool.h>
#include <errno.h>
#include "pkg.h"
@@ -1494,8 +1495,24 @@ int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
scripts when running with offline_root mode and/or a dest other
than '/'. I've been playing around with some clever chroot
tricks and I might come up with something workable. */
+ /*
+ * Attempt to provide a restricted environment for offline operation
+ * Need the following set as a minimum:
+ * OPKG_OFFLINE_ROOT = absolute path to root dir
+ * D = absolute path to root dir (for OE generated postinst)
+ * PATH = something safe (a restricted set of utilities)
+ */
+
+ bool AllowOfflineMode = false;
if (conf->offline_root) {
setenv("OPKG_OFFLINE_ROOT", conf->offline_root, 1);
+ setenv("D", conf->offline_root, 1);
+ if (NULL == conf->offline_root_path || '\0' == conf->offline_root_path[0]) {
+ setenv("PATH", "/dev/null", 1);
+ } else {
+ setenv("PATH", conf->offline_root_path, 1);
+ AllowOfflineMode = true;
+ }
}
setenv("PKG_ROOT",
@@ -1506,7 +1523,7 @@ int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
return 0;
}
- if (conf->offline_root) {
+ if (conf->offline_root && !AllowOfflineMode) {
fprintf(stderr, "(offline root mode: not running %s.%s)\n", pkg->name, script);
free(path);
return 0;