WebappConfig/db.py: do not leave behind stray install files

Thanks Devan Franchini <twitch153@hotmail.com> for testing.

X-Gentoo-Bug: 213130
X-Gentoo-Bug-URL: https://bugs.gentoo.org/213130
Reported-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/ebuild.py: don't ignore vhost_config_dir value

Thanks Devan Franchini <twitch153@hotmail.com> for testing.

X-Gentoo-Bug: 438276
X-Gentoo-Bug-URL: https://bugs.gentoo.org/438276
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/worker.py: correct permissions for server-owned dirs

app-admin/webapp-config uses 'os.makedirs(dst_dir, perm(0x755))'
to create new directories without any 'os.chown' after.  If the
configuration contains 'vhost_perms_serverowned_dir="0775"' or
vhost_perms_serverowned_dir="g+w" those permissions will be filtered
with the default python umask which is '022', resulting in a '0755'
permission instead of a '0775' one.

Thanks Devan Franchini <twitch153@hotmail.com> for testing.

X-Gentoo-Bug: 434894
X-Gentoo-Bug-URL: https://bugs.gentoo.org/434894
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/wrapper.py: do not use portage.root to retrive $ROOT

On a prefix system, portage.root equals portage.settings['EROOT'] and
not portage.settings['ROOT'], but we need the latter.

X-Gentoo-Bug: 434894
X-Gentoo-Bug-URL: https://bugs.gentoo.org/434894
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
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@gentoo.org>
doc/webapp-config.8.xml: fix unpaired tag

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/{db,filetype,permissions}.py: code cleanup

1) Add a __str__ method on class PermissionMap for debugging.
2) Fix a wrong debug mesasge in WebappSource.
3) Replace __fix(i).strip() by __fix(i) in FileType since
__fix already strip the input.
4) Add missing cases in FileType comments

Thanks Devan Franchini <twitch153@hotmail.com> for testing.

X-Gentoo-Bug: 231482
X-Gentoo-Bug-URL: https://bugs.gentoo.org/231482
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Webappconfig/config.py: Adds check for package name and version

This check is done in the run() function if self.work == "clean" to avoid
uninstalling a webapp if the package name and version being listed exist,
but aren't the ones located in the .webapp in the specified directory taken
from the -d flag.

X-Gentoo-Bug: 461410
X-Gentoo-Bug-URL: https://bugs.gentoo.org/461410
WebappConfig/{config.py,server.py}: set server uid/gid in the config

X-Gentoo-Bug: 432908
X-Gentoo-Bug-URL: https://bugs.gentoo.org/432908
WebappConfig/wrapper.py: fix paludis support

X-Gentoo-Bug: 428378
X-Gentoo-Bug-URL: https://bugs.gentoo.org/428378
WebappConfig/content.py: use hashlib instead of md5 module

X-Gentoo-Bug: 282831
X-Gentoo-Bug-URL: https://bugs.gentoo.org/282831
Bump to version 1.51
WebappConfig/config.py: fix indentation

X-Gentoo-Bug: 479884
X-Gentoo-Bug-URL: https://bugs.gentoo.org/479884

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Webappconfig/{config.py,worker.py}: Adds configurable --copy option.

This allows for altering the value of vhost_link_type in
/etc/vhosts/webapp-config to copy files by default when installing
a webapp as opposed to soft-linking or hard-linking.  This patch also
repairs the previous damage in which the behavior of the --copy flag
was being ignored; due to the fact that the boolean g_copy was not
being passed down throughout the program because of the extra --cp
flag.  Man page alterations have also been made to reflect the removal
of the --cp flag in the program.

X-Gentoo-Bug: 231482
X-Gentoo-Bug-URL: https://bugs.gentoo.org/231482

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/permissions.py: Corrected syntax for eval() function.

When the permissions octal was being passed to the eval() function they
were previously not being evaluated with python3.2 due to the fact that
the octal value was not being declared as an octal. To fix this, it was
simply stated that the octal value was one by appending '0o' to the
values being piped into the eval() function.

X-GENTOO-BUG: 481298
X-GENTOO-BUG-URL: https://bugs.gentoo.org/481298
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/compat.py: Adds compatibility check for file_md5().

When the file_md5() function is called in python3.2+ a hash file is
supposed to be created, and on a if an object is unicode, it needs to be
encoded prior to hashing. In order to do this, a file called compat.py
has a function in it called create_md5(); this function checks the
hexidecimal python version and based on the version, either encodes the
file before it hashes, or simply returns the md5 hash.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/content.py: Adds use of create_md5() function.

This update adds the use of compat.py into content.py and makes use of
the create_md5() function.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/db.py: Converts dict_keys into a list to allow sorting.

When appending the --list-installs flag to webapp-config and using
python3.2+ you will receive an error declaring: "AttributeError:
'dict_keys' object has no attribute 'sort'". By setting keys as a list
you are then able to list your webapp-config installs without getting
any errors. This has also been tested on python2.7.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
WebappConfig/content.py: Fixed inconsistent tab in file where create_md5() is declared.
WebappConfig/content.py: returns value from create_md5 to prevent nulls.