summaryrefslogtreecommitdiffstats
path: root/patches/opkg-utils-r4747/0025-opkg.py-get_file_list_dir-fix-empty-output-from-find.patch
blob: 390e255994e5be96de477637039d0e62bc724fd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Martin Jansa <Martin.Jansa@gmail.com>
Date: Thu, 5 Apr 2012 13:03:17 +0200
Subject: [PATCH] opkg.py: get_file_list_dir: fix empty output from find if
 package disappers

* if .ipk disappers before parsing Packages.old then it's fine and it's not used at all
* but if it disappers between parsing Packages.old and generating Packages.filelist then
  it would fail to split() empty output

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 opkg.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/opkg.py b/opkg.py
index 707a882..84a8eb1 100644
--- a/opkg.py
+++ b/opkg.py
@@ -330,9 +330,10 @@ class Package:
             try:
                 cmd = "find %s -name %s | head -n 1" % (directory, self.filename)
                 rc = subprocess.check_output(cmd, shell=True)
-                newfn = str(rc).split()[0]
-#                sys.stderr.write("Package '%s' with empty fn and filename is '%s' was found in '%s', updating fn\n" % (self.package, self.filename, newfn))
-                self.fn = newfn
+                if rc != "":
+                    newfn = str(rc).split()[0]
+#                    sys.stderr.write("Package '%s' with empty fn and filename is '%s' was found in '%s', updating fn\n" % (self.package, self.filename, newfn))
+                    self.fn = newfn
             except OSError as e:
                 sys.stderr.write("Cannot find current fn for package '%s' filename '%s' in dir '%s'\n(%s)\n" % (self.package, self.filename, directory, e))
             except IOError as e:
@@ -342,7 +343,7 @@ class Package:
 
     def get_file_list(self):
         if not self.fn:
-            sys.stderr.write("Package '%s' has empty fn returning empty filelist\n" % (self.package))
+            sys.stderr.write("Package '%s' has empty fn, returning empty filelist\n" % (self.package))
             return []
         f = open(self.fn, "rb")
         ar = arfile.ArFile(f, self.fn)