[arch-commits] Commit in (5 files)
Pierre Neidhardt
ambrevar at archlinux.org
Wed Jan 13 23:47:20 UTC 2016
Date: Thursday, January 14, 2016 @ 00:47:19
Author: ambrevar
Revision: 156339
Init
Added:
trash-cli/
trash-cli/repos/
trash-cli/trunk/
trash-cli/trunk/53.patch
trash-cli/trunk/PKGBUILD
----------+
53.patch | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PKGBUILD | 35 +++++++++++++
2 files changed, 199 insertions(+)
Added: trash-cli/trunk/53.patch
===================================================================
--- trash-cli/trunk/53.patch (rev 0)
+++ trash-cli/trunk/53.patch 2016-01-13 23:47:19 UTC (rev 156339)
@@ -0,0 +1,164 @@
+From c39f4e92433fb27b42b36c2747cff63b98b11ccb Mon Sep 17 00:00:00 2001
+From: Antony Lee <anntzer.lee at 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 at 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)
Added: trash-cli/trunk/PKGBUILD
===================================================================
--- trash-cli/trunk/PKGBUILD (rev 0)
+++ trash-cli/trunk/PKGBUILD 2016-01-13 23:47:19 UTC (rev 156339)
@@ -0,0 +1,35 @@
+# Maintainer: Pierre Neidhardt <ambrevar at gmail.com>
+# Contributor: Eli Schwartz <eschwartz93 at gmail.com>
+# Contributor: Renato Garcia <fgarcia.renato at gmail.com>
+
+pkgname=trash-cli
+pkgver=0.12.9.14.r34.g7913a0b
+_commit=7913a0b8296b006c942e117dd1e94397110467b7
+pkgrel=3
+pkgdesc="Command line trashcan (recycle bin) interface"
+arch=("any")
+url="https://github.com/andreafrancia/$pkgname"
+license=("GPL")
+depends=("python2")
+makedepends=("python2-setuptools")
+source=("$url/archive/$_commit.tar.gz"
+ "53.patch")
+sha256sums=("6a2e3d522072c3fdb76ffa1f1067aeda5a551ecf6b3d71f724b82764ecd2d292"
+ "c0320a095b0d33be8809d61fde49670ca207dac23cadcb8c1ddea0fc15d50833")
+
+prepare(){
+ cd "$srcdir/$pkgname-$_commit"
+
+ # Fix segfaults, see: https://github.com/andreafrancia/trash-cli/issues/52
+ patch -p1 -i "$srcdir/53.patch"
+}
+
+build() {
+ cd "$srcdir/$pkgname-$_commit"
+ python2 setup.py build
+}
+
+package(){
+ cd "$srcdir/$pkgname-$_commit"
+ python2 setup.py install --root="$pkgdir" --optimize=1
+}
More information about the arch-commits
mailing list