当前位置: 首页>>代码示例>>Python>>正文


Python Package.read方法代码示例

本文整理汇总了Python中pisi.package.Package.read方法的典型用法代码示例。如果您正苦于以下问题:Python Package.read方法的具体用法?Python Package.read怎么用?Python Package.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pisi.package.Package的用法示例。


在下文中一共展示了Package.read方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: calc_build_no

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
    def calc_build_no(self, package_name):
        """Calculate build number"""

        # find previous build in ctx.config.options.output_dir
        found = []
        for root, dirs, files in os.walk(ctx.config.options.output_dir):
            for fn in files:
                fn = fn.decode('utf-8')
                if fn.startswith(package_name + '-') and \
                    fn.endswith(ctx.const.package_prefix):
                    old_package_fn = os.path.join(root, fn)
                    ctx.ui.info('(found old version %s)' % old_package_fn)
                    old_pkg = Package(old_package_fn, 'r')
                    old_pkg.read(os.path.join(ctx.config.tmp_dir(), 'oldpkg'))
                    old_build = old_pkg.metadata.package.build
                    found.append( (old_package_fn, old_build) )
        if not found:
            return 0
            ctx.ui.warning('(no previous build found, setting build no to 0.)')
        else:
            a = filter(lambda (x,y): y != None, found)
            if a:
                a.sort(lambda x,y : cmp(x[1],y[1]))
                old_package_fn = a[0][0]
                old_build = a[0][1]
            else:
                old_build = None

            # compare old files.xml with the new one..
            old_pkg = Package(old_package_fn, 'r')
            old_pkg.read(os.path.join(ctx.config.tmp_dir(), 'oldpkg'))

            # FIXME: TAKE INTO ACCOUNT MINOR CHANGES IN METADATA
            changed = False
            fnew = self.files.list
            fold = old_pkg.files.list
            fold.sort(lambda x,y : cmp(x.path,y.path))
            fnew.sort(lambda x,y : cmp(x.path,y.path))
            if len(fnew) != len(fold):
                changed = True
            else:
                for i in range(len(fold)):
                    fo = fold.pop(0)
                    fn = fnew.pop(0)
                    if fo.path != fn.path:
                        changed = True
                        break
                    else:
                        if fo.hash != fn.hash:
                            changed = True
                            break

            # set build number
            if old_build is None:
                ctx.ui.warning('(old package lacks a build no, setting build no to 0.)')
                return 0
            elif changed:
                return old_build + 1
            else:
                return old_build
开发者ID:Tayyib,项目名称:uludag,代码行数:62,代码来源:build.py

示例2: locate_old_package

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
 def locate_old_package(old_package_fn):
     if util.is_package_name(os.path.basename(old_package_fn), package_name):
         try:
             old_pkg = Package(old_package_fn, 'r')
             old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
             ctx.ui.info(_('(found old version %s)') % old_package_fn)
             if str(old_pkg.metadata.package.name) != package_name:
                 ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
                                         old_package_fn)
                 return
             old_build = old_pkg.metadata.package.build
             found.append( (old_package_fn, old_build) )
         except Error:
             ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:16,代码来源:build.py

示例3: locate_package_names

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
 def locate_package_names(files):
      for fn in files:
          fn = fn.decode('utf-8')
          if util.is_package_name(fn, package_name):
              old_package_fn = os.path.join(root, fn)
              ctx.ui.info('(found old version %s)' % old_package_fn)
              old_pkg = Package(old_package_fn, 'r')
              old_pkg.read(os.path.join(ctx.config.tmp_dir(), 'oldpkg'))
              if str(old_pkg.metadata.package.name) != package_name:
                  ctx.ui.warning('Skipping %s with wrong pkg name ' %
                                 old_package_fn)
                  continue
              old_build = old_pkg.metadata.package.build
              found.append( (old_package_fn, old_build) )
开发者ID:Tayyib,项目名称:uludag,代码行数:16,代码来源:build.py

