public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/webapp-config:master commit in: WebappConfig/, doc/
Date: Fri, 29 Mar 2013 23:10:55 +0000 (UTC)	[thread overview]
Message-ID: <1364598600.a1e489227f090025610d08e4d2a43faa7e4cf80e.blueness@gentoo> (raw)

commit:     a1e489227f090025610d08e4d2a43faa7e4cf80e
Author:     Devan Franchini <twitch153 <AT> hotmail <DOT> com>
AuthorDate: Fri Mar 29 03:16:53 2013 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Fri Mar 29 23:10:00 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=a1e48922

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 <blueness <AT> 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. <NOTE>: 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 @@
 	  <arg choice="opt">
 	    <option>-dghusDE</option>
 	    <option>--soft</option>
+	    <option>--copy</option>
 	    <option>--secure</option>
 	  </arg>
 	  <arg choice="req">
@@ -217,14 +218,15 @@
 	</refsect2>
 
 	<refsect2>
-	  <title>Hard Linking vs Soft Linking</title>
+	  <title>File Copying Options</title>
 	  <para>A <glossterm>virtual copy</glossterm> is built mostly by creating hard links to files under <filename>/usr/share/webapps</filename>.  If a hard link cannot be created, the file is copied from <filename>/usr/share/webapps</filename> instead.</para>
 	  <para>Hard links can only be created to files on the same filesystem.  If you keep <filename>/usr/share/webapps</filename> and <filename>/var/www</filename> on different filesystems, <command>webapp-config</command> cannot use hard links, and will be forced to copy the files instead.</para>
-	  <para>There are two ways to get around the hard link problem.</para>
+	  <para>There are three ways to get around the hard link problem.</para>
 	  <para>The easiest way is to make <filename>/usr/share/webapps</filename> a symlink to a directory under <filename>/var/www</filename>.  For most people, this will ensure that everything is on the same filesystem.</para>
 	  <para>However, if you keep the websites you host on separate filesystems (like I do), then <command>webapp-config</command> is never going to be able to hard-link files for you.</para>
-	  <para>You can choose to use the <option>--soft</option> command-line switch instead.  This switch tells <command>webapp-config</command> to create symbolic links instead of hard links.  Symbolic links work across filesystems.</para>
+	  <para>As an alternative you can choose to use the <option>--soft</option> command-line switch.  This switch tells <command>webapp-config</command> to create symbolic links instead of hard links.  Symbolic links work across filesystems.</para>
 	  <para>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 <command>webapp-config</command> any more.</para>
+          <para>You may also choose the <option>--copy</option> command-line switch.  This particular switch tells <command>webapp-config</command> to directly copy the files from <filename>/usr/share/webapps/</filename> 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 <filename>/usr/share/webapps/</filename> will not be touched when the files in the location of your virtualhost are altered.</para>
 	</refsect2>
 
         <refsect2>
@@ -465,12 +467,20 @@
 	  <varlistentry>
 	    <term><option>--soft</option></term>
 	    <listitem>
-	      <para>Use this option to create the virtual copy using symbolic links instead of hard links.</para>
+	      <para>Use this option to create the virtual copy using symbolic links.</para>
 	      <para>You may find this option useful if <filename>/usr/share/webapps</filename> 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 <filename>/usr/share/webapps</filename> a symlink to a directory on the same filesystem as your htdocs directories.</para>
 	    </listitem>
 	  </varlistentry>
 
 	  <varlistentry>
+	    <term><option>--cp</option></term>
+	    <term><option>--copy</option></term>
+	    <listitem>
+	      <para>Use this option to create the virtual copy by copying the files from the <filename>/usr/share/webapps/</filename> directories.</para>
+	      <para>This option is useful if you want to copy the files directly from <filename>/usr/share/webapps/</filename> 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.</para>
+	  </varlistentry>
+
+	  <varlistentry>
 	    <term><option>--secure</option></term>
 	    <listitem>
 	      <para>Use this option to install into the <filename>htdocs-secure</filename> directory rather than into the <filename>htdocs</filename> directory.</para>


             reply	other threads:[~2013-03-29 23:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-29 23:10 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-07-02 14:31 [gentoo-commits] proj/webapp-config:master commit in: WebappConfig/, doc/ Devan Franchini
2013-08-24 23:06 Anthony G. Basile
2013-08-03 13:24 Anthony G. Basile
2013-03-29 23:03 Anthony G. Basile
2011-12-29 21:24 Anthony G. Basile

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364598600.a1e489227f090025610d08e4d2a43faa7e4cf80e.blueness@gentoo \
    --to=blueness@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox