From 7ea7deded031b43042c68db0f7c5c6c8b21c18c2 Mon Sep 17 00:00:00 2001 From: Damodar Date: Tue, 26 Aug 2014 10:57:56 +0530 Subject: [PATCH] CLOUDSTACK-7106 : RPM build failing with RHEL7 Reviewed By : Rayees Signed-off-by: Santhosh Edukulla --- client/tomcatconf/server7-nonssl.xml.in | 231 +++++++++++++++ client/tomcatconf/server7-ssl.xml.in | 263 ++++++++++++++++++ packaging/centos63/cloud-management.rc | 9 +- packaging/centos63/cloud.spec | 59 ++-- packaging/centos63/default/macros.spec | 27 ++ packaging/centos63/default/tomcat.sh | 18 ++ packaging/centos63/package.sh | 54 +++- .../centos63/rhel7/cloud-management.service | 32 +++ packaging/centos63/rhel7/macros.spec | 27 ++ packaging/centos63/rhel7/tomcat.sh | 18 ++ python/lib/cloudutils/serviceConfigServer.py | 4 +- 11 files changed, 703 insertions(+), 39 deletions(-) create mode 100755 client/tomcatconf/server7-nonssl.xml.in create mode 100755 client/tomcatconf/server7-ssl.xml.in create mode 100644 packaging/centos63/default/macros.spec create mode 100644 packaging/centos63/default/tomcat.sh create mode 100644 packaging/centos63/rhel7/cloud-management.service create mode 100644 packaging/centos63/rhel7/macros.spec create mode 100644 packaging/centos63/rhel7/tomcat.sh diff --git a/client/tomcatconf/server7-nonssl.xml.in b/client/tomcatconf/server7-nonssl.xml.in new file mode 100755 index 00000000000..16085d740f6 --- /dev/null +++ b/client/tomcatconf/server7-nonssl.xml.in @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/tomcatconf/server7-ssl.xml.in b/client/tomcatconf/server7-ssl.xml.in new file mode 100755 index 00000000000..e8f3f10d8e4 --- /dev/null +++ b/client/tomcatconf/server7-ssl.xml.in @@ -0,0 +1,263 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/centos63/cloud-management.rc b/packaging/centos63/cloud-management.rc index 2f04793b79c..eaabd30d593 100755 --- a/packaging/centos63/cloud-management.rc +++ b/packaging/centos63/cloud-management.rc @@ -43,6 +43,7 @@ fi NAME="$(basename $0)" +export SERVICE_NAME="$NAME" stop() { SHUTDOWN_WAIT="30" count="0" @@ -85,6 +86,10 @@ handle_pid_file() { fi } +start() { + source $(dirname $0)/tomcat.sh +} + # See how we were called. case "$1" in status) @@ -99,11 +104,11 @@ case "$1" in stop set start set_ulimit - . /etc/rc.d/init.d/tomcat6 + start ;; *) set_ulimit - . /etc/rc.d/init.d/tomcat6 + start esac exit $RETVAL diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec index 7565f950359..790f57bb893 100644 --- a/packaging/centos63/cloud.spec +++ b/packaging/centos63/cloud.spec @@ -5,7 +5,7 @@ # to you 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, @@ -43,8 +43,10 @@ Group: System Environment/Libraries Source0: %{name}-%{_maventag}.tgz BuildRoot: %{_tmppath}/%{name}-%{_maventag}-%{release}-build +%include SPECS/%{_os}/macros.spec + BuildRequires: java-1.7.0-openjdk-devel -BuildRequires: tomcat6 +BuildRequires: %{_tomcatversion} BuildRequires: ws-commons-util BuildRequires: jpackage-utils BuildRequires: gcc @@ -59,8 +61,8 @@ intelligent IaaS cloud implementation. %package management Summary: CloudStack management server UI -Requires: tomcat6 -Requires: java7 +Requires: %{_tomcatversion} +Requires: %{_javaversion} Requires: python Requires: bash Requires: bzip2 @@ -80,14 +82,15 @@ Requires: /sbin/chkconfig Requires: /usr/bin/ssh-keygen Requires: mkisofs Requires: MySQL-python -Requires: python-paramiko +%{_pythonparamiko} Requires: ipmitool Requires: %{name}-common = %{_ver} -Requires: %{name}-awsapi = %{_ver} +Requires: %{name}-awsapi = %{_ver} +%{_iptablesservice} Obsoletes: cloud-client < 4.1.0 Obsoletes: cloud-client-ui < 4.1.0 Obsoletes: cloud-server < 4.1.0 -Obsoletes: cloud-test < 4.1.0 +Obsoletes: cloud-test < 4.1.0 Provides: cloud-client Group: System Environment/Libraries %description management @@ -113,14 +116,14 @@ The Apache CloudStack files shared between agent and management server %package agent Summary: CloudStack Agent for KVM hypervisors Requires: openssh-clients -Requires: java7 +Requires: %{_javaversion} Requires: %{name}-common = %{_ver} Requires: libvirt Requires: bridge-utils Requires: ebtables Requires: iptables Requires: ethtool -Requires: vconfig +Requires: %{_vlanconfigtool} Requires: ipset Requires: jsvc Requires: jakarta-commons-daemon @@ -151,7 +154,7 @@ The CloudStack baremetal agent %package usage Summary: CloudStack Usage calculation server -Requires: java7 +Requires: %{_javaversion} Requires: jsvc Requires: jakarta-commons-daemon Requires: jakarta-commons-daemon-jsvc @@ -182,7 +185,7 @@ Apache Cloudstack AWS API compatibility wrapper %package mysql-ha Summary: Apache CloudStack Balancing Strategy for MySQL Requires: mysql-connector-java -Requires: tomcat7 +Requires: %{_tomcatversion} Group: System Environmnet/Libraries %description mysql-ha Apache CloudStack Balancing Strategy for MySQL @@ -252,9 +255,9 @@ mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management # Specific for tomcat mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost/client -ln -sf /usr/share/tomcat6/bin ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/bin +ln -sf /usr/share/%{_tomcatpathname}/bin ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/bin ln -sf /etc/%{name}/management ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/conf -ln -sf /usr/share/tomcat6/lib ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/lib +ln -sf /usr/share/%{_tomcatpathname}/lib ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/lib ln -sf /var/log/%{name}/management ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/logs ln -sf /var/cache/%{name}/management/temp ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/temp ln -sf /var/cache/%{name}/management/work ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/work @@ -278,12 +281,19 @@ cp -r client/target/cloud-client-ui-%{_maventag}/* ${RPM_BUILD_ROOT}%{_datadir}/ rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/scripts rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/vms -for name in db.properties log4j-cloud.xml tomcat6-nonssl.conf tomcat6-ssl.conf server-ssl.xml server-nonssl.xml \ +for name in db.properties log4j-cloud.xml tomcat6-nonssl.conf tomcat6-ssl.conf %{_serverxmlname}-ssl.xml %{_serverxmlname}-nonssl.xml \ catalina.policy catalina.properties classpath.conf tomcat-users.xml web.xml environment.properties ; do mv ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/$name \ ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/$name done +if [ -f "${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/server7-nonssl.xml" ]; then + mv ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/server7-nonssl.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/server-nonssl.xml +fi +if [ -f "${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/server7-ssl.xml" ]; then + mv ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/server7-ssl.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/server-ssl.xml +fi + ln -s %{_sysconfdir}/%{name}/management/log4j-cloud.xml \ ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/log4j-cloud.xml @@ -294,8 +304,10 @@ install python/bindir/cloud-external-ipallocator.py ${RPM_BUILD_ROOT}%{_bindir}/ install -D client/target/pythonlibs/jasypt-1.9.0.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/jasypt-1.9.0.jar install -D packaging/centos63/cloud-ipallocator.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-ipallocator -install -D packaging/centos63/cloud-management.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-management +install -D packaging/centos63/cloud-management.rc ${RPM_BUILD_ROOT}%{_managementstartscriptpath}/%{name}-management install -D packaging/centos63/cloud-management.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/%{name}-management +install -D packaging/centos63/%{_os}/tomcat.sh ${RPM_BUILD_ROOT}%{_managementstartscriptpath}/tomcat.sh +%{_managementservice} chmod 770 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina chmod 770 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost @@ -581,16 +593,19 @@ fi %config(noreplace) %{_sysconfdir}/%{name}/management/cloud-bridge.properties %config(noreplace) %{_sysconfdir}/%{name}/management/commons-logging.properties %config(noreplace) %{_sysconfdir}/%{name}/management/ec2-service.properties -%attr(0755,root,root) %{_initrddir}/%{name}-management +%attr(0755,root,root) %{_managementstartscriptpath}/%{name}-management +%attr(0755,root,root) %{_managementstartscriptpath}/tomcat.sh +%{_managementserviceattribute} + %attr(0755,root,root) %{_bindir}/%{name}-setup-management %attr(0755,root,root) %{_bindir}/%{name}-update-xenserver-licenses %{_datadir}/%{name}-management/webapps -%dir %{_datadir}/%{name}-management/bin -%dir %{_datadir}/%{name}-management/conf -%dir %{_datadir}/%{name}-management/lib -%dir %{_datadir}/%{name}-management/logs -%dir %{_datadir}/%{name}-management/temp -%dir %{_datadir}/%{name}-management/work +%{_datadir}/%{name}-management/bin +%{_datadir}/%{name}-management/conf +%{_datadir}/%{name}-management/lib +%{_datadir}/%{name}-management/logs +%{_datadir}/%{name}-management/temp +%{_datadir}/%{name}-management/work %attr(0755,root,root) %{_bindir}/%{name}-setup-databases %attr(0755,root,root) %{_bindir}/%{name}-migrate-databases %attr(0755,root,root) %{_bindir}/%{name}-set-guest-password diff --git a/packaging/centos63/default/macros.spec b/packaging/centos63/default/macros.spec new file mode 100644 index 00000000000..f3c937cac37 --- /dev/null +++ b/packaging/centos63/default/macros.spec @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +%define _pythonparamiko Requires: python-paramiko +%define _javaversion java7 +%define _tomcatversion tomcat6 +%define _vlanconfigtool vconfig +%define _tomcatpathname tomcat6 +%define _managementstartscriptpath %{_initrddir} +%define _managementservice %{nil} +%define _managementserviceattribute %{nil} +%define _iptablesservice %{nil} +%define _serverxmlname server \ No newline at end of file diff --git a/packaging/centos63/default/tomcat.sh b/packaging/centos63/default/tomcat.sh new file mode 100644 index 00000000000..0908da4696e --- /dev/null +++ b/packaging/centos63/default/tomcat.sh @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +. /etc/rc.d/init.d/tomcat6 start diff --git a/packaging/centos63/package.sh b/packaging/centos63/package.sh index 07f95fc0cdd..d239d2e5a7b 100755 --- a/packaging/centos63/package.sh +++ b/packaging/centos63/package.sh @@ -18,11 +18,13 @@ function usage() { echo "" - echo "usage: ./package.sh [-p|--pack] [-h|--help] [ARGS]" + echo "usage: ./package.sh [-p|--pack] [-h|--help] [-o|--operating-system] [ARGS]" echo "" echo "The commonly used Arguments are:" - echo "oss|OSS To package with only redistributable libraries (default)" - echo "noredist|NOREDIST To package with non-redistributable libraries" + echo "-p|--pack oss|OSS To package with only redistributable libraries (default)" + echo "-p|--pack noredist|NOREDIST To package with non-redistributable libraries" + echo "-o default|DEFAULT To build in default Operating System mode" + echo "-o rhel7|RHEL7 To build for rhel7" echo "" echo "Examples: ./package.sh -p|--pack oss|OSS" echo " ./package.sh -p|--pack noredist|NOREDIST" @@ -34,8 +36,13 @@ function packaging() { CWD=`pwd` RPMDIR=$CWD/../../dist/rpmbuild PACK_PROJECT=cloudstack - if [ -n "$1" ] ; then - DEFOSSNOSS="-D_ossnoss $packageval" + if [ -n "$1" ] ;then + DOS="-D_os $1" + echo "$DOS" + fi + if [ -n "$2" ] ; then + DEFOSSNOSS="-D_ossnoss $2" + echo "$DEFOSSNOSS" fi VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep --color=none '^[0-9]\.'` @@ -64,22 +71,23 @@ function packaging() { echo ". executing rpmbuild" cp cloud.spec $RPMDIR/SPECS + cp -rf default $RPMDIR/SPECS + cp -rf rhel7 $RPMDIR/SPECS - (cd $RPMDIR; rpmbuild --define "_topdir $RPMDIR" "${DEFVER}" "${DEFREL}" ${DEFPRE+"${DEFPRE}"} ${DEFOSSNOSS+"$DEFOSSNOSS"} -bb SPECS/cloud.spec) + (cd $RPMDIR; rpmbuild --define "_topdir $RPMDIR" "${DEFVER}" "${DEFREL}" ${DEFPRE+"${DEFPRE}"} ${DEFOSSNOSS+"$DEFOSSNOSS"} "${DOS}" -bb SPECS/cloud.spec) echo "Done" exit } if [ $# -lt 1 ] ; then - packaging + packaging "default" elif [ $# -gt 0 ] ; then - SHORTOPTS="hp:" - LONGOPTS="help,pack:" - - ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@" ) + SHORTOPTS="hp:o:" + LONGOPTS="help,pack:,operating-system:" + ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@") eval set -- "$ARGS" - + echo "$ARGS" while [ $# -gt 0 ] ; do case "$1" in -h | --help) @@ -89,14 +97,29 @@ elif [ $# -gt 0 ] ; then -p | --pack) echo "Doing CloudStack Packaging ....." packageval=$2 + echo "$packageval" if [ "$packageval" == "oss" -o "$packageval" == "OSS" ] ; then - packaging + packageval = "" elif [ "$packageval" == "noredist" -o "$packageval" == "NOREDIST" ] ; then - packaging noredist + packageval="noredist" else echo "Error: Incorrect value provided in package.sh script, Please see help ./package.sh --help|-h for more details." exit 1 fi + shift + ;; + -o | --operating-system) + os=$2 + echo "$os" + if [ "$os" == "default" -o "$os" == "DEFAULT" ] ; then + os = "default" + elif [ "$os" == "rhel7" -o "$os" == "RHEL7" ] ; then + os="rhel7" + else + echo "Error: Incorrect value provided in package.sh script for -o, Please see help ./package.sh --help|-h for more details." + exit 1 + fi + shift ;; -) echo "Unrecognized option..." @@ -108,6 +131,9 @@ elif [ $# -gt 0 ] ; then ;; esac done + + echo "Passed OS = $os and packageval = $packageval" + packaging $os $packageval else echo "Incorrect choice. Nothing to do." >&2 echo "Please, execute ./package.sh --help for more help" diff --git a/packaging/centos63/rhel7/cloud-management.service b/packaging/centos63/rhel7/cloud-management.service new file mode 100644 index 00000000000..5d698856404 --- /dev/null +++ b/packaging/centos63/rhel7/cloud-management.service @@ -0,0 +1,32 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +[Unit] +Description=Citrix Cloud Plaltform +After=syslog.target network.target + +[Service] +Type=forking +ExecStart=/usr/sbin/cloudstack-management start +ExecStop=/usr/sbin/cloudstack-management stop +SuccessExitStatus=143 +User=cloud +Group=cloud + + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/packaging/centos63/rhel7/macros.spec b/packaging/centos63/rhel7/macros.spec new file mode 100644 index 00000000000..4b7109280ab --- /dev/null +++ b/packaging/centos63/rhel7/macros.spec @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +%define _pythonparamiko %{nil} +%define _javaversion java => 1.7.0 +%define _tomcatversion tomcat => 7.0 +%define _vlanconfigtool iproute +%define _tomcatpathname tomcat +%define _managementstartscriptpath %{_sbindir} +%define _managementservice install -D packaging/centos63/%{_os}/cloud-management.service ${RPM_BUILD_ROOT}%{_unitdir}/%{name}-management.service +%define _managementserviceattribute %attr(0755,root,root) %{_unitdir}/%{name}-management.service +%define _iptablesservice Requires: iptables-services +%define _serverxmlname server7 \ No newline at end of file diff --git a/packaging/centos63/rhel7/tomcat.sh b/packaging/centos63/rhel7/tomcat.sh new file mode 100644 index 00000000000..03c6e7b9784 --- /dev/null +++ b/packaging/centos63/rhel7/tomcat.sh @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +. /usr/sbin/tomcat start diff --git a/python/lib/cloudutils/serviceConfigServer.py b/python/lib/cloudutils/serviceConfigServer.py index 2c19d7e2a31..b928df4d49d 100644 --- a/python/lib/cloudutils/serviceConfigServer.py +++ b/python/lib/cloudutils/serviceConfigServer.py @@ -102,7 +102,9 @@ class cloudManagementConfig(serviceCfgBase): bash("rm -f /etc/cloudstack/management/tomcat6.conf") bash("ln -s /etc/cloudstack/management/server-nonssl.xml /etc/cloudstack/management/server.xml") bash("ln -s /etc/cloudstack/management/tomcat6-nonssl.conf /etc/cloudstack/management/tomcat6.conf") - + + bash("touch /var/run/cloudstack-management.pid") + bash("chown cloud.cloud /var/run/cloudstack-management.pid") #distro like sl 6.1 needs this folder, or tomcat6 failed to start checkHostName() bash("mkdir /var/log/cloudstack-management/")