示例4: Install

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
class Install(AtomicOperation):
    "Install class, provides install routines for pisi packages"

    def __init__(self, package_fname, ignore_dep = None):
        "initialize from a file name"
        super(Install, self).__init__(ignore_dep)
        self.package = Package(package_fname)
        self.package.read()
        self.metadata = self.package.metadata
        self.files = self.package.files
        self.pkginfo = self.metadata.package

    def install(self, ask_reinstall = True):
        "entry point"
        ctx.ui.status(_('Installing %s, version %s, release %s, build %s') %
                (self.pkginfo.name, self.pkginfo.version,
                 self.pkginfo.release, self.pkginfo.build))
        ctx.ui.notify(pisi.ui.installing, package = self.pkginfo, files = self.files)

        self.ask_reinstall = ask_reinstall
        self.check_requirements()
        self.check_relations()
        self.check_reinstall()
        self.extract_install()
        self.store_pisi_files()
        if ctx.comar:
            import pisi.comariface as comariface
            self.register_comar_scripts()
            ctx.ui.notify(pisi.ui.configuring, package = self.pkginfo, files = self.files)
            comariface.run_postinstall(self.pkginfo.name)
            ctx.ui.notify(pisi.ui.configured, package = self.pkginfo, files = self.files)

        txn = ctx.dbenv.txn_begin()
        try:
            self.update_databases(txn)
            txn.commit()
        except db.DBError, e:
            txn.abort()
            raise e

        self.update_environment()
        ctx.ui.status()
        if self.upgrade:
            event = pisi.ui.upgraded
        else:
            event = pisi.ui.installed
        ctx.ui.notify(event, package = self.pkginfo, files = self.files)
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:49,代码来源:atomicoperations.py

示例5: locate_package_names

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
 def locate_package_names(files):
     for fn in files:
         if util.is_package_name(fn, package_name):
             old_package_fn = util.join_path(root, fn)
             try:
                 old_pkg = Package(old_package_fn, 'r')
                 old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
                 ctx.ui.info(_('(found old version %s)') % old_package_fn)
                 if str(old_pkg.metadata.package.name) != package_name:
                     ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
                                    old_package_fn)
                     continue
                 old_build = old_pkg.metadata.package.build
                 found.append( (old_package_fn, old_build) )
             except:
                 ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
                 continue
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:19,代码来源:build.py

示例6: calc_build_no

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
    def calc_build_no(self, package_name):
        """Calculate build number"""

        def metadata_changed(old_metadata, new_metadata):
            for key in old_metadata.package.__dict__.keys():
                if old_metadata.package.__dict__[key] != new_metadata.package.__dict__[key]:
                    if key != "build":
                        return True

            return False
            
        # find previous build in packages dir
        found = []        
        def locate_old_package(old_package_fn):
            if util.is_package_name(os.path.basename(old_package_fn), package_name):
                try:
                    old_pkg = Package(old_package_fn, 'r')
                    old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
                    ctx.ui.info(_('(found old version %s)') % old_package_fn)
                    if str(old_pkg.metadata.package.name) != package_name:
                        ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
                                                old_package_fn)
                        return
                    old_build = old_pkg.metadata.package.build
                    found.append( (old_package_fn, old_build) )
                except Error:
                    ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)

        for root, dirs, files in os.walk(ctx.config.packages_dir()):
            for file in files:
                locate_old_package(join(root,file))

        outdir=ctx.get_option('output_dir')
        if not outdir:
            outdir = '.'
        for file in [join(outdir,entry) for entry in os.listdir(outdir)]:
            if os.path.isfile(file):
                locate_old_package(file)

        if not found:
            return (1, None)
            ctx.ui.warning(_('(no previous build found, setting build no to 1.)'))
        else:
            a = filter(lambda (x,y): y != None, found)
            ctx.ui.debug(str(a))
            if a:
                # sort in order of increasing build number
                a.sort(lambda x,y : cmp(x[1],y[1]))
                old_package_fn = a[-1][0]   # get the last one
                old_build = a[-1][1]

                # compare old files.xml with the new one..
                old_pkg = Package(old_package_fn, 'r')
                old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
    
                changed = False
                fnew = self.files.list
                fold = old_pkg.files.list
                fold.sort(lambda x,y : cmp(x.path,y.path))
                fnew.sort(lambda x,y : cmp(x.path,y.path))
                    
                if len(fnew) != len(fold):
                    changed = True
                else:
                    for i in range(len(fold)):
                        fo = fold.pop(0)
                        fn = fnew.pop(0)
                        if fo.path != fn.path:
                            changed = True
                            break
                        else:
                            if fo.hash != fn.hash:
                                changed = True
                                break
                
                if metadata_changed(old_pkg.metadata, self.metadata):
                    changed = True

                self.old_packages.append(os.path.basename(old_package_fn))
            else: # no old build had a build number
                old_build = None

            ctx.ui.debug('old build number: %s' % old_build)
                            
            # set build number
            if old_build is None:
                ctx.ui.warning(_('(old package lacks a build no, setting build no to 1.)'))
                return (1, None)
            elif changed:
                ctx.ui.info(_('There are changes, incrementing build no to %d') % (old_build + 1))
                return (old_build + 1, old_build)
            else:
                ctx.ui.info(_('There is no change from previous build %d') % old_build)
                return (old_build, old_build)
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:96,代码来源:build.py

