コード例 #1
0
ファイル: check_archive.py プロジェクト: tanglu-org/tdak
def check_timestamps():
    """
    Check all files for timestamps in the future; common from hardware
    (e.g. alpha) which have far-future dates as their default dates.
    """

    global current_file

    q = DBConn().session().query(PoolFile).filter(PoolFile.filename.like('.deb$'))

    db_files.clear()
    count = 0

    for pf in q.all():
        filename = os.path.abspath(os.path.join(pf.location.path, pf.filename))
        if os.access(filename, os.R_OK):
            f = utils.open_file(filename)
            current_file = filename
            sys.stderr.write("Processing %s.\n" % (filename))
            apt_inst.debExtract(f, Ent, "control.tar.gz")
            f.seek(0)
            apt_inst.debExtract(f, Ent, "data.tar.gz")
            count += 1

    print "Checked %d files (out of %d)." % (count, len(db_files.keys()))
コード例 #2
0
def check_timestamps():
    """
    Check all files for timestamps in the future; common from hardware
    (e.g. alpha) which have far-future dates as their default dates.
    """

    global current_file

    q = DBConn().session().query(PoolFile).filter(
        PoolFile.filename.like('.deb$'))

    db_files.clear()
    count = 0

    for pf in q.all():
        filename = os.path.abspath(os.path.join(pf.location.path, pf.filename))
        if os.access(filename, os.R_OK):
            f = utils.open_file(filename)
            current_file = filename
            sys.stderr.write("Processing %s.\n" % (filename))
            apt_inst.debExtract(f, Ent, "control.tar.gz")
            f.seek(0)
            apt_inst.debExtract(f, Ent, "data.tar.gz")
            count += 1

    print "Checked %d files (out of %d)." % (count, len(db_files.keys()))
コード例 #3
0
def main():
    """Main function"""
    if len(sys.argv) < 2:
        print >> sys.stderr, "need filename argumnet"
        sys.exit(1)

    fobj = open(sys.argv[1])
    try:
        apt_inst.debExtract(fobj, callback, "data.tar.gz")
    finally:
        fobj.close()
コード例 #4
0
ファイル: debfile.py プロジェクト: 3oyka/python-apt
 def filelist(self):
     """ return the list of files in the deb """
     files = []
     def extract_cb(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor):
         #print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u"\
         #      % (What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor)
         files.append(Name)
     for member in self._supported_data_members:
         if arCheckMember(open(self.filename), member):
             try:
                 apt_inst.debExtract(open(self.filename), extract_cb, member)
                 break
             except SystemError, e:
                 return [_("List of files for '%s'could not be read" % self.filename)]
コード例 #5
0
    def filelist(self):
        """ return the list of files in the deb """
        files = []

        def extract_cb(What, Name, Link, Mode, UID, GID, Size, MTime, Major,
                       Minor):
            #print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u"\
            #      % (What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor)
            files.append(Name)

        for member in self._supported_data_members:
            if arCheckMember(open(self.filename), member):
                try:
                    apt_inst.debExtract(open(self.filename), extract_cb,
                                        member)
                    break
                except SystemError, e:
                    return [
                        _("List of files for '%s'could not be read" %
                          self.filename)
                    ]
コード例 #6
0
    def items(self):
        """ Return the list of items in the package.
        Each file is represented by an instance of  FileInfo """
        items = []

        def extract_cb(kind, name, target, mode, uid, gid, size, mtime, major, minor):
            if kind == "FILE":
                items.append(FileInfo(name, mode, uid, gid, size, mtime))
            elif kind == "DIR":
                items.append(DirectoryInfo(name, mode, uid, gid, size, mtime))
            elif kind == "SYMLINK":
                items.append(SymbolicLinkInfo(name, target, mode, uid, gid, size, mtime))
            elif kind == "HARDLINK":
                items.append(HardLinkInfo(name, target, mode, uid, gid, size, mtime))
            elif kind == "FIFO":
                items.append(FifoInfo(name, mode, uid, gid, size, mtime))
            else:
                print "unsupported kind: %s" % kind
        try:
            apt_inst.debExtract(open(self.filename), extract_cb, "data.tar.gz")
        except:
            apt_inst.debExtract(open(self.filename), extract_cb, "data.tar.bz2")
        return items
コード例 #7
0
ファイル: deb_inspect.py プロジェクト: xaadim/python-apt
def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor):
    """ callback for debExtract """

    print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u"\
          % (What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor)


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "need filename argumnet"
        sys.exit(1)
    file = sys.argv[1]

    print "Working on: %s" % file
    print "Displaying data.tar.gz:"
    apt_inst.debExtract(open(file), Callback, "data.tar.gz")

    print "Now extracting the control file:"
    control = apt_inst.debExtractControl(open(file))
    sections = apt_pkg.ParseSection(control)

    print "Maintainer is: "
    print sections["Maintainer"]

    print
    print "DependsOn: "
    depends = sections["Depends"]
    print apt_pkg.ParseDepends(depends)

    print "extracting archive"
    dir = "/tmp/deb"
コード例 #8
0
def main():
    member = "data.tar.lzma"
    if len(sys.argv) > 2:
        member = sys.argv[2]
    apt_inst.debExtract(open(sys.argv[1]), Callback, member)
コード例 #9
0
def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor):
    """ callback for debExtract """
    print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" \
          % (What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor)


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "need filename argumnet"
        sys.exit(1)
    file = sys.argv[1]

    print "Working on: %s" % file
    print "Displaying data.tar.gz:"
    apt_inst.debExtract(open(file), Callback, "data.tar.gz")

    print "Now extracting the control file:"
    control = apt_inst.debExtractControl(open(file))
    sections = apt_pkg.ParseSection(control)

    print "Maintainer is: "
    print sections["Maintainer"]

    print
    print "DependsOn: "
    depends = sections["Depends"]
    print apt_pkg.ParseDepends(depends)


    print "extracting archive"
コード例 #10
0
ファイル: test_debextract.py プロジェクト: xaadim/python-apt
#!/usr/bin/python

import apt_inst
import sys


def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor):
    print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % (
        What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor)


member = "data.tar.lzma"
if len(sys.argv) > 2:
    member = sys.argv[2]
apt_inst.debExtract(open(sys.argv[1]), Callback, member)
コード例 #11
0
ファイル: test_debextract.py プロジェクト: 3oyka/python-apt
#!/usr/bin/python

import apt_inst
import sys

def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor):
    print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % (
        What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor)

member = "data.tar.lzma" 
if len(sys.argv) > 2:
    member = sys.argv[2]
apt_inst.debExtract(open(sys.argv[1]), Callback, member)