From 11b4a5501d6d7f8db85a4ce85b0cac849ef1f0e6 Mon Sep 17 00:00:00 2001 From: Ghe Rivero Date: Mon, 28 Jan 2013 06:41:54 +0100 Subject: [PATCH] Create install-packages as a binary. Only supports Debian family distribution so far. Change-Id: I9fa0b833c34a614fe498c6c6ae599733a69c1309 --- elements/base/bin/install-packages | 38 +++++++++++++++++++ .../base/install.d/00-baseline-environment | 2 +- elements/base/pre-install.d/01-install-bin | 3 ++ .../{01-baseline-tools => 02-baseline-tools} | 2 +- .../devstack/install.d/52-image-toolchain | 2 +- elements/devstack/install.d/53-devstack | 2 +- elements/devstack/install.d/97-haveged | 2 +- elements/glance-api/install.d/05-glance-api | 3 +- elements/heat-jeos/install.d/05-heat-jeos | 2 +- elements/heat-jeos/install.d/10-ec2-user | 2 +- elements/hwdiscovery/install.d/10-hwinfo | 2 +- elements/icinga-core/install.d/05-icinga-core | 2 +- elements/icinga-web/install.d/06-icinga-web | 2 +- elements/jenkins/install.d/10-jenkins | 4 +- elements/keystone/install.d/05-keystone | 2 +- elements/mysql/install.d/10-mysql | 4 +- elements/mysql/install.d/97-haveged | 2 +- elements/nova-api/install.d/05-nova-api | 2 +- .../nova-vm/install.d/05-controller-code-deps | 2 +- .../install.d/10-controller-openstack-deps | 2 +- elements/quantum-api/install.d/05-quantum-api | 2 +- elements/salt-master/install.d/10-salt-master | 2 +- elements/salt-minion/install.d/10-salt-minion | 2 +- elements/swift/install.d/10-swift-deps | 2 +- lib/img-functions | 7 +++- 25 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 elements/base/bin/install-packages create mode 100755 elements/base/pre-install.d/01-install-bin rename elements/base/pre-install.d/{01-baseline-tools => 02-baseline-tools} (71%) diff --git a/elements/base/bin/install-packages b/elements/base/bin/install-packages new file mode 100644 index 00000000..097d1e72 --- /dev/null +++ b/elements/base/bin/install-packages @@ -0,0 +1,38 @@ +#!/bin/sh + +# Copyright 2012 Hewlett-Packard Development Company, L.P. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +set -e + +# install-packages package [package ...] +install_deb_packages() { + DEBIAN_FRONTEND=noninteractive \ + http_proxy=$http_proxy https_proxy=$https_proxy \ + no_proxy=$no_proxy \ + apt-get --option "Dpkg::Options::=--force-confold" --assume-yes install "$@" +} + +DISTRO=`lsb_release -si` + +case $DISTRO in + 'Ubuntu'|'Debian') + install_deb_packages $@ + ;; + *) + echo "Distribution not supported" + exit 1 + ;; +esac diff --git a/elements/base/install.d/00-baseline-environment b/elements/base/install.d/00-baseline-environment index 6438bc7d..d0004bb1 100755 --- a/elements/base/install.d/00-baseline-environment +++ b/elements/base/install.d/00-baseline-environment @@ -3,4 +3,4 @@ set -e -apt-get -y install linux-image-generic vlan open-iscsi +install-packages linux-image-generic vlan open-iscsi diff --git a/elements/base/pre-install.d/01-install-bin b/elements/base/pre-install.d/01-install-bin new file mode 100755 index 00000000..555bc782 --- /dev/null +++ b/elements/base/pre-install.d/01-install-bin @@ -0,0 +1,3 @@ +#!/bin/sh + +install -m 0755 -o root -g root $(dirname $0)/../bin/* /usr/local/bin diff --git a/elements/base/pre-install.d/01-baseline-tools b/elements/base/pre-install.d/02-baseline-tools similarity index 71% rename from elements/base/pre-install.d/01-baseline-tools rename to elements/base/pre-install.d/02-baseline-tools index d5b428a8..403befd2 100755 --- a/elements/base/pre-install.d/01-baseline-tools +++ b/elements/base/pre-install.d/02-baseline-tools @@ -4,5 +4,5 @@ set -e apt-get -y update -apt-get -y install python-software-properties +install-packages python-software-properties add-apt-repository -y ppa:tripleo/demo diff --git a/elements/devstack/install.d/52-image-toolchain b/elements/devstack/install.d/52-image-toolchain index 058a2dfe..1c8e8bb0 100755 --- a/elements/devstack/install.d/52-image-toolchain +++ b/elements/devstack/install.d/52-image-toolchain @@ -6,7 +6,7 @@ set -e set -o xtrace -apt-get -y install git +install-packages git if [ -n "$http_proxy" ]; then sudo -Hiu stack git config --global http.proxy $http_proxy fi diff --git a/elements/devstack/install.d/53-devstack b/elements/devstack/install.d/53-devstack index 0829e4a1..58769b9a 100755 --- a/elements/devstack/install.d/53-devstack +++ b/elements/devstack/install.d/53-devstack @@ -4,7 +4,7 @@ set -e set -o xtrace -apt-get -y install git +install-packages git if [ -n "$http_proxy" ]; then sudo -Hiu stack git config --global http.proxy $http_proxy fi diff --git a/elements/devstack/install.d/97-haveged b/elements/devstack/install.d/97-haveged index dcfaf965..1c1b2db8 100755 --- a/elements/devstack/install.d/97-haveged +++ b/elements/devstack/install.d/97-haveged @@ -4,4 +4,4 @@ set -e set -o xtrace -apt-get -y install haveged +install-packages haveged diff --git a/elements/glance-api/install.d/05-glance-api b/elements/glance-api/install.d/05-glance-api index 82d867f8..ea79fce2 100755 --- a/elements/glance-api/install.d/05-glance-api +++ b/elements/glance-api/install.d/05-glance-api @@ -5,7 +5,7 @@ set -e set -o xtrace -DEBIAN_FRONTEND=noninteractive apt-get -y install \ +install-packages \ python-pip git-core python-setuptools python-dev python-lxml python-netaddr \ python-pastescript python-pastedeploy python-paste python-sqlalchemy \ python-greenlet python-routes python-simplejson python-webob rabbitmq-server @@ -30,4 +30,3 @@ cp $GLANCE_ROOT/etc/glance-api.conf /etc/glance cp $GLANCE_ROOT/etc/policy.json /etc/glance cp $GLANCE_ROOT/etc/glance-api-paste.ini /etc/glance cp $GLANCE_ROOT/etc/logging.cnf.sample /etc/glance/logging.conf - diff --git a/elements/heat-jeos/install.d/05-heat-jeos b/elements/heat-jeos/install.d/05-heat-jeos index ff2d906a..ad220dfa 100755 --- a/elements/heat-jeos/install.d/05-heat-jeos +++ b/elements/heat-jeos/install.d/05-heat-jeos @@ -9,7 +9,7 @@ HEAT_API_SOURCE=https://github.com/heat-api/heat-jeos.git OS_ROOT=/opt/stack JEOS_ROOT=$OS_ROOT/heat-jeos -DEBIAN_FRONTEND=noninteractive apt-get -y install git-core python-psutil +install-packages git-core python-psutil mkdir -p $OS_ROOT git clone $HEAT_API_SOURCE $JEOS_ROOT diff --git a/elements/heat-jeos/install.d/10-ec2-user b/elements/heat-jeos/install.d/10-ec2-user index 19b736c3..dceb4588 100755 --- a/elements/heat-jeos/install.d/10-ec2-user +++ b/elements/heat-jeos/install.d/10-ec2-user @@ -23,4 +23,4 @@ Pin: release o=LP-PPA-tripleo-demo Pin-Priority: 900 EOF # Should pull from demo PPA if cloud-init exists there. -apt-get -y install cloud-init +install-packages cloud-init diff --git a/elements/hwdiscovery/install.d/10-hwinfo b/elements/hwdiscovery/install.d/10-hwinfo index 08cb52de..baf74b63 100644 --- a/elements/hwdiscovery/install.d/10-hwinfo +++ b/elements/hwdiscovery/install.d/10-hwinfo @@ -4,4 +4,4 @@ set -e set -o xtrace -apt-get -y install hwinfo +install-packages hwinfo diff --git a/elements/icinga-core/install.d/05-icinga-core b/elements/icinga-core/install.d/05-icinga-core index 8493a05a..dbdb01de 100755 --- a/elements/icinga-core/install.d/05-icinga-core +++ b/elements/icinga-core/install.d/05-icinga-core @@ -5,4 +5,4 @@ set -e set -o xtrace -DEBIAN_FRONTEND=noninteractive apt-get -y install icinga-core +install-packages icinga-core diff --git a/elements/icinga-web/install.d/06-icinga-web b/elements/icinga-web/install.d/06-icinga-web index 404829f5..d0fc3ea0 100755 --- a/elements/icinga-web/install.d/06-icinga-web +++ b/elements/icinga-web/install.d/06-icinga-web @@ -5,5 +5,5 @@ set -e set -o xtrace -DEBIAN_FRONTEND=noninteractive apt-get -y install icinga-web icinga-cgi +install-packages icinga-web icinga-cgi diff --git a/elements/jenkins/install.d/10-jenkins b/elements/jenkins/install.d/10-jenkins index a30c3923..e79e1cd1 100755 --- a/elements/jenkins/install.d/10-jenkins +++ b/elements/jenkins/install.d/10-jenkins @@ -3,8 +3,8 @@ set -e set -o xtrace -apt-get -y install jenkins +install-packages jenkins -# jenkins installs into /var/lib/jenkins which is rather restrictive. +# jenkins installs into /var/lib/jenkins which is rather restrictive. mv /var/lib/jenkins /mnt/ ln -s /mnt/jenkins /var/lib/jenkins diff --git a/elements/keystone/install.d/05-keystone b/elements/keystone/install.d/05-keystone index 6bada6fe..1d1992dc 100755 --- a/elements/keystone/install.d/05-keystone +++ b/elements/keystone/install.d/05-keystone @@ -5,7 +5,7 @@ set -e set -o xtrace -DEBIAN_FRONTEND=noninteractive apt-get -y install \ +install-packages \ python-pip git-core python-setuptools python-dev python-lxml python-netaddr \ python-pastescript python-pastedeploy python-paste python-sqlalchemy \ python-greenlet python-routes python-simplejson python-webob diff --git a/elements/mysql/install.d/10-mysql b/elements/mysql/install.d/10-mysql index 129fc9fc..4f7f6e58 100755 --- a/elements/mysql/install.d/10-mysql +++ b/elements/mysql/install.d/10-mysql @@ -5,5 +5,5 @@ set -e set -o xtrace -#DEBIAN_FRONTEND=noninteractive apt-get -y install sysstat mytop percona-toolkit percona-server-server-5.5 percona-server-client-5.5 -DEBIAN_FRONTEND=noninteractive apt-get -y install sysstat mytop percona-toolkit mysql-server-5.5 mysql-client-5.5 +#install-packages sysstat mytop percona-toolkit percona-server-server-5.5 percona-server-client-5.5 +install-packages sysstat mytop percona-toolkit mysql-server-5.5 mysql-client-5.5 diff --git a/elements/mysql/install.d/97-haveged b/elements/mysql/install.d/97-haveged index dcfaf965..1c1b2db8 100755 --- a/elements/mysql/install.d/97-haveged +++ b/elements/mysql/install.d/97-haveged @@ -4,4 +4,4 @@ set -e set -o xtrace -apt-get -y install haveged +install-packages haveged diff --git a/elements/nova-api/install.d/05-nova-api b/elements/nova-api/install.d/05-nova-api index 80752f68..fc61668d 100755 --- a/elements/nova-api/install.d/05-nova-api +++ b/elements/nova-api/install.d/05-nova-api @@ -3,7 +3,7 @@ set -eux useradd -G admin -m nova -s /bin/false -DEBIAN_FRONTEND=noninteractive apt-get -y install \ +install-packages \ python-pip git-core python-setuptools python-dev python-lxml python-netaddr \ python-pastescript python-pastedeploy python-paste python-sqlalchemy \ python-greenlet python-routes python-simplejson python-webob rabbitmq-server diff --git a/elements/nova-vm/install.d/05-controller-code-deps b/elements/nova-vm/install.d/05-controller-code-deps index 08ce8ef7..f0a45595 100755 --- a/elements/nova-vm/install.d/05-controller-code-deps +++ b/elements/nova-vm/install.d/05-controller-code-deps @@ -5,4 +5,4 @@ set -e set -o xtrace -DEBIAN_FRONTEND=noninteractive apt-get -y install haproxy rabbitmq-server mysql-server ntp dkms +install-packages haproxy rabbitmq-server mysql-server ntp dkms diff --git a/elements/nova-vm/install.d/10-controller-openstack-deps b/elements/nova-vm/install.d/10-controller-openstack-deps index 83947cd6..bb94d989 100755 --- a/elements/nova-vm/install.d/10-controller-openstack-deps +++ b/elements/nova-vm/install.d/10-controller-openstack-deps @@ -5,5 +5,5 @@ set -e set -o xtrace -apt-get -y install keystone glance nova-api nova-cert nova-common nova-scheduler python-nova python-novaclient nova-consoleauth novnc nova-novncproxy cinder-api cinder-scheduler cinder-volume iscsitarget open-iscsi iscsitarget-dkms python-cinderclient nova-network +install-packages keystone glance nova-api nova-cert nova-common nova-scheduler python-nova python-novaclient nova-consoleauth novnc nova-novncproxy cinder-api cinder-scheduler cinder-volume iscsitarget open-iscsi iscsitarget-dkms python-cinderclient nova-network diff --git a/elements/quantum-api/install.d/05-quantum-api b/elements/quantum-api/install.d/05-quantum-api index 300c70c8..0dd57206 100755 --- a/elements/quantum-api/install.d/05-quantum-api +++ b/elements/quantum-api/install.d/05-quantum-api @@ -4,7 +4,7 @@ set -o xtrace useradd -G admin -m quantum -s /bin/false -DEBIAN_FRONTEND=noninteractive apt-get -y install \ +install-packages \ python-pip git-core python-setuptools python-dev python-lxml python-netaddr \ python-pastescript python-pastedeploy python-paste python-sqlalchemy \ python-greenlet python-routes python-simplejson python-webob rabbitmq-server diff --git a/elements/salt-master/install.d/10-salt-master b/elements/salt-master/install.d/10-salt-master index a15e4afd..b16d9344 100755 --- a/elements/salt-master/install.d/10-salt-master +++ b/elements/salt-master/install.d/10-salt-master @@ -3,5 +3,5 @@ set -e set -o xtrace -apt-get -y install salt-master +install-packages salt-master diff --git a/elements/salt-minion/install.d/10-salt-minion b/elements/salt-minion/install.d/10-salt-minion index a1529060..15d5ee4d 100755 --- a/elements/salt-minion/install.d/10-salt-minion +++ b/elements/salt-minion/install.d/10-salt-minion @@ -3,5 +3,5 @@ set -e set -o xtrace -apt-get -y install salt-minion +install-packages salt-minion diff --git a/elements/swift/install.d/10-swift-deps b/elements/swift/install.d/10-swift-deps index ba0add10..57e52138 100755 --- a/elements/swift/install.d/10-swift-deps +++ b/elements/swift/install.d/10-swift-deps @@ -5,5 +5,5 @@ set -e set -o xtrace -apt-get -y install swift rsync memcached python-netifaces python-xattr python-memcache +install-packages swift rsync memcached python-netifaces python-xattr python-memcache diff --git a/lib/img-functions b/lib/img-functions index 8e6278c9..2dee2fb8 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -235,6 +235,11 @@ function do_install () { function do_extra_package_install () { # Install any packages that were requested with the -p command line option if [ "$INSTALL_PACKAGES" != "" ]; then - run_in_target apt-get -y install ${INSTALL_PACKAGES[@]} + run_in_target install-packages ${INSTALL_PACKAGES[@]} fi } + +function copy_elements_lib () { + sudo mkdir -p $TMP_MOUNT_PATH/lib/diskimage-builder + sudo cp -t $TMP_MOUNT_PATH/lib/diskimage-builder $_LIB/elements-functions +} \ No newline at end of file