示例7: __init__

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
class Installer:
    "Installer class, provides install routines for pisi packages"

    def __init__(self, package_fname):
        "initialize from a file name"
        self.package = Package(package_fname)
        self.package.read()
        self.metadata = self.package.metadata
        self.files = self.package.files
        self.pkginfo = self.metadata.package

    def install(self, ask_reinstall = True):
        "entry point"
        ctx.ui.info('Installing %s, version %s, release %s, build %s' %
                (self.pkginfo.name, self.pkginfo.version,
                 self.pkginfo.release, self.pkginfo.build))
        self.ask_reinstall = ask_reinstall
        self.check_requirements()
        self.check_relations()
        self.reinstall()
        self.extract_install()
        self.store_pisi_files()
        if ctx.comard:
            self.register_comar_scripts()
        self.update_databases()

    def check_requirements(self):
        """check system requirements"""
        #TODO: IS THERE ENOUGH SPACE?
        # what to do if / is split into /usr, /var, etc.
        pass

    def check_relations(self):
        # check if package is in database
        # If it is not, put it into 3rd party packagedb
        if not packagedb.has_package(self.pkginfo.name):
            db = packagedb.thirdparty_packagedb
            db.add_package(self.pkginfo)

        # check conflicts
        for pkg in self.metadata.package.conflicts:
            if ctx.installdb.is_installed(self.pkginfo):
                raise InstallError("Package conflicts " + pkg)

        # check dependencies
        if not ctx.config.get_option('ignore_dependency'):
            if not dependency.installable(self.pkginfo.name):
                ctx.ui.error('Dependencies for ' + self.pkginfo.name +
                             ' not satisfied')
                raise InstallError("Package not installable")

    def reinstall(self):
        "check reinstall, confirm action, and remove package if reinstall"

        pkg = self.pkginfo

        if ctx.installdb.is_installed(pkg.name): # is this a reinstallation?
            (iversion, irelease, ibuild) = ctx.installdb.get_version(pkg.name)

            # determine if same version
            same_ver = False
            ignore_build = ctx.config.options and ctx.config.options.ignore_build_no
            if (not ibuild) or (not pkg.build) or ignore_build:
                # we don't look at builds to compare two package versions
                if pkg.version == iversion and pkg.release == irelease:
                    same_ver = True
            else:
                if pkg.build == ibuild:
                    same_ver = True

            if same_ver:
                if self.ask_reinstall:
                    if not ctx.ui.confirm('Re-install same version package?'):
                        raise InstallError('Package re-install declined')
            else:
                upgrade = False
                # is this an upgrade?
                # determine and report the kind of upgrade: version, release, build
                if pkg.version > iversion:
                    ctx.ui.info('Upgrading to new upstream version')
                    upgrade = True
                elif pkg.release > irelease:
                    ctx.ui.info('Upgrading to new distribution release')
                    upgrade = True
                elif ((not ignore_build) and ibuild and pkg.build
                       and pkg.build > ibuild):
                    ctx.ui.info('Upgrading to new distribution build')
                    upgrade = True

                # is this a downgrade? confirm this action.
                if self.ask_reinstall and (not upgrade):
                    if pkg.version < iversion:
                        x = 'Downgrade to old upstream version?'
                    elif pkg.release < irelease:
                        x = 'Downgrade to old distribution release?'
                    else:
                        x = 'Downgrade to old distribution build?'
                    if not ctx.ui.confirm(x):
                        raise InstallError('Package downgrade declined')

