summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn ShaggyTwoDope Jenkins2015-08-19 20:24:51 -0700
committerJohn ShaggyTwoDope Jenkins2015-08-19 20:24:51 -0700
commit1cd15ed7a8a41f530a3d483e3d492c61382b2f0c (patch)
treef78438019d4ed7dd529e39e1e560b615f1b5cb15
parent2323b66e1dbd513e8452720158103141b608d397 (diff)
downloadaur-1cd15ed7a8a41f530a3d483e3d492c61382b2f0c.tar.gz
pull req 53 patch
-rw-r--r--53.patch164
-rw-r--r--PKGBUILD9
2 files changed, 170 insertions, 3 deletions
diff --git a/53.patch b/53.patch
new file mode 100644
index 000000000000..1fc5ae434df7
--- /dev/null
+++ b/53.patch
@@ -0,0 +1,164 @@
+From c39f4e92433fb27b42b36c2747cff63b98b11ccb Mon Sep 17 00:00:00 2001
+From: Antony Lee <anntzer.lee@gmail.com>
+Date: Tue, 16 Jun 2015 19:45:51 -0700
+Subject: [PATCH 1/2] Rely on Python to open/close files.
+
+Fixes #52.
+---
+ trashcli/list_mount_points.py | 31 ++++++++++++++-----------------
+ 1 file changed, 14 insertions(+), 17 deletions(-)
+
+diff --git a/trashcli/list_mount_points.py b/trashcli/list_mount_points.py
+index 7f481f3..a26aef5 100644
+--- a/trashcli/list_mount_points.py
++++ b/trashcli/list_mount_points.py
+@@ -27,8 +27,8 @@ def chomp(string):
+ yield line.split(None, 5)[-1]
+
+ def _mounted_filesystems_from_getmnt() :
+- from ctypes import Structure, c_char_p, c_int, c_void_p, cdll, POINTER
+- from ctypes.util import find_library
++ from ctypes import (
++ c_char_p, c_int, c_void_p, cdll, POINTER, pythonapi, Structure, util)
+ import sys
+ class Filesystem:
+ def __init__(self, mount_dir, type, name) :
+@@ -49,26 +49,23 @@ class mntent_struct(Structure):
+ if sys.platform == "cygwin":
+ libc_name = "cygwin1.dll"
+ else:
+- libc_name = find_library("c")
+-
+- if libc_name == None :
+- libc_name="/lib/libc.so.6" # fix for my Gentoo 4.0
+-
++ libc_name = util.find_library("c") or "/lib/libc.so.6" # fix for my Gentoo 4.0
+ libc = cdll.LoadLibrary(libc_name)
+ libc.getmntent.restype = POINTER(mntent_struct)
+- libc.fopen.restype = c_void_p
++ PyFile_AsFile = pythonapi.PyFile_AsFile
++ PyFile_AsFile.argtypes = [pythonapi.py_object]
+
+- f = libc.fopen("/proc/mounts", "r")
+- if f==None:
+- f = libc.fopen("/etc/mtab", "r")
+- if f == None:
++ try:
++ f = open("/proc/mounts")
++ except IOError:
++ try:
++ f = open("/etc/mtab")
++ except IOError:
+ raise IOError("Unable to open /proc/mounts nor /etc/mtab")
+
+- while True:
+- entry = libc.getmntent(f)
+- if bool(entry) == False:
+- libc.fclose(f)
+- break
++ for entry in iter(lambda: libc.getmntent(PyFile_AsFile(f)), None):
+ yield Filesystem(entry.contents.mnt_dir,
+ entry.contents.mnt_type,
+ entry.contents.mnt_fsname)
++
++ f.close()
+
+From 8ab3c23f70eb2f373df7c588317b21211ea1b185 Mon Sep 17 00:00:00 2001
+From: Antony Lee <anntzer.lee@gmail.com>
+Date: Wed, 24 Jun 2015 11:14:11 -0700
+Subject: [PATCH 2/2] Another fix that does not depend on pythonapi.
+
+---
+ trashcli/list_mount_points.py | 47 +++++++++++++++++++++++--------------------
+ 1 file changed, 25 insertions(+), 22 deletions(-)
+
+diff --git a/trashcli/list_mount_points.py b/trashcli/list_mount_points.py
+index a26aef5..0d782bd 100644
+--- a/trashcli/list_mount_points.py
++++ b/trashcli/list_mount_points.py
+@@ -1,4 +1,11 @@
+ # Copyright (C) 2009-2011 Andrea Francia Trivolzio(PV) Italy
++from collections import namedtuple
++from ctypes import Structure, c_char_p, c_int, c_void_p, cdll, POINTER
++from ctypes.util import find_library
++from itertools import imap, repeat, takewhile
++import subprocess
++import sys
++
+
+ def mount_points():
+ try:
+@@ -6,15 +13,17 @@ def mount_points():
+ except AttributeError:
+ return mount_points_from_df()
+
++
+ def mount_points_from_getmnt():
+ for elem in _mounted_filesystems_from_getmnt():
+ yield elem.mount_dir
+
++
+ def mount_points_from_df():
+- import subprocess
+ df_output = subprocess.Popen(["df", "-P"], stdout=subprocess.PIPE).stdout
+ return list(_mount_points_from_df_output(df_output))
+
++
+ def _mount_points_from_df_output(df_output):
+ def skip_header():
+ df_output.readline()
+@@ -26,15 +35,11 @@ def chomp(string):
+ line = chomp(line)
+ yield line.split(None, 5)[-1]
+
++
+ def _mounted_filesystems_from_getmnt() :
+- from ctypes import (
+- c_char_p, c_int, c_void_p, cdll, POINTER, pythonapi, Structure, util)
+- import sys
+- class Filesystem:
+- def __init__(self, mount_dir, type, name) :
+- self.mount_dir = mount_dir
+- self.type = type
+- self.name = name
++
++ Filesystem = namedtuple("Filesystem", "mount_dir type name")
++
+ class mntent_struct(Structure):
+ _fields_ = [("mnt_fsname", c_char_p), # Device or server for
+ # filesystem.
+@@ -49,23 +54,21 @@ class mntent_struct(Structure):
+ if sys.platform == "cygwin":
+ libc_name = "cygwin1.dll"
+ else:
+- libc_name = util.find_library("c") or "/lib/libc.so.6" # fix for my Gentoo 4.0
++ libc_name = (find_library("c") or
++ find_library("/lib/libc.so.6")) # fix for Gentoo 4.0
++
+ libc = cdll.LoadLibrary(libc_name)
++ libc.fopen.restype = c_void_p
++ libc.getmntent.argtypes = libc.fclose.argtypes = [c_void_p]
+ libc.getmntent.restype = POINTER(mntent_struct)
+- PyFile_AsFile = pythonapi.PyFile_AsFile
+- PyFile_AsFile.argtypes = [pythonapi.py_object]
+
+- try:
+- f = open("/proc/mounts")
+- except IOError:
+- try:
+- f = open("/etc/mtab")
+- except IOError:
+- raise IOError("Unable to open /proc/mounts nor /etc/mtab")
+-
+- for entry in iter(lambda: libc.getmntent(PyFile_AsFile(f)), None):
++ f = libc.fopen("/proc/mounts", "r") or libc.fopen("/etc/mtab", "r")
++ if not f:
++ raise IOError("Unable to open /proc/mounts nor /etc/mtab")
++
++ for entry in takewhile(bool, imap(libc.getmntent, repeat(f))):
+ yield Filesystem(entry.contents.mnt_dir,
+ entry.contents.mnt_type,
+ entry.contents.mnt_fsname)
+
+- f.close()
++ libc.fclose(f)
diff --git a/PKGBUILD b/PKGBUILD
index 2899026b2394..673d29931e34 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,7 +4,7 @@
pkgname=trash-cli-git
_pkgname=trash-cli
-pkgver=413.7913a0b
+pkgver=415.e888f86
pkgrel=1
pkgdesc='Command line trashcan (recycle bin) interface'
arch=('any')
@@ -14,8 +14,10 @@ depends=('python2' 'python2-distribute')
makedepends=('git')
provides=('trash-cli')
conflicts=('trash-cli')
-source=("git+http://github.com/andreafrancia/${_pkgname}.git")
-md5sums=('SKIP')
+source=("git+http://github.com/andreafrancia/${_pkgname}.git"
+ 53.patch)
+md5sums=('SKIP'
+ '5f9f91c242c4c79de663e6481d226451')
pkgver() {
cd "${_pkgname}"
@@ -24,6 +26,7 @@ pkgver() {
build() {
cd "${_pkgname}"
+ patch -Np1 -i "$srcdir/53.patch"
python2 setup.py build
}