diff --git a/pisi/actionsapi/pisitools.py b/pisi/actionsapi/pisitools.py index 4e70f3e2..b4e632b5 100644 --- a/pisi/actionsapi/pisitools.py +++ b/pisi/actionsapi/pisitools.py @@ -203,16 +203,16 @@ def dosym(sourceFile, destinationFile): except OSError: error(_('ActionsAPI [dosym]: File exists: %s') % (sourceFile)) -def insinto(destinationDirectory, sourceFile, destinationFile = ''): +def insinto(destinationDirectory, sourceFile, destinationFile = '', sym = True): '''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions''' makedirs(join_path(get.installDIR(), destinationDirectory)) if not destinationFile: for filePath in glob.glob(sourceFile): if can_access_file(filePath): - copy(filePath, join_path(get.installDIR(), join_path(destinationDirectory, os.path.basename(filePath)))) + copy(filePath, join_path(get.installDIR(), join_path(destinationDirectory, os.path.basename(filePath))), sym) else: - copy(sourceFile, join_path(get.installDIR(), join_path(destinationDirectory, destinationFile))) + copy(sourceFile, join_path(get.installDIR(), join_path(destinationDirectory, destinationFile)), sym) def newdoc(sourceFile, destinationFile): '''inserts a sourceFile into /usr/share/doc/PACKAGE/ directory as a destinationFile''' diff --git a/pisi/actionsapi/shelltools.py b/pisi/actionsapi/shelltools.py index 45e42ba3..7411c0da 100644 --- a/pisi/actionsapi/shelltools.py +++ b/pisi/actionsapi/shelltools.py @@ -122,7 +122,7 @@ def move(source, destination): else: error(_('ActionsAPI [move]: File %s doesn\'t exists.') % (filePath)) -def copy(source, destination): +def copy(source, destination, sym = True): '''recursively copy a "source" file or directory to "destination"''' for filePath in glob.glob(source): if isFile(filePath) and not isLink(filePath): @@ -130,15 +130,17 @@ def copy(source, destination): shutil.copy(filePath, destination) except IOError: error(_('ActionsAPI [copy]: Permission denied: %s to %s') % (filePath, destination)) - elif isLink(filePath): + elif isLink(filePath) and sym: if isDirectory(destination): os.symlink(os.readlink(filePath), join_path(destination, os.path.basename(filePath))) else: if isFile(destination): os.remove(destination) os.symlink(os.readlink(filePath), destination) + elif isLink(filePath) and not sym: + shutil.copy(os.readlink(filePath), destination) elif isDirectory(filePath): - copytree(filePath, destination) + copytree(filePath, destination, sym) else: error(_('ActionsAPI [copy]: File %s does not exist.') % filePath)