#.........这里部分代码省略.........
开发者ID:Tayyib,项目名称:uludag,代码行数:103,代码来源:install.py

示例8: calc_build_no

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
    def calc_build_no(self, package_name):
        """Calculate build number"""

        # find previous build in output dir and packages dir
        found = []        
        def locate_package_names(files):
            for fn in files:
                fn = fn.decode('utf-8')
                if util.is_package_name(fn, package_name):
                    old_package_fn = util.join_path(root, fn)
                    try:
                        old_pkg = Package(old_package_fn, 'r')
                        old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
                        ctx.ui.info(_('(found old version %s)') % old_package_fn)
                        if str(old_pkg.metadata.package.name) != package_name:
                            ctx.ui.warning(_('Skipping %s with wrong pkg name ') %
                                           old_package_fn)
                            continue
                        old_build = old_pkg.metadata.package.build
                        found.append( (old_package_fn, old_build) )
                    except:
                        ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
                        continue

        for root, dirs, files in os.walk(ctx.config.options.output_dir):
            dirs = [] # don't recurse
            locate_package_names(files)
        for root, dirs, files in os.walk(ctx.config.packages_dir()):
            locate_package_names(files)

        if not found:
            return 1
            ctx.ui.warning(_('(no previous build found, setting build no to 1.)'))
        else:
            a = filter(lambda (x,y): y != None, found)
            ctx.ui.debug(str(a))
            if a:
                # sort in order of increasing build number
                a.sort(lambda x,y : cmp(x[1],y[1]))
                old_package_fn = a[-1][0]   # get the last one
                old_build = a[-1][1]

                # compare old files.xml with the new one..
                old_pkg = Package(old_package_fn, 'r')
                old_pkg.read(util.join_path(ctx.config.tmp_dir(), 'oldpkg'))
    
                # FIXME: TAKE INTO ACCOUNT MINOR CHANGES IN METADATA
                changed = False
                fnew = self.files.list
                fold = old_pkg.files.list
                fold.sort(lambda x,y : cmp(x.path,y.path))
                fnew.sort(lambda x,y : cmp(x.path,y.path))
                    
                if len(fnew) != len(fold):
                    changed = True
                else:
                    for i in range(len(fold)):
                        fo = fold.pop(0)
                        fn = fnew.pop(0)
                        if fo.path != fn.path:
                            changed = True
                            break
                        else:
                            #FIXME: workaround for .a issue, skip .a files
                            if fn.path.endswith('.a') and fn.type=='library':
                                continue
                            if fo.hash != fn.hash:
                                changed = True
                                break
            else: # no old build had a build number
                old_build = None

            ctx.ui.debug('old build number: %s' % old_build)
                            
            # set build number
            if old_build is None:
                ctx.ui.warning(_('(old package lacks a build no, setting build no to 1.)'))
                return 1
            elif changed:
                ctx.ui.info(_('There are changes, incrementing build no to %d') % (old_build + 1))
                return old_build + 1
            else:
                ctx.ui.info(_('There is no change from previous build %d') % old_build)
                return old_build
开发者ID:Tayyib,项目名称:uludag,代码行数:86,代码来源:build.py

示例9: Install

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
class Install(AtomicOperation):
    "Install class, provides install routines for pisi packages"

    @staticmethod
    def from_name(name):
        # download package and return an installer object
        # find package in repository
        repo = packagedb.which_repo(name)
        if repo:
            repo = ctx.repodb.get_repo(repo)
            pkg = packagedb.get_package(name)
    
            # FIXME: let pkg.packageURI be stored as URI type rather than string
            pkg_uri = URI(pkg.packageURI)
            if pkg_uri.is_absolute_path():
                pkg_path = str(pkg.packageURI)
            else:
                pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()),
                                        str(pkg_uri.path()))
    
            ctx.ui.debug(_("Package URI: %s") % pkg_path)
    
            return Install(pkg_path)
        else:
            raise Error(_("Package %s not found in any active repository.") % name)

    def __init__(self, package_fname, ignore_dep = None):
        "initialize from a file name"
        super(Install, self).__init__(ignore_dep)
        self.package = Package(package_fname)
        self.package.read()
        self.metadata = self.package.metadata
        self.files = self.package.files
        self.pkginfo = self.metadata.package

    def install(self, ask_reinstall = True):
        "entry point"
        ctx.ui.status(_('Installing %s, version %s, release %s, build %s') %
                (self.pkginfo.name, self.pkginfo.version,
                 self.pkginfo.release, self.pkginfo.build))
        ctx.ui.notify(pisi.ui.installing, package = self.pkginfo, files = self.files)

        self.ask_reinstall = ask_reinstall
        self.check_requirements()
        self.check_relations()
        self.check_reinstall()
        self.extract_install()
        self.store_pisi_files()

        self.config_later = False

        if self.metadata.package.providesComar:
            if ctx.comar:
                import pisi.comariface as comariface
                self.register_comar_scripts()
            else:
                self.config_later = True # configure-pending will register scripts later

        if 'System.Package' in [x.om for x in self.metadata.package.providesComar]:
            if ctx.comar:
                ctx.ui.notify(pisi.ui.configuring, package = self.pkginfo, files = self.files)
                comariface.run_postinstall(self.pkginfo.name)
                ctx.ui.notify(pisi.ui.configured, package = self.pkginfo, files = self.files)
            else:
                self.config_later = True

        txn = ctx.dbenv.txn_begin()
        try:
            self.update_databases(txn)
            txn.commit()
        except db.DBError, e:
            txn.abort()
            raise e

        self.update_environment()
        ctx.ui.status()
        if self.upgrade:
            event = pisi.ui.upgraded
        else:
            event = pisi.ui.installed
        ctx.ui.notify(event, package = self.pkginfo, files = self.files)
开发者ID:Tayyib,项目名称:uludag,代码行数:83,代码来源:atomicoperations.py

