Move scripts of building rpm to os-xenapi
This patch is to move scripts that build OpenStack dom0 plugins into os-xenapi repo as we have changed nova to use os-xenapi and we are changing neutron to use os-xenapi. ATM, there are two places that contain building rpm scripts: 1. https://github.com/citrix-openstack/xenserver-nova-suppack-builder 2. https://github.com/openstack/neutron/tree/master/neutron/plugins/ ml2/drivers/openvswitch/agent/xenapi For neutron, I have a patch to make it use os-xenapi, see https://review.openstack.org/#/c/402330/ Change-Id: Ibdc17c436e794b474c72f6a5f4686b3a77c58aa2
This commit is contained in:
parent
beb6df6390
commit
55d0890c90
31
Makefile
Normal file
31
Makefile
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
THIS_DIR=$(shell pwd)
|
||||
RPMBUILD_DIR=${THIS_DIR}/os_xenapi/dom0/rpmbuild
|
||||
PACKAGE=xenapi-plugins
|
||||
VERSION_FILE=${THIS_DIR}/os_xenapi/dom0/etc/xapi.d/plugins/dom0_plugin_version.py
|
||||
VERSION=$(shell awk '/PLUGIN_VERSION = / {gsub(/"/, ""); print $$3}' ${VERSION_FILE})
|
||||
|
||||
RPM_NAME=${PACKAGE}-${VERSION}-1.noarch.rpm
|
||||
|
||||
rpm: ${THIS_DIR}/output/${RPM_NAME}
|
||||
|
||||
${THIS_DIR}/output/${RPM_NAME}:
|
||||
mkdir -p ${THIS_DIR}/output
|
||||
mkdir -p ${RPMBUILD_DIR}
|
||||
@for dir in BUILD BUILDROOT SRPMS RPMS SPECS SOURCES; do \
|
||||
rm -rf ${RPMBUILD_DIR}/$$dir; \
|
||||
mkdir -p ${RPMBUILD_DIR}/$$dir; \
|
||||
done
|
||||
cp ${THIS_DIR}/os_xenapi/dom0/${PACKAGE}.spec ${RPMBUILD_DIR}/SPECS
|
||||
rm -rf /tmp/${PACKAGE}
|
||||
mkdir /tmp/${PACKAGE}
|
||||
cp -r ${THIS_DIR}/os_xenapi/dom0/etc/xapi.d /tmp/${PACKAGE}
|
||||
tar czf ${RPMBUILD_DIR}/SOURCES/${PACKAGE}-${VERSION}.tar.gz -C /tmp ${PACKAGE}
|
||||
rpmbuild -ba --nodeps --define "_topdir ${RPMBUILD_DIR}" --define "version ${VERSION}" ${RPMBUILD_DIR}/SPECS/${PACKAGE}.spec
|
||||
mv ${RPMBUILD_DIR}/RPMS/noarch/* ${THIS_DIR}/output
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -rf ${RPMBUILD_DIR}
|
@ -5,4 +5,13 @@ If you install them manually, you will need to ensure that the newly
|
||||
added files are executable. You can do this by running the following
|
||||
command (from dom0):
|
||||
|
||||
chmod a+x /etc/xapi.d/plugins/*
|
||||
chmod a+x /etc/xapi.d/plugins/*
|
||||
|
||||
Otherwise, you can build rpm package by running the following command:
|
||||
|
||||
cd $OS_XENAPI_ROOT
|
||||
make rpm
|
||||
|
||||
and install the package by running the following command in dom0:
|
||||
|
||||
rpm -i xenapi-plugins-*.noarch.rpm
|
||||
|
64
os_xenapi/dom0/xenapi-plugins.spec
Normal file
64
os_xenapi/dom0/xenapi-plugins.spec
Normal file
@ -0,0 +1,64 @@
|
||||
Name: xenapi-plugins
|
||||
Version: %{version}
|
||||
Release: 1
|
||||
Summary: Files for XenAPI support.
|
||||
License: ASL 2.0
|
||||
Group: Applications/Utilities
|
||||
Source0: xenapi-plugins-%{version}.tar.gz
|
||||
BuildArch: noarch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
%define debug_package %{nil}
|
||||
|
||||
%description
|
||||
This package contains files that are required for XenAPI support for OpenStack.
|
||||
|
||||
%prep
|
||||
%setup -q -n xenapi-plugins
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT/etc
|
||||
rsync -avz --exclude '*.pyc' --exclude '*.pyo' xapi.d $RPM_BUILD_ROOT/etc
|
||||
chmod a+x $RPM_BUILD_ROOT/etc/xapi.d/plugins/*
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
set -eu
|
||||
default_sr="$(xe pool-list params=default-SR minimal=true)"
|
||||
if [ -z "$default_sr" ]; then
|
||||
echo "Failed to get the default SR" >&2
|
||||
exit 1
|
||||
fi
|
||||
sr_mount_dir="/var/run/sr-mount/$default_sr"
|
||||
if ! [ -d "$sr_mount_dir" ]; then
|
||||
echo "Cannot find the folder that sr mount" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [ -d /images ]; then
|
||||
os_images_dir="$sr_mount_dir/os-images"
|
||||
|
||||
echo "Creating /images" >&2
|
||||
if ! [ -d "$os_images_dir" ]; then
|
||||
echo "Creating $os_images_dir" >&2
|
||||
mkdir -p "$os_images_dir"
|
||||
fi
|
||||
|
||||
echo "Setting up symlink: /images -> $os_images_dir" >&2
|
||||
ln -s "$os_images_dir" /images
|
||||
fi
|
||||
|
||||
images_dev=$(stat -c %d "/images/")
|
||||
sr_dev=$(stat -c %d "$sr_mount_dir/")
|
||||
|
||||
if [ "$images_dev" != "$sr_dev" ]; then
|
||||
echo "ERROR: /images/ and the default SR are on different devices"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
/etc/xapi.d/plugins/*
|
Loading…
x
Reference in New Issue
Block a user