From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 82CC2138010 for ; Fri, 29 Mar 2013 23:03:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E2630E0A41; Fri, 29 Mar 2013 23:03:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 66E54E0A41 for ; Fri, 29 Mar 2013 23:03:30 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 56D50335E30 for ; Fri, 29 Mar 2013 23:03:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id E3240E4073 for ; Fri, 29 Mar 2013 23:03:27 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1364597842.55d20d366085adcfd8783d56de11bb024a446bb1.blueness@gentoo> Subject: [gentoo-commits] proj/webapp-config:master commit in: WebappConfig/, doc/ X-VCS-Repository: proj/webapp-config X-VCS-Files: WebappConfig/config.py WebappConfig/worker.py doc/webapp-config.8.xml X-VCS-Directories: WebappConfig/ doc/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 55d20d366085adcfd8783d56de11bb024a446bb1 X-VCS-Branch: master Date: Fri, 29 Mar 2013 23:03:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5f8c6aac-2bed-4abe-85e1-304b2f65fd61 X-Archives-Hash: a312431ea0d3c055a4f5cf5e43313701 commit: 55d20d366085adcfd8783d56de11bb024a446bb1 Author: twitch153 hotmail com> AuthorDate: Fri Mar 29 03:16:53 2013 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Fri Mar 29 22:57:22 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=55d20d36 WebappConfig/{config,worker}.py: add option to copy files This adds an option to copy the webapp files rather than hardlink them even if they are on the same filesystem. While this takes up more disk space, it allows one to modify different instances of webapp installations without affecting other instances. X-Gentoo-Bug: 231482 X-Gentoo-Bug-URL: https://bugs.gentoo.org/231482 Signed-off-by: Anthony G. Basile gentoo.org> --- WebappConfig/config.py | 16 ++++++++++++++++ WebappConfig/worker.py | 36 ++++++++++++++++++++++++++++++++++++ doc/webapp-config.8.xml | 18 ++++++++++++++---- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/WebappConfig/config.py b/WebappConfig/config.py index 37fb0e2..fd106c5 100644 --- a/WebappConfig/config.py +++ b/WebappConfig/config.py @@ -490,6 +490,13 @@ class Config: ' when creating virtual files. : some pack' 'ages will not work if you use this option') + group.add_option('--cp', + '--copy', + action='store_true', + help = 'Directly copy the webapp files from' + ' the /usr/share/webapps/ directory when installing' + ' the webapp.') + group.add_option('--virtual-files', '--vf', type = 'choice', @@ -845,6 +852,7 @@ class Config: 'user' : 'vhost_config_uid', 'group' : 'vhost_config_gid', 'soft' : 'g_soft', + 'copy' : 'g_copy', 'virtual_files': 'vhost_config_virtual_files', 'default_dirs' : 'vhost_config_default_dirs', 'pretend' : 'g_pretend', @@ -990,6 +998,14 @@ class Config: OUT.debug('Selecting soft links' , 7) self.config.set('USER', 'g_link_type', 'soft') + + elif (self.config.has_option('USER', 'g_copy') and + self.config.getboolean('USER', 'g_copy')): + + OUT.debug('Selecting copying of links', 7) + + self.config.set('USER', 'g_link_type', 'clone') + else: OUT.debug('Selecting hard links' , 7) diff --git a/WebappConfig/worker.py b/WebappConfig/worker.py index 07a2f1a..250f068 100644 --- a/WebappConfig/worker.py +++ b/WebappConfig/worker.py @@ -495,6 +495,10 @@ class WebappAdd: OUT.debug('Trying to softlink', 8) if not self.__p: + if self.__v: + print("\n>>> SOFTLINKING FILE: ") + print(">>> Source: " + src_name + + "\n>>> Destination: " + dst_name + "\n") os.symlink(src_name, dst_name) my_contenttype = 'sym' @@ -504,12 +508,35 @@ class WebappAdd: if self.__v: OUT.warn('Failed to softlink (' + str(e) + ')') + elif self.__link_type == 'clone': + try: + + OUT.debug('Trying to copy files directly', 8) + + if not self.__p: + if self.__v: + print("\n>>> COPYING FILE: ") + print(">>> Source: " + src_name + + "\n>>> Destination: " + dst_name + "\n") + shutil.copy(src_name, dst_name) + + my_contenttype = 'file' + + except Exception as e: + + if self.__v: + OUT.warn('Failed to copy (' + str(e) + ')') + elif os.path.islink(src_name): try: OUT.debug('Trying to copy symlink', 8) if not self.__p: + if self.__v: + print("\n>>> SYMLINK COPY: ") + print(">>> Source: " + src_name + + "\n>>> Destination: " + dst_name + "\n") os.symlink(os.readlink(src_name), dst_name) my_contenttype = 'sym' @@ -525,6 +552,10 @@ class WebappAdd: OUT.debug('Trying to hardlink', 8) if not self.__p: + if self.__v: + print("\n>>> HARDLINKING FILE: ") + print(">>> Source: " + src_name + + "\n>>> Destination: " + dst_name + "\n") os.link(src_name, dst_name) my_contenttype = 'file' @@ -535,7 +566,12 @@ class WebappAdd: OUT.warn('Failed to hardlink (' + str(e) + ')') if not my_contenttype: + if not self.__p: + if self.__v: + print("\n>>> COPYING FILE: ") + print(">>> Source: " + src_name + + "\n>>> Destination: " + dst_name + "\n") shutil.copy(src_name, dst_name) my_contenttype = 'file' diff --git a/doc/webapp-config.8.xml b/doc/webapp-config.8.xml index e3f2c08..dda1ec4 100644 --- a/doc/webapp-config.8.xml +++ b/doc/webapp-config.8.xml @@ -68,6 +68,7 @@ + @@ -217,14 +218,15 @@ - Hard Linking vs Soft Linking + File Copying Options A virtual copy is built mostly by creating hard links to files under /usr/share/webapps. If a hard link cannot be created, the file is copied from /usr/share/webapps instead. Hard links can only be created to files on the same filesystem. If you keep /usr/share/webapps and /var/www on different filesystems, webapp-config cannot use hard links, and will be forced to copy the files instead. - There are two ways to get around the hard link problem. + There are three ways to get around the hard link problem. The easiest way is to make /usr/share/webapps a symlink to a directory under /var/www. For most people, this will ensure that everything is on the same filesystem. However, if you keep the websites you host on separate filesystems (like I do), then webapp-config is never going to be able to hard-link files for you. - You can choose to use the command-line switch instead. This switch tells webapp-config to create symbolic links instead of hard links. Symbolic links work across filesystems. + As an alternative you can choose to use the command-line switch. This switch tells webapp-config to create symbolic links instead of hard links. Symbolic links work across filesystems. The problem with using symbolic links is that some packages do not work when the virtual copy is made from symbolic links. Many users - and system administrators alas - have also complained that they find directories full of symbolic links confusing. For these reasons, symbolic links are not used by default in webapp-config any more. + You may also choose the command-line switch. This particular switch tells webapp-config to directly copy the files from /usr/share/webapps/ instead of hard links. Copying directly works across filesystems with the drawback of using more space but if you are going to use it across file systems you may want this instead of symbolic links, as this means that the files in /usr/share/webapps/ will not be touched when the files in the location of your virtualhost are altered. @@ -465,12 +467,20 @@ - Use this option to create the virtual copy using symbolic links instead of hard links. + Use this option to create the virtual copy using symbolic links. You may find this option useful if /usr/share/webapps is on a different filesystem to your htdocs directories. However, it has been discovered that some packages do not work with this option, which is why it is no longer the default behaviour. You are always better off making /usr/share/webapps a symlink to a directory on the same filesystem as your htdocs directories. + + + + Use this option to create the virtual copy by copying the files from the /usr/share/webapps/ directories. + This option is useful if you want to copy the files directly from /usr/share/webapps/ to your virtual host in /var/www without the use of softlinks, or hardlinks. Be aware that because this is a direct copying of files it will prove to take up more space on your filesystem as opposed to the other two options since you are duplicating the webapp. + + + Use this option to install into the htdocs-secure directory rather than into the htdocs directory.