From d32559081e8dc4059bc05ec94f0545e696c75608 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 7 Jan 2015 17:44:50 +0530 Subject: [PATCH] Fixed issue in PHP, Added Swap creation --- ee/cli/plugins/stack.py | 13 ++++++ ee/core/addswap.py | 2 +- ee/core/aptget.py | 95 ++++++++++++++++++++++------------------- ee/core/fileutils.py | 5 ++- ee/core/variables.py | 5 ++- 5 files changed, 72 insertions(+), 48 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 793d8fe1..f15bdbb7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -297,6 +297,19 @@ class EEStackController(CementBaseController): " /etc/php5/fpm/pool.d/www.conf") config.write(configfile) + # Generate /etc/php5/fpm/pool.d/debug.conf + EEFileUtils.copyfile(self, "/etc/php5/fpm/pool.d/www.conf", + "/etc/php5/fpm/pool.d/debug.conf") + EEFileUtils.searchreplace(self, "/etc/php5/fpm/pool.d/" + "debug.conf", "[www]", "[debug]") + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/pool.d/debug.conf') + config['debug']['listen'] = '127.0.0.1:9001' + with open('/etc/php5/fpm/pool.d/debug.conf', 'w') as confifile: + self.app.log.debug("writting PHP5 configartion into " + " /etc/php5/fpm/pool.d/debug.conf") + config.write(confifile) + if set(EEVariables.ee_mysql).issubset(set(apt_packages)): config = configparser.ConfigParser() config.read('/etc/mysql/my.cnf') diff --git a/ee/core/addswap.py b/ee/core/addswap.py index 6ae7d009..192ba79d 100644 --- a/ee/core/addswap.py +++ b/ee/core/addswap.py @@ -21,4 +21,4 @@ class EESwap(): EEFileUtils.chmod(self, "/ee-swapfile", 0o600) EEShellExec.cmd_exec(self, "swapon /ee-swapfile") with open("/etc/fstab", "a") as swap_file: - myfile.write("/ee-swapfile\tnone\tswap\tsw\t0 0") + swap_file.write("/ee-swapfile\tnone\tswap\tsw\t0 0") diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 29a78833..2ab468c3 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -161,52 +161,61 @@ class EEAptGet(): .format(package_name=package.name)) continue if package.marked_delete: + my_selected_packages.append(package.name) + # Mark for deletion the first package, to fire up + # auto_removable Purge? + if purge: + package.mark_delete(purge=True) + else: + package.mark_delete(purge=False) continue else: my_selected_packages.append(package.name) - # How logic works: - # 1) We loop trough dependencies's dependencies and add them to - # the list. - # 2) We sequentially remove every package in list - # - via is_auto_installed we check if we can safely remove it - deplist = [] - onelevel = __dependencies_loop(cache, deplist, package, - onelevel=True) - # Mark for deletion the first package, to fire up auto_removable - # Purge? - if purge: - package.mark_delete(purge=True) - else: - package.mark_delete(purge=False) - # Also ensure we remove AT LEAST the first level of dependencies - # (that is, the actual package's dependencies). - if auto: - markedauto = [] - for pkg in onelevel: - if (not pkg.marked_install and pkg.is_installed - and not pkg.is_auto_installed): - pkg.mark_auto() - markedauto.append(pkg) - - for pkg in deplist: - if (not pkg.marked_install and pkg.is_installed and - pkg.is_auto_removable): - # Purge? - if purge: - pkg.mark_delete(purge=True) - else: - pkg.mark_delete(purge=False) - # Restore auted items - for pkg in markedauto: - if not pkg.marked_delete: - pkg.mark_auto(False) - else: - # We need to ensure that the onelevel packages are not marked - # as automatically installed, otherwise the user may drop - # them via autoremove or aptitude. - for pkg in onelevel: - if pkg.is_installed and pkg.is_auto_installed: - pkg.mark_auto(auto=False) + print(my_selected_packages) + # How logic works: + # 1) We loop trough dependencies's dependencies and add them to + # the list. + # 2) We sequentially remove every package in list + # - via is_auto_installed we check if we can safely remove it + deplist = [] + onelevel = __dependencies_loop(cache, deplist, package, + onelevel=True) + # Mark for deletion the first package, to fire up + # auto_removable Purge? + if purge: + package.mark_delete(purge=True) + else: + package.mark_delete(purge=False) + + # Also ensure we remove AT LEAST the first level of + # dependencies (that is, the actual package's dependencies). + if auto: + markedauto = [] + for pkg in onelevel: + if (not pkg.marked_install and pkg.is_installed + and not pkg.is_auto_installed): + pkg.mark_auto() + markedauto.append(pkg) + + for pkg in deplist: + if (not pkg.marked_install and pkg.is_installed and + pkg.is_auto_removable): + # Purge? + if purge: + pkg.mark_delete(purge=True) + else: + pkg.mark_delete(purge=False) + # Restore auted items + for pkg in markedauto: + if not pkg.marked_delete: + pkg.mark_auto(False) + else: + # We need to ensure that the onelevel packages are not + # marked as automatically installed, otherwise the user may + # drop them via autoremove or aptitude. + for pkg in onelevel: + if pkg.is_installed and pkg.is_auto_installed: + pkg.mark_auto(auto=False) # Check if packages available for remove/update. if cache.delete_count > 0: diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 7250adcc..0199a463 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -47,7 +47,7 @@ class EEFileUtils(): .format(e.errno, e.strerror)) sys.exit(1) - def copyfile(self, src, dst): + def copyfile(self, src, dest): try: shutil.copy2(src, dest) except shutil.Error as e: @@ -58,7 +58,8 @@ class EEFileUtils(): def searchreplace(self, fnm, sstr, rstr): try: for line in fileinput.input(fnm, inplace=True): - print(line.replace(textToSearch, textToReplace), end='') + print(line.replace(sstr, rstr), end='') + fileinput.close() except Exception as e: print('Error : {0}'.format(e)) diff --git a/ee/core/variables.py b/ee/core/variables.py index 043e69f9..e8dc451c 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -52,8 +52,9 @@ class EEVariables(): elif ee_platform_codename == 'wheezy': ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all" .format(codename=ee_platform_codename)) - ee_php = ["php5-curl", "php5-gd", "php5-cli", "php5-fpm", "php5-imap", - "php5-mcrypt", "php5-xdebug"] + ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-cli", "php5-imap", + "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", + "php5-mysql"] # MySQL repo and packages ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main"