Skip to content

Commit 1708838

Browse files
khos2owDaanHoogland
authored andcommitted
CLOUDSTACK-10268: Fix and enhance package script (#2433)
- new flag `-T, --use-timestamp` to use `timestamp` when POM version contains SNAPSHOT - in the final artifacts (jar) name - in the final package (rpm, deb) name - in `/etc/cloudstack-release` file of SystemVMs - in the Management Server > About dialog - if there's a "branding" string in the POM version (e.g. `x.y.z.a-NAME[-SNAPSHOT]`), the branding name will be used in the final generated pacakge name such as following: - `cloudstack-management-x.y.z.a-NAME.NUMBER.el7.centos.x86_64` - `cloudstack-management_x.y.z.a-NAME-NUMBER~xenial_all.deb` - branding string can be overriden with newly added `-b, --brand` flag - handle the new format version for VR version - fix long opts (they were broken) - tolerate and show a warning message for unrecognized flags - usage help reformat * Deprecate Version class in favor or CloudStackVersion
1 parent 972b8b7 commit 1708838

File tree

13 files changed

+574
-290
lines changed

13 files changed

+574
-290
lines changed

engine/schema/src/main/java/com/cloud/upgrade/DatabaseIntegrityChecker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
import org.apache.log4j.Logger;
2727
import org.springframework.stereotype.Component;
2828

29-
import com.cloud.maint.Version;
29+
import org.apache.cloudstack.utils.CloudStackVersion;
30+
3031
import com.cloud.upgrade.dao.VersionDao;
3132
import com.cloud.utils.component.AdapterBase;
3233
import com.cloud.utils.component.ComponentLifecycle;
@@ -210,7 +211,7 @@ private boolean checkMissedPremiumUpgradeFor228() {
210211
return false;
211212
}
212213

213-
if (Version.compare(Version.trimToPatch(dbVersion), Version.trimToPatch("2.2.8")) != 0) {
214+
if (CloudStackVersion.compare(dbVersion, "2.2.8") != 0) {
214215
txn.commit();
215216
return true;
216217
}

packaging/build-deb.sh

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,104 @@
4040
# docker run -ti -v /tmp:/src ubuntu:14.04 /bin/bash -c "apt-get update && apt-get install -y dpkg-dev python debhelper openjdk-8-jdk genisoimage python-mysql.connector maven lsb-release devscripts dh-systemd python-setuptools && /src/cloudstack/packaging/build-deb.sh"
4141
#
4242

43-
cd `dirname $0`
44-
cd ..
43+
function usage() {
44+
cat << USAGE
45+
Usage: ./build-deb.sh [OPTIONS]...
46+
Package CloudStack for Debian based distribution.
47+
48+
If there's a "branding" string in the POM version (e.g. x.y.z.a-NAME[-SNAPSHOT]), the branding name will
49+
be used in the final generated pacakge like: cloudstack-management_x.y.z.a-NAME-SNAPSHOT~xenial_all.deb
50+
note that you can override/provide "branding" string with "-b, --brand" flag as well.
51+
52+
Optional arguments:
53+
-b, --brand string Set branding to be used in package name (it will override any branding string in POM version)
54+
-T, --use-timestamp Use epoch timestamp instead of SNAPSHOT in the package name (if not provided, use "SNAPSHOT")
55+
56+
Other arguments:
57+
-h, --help Display this help message and exit
58+
59+
Examples:
60+
build-deb.sh --use-timestamp
61+
build-deb.sh --brand foo
62+
63+
USAGE
64+
exit 0
65+
}
66+
67+
BRANDING=""
68+
USE_TIMESTAMP="false"
69+
70+
while [ -n "$1" ]; do
71+
case "$1" in
72+
-h | --help)
73+
usage
74+
;;
75+
76+
-b | --brand)
77+
if [ -n "$BRANDING" ]; then
78+
echo "ERROR: you have already entered value for -b, --brand"
79+
exit 1
80+
else
81+
BRANDING=$2
82+
shift 2
83+
fi
84+
;;
85+
86+
-T | --use-timestamp)
87+
if [ "$USE_TIMESTAMP" == "true" ]; then
88+
echo "ERROR: you have already entered value for -T, --use-timestamp"
89+
exit 1
90+
else
91+
USE_TIMESTAMP="true"
92+
shift 1
93+
fi
94+
;;
95+
96+
-*|*)
97+
echo "ERROR: no such option $1. -h or --help for help"
98+
exit 1
99+
;;
100+
esac
101+
done
45102

