Kaydet (Commit) 9ed6a21c authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Changes

üst 0c3fe2a7
......@@ -118,12 +118,6 @@ def dodoc(*sourceFiles, **kw):
destDir = kw.get("destDir", get.srcNAME())
readable_insinto(join_path(get.installDIR(), get.docDIR(), destDir), *sourceFiles)
def doexe(sourceFile, destinationDirectory):
'''insert a executable file into destination directory'''
''' example call: inarytools.doexe("kde-3.4.sh", "/etc/X11/Sessions")'''
executable_insinto(join_path(get.installDIR(), destinationDirectory), sourceFile)
def dohtml(*sourceFiles, **kw):
'''inserts the files in the list of files into /usr/share/doc/PACKAGE/html'''
......@@ -158,33 +152,16 @@ def doinfo(*sourceFiles):
'''inserts the into files in the list of files into /usr/share/info'''
readable_insinto(join_path(get.installDIR(), get.infoDIR()), *sourceFiles)
def dolib(sourceFile, destinationDirectory = '/usr/lib'):
def dolib(sourceFile, destinationDirectory = '/usr/lib', mode=755):
'''insert the library into /usr/lib'''
'''example call: inarytools.dolib("libz.a")'''
'''example call: inarytools.dolib("libz.so")'''
if mode==755 and sourceFile.endswith('.a'):
mode=644
sourceFile = join_path(os.getcwd(), sourceFile)
destinationDirectory = join_path(get.installDIR(), destinationDirectory)
lib_insinto(sourceFile, destinationDirectory, 755)
def dolib_a(sourceFile, destinationDirectory = '/usr/lib'):
'''insert the static library into /usr/lib with permission 0644'''
'''example call: inarytools.dolib_a("staticlib/libvga.a")'''
sourceFile = join_path(os.getcwd(), sourceFile)
destinationDirectory = join_path(get.installDIR(), destinationDirectory)
lib_insinto(sourceFile, destinationDirectory, 644)
def dolib_so(sourceFile, destinationDirectory = '/usr/lib'):
'''insert the dynamic library into /usr/lib with permission 0755'''
'''example call: inarytools.dolib_so("pppd/plugins/minconn.so")'''
sourceFile = join_path(os.getcwd(), sourceFile)
destinationDirectory = join_path(get.installDIR(), destinationDirectory)
lib_insinto(sourceFile, destinationDirectory, 755)
lib_insinto(sourceFile, destinationDirectory, mode)
def doman(*sourceFiles):
'''inserts the man pages in the list of files into /usr/share/man/'''
......
......@@ -162,7 +162,7 @@ def install():
dumpVersion()
# Install kernel image
inarytools.insinto("/boot/", "arch/x86/boot/bzImage", "kernel-{}".formar(suffix))
inarytools.insinto("/boot/", "arch/x86/boot/bzImage", "kernel-{}".format(suffix))
# Install the modules
# mod-fw= avoids firmwares from installing
......@@ -215,6 +215,8 @@ def installHeaders(extraHeaders=None):
# Install additional headers
for headers in extras:
if not os.path.exist("{0}/{1}".format(destination, headers)):
shelltools.system("mkdir {0}/{1}".format(destination, headers))
shelltools.system("cp -a {0}/*.h {1}/{2}".format(headers, destination, headers))
# Install remaining headers
......
......@@ -15,10 +15,19 @@ import glob
import os
import threading
import gettext
__trans = gettext.translation("inary", fallback=True)
_ = __trans.gettext
import ctypes
from ctypes import c_char_p, c_int, c_size_t, c_void_p
import ctypes.util
class MagicException(Exception):
def __init__(self, message):
super(MagicException, self).__init__(message)
self.message = message
libmagic = None
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') or ctypes.util.find_library('cygmagic-1')
......@@ -26,8 +35,24 @@ if dll:
libmagic = ctypes.CDLL(dll)
if not libmagic or not libmagic._name:
raise ImportError('failed to find libmagic. Check your installation')
magic_dlls = {'darwin': ['/opt/local/lib/libmagic.dylib',
'/usr/local/lib/libmagic.dylib',
glob.glob('/usr/local/Cellar/libmagic/*/lib/libmagic.dylib')],
'win32': 'magic1.dll','cygmagic-1.dll',
'linux': ['libmagic.so.1'],
}
if sys.platform.startswith('linux'):
platform = 'linux'
else:
platform = sys.platform
for dll in magic_dlls.get(platform, []):
try:
libmagic = ctypes.CDLL(dll)
break
except OSError:
pass
#Magic Flags from libmagic.so
MAGIC_CONTINUE = 0x000020
......@@ -52,7 +77,7 @@ def errorcheck(result, func, args):
else:
return result
# Declarations
magic_file = libmagic.magic_file
magic_file.restype = c_char_p
magic_file.argtypes = [magic_t, c_char_p]
......@@ -122,11 +147,10 @@ class Magic:
if type(data) == str and str != bytes:
buf = data.encode('utf-8', errors='replace')
return magic_buffer(self.cookie, data, len(data))
except Exception as err:
except MagicException as err:
raise(_("Can Not load file or buffer {}").format(err))
def __del__(self):
if self.cookie and magic_close:
magic_close(self.cookie)
self.cookie = None
......@@ -10,7 +10,10 @@
# Please read the COPYING file.
#
import os
import inary
import inary.context as ctx
import inary.db
import inary.data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment