Browse code

Create custom toolchain & build maven using maven

Change-Id: I51e0dd8d761632ea74d1712f982ccf07fd10aedd
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2584
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>

harishspqr authored on 2017/05/02 10:05:20
Showing 4 changed files
... ...
@@ -1,17 +1,17 @@
1 1
 Summary:	Apache Maven
2 2
 Name:		apache-maven
3
-Version:	3.3.9
4
-Release:	8%{?dist}
3
+Version:	3.5.0
4
+Release:	1%{?dist}
5 5
 License:	Apache
6 6
 URL:		http://maven.apache.org
7 7
 Group:		Applications/System
8 8
 Vendor:		VMware, Inc.
9 9
 Distribution: 	Photon
10
-BuildArch:      noarch
10
+BuildArch:      x86_64
11 11
 Source0:	http://apache.mirrors.lucidnetworks.net//maven/source/%{name}-%{version}-src.tar.gz
12
-%define sha1 apache-maven=1912316078f1f7041dd8cd2580f210d30f898162
12
+%define sha1 apache-maven=1730812af1cdd77493e269b371ef8ac536230c15
13 13
 
14
-%define java_macros_version 1.8.0.112-2%{?dist}
14
+%define java_macros_version 1.8.0.121-1%{?dist}
15 15
 Requires: openjre >= %{java_macros_version}
16 16
 BuildRequires: openjre >= %{java_macros_version}
17 17
 BuildRequires: openjdk >= %{java_macros_version}
... ...
@@ -28,7 +28,7 @@ The Maven package contains binaries for a build system
28 28
 %prep
29 29
 
30 30
 %setup -q
31
-find . -name build.xml | xargs sed -i 's/timeout="600000"/timeout="1200000"/g'
31
+#find . -name build.xml | xargs sed -i 's/timeout="600000"/timeout="1200000"/g'
32 32
 
33 33
 %build
34 34
 MAVEN_DIST_DIR=%{_prefix}
... ...
@@ -36,29 +36,30 @@ MAVEN_DIST_DIR=%{_prefix}
36 36
 export JAVA_HOME=%{_java_home}
37 37
 export ANT_HOME=%{_ant_home}
38 38
 export PATH=$PATH:$ANT_HOME/bin
39
+source /etc/profile.d/apache-maven.sh
39 40
 
40 41
 sed -i 's/www.opensource/opensource/g' DEPENDENCIES
41
-ant -Dmaven.home=$MAVEN_DIST_DIR
42
+
43
+mvn -DdistributionTargetDir=$MAVEN_DIST_DIR clean package
42 44
 
43 45
 %install
44 46
 MAVEN_DIST_DIR=%{_prefix}
45 47
 
46 48
 [ %{buildroot} != "/" ] && rm -rf %{buildroot}/*
47
-
48 49
 mkdir -p -m 700 %{buildroot}/var/opt
49 50
 
50 51
 cp -r "$MAVEN_DIST_DIR"  %{buildroot}/var/opt
51 52
 
53
+# install exports file.
52 54
 install -d -m 755 %{buildroot}/etc/profile.d/
53
-
54 55
 echo 'export MAVEN_HOME=/var/opt/%{name}-%{version}' > %{buildroot}/etc/profile.d/%{name}.sh
55 56
 echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> %{buildroot}/etc/profile.d/%{name}.sh
56 57
 echo 'export MAVEN_OPTS=-Xms256m' >> %{buildroot}/etc/profile.d/%{name}.sh
57 58
 
58 59
 %files
59 60
 %defattr(-,root,root)
60
-%{_bindir}/*
61
-%{_libdir}/*
61
+%{_libdir}
62
+%{_bindir}
62 63
 %{_sysconfdir}/profile.d/%{name}.sh
63 64
 %{_prefix}/LICENSE
64 65
 %{_prefix}/NOTICE
... ...
@@ -67,8 +68,11 @@ echo 'export MAVEN_OPTS=-Xms256m' >> %{buildroot}/etc/profile.d/%{name}.sh
67 67
 %{_prefix}/conf/logging/simplelogger.properties
68 68
 %{_prefix}/conf/settings.xml
69 69
 %{_prefix}/conf/toolchains.xml
70
+%exclude %{_libdir}/jansi-native
70 71
 
71 72
 %changelog
73
+*   Mon Apr 24 2017 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 3.5.0-1
74
+-   Updated apache-maven to version 3.5.0
72 75
 *   Fri Mar 31 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 3.3.9-8
73 76
 -   use java rpm macros to determine versions
74 77
 *   Wed Dec 21 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 3.3.9-7
... ...
@@ -136,18 +136,24 @@ class ToolChainUtils(object):
136 136
         if retval != 0:
137 137
             self.logger.error("Installing tool chain  failed")
138 138
             raise Exception("RPM installation failed")
139
-        self.logger.info("Successfully installed all Tool Chain RPMS in Chroot:"+chrootID)
140
-        if "openjdk" in packageName or "openjre" in packageName:
141
-            self.installToolChainXRPMS(chrootID);
139
+        self.logger.info("Successfully installed default Tool Chain RPMS in Chroot:"+chrootID)
140
+        print "Building Package:"+ packageName
141
+	print constants.perPackageToolChain
142
+        if packageName in constants.perPackageToolChain:
143
+            print constants.perPackageToolChain[packageName]
144
+            self.installCustomToolChainRPMS(chrootID, constants.perPackageToolChain[packageName], packageName);
142 145
    
143
-    def installToolChainXRPMS(self, chrootID):
144
-        self.logger.info("Installing Tool Chain X package RPMS.......")
146
+    def installCustomToolChainRPMS(self, chrootID, listOfToolChainPkgs, packageName):
147
+        self.logger.info("Installing package specific tool chain RPMs for " + packageName + ".......")
145 148
         rpmFiles = ""
146 149
         packages = ""
147
-        for package in constants.listToolChainXRPMsToInstall:
150
+        for package in listOfToolChainPkgs:
148 151
             pkgUtils=PackageUtils(self.logName,self.logPath)
149 152
 	    print "DEBUG:" + package
150
-            rpmFile=self.findRPMFileInGivenLocation(package, constants.prevPublishXRPMRepo)
153
+            if "openjre" in packageName or "openjdk" in packageName:
154
+                rpmFile=self.findRPMFileInGivenLocation(package, constants.prevPublishXRPMRepo)
155
+            else:
156
+                rpmFile=self.findRPMFileInGivenLocation(package, constants.prevPublishRPMRepo)
151 157
             if rpmFile is None:
152 158
                 self.logger.error("Unable to find rpm "+ package +" in current and previous versions")
153 159
                 raise Exception("Input Error")
... ...
@@ -194,8 +194,7 @@ class constants(object):
194 194
         "cpio",
195 195
         "go"]
196 196
 
197
-    # List of X library RPMS that will be installed in a chroot prior to build openjdk & openjre package. 
198
-    listToolChainXRPMsToInstall=[
197
+    perPackageToolChain = dict.fromkeys(["openjdk", "openjdk-doc", "openjdk-src", "openjdk-sample", "openjre" ], [
199 198
         "glib-devel",
200 199
         "icu-devel",
201 200
 	"openjdk",
... ...
@@ -234,7 +233,8 @@ class constants(object):
234 234
         "libXmu-devel",
235 235
         "libXrender",
236 236
         "libXrender-devel"
237
-	]
237
+	])
238
+    perPackageToolChain["apache-maven"] = ["apache-maven"]
238 239
     # List of RPMs which are not published. They will be created during the
239 240
     # build process
240 241
     listOfRPMsProvidedAfterBuild=[
... ...
@@ -1,5 +1,6 @@
1 1
 noarch/linux-api-headers-4.2.0-1.ph1.noarch.rpm
2 2
 noarch/man-pages-3.59-1.ph1.noarch.rpm
3
+noarch/apache-maven-3.3.9-4.ph1.noarch.rpm
3 4
 x86_64/python2-devel-2.7.11-1.ph1.x86_64.rpm
4 5
 x86_64/nspr-4.11-1.ph1.x86_64.rpm
5 6
 x86_64/rpm-4.11.2-6.ph1.x86_64.rpm