]> git.ipfire.org Git - people/pmueller/ipfire-3.x.git/commitdiff
mc: Patch/Drop python 2 based helper scripts
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 11 Mar 2023 11:39:50 +0000 (11:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 13 Mar 2023 14:43:57 +0000 (14:43 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
mc/mc.nm
mc/patches/mc-python3.patch [new file with mode: 0644]

index 70f60246a39ac91264dac75cc3c992be7bb4e109..4830ff4d0424ac97e57d97d5466a1a9c2cec3a85 100644 (file)
--- a/mc/mc.nm
+++ b/mc/mc.nm
@@ -5,7 +5,7 @@
 
 name       = mc
 version    = 4.8.29
-release    = 1
+release    = 2
 
 groups     = Applications/System
 url        = https://midnight-commander.org
@@ -41,7 +41,11 @@ build
                --disable-rpath
 
        install_cmds
+               # Fix permissions
                chmod 1755 %{BUILDROOT}/usr/lib/mc/cons.saver
+
+               # Remove python2 based helper script for amazon S3.
+               rm -rvf %{BUILDROOT}/usr/lib/mc/extfs.d/s3+
        end
 end
 
diff --git a/mc/patches/mc-python3.patch b/mc/patches/mc-python3.patch
new file mode 100644 (file)
index 0000000..ce06610
--- /dev/null
@@ -0,0 +1,69 @@
+--- a/src/vfs/extfs/helpers/uc1541
++++ b/src/vfs/extfs/helpers/uc1541
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ """
+ UC1541 Virtual filesystem
+--- a/src/vfs/extfs/helpers/s3+.in     (original)
++++ b/src/vfs/extfs/helpers/s3+.in     (refactored)
+@@ -153,16 +153,16 @@
+       Propagates exception safely.
+       """
+       from threading import Thread
+-      import Queue
++      import queue
+       items = list(iterable)
+       nitems = len(items)
+       if nitems < 2:
+-              return map(fun, items)
++              return list(map(fun, items))
+       # Create and fill input queue
+-      input = Queue.Queue()
+-      output = Queue.Queue()
++      input = queue.Queue()
++      output = queue.Queue()
+       for i,item in enumerate(items):
+               input.put( (i,item) )
+@@ -181,7 +181,7 @@
+                                               output.put( (i,result) )
+                                       except:
+                                               output.put( (None,sys.exc_info()) )
+-                              except Queue.Empty:
++                              except queue.Empty:
+                                       return
+       # Start threads
+@@ -196,8 +196,8 @@
+               try:
+                       i,res = output.get()
+                       if i == None:
+-                              raise res[0],res[1],res[2]
+-              except Queue.Empty:
++                              raise res[0](res[1]).with_traceback(res[2])
++              except queue.Empty:
+                       break
+               ret.append(res)
+@@ -241,7 +241,7 @@
+               b = s3.get_bucket(name, validate=False)
+               b.get_location() # just to raise an exception on error
+               return b
+-      except boto.exception.S3ResponseError, e:
++      except boto.exception.S3ResponseError as e:
+               # Seems this is the only proper way to switch to the bucket's region.
+               # Requesting of the default region for "?location" does not work unfortunately.
+               m = re.search(r'<Region>(.*?)</Region>', e.body)
+@@ -340,7 +340,7 @@
+       expr = re.compile(r'^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d{3}Z$')
+       def convDate(awsdatetime):
+               m = expr.match(awsdatetime)
+-              ye,mo,da,ho,mi,se = map(int,m.groups())
++              ye,mo,da,ho,mi,se = list(map(int,m.groups()))
+               dt = datetime.datetime(ye,mo,da,ho,mi,se, tzinfo=pytz.utc)
+               return dt.astimezone(tz).strftime('%m-%d-%Y %H:%M')