def doFile(self, path): basename = os.path.basename(path) target = util.joinPaths(self.macros['initdir'], basename) if os.path.exists(self.macros['destdir'] + os.sep + target): raise policy.PolicyError( "Conflicting initscripts %s and %s installed" %( path, target)) util.mkdirChain(self.macros['destdir'] + os.sep + self.macros['initdir']) util.rename(self.macros['destdir'] + path, self.macros['destdir'] + target) try: self.recipe.recordMove(self.macros['destdir'] + path, self.macros['destdir'] + target) except AttributeError: pass
def do(self): e = '%(destdir)s/%(sysconfdir)s/X11/app-defaults' % self.macros if not os.path.isdir(e): return x = '%(destdir)s/%(x11prefix)s/lib/X11/app-defaults' % self.macros self.warn('app-default files misplaced in' ' %(sysconfdir)s/X11/app-defaults' % self.macros) if os.path.islink(x): util.remove(x) util.mkdirChain(x) for file in os.listdir(e): util.rename(util.joinPaths(e, file), util.joinPaths(x, file)) try: self.recipe.recordMove(util.joinPaths(e, file), util.joinPaths(x, file)) except AttributeError: pass
def doFile(self, filename): if hasattr(self.recipe, '_getCapsulePathsForFile'): if self.recipe._getCapsulePathsForFile(filename): return libdir = self.recipe.macros.libdir destdir = self.recipe.macros.destdir basename = os.path.basename(filename) if not filename.startswith(libdir): dest = util.joinPaths(destdir, libdir, 'pkgconfig', basename) if util.exists(dest): self.error('%s and %s/%s/%s both exist', filename, libdir, 'pkgconfig', basename) return util.mkdirChain(os.path.dirname(dest)) util.rename(destdir+filename, dest) try: self.recipe.recordMove(destdir+filename, dest) except AttributeError: pass
def doFile(self, filename): if hasattr(self.recipe, '_getCapsulePathsForFile'): if self.recipe._getCapsulePathsForFile(filename): return libdir = self.recipe.macros.libdir destdir = self.recipe.macros.destdir basename = os.path.basename(filename) if not filename.startswith(libdir): dest = util.joinPaths(destdir, libdir, 'pkgconfig', basename) if util.exists(dest): self.error('%s and %s/%s/%s both exist', filename, libdir, 'pkgconfig', basename) return util.mkdirChain(os.path.dirname(dest)) util.rename(destdir + filename, dest) try: self.recipe.recordMove(destdir + filename, dest) except AttributeError: pass
def doFile(self, path): if hasattr(self.recipe, '_getCapsulePathsForFile'): if self.recipe._getCapsulePathsForFile(path): return destdir = self.macros.destdir fullpath = util.joinPaths(destdir, path) mode = os.lstat(fullpath)[stat.ST_MODE] m = self.recipe.magic[path] if stat.S_ISREG(mode) and ( not m or (m.name != "ELF" and m.name != "ar")): self.warn("non-object file with library name %s", path) return basename = os.path.basename(path) currentsubtree = self.currentsubtree % self.macros targetdir = self.dirmap[currentsubtree] # we want to append whatever path came after the currentsubtree - # e.g. if the original path is /usr/lib/subdir/libfoo.a, # we still need to add the /subdir/ targetdir += os.path.dirname(path[len(currentsubtree):]) target = util.joinPaths(targetdir, basename) fulltarget = util.joinPaths(destdir, target) if os.path.exists(fulltarget): tmode = os.lstat(fulltarget)[stat.ST_MODE] tm = self.recipe.magic[target] if (not stat.S_ISREG(mode) or not stat.S_ISREG(tmode)): # one or both might be symlinks, in which case we do # not want to touch this return if ('abi' in m.contents and 'abi' in tm.contents and m.contents['abi'] != tm.contents['abi']): # path and target both exist and are of different abis. # This means that this is actually a multilib package # that properly contains both lib and lib64 items, # and we shouldn't try to fix them. return raise policy.PolicyError( "Conflicting library files %s and %s installed" %( path, target)) self.warn('file %s found in wrong directory, attempting to fix...', path) util.mkdirChain(destdir + targetdir) if stat.S_ISREG(mode): util.rename(destdir + path, fulltarget) try: self.recipe.recordMove(destdir + path, fulltarget) except AttributeError: pass else: # we should have a symlink that may need the contents changed contents = os.readlink(fullpath) if contents.find('/') == -1: # simply rename util.rename(destdir + path, destdir + target) try: self.recipe.recordMove(destdir + path, fulltarget) except AttributeError: pass else: # need to change the contents of the symlink to point to # the new location of the real file contentdir = os.path.dirname(contents) contenttarget = os.path.basename(contents) olddir = os.path.dirname(path) if contentdir.startswith('/'): # absolute path if contentdir == olddir: # no need for a path at all, change to local relative os.symlink(contenttarget, destdir + target) os.remove(fullpath) return if not contentdir.startswith('.'): raise policy.PolicyError( 'Multilib: cannot fix relative path %s in %s -> %s\n' 'Library files should be in %s' %(contentdir, path, contents, targetdir)) # now deal with .. # first, check for relative path that resolves to same dir i = contentdir.find(olddir) if i != -1: dotlist = contentdir[:i].split('/') dirlist = contentdir[i+1:].split('/') if len(dotlist) == len(dirlist): # no need for a path at all, change to local relative os.symlink(contenttarget, destdir + target) os.remove(fullpath) return raise policy.PolicyError( 'Multilib: cannot fix relative path %s in %s -> %s\n' 'Library files should be in %s' %(contentdir, path, contents, targetdir))
def doFile(self, path): if hasattr(self.recipe, '_getCapsulePathsForFile'): if self.recipe._getCapsulePathsForFile(path): return destdir = self.macros.destdir fullpath = util.joinPaths(destdir, path) mode = os.lstat(fullpath)[stat.ST_MODE] m = self.recipe.magic[path] if stat.S_ISREG(mode) and (not m or (m.name != "ELF" and m.name != "ar")): self.warn("non-object file with library name %s", path) return basename = os.path.basename(path) currentsubtree = self.currentsubtree % self.macros targetdir = self.dirmap[currentsubtree] # we want to append whatever path came after the currentsubtree - # e.g. if the original path is /usr/lib/subdir/libfoo.a, # we still need to add the /subdir/ targetdir += os.path.dirname(path[len(currentsubtree):]) target = util.joinPaths(targetdir, basename) fulltarget = util.joinPaths(destdir, target) if os.path.exists(fulltarget): tmode = os.lstat(fulltarget)[stat.ST_MODE] tm = self.recipe.magic[target] if (not stat.S_ISREG(mode) or not stat.S_ISREG(tmode)): # one or both might be symlinks, in which case we do # not want to touch this return if ('abi' in m.contents and 'abi' in tm.contents and m.contents['abi'] != tm.contents['abi']): # path and target both exist and are of different abis. # This means that this is actually a multilib package # that properly contains both lib and lib64 items, # and we shouldn't try to fix them. return raise policy.PolicyError( "Conflicting library files %s and %s installed" % (path, target)) self.warn('file %s found in wrong directory, attempting to fix...', path) util.mkdirChain(destdir + targetdir) if stat.S_ISREG(mode): util.rename(destdir + path, fulltarget) try: self.recipe.recordMove(destdir + path, fulltarget) except AttributeError: pass else: # we should have a symlink that may need the contents changed contents = os.readlink(fullpath) if contents.find('/') == -1: # simply rename util.rename(destdir + path, destdir + target) try: self.recipe.recordMove(destdir + path, fulltarget) except AttributeError: pass else: # need to change the contents of the symlink to point to # the new location of the real file contentdir = os.path.dirname(contents) contenttarget = os.path.basename(contents) olddir = os.path.dirname(path) if contentdir.startswith('/'): # absolute path if contentdir == olddir: # no need for a path at all, change to local relative os.symlink(contenttarget, destdir + target) os.remove(fullpath) return if not contentdir.startswith('.'): raise policy.PolicyError( 'Multilib: cannot fix relative path %s in %s -> %s\n' 'Library files should be in %s' % (contentdir, path, contents, targetdir)) # now deal with .. # first, check for relative path that resolves to same dir i = contentdir.find(olddir) if i != -1: dotlist = contentdir[:i].split('/') dirlist = contentdir[i + 1:].split('/') if len(dotlist) == len(dirlist): # no need for a path at all, change to local relative os.symlink(contenttarget, destdir + target) os.remove(fullpath) return raise policy.PolicyError( 'Multilib: cannot fix relative path %s in %s -> %s\n' 'Library files should be in %s' % (contentdir, path, contents, targetdir))