示例10: Install

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
class Install(AtomicOperation):
    "Install class, provides install routines for pisi packages"

    def __init__(self, package_fname, ignore_dep = None):
        "initialize from a file name"
        super(Install, self).__init__(ignore_dep)
        self.package = Package(package_fname)
        self.package.read()
        self.metadata = self.package.metadata
        self.files = self.package.files
        self.pkginfo = self.metadata.package

    def install(self, ask_reinstall = True):
        "entry point"
        ctx.ui.status(_('Installing %s, version %s, release %s, build %s') %
                (self.pkginfo.name, self.pkginfo.version,
                 self.pkginfo.release, self.pkginfo.build))
        ctx.ui.notify(pisi.ui.installing, package = self.pkginfo, files = self.files)
        self.ask_reinstall = ask_reinstall
        self.check_requirements()
        self.check_relations()
        self.check_reinstall()
        self.extract_install()
        self.store_pisi_files()
        if ctx.comar:
            import pisi.comariface as comariface
            self.register_comar_scripts()
            comariface.run_postinstall(self.pkginfo.name)
        self.update_databases()
        self.update_environment()
        ctx.ui.status()
        if self.upgrade:
            event = pisi.ui.upgraded
        else:
            event = pisi.ui.installed
        ctx.ui.notify(event, package = self.pkginfo, files = self.files)

    def check_requirements(self):
        """check system requirements"""
        #TODO: IS THERE ENOUGH SPACE?
        # what to do if / is split into /usr, /var, etc.
        pass

    def check_relations(self):
        # check conflicts
        for pkg in self.metadata.package.conflicts:
            if ctx.installdb.is_installed(self.pkginfo):
                raise Error(_("Package conflicts %s") % pkg)

        # check dependencies
        if not ctx.config.get_option('ignore_dependency'):
            if not self.pkginfo.installable():
                ctx.ui.error(_('Dependencies for %s not satisfied') %
                             self.pkginfo.name)
                raise Error(_("Package not installable"))

        # check if package is in database
        # If it is not, put it into 3rd party packagedb
        if not packagedb.has_package(self.pkginfo.name):
            db = packagedb.thirdparty_packagedb
            db.add_package(self.pkginfo)

    def check_reinstall(self):
        "check reinstall, confirm action, and schedule reinstall"

        pkg = self.pkginfo

        self.reinstall = False
        self.upgrade = False
        if ctx.installdb.is_installed(pkg.name): # is this a reinstallation?
            (iversion, irelease, ibuild) = ctx.installdb.get_version(pkg.name)

            # determine if same version
            same_ver = False
            ignore_build = ctx.config.options and ctx.config.options.ignore_build_no
            if (not ibuild) or (not pkg.build) or ignore_build:
                # we don't look at builds to compare two package versions
                if pkg.version == iversion and pkg.release == irelease:
                    same_ver = True
            else:
                if pkg.build == ibuild:
                    same_ver = True

            if same_ver:
                if self.ask_reinstall:
                    if not ctx.ui.confirm(_('Re-install same version package?')):
                        raise Error(_('Package re-install declined'))
            else:
                upgrade = False
                # is this an upgrade?
                # determine and report the kind of upgrade: version, release, build
                if pkg.version > iversion:
                    ctx.ui.info(_('Upgrading to new upstream version'))
                    upgrade = True
                elif pkg.release > irelease:
                    ctx.ui.info(_('Upgrading to new distribution release'))
                    upgrade = True
                elif ((not ignore_build) and ibuild and pkg.build
                       and pkg.build > ibuild):
                    ctx.ui.info(_('Upgrading to new distribution build'))
#.........这里部分代码省略.........
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:103,代码来源:atomicoperations.py

示例11: len

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
import pisi.specfile as specfile
import pisi.context as ctx
import pisi.util as util
from pisi.package import Package

locale.setlocale(locale.LC_ALL, '')
options = pisi.config.Options()
if len(sys.argv) > 2:
    options.destdir=sys.argv[2]
else:
    options.destdir = '/'
pisi.api.init(database=True, comar=False, options=options)

filename = sys.argv[1]
package = Package(filename)
package.read()
util.clean_dir('/tmp/install')
package.extract_dir_flat('install', '/tmp/install')
deps = set()
needed = set()
for file in package.files.list:
    #print file.path, file.type
    if file.type == 'executable':
        (ret, lines) = util.run_batch('objdump -p %s' % util.join_path('/tmp/install', file.path))
        for x in lines:
            if x.startswith('  NEEDED'):
                needed.add(x[8:].strip())

#print 'needed guys', needed

for lib in needed:
开发者ID:Tayyib,项目名称:uludag,代码行数:33,代码来源:find-lib-deps.py

示例12: calc_build_no

# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import read [as 别名]
    def calc_build_no(self, package_name):
        """Calculate build number"""

        def found_package(fn):
            "did we find the filename we were looking for?"
            if fn.startswith(package_name + '-'):
                if fn.endswith(ctx.const.package_prefix):
                    # get version string, skip separator '-'
                    verstr = fn[len(package_name) + 1:
                                len(fn)-len(ctx.const.package_prefix)]
                    import string
                    for x in verstr.split('-'):
                        # weak rule: version components start with a digit
                        if x is '' or (not x[0] in string.digits):
                            return False
                    return True
            return False

        # find previous build in ctx.config.options.output_dir
        found = []
#        for root, dirs, files in os.walk(ctx.config.options.output_dir):
#             for fn in files:
#                 fn = fn.decode('utf-8')
#                 if found_package(fn):
#                     old_package_fn = os.path.join(root, fn)
#                     ctx.ui.info('(found old version %s)' % old_package_fn)
#                     old_pkg = Package(old_package_fn, 'r')
#                     old_pkg.read(os.path.join(ctx.config.tmp_dir(), 'oldpkg'))
#                     if str(old_pkg.metadata.package.name) != package_name:
#                         ctx.ui.warning('Skipping %s with wrong pkg name ' %
#                                        old_package_fn)
#                         continue
#                     old_build = old_pkg.metadata.package.build
#                     found.append( (old_package_fn, old_build) )
#
# FIXME: Following dirty lines of code just search in the output_dir and
# packages dir for previous packages. But we should find a neat way
# for this...
        files = []
        for f in os.listdir(ctx.config.options.output_dir):
            fp = os.path.join(ctx.config.options.output_dir, f)
            if os.path.isfile(fp):
                files.append(fp)

        packages_dir = ctx.config.packages_dir()
        # FIXME: packages_dir() should be there!
        if not os.path.exists(packages_dir):
            os.makedirs(packages_dir)
        for f in os.listdir(packages_dir):
            fp = os.path.join(packages_dir, f)
            if os.path.isfile(fp):
                files.append(fp)

        for fn in files:
            fn = fn.decode('utf-8')
            if found_package(os.path.basename(fn)):
                old_package_fn = fn
                ctx.ui.info('(found old version %s)' % old_package_fn)
                old_pkg = Package(old_package_fn, 'r')
                old_pkg.read(os.path.join(ctx.config.tmp_dir(), 'oldpkg'))
                if str(old_pkg.metadata.package.name) != package_name:
                    ctx.ui.warning('Skipping %s with wrong pkg name ' %
                                   old_package_fn)
                    continue
                old_build = old_pkg.metadata.package.build
                found.append( (old_package_fn, old_build) )
        if not found:
            return 0
            ctx.ui.warning('(no previous build found, setting build no to 0.)')
        else:
            a = filter(lambda (x,y): y != None, found)
            ctx.ui.debug(str(a))
            if a:
                a.sort(lambda x,y : cmp(x[1],y[1]))
                old_package_fn = a[0][0]
                old_build = a[0][1]
            else:
                old_build = None

            # compare old files.xml with the new one..
            old_pkg = Package(old_package_fn, 'r')
            old_pkg.read(os.path.join(ctx.config.tmp_dir(), 'oldpkg'))

            # FIXME: TAKE INTO ACCOUNT MINOR CHANGES IN METADATA
            changed = False
            fnew = self.files.list
            fold = old_pkg.files.list
            fold.sort(lambda x,y : cmp(x.path,y.path))
            fnew.sort(lambda x,y : cmp(x.path,y.path))
            if len(fnew) != len(fold):
                changed = True
            else:
                for i in range(len(fold)):
                    fo = fold.pop(0)
                    fn = fnew.pop(0)
                    if fo.path != fn.path:
                        changed = True
                        break
                    else:
                        if fo.hash != fn.hash:
#.........这里部分代码省略.........
开发者ID:Tayyib,项目名称:uludag,代码行数:103,代码来源:build.py


注:本文中的pisi.package.Package.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。