Remove node.js from being needed in the bootstrap phase and only install it in the horizon component preinstall phase

This commit is contained in:
Joshua Harlow
2012-12-10 12:34:27 -08:00
parent fef440e2e8
commit b8b293d5b4
7 changed files with 53 additions and 33 deletions

View File

@@ -16,11 +16,17 @@
from anvil import colorizer
from anvil import components as comp
from anvil import downloader as down
from anvil import exceptions as excp
from anvil import log as logging
from anvil import shell as sh
from anvil import utils
from anvil.packaging import yum
from tempfile import NamedTemporaryFile
import os
import re
from anvil.components.helpers import db as dbhelper
@@ -76,6 +82,38 @@ class HorizonInstaller(comp.PythonInstallComponent):
comp.PythonInstallComponent.verify(self)
self._check_ug()
def pre_install(self):
self._install_node_repo()
def _install_node_repo(self):
repo_url = self.get_option('nodejs_repo')
if not repo_url:
return
# Download the said url and install it so that we can actually install
# the node.js requirement which seems to be needed by horizon for css compiling??
repo_basename = sh.basename(repo_url)
(_fn, fn_ext) = os.path.splitext(repo_basename)
fn_ext = fn_ext.lower().strip()
if fn_ext not in ['.rpm', '.repo']:
LOG.warn("Unknown node.js repository configuration extension %s (we only support .rpm or .repo)!", colorizer.quote(fn_ext))
return
with NamedTemporaryFile(suffix=fn_ext) as temp_fh:
LOG.info("Downloading node.js repository configuration from %s to %s.", repo_url, temp_fh.name)
down.UrlLibDownloader(repo_url, temp_fh.name).download()
temp_fh.flush()
if fn_ext == ".repo":
# Just write out the repo file after downloading it...
repo_file_name = sh.joinpths("/etc/yum.repos.d", repo_basename)
if not sh.exists(repo_file_name):
with sh.Rooted(True):
sh.write_file(repo_file_name, sh.load_file(temp_fh.name),
tracewriter=self.tracewriter)
sh.chmod(repo_file_name, 0644)
elif fn_ext == ".rpm":
# Install it instead from said rpm (which likely is a
# file that contains said repo location)...
packager = yum.YumPackager(self.distro).direct_install(temp_fh.name)
@property
def symlinks(self):
links = super(HorizonInstaller, self).symlinks

View File

@@ -67,6 +67,10 @@ class YumPackager(pack.Packager):
return sh.execute(*yum_cmd, run_as_root=True,
check_exit_code=True, **kargs)
def direct_install(self, filename):
cmd = YUM_INSTALL + [filename]
self._execute_yum(cmd)
def _remove_special(self, name, info):
return False

View File

@@ -663,7 +663,7 @@ def unlink(path, ignore_errors=True, run_as_root=False):
pass
def copy(src, dst):
def copy(src, dst, tracewriter=None):
LOG.debug("Copying: %r => %r" % (src, dst))
if not is_dry_run():
shutil.copy(src, dst)

View File

@@ -17,6 +17,13 @@ apache_user: "$(auto:user)"
# Port horizon should run on
port: 80
# We need to get a viable node.js repository to work
# with, this is only really needed for distributions where
# said distributions do not have node.js available yet...
#
# NOTE(harlowja): blank out/remove as needed...
nodejs_repo: "http://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm"
# Needed for setting up your database
db:
type: "$(db:type)"

View File

@@ -509,6 +509,7 @@ components:
uninstall: anvil.components.rabbit:RabbitUninstaller
packages:
- name: rabbitmq-server
# Disable qpidd as these rabbitmq & qpidd conflict
pre-install:
- cmd:
- service
@@ -516,6 +517,7 @@ components:
- stop
ignore_failure: true
run_as_root: true
# Also stop it from starting on boot (if rebooted)
- cmd:
- chkconfig
- qpidd

32
smithy
View File

@@ -1,15 +1,9 @@
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root!" 1>&2
exit 1
fi
shopt -s nocasematch
RHEL_VERSION=$(lsb_release -r | awk '{ print $2 }' | cut -d"." -f1)
EPEL_RPM_LIST="http://mirrors.kernel.org/fedora-epel/$RHEL_VERSION/i386"
NODE_RPM_URL="http://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm"
YUM_OPTS="--assumeyes --nogpgcheck"
PIP_CMD="pip-python"
@@ -32,25 +26,6 @@ if [ -z "$BOOT_FILES" ]; then
BOOT_FILES="${PWD}/$BOOT_FN"
fi
bootstrap_node()
{
if [ -z "$NODE_RPM_URL" ]; then
return 0
fi
echo "Installing node.js yum repository configuration."
JS_REPO_RPM_FN=$(basename $NODE_RPM_URL)
if [ ! -f "/tmp/$JS_REPO_RPM_FN" ]; then
echo "Downloading $JS_REPO_RPM_FN to /tmp/$JS_REPO_RPM_FN..."
wget -q -O "/tmp/$JS_REPO_RPM_FN" "$NODE_RPM_URL"
if [ $? -ne 0 ]; then
return 1
fi
fi
echo "Installing /tmp/$JS_REPO_RPM_FN..."
yum install $YUM_OPTS -t "/tmp/$JS_REPO_RPM_FN" 2>&1
return $?
}
bootstrap_epel()
{
if [ -z "$EPEL_RPM_LIST" ]; then
@@ -118,13 +93,6 @@ bootstrap_rhel()
echo "Bootstrapping RHEL: $1"
echo "Please wait..."
# Node is typically needed for horizon (some css stuff)
bootstrap_node
if [ "$?" != "0" ];
then
return $?
fi
# EPEL provides most of the python dependencies for RHEL
bootstrap_epel
if [ "$?" != "0" ];

View File

@@ -9,3 +9,4 @@ python-ordereddict
python-pip
python-progressbar
python-psutil