aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/opkg
diff options
context:
space:
mode:
authorChris Larson <clarson@mvista.com>2009-10-05 18:22:03 -0700
committerChris Larson <clarson@mvista.com>2009-11-03 13:56:13 -0700
commitf1d0fab3acc99d329deb0338fc51921e32fbe6f4 (patch)
treeb18dfe8a31dff3edccb91ef54974507306e91b2a /recipes/opkg
parent1632c44d94d986f4933ae04e034f3fda11fb7e0b (diff)
downloadopenembedded-f1d0fab3acc99d329deb0338fc51921e32fbe6f4.tar.gz
opkg: Don't prompt for user input from stdin if it's not a tty.
Also fixes a minor memory leak while we're at it, as the code was strdup'ing the malloc'd string read from stdin without ever freeing the original. Signed-off-by: Chris Larson <clarson@mvista.com>
Diffstat (limited to 'recipes/opkg')
-rw-r--r--recipes/opkg/opkg.inc5
-rw-r--r--recipes/opkg/opkg/isatty.patch64
2 files changed, 67 insertions, 2 deletions
diff --git a/recipes/opkg/opkg.inc b/recipes/opkg/opkg.inc
index c146c75b79..aa91955c3a 100644
--- a/recipes/opkg/opkg.inc
+++ b/recipes/opkg/opkg.inc
@@ -4,13 +4,14 @@ SECTION = "base"
LICENSE = "GPL"
DEPENDS = "curl gpgme"
PV = "0.1.6+svnr${SRCREV}"
-INC_PR = "r15"
+INC_PR = "r16"
FILESPATHPKG =. "opkg:"
SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \
file://opkg_unarchive.patch;patch=1;maxrev=201 \
- file://opkg-intercept-cleanup.patch;patch=1"
+ file://opkg-intercept-cleanup.patch;patch=1 \
+ file://isatty.patch;patch=1"
SRC_URI += "file://configure"
diff --git a/recipes/opkg/opkg/isatty.patch b/recipes/opkg/opkg/isatty.patch
new file mode 100644
index 0000000000..c935f153d1
--- /dev/null
+++ b/recipes/opkg/opkg/isatty.patch
@@ -0,0 +1,64 @@
+Copyright (c) 2009 MontaVista Software, Inc. All rights reserved.
+
+Don't prompt for user input from stdin if it's not a tty. Fixes a minor
+memory leak while we're at it, as the code was strdup'ing the malloc'd string
+read from stdin without ever freeing the original.
+---
+ libopkg/libopkg.c | 13 ++++++++-----
+ libopkg/opkg_install.c | 3 +++
+ libopkg/user.c | 10 +++++++---
+ 3 files changed, 18 insertions(+), 8 deletions(-)
+
+--- trunk.orig/libopkg/libopkg.c
++++ trunk/libopkg/libopkg.c
+@@ -71,11 +71,14 @@ int default_opkg_status_callback(char *n
+ char* default_opkg_response_callback(char *question)
+ {
+ char *response = NULL;
+- printf("%s",question);
+- fflush(stdout);
+- do {
+- response = (char *)file_read_line_alloc(stdin);
+- } while (response == NULL);
++ if (isatty(fileno(stdin)))
++ {
++ printf("%s",question);
++ fflush(stdout);
++ do {
++ response = (char *)file_read_line_alloc(stdin);
++ } while (response == NULL);
++ }
+ return response;
+ }
+
+--- trunk.orig/libopkg/user.c
++++ trunk/libopkg/user.c
+@@ -44,9 +44,13 @@ char *get_user_response(const char *form
+ len = vsnprintf(question,question_len,format,ap);
+ va_end(ap);
+ } while (len > question_len);
+- response = strdup(opkg_cb_response(question));
+- str_chomp(response);
+- str_tolower(response);
++
++ response = opkg_cb_response(question);
++ if (response)
++ {
++ str_chomp(response);
++ str_tolower(response);
++ }
+
+ return response;
+ }
+--- trunk.orig/libopkg/opkg_install.c
++++ trunk/libopkg/opkg_install.c
+@@ -1613,6 +1613,9 @@ static int user_prefers_old_conffile(con
+ " D : show the differences between the versions (if diff is installed)\n"
+ " The default action is to keep your current version.\n"
+ " *** %s (Y/I/N/O/D) [default=N] ? ", file_name, short_file_name);
++ if (!response)
++ return 1;
++
+ if (strcmp(response, "y") == 0
+ || strcmp(response, "i") == 0
+ || strcmp(response, "yes") == 0) {