46103
DCH=$(which dch)
47104
if [ -z "$DCH" ] ; then
48105
echo -e "dch not found, please install devscripts at first. \nDEB Build Failed"
49-
exit
106+
exit 1
50107
fi
51108

109+
NOW="$(date +%s)"
110+
PWD=$(cd $(dirname "$0") && pwd -P)
111+
cd $PWD/../
112+
52113
VERSION=$(head -n1 debian/changelog |awk -F [\(\)] '{print $2}')
53114
DISTCODE=$(lsb_release -sc)
54115

116+
if [ "$USE_TIMESTAMP" == "true" ]; then
117+
# use timestamp instead of SNAPSHOT
118+
if echo "$VERSION" | grep -q SNAPSHOT ; then
119+
# apply/override branding, if provided
120+
if [ "$BRANDING" != "" ]; then
121+
VERSION=$(echo "$VERSION" | cut -d '-' -f 1) # remove any existing branding from POM version to be overriden
122+
VERSION="$VERSION-$BRANDING-$NOW"
123+
else
124+
VERSION=`echo $VERSION | sed 's/-SNAPSHOT/-'$NOW'/g'`
125+
fi
126+
127+
branch=$(cd $PWD; git rev-parse --abbrev-ref HEAD)
128+
(cd $PWD; ./tools/build/setnextversion.sh --version $VERSION --sourcedir . --branch $branch --no-commit)
129+
fi
130+
else
131+
# apply/override branding, if provided
132+
if [ "$BRANDING" != "" ]; then
133+
VERSION=$(echo "$VERSION" | cut -d '-' -f 1) # remove any existing branding from POM version to be overriden
134+
VERSION="$VERSION-$BRANDING"
135+
136+
branch=$(cd $PWD; git rev-parse --abbrev-ref HEAD)
137+
(cd $PWD; ./tools/build/setnextversion.sh --version $VERSION --sourcedir . --branch $branch --no-commit)
138+
fi
139+
fi
140+
55141
/bin/cp debian/changelog /tmp/changelog.orig
56142

57143
dch -b -v "${VERSION}~${DISTCODE}" -u low -m "Apache CloudStack Release ${VERSION}"
@@ -61,3 +147,5 @@ dpkg-checkbuilddeps
61147
dpkg-buildpackage -uc -us -b
62148

63149
/bin/mv /tmp/changelog.orig debian/changelog
150+
151+
(cd $PWD; git reset --hard)

packaging/centos63/cloud.spec

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,8 @@
2424
Name: cloudstack
2525
Summary: CloudStack IaaS Platform
2626
#http://fedoraproject.org/wiki/PackageNamingGuidelines#Pre-Release_packages
27-
%if "%{?_prerelease}" != ""
28-
%define _maventag %{_ver}-SNAPSHOT
27+
%define _maventag %{_fullver}
2928
Release: %{_rel}%{dist}
30-
%else
31-
%define _maventag %{_ver}
32-
Release: %{_rel}%{dist}
33-
%endif
3429

3530
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
3631

packaging/centos7/cloud.spec

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,8 @@
2424
Name: cloudstack
2525
Summary: CloudStack IaaS Platform
2626
#http://fedoraproject.org/wiki/PackageNamingGuidelines#Pre-Release_packages
27-
%if "%{?_prerelease}" != ""
28-
%define _maventag %{_ver}-SNAPSHOT
27+
%define _maventag %{_fullver}
2928
Release: %{_rel}%{dist}
30-
%else
31-
%define _maventag %{_ver}
32-
Release: %{_rel}%{dist}
33-
%endif
3429

3530
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
3631

0 commit comments

Comments
 (0)