From 722cc4d4afc989f1a37d7cae3b43cb37ed69c095 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Tue, 28 Feb 2006 23:19:54 +0000 Subject: [PATCH] =?UTF-8?q?=20copy=20ve=20copytree=20daha=20d=C3=BCzg?= =?UTF-8?q?=C3=BCn=20=C3=A7al=C4=B1=C5=9Fs=C4=B1n..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit linux sistemlerdeki cp komutu ile uyumlu hale getirdim davranışlarını, fakat yeterince test edemedim (sadece live555'in de içinde olduğu 3-4 paket ile test ettim).. bu yüzden depoda shelltools.copy kullanan paketlerin sahiplerinin kontrol edip doğru çalıştığını teyyid etmeleri çok iyi olurdu. değişiklikten etkilenme ihtimali olan paketler şunlar: tetex-texmf asciidoc firefox thunderbird amsn amsn-kde dragonegg kio-to-local aquafont dejavu-fonts xscreensaver ati-drivers nvidia nvidia-old cg fpc gambas tcl xerces-c libstdc++ glut tcltk nspr metis ufsparse nss atlas live555 libtool python e2fsprogs pam gdbm sudo --- pisi/actionsapi/shelltools.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pisi/actionsapi/shelltools.py b/pisi/actionsapi/shelltools.py index efc08ee4..7e1c4648 100644 --- a/pisi/actionsapi/shelltools.py +++ b/pisi/actionsapi/shelltools.py @@ -31,6 +31,7 @@ import pisi.actionsapi.get from pisi.actionsapi import error from pisi.util import run_batch +from pisi.util import join_path def can_access_file(sourceFile): '''test the existence of file''' @@ -124,11 +125,17 @@ def move(sourceFile, destinationFile): def copy(sourceFile, destinationFile): '''recursively copy a sourceFile or directory to destinationFile''' for file in glob.glob(sourceFile): - if isFile(file) or isLink(file): + if isFile(file) and not isLink(file): try: shutil.copy(file, destinationFile) except IOError: error(_('ActionsAPI [copy]: Permission denied: %s to %s') % (file, destinationFile)) + elif isLink(file): + if isDirectory(destinationFile): + os.symlink(os.readlink(file), join_path(destinationFile, os.path.basename(file))) + if isFile(destinationFile): + os.remove(destinationFile) + os.symlink(os.readlink(file), destinationFile) elif isDirectory(file): copytree(file, destinationFile) else: @@ -136,7 +143,10 @@ def copy(sourceFile, destinationFile): def copytree(source, destination, sym = False): '''recursively copy an entire directory tree rooted at source''' - if isDirectory(source) or isLink(source): + if isDirectory(source): + if os.path.exists(destination): + copytree(source, join_path(destination, os.path.basename(source))) + return try: shutil.copytree(source, destination, sym) except OSError, e: