... | ... |
@@ -36,6 +36,7 @@ packages: check $(PHOTON_TOOLCHAIN_MINIMAL) $(PHOTON_SOURCES) |
36 | 36 |
@echo "Building all RPMS..." |
37 | 37 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
38 | 38 |
$(PHOTON_PACKAGE_BUILDER) -a \ |
39 |
+ -b $(PHOTON_CHROOT_PATH) \ |
|
39 | 40 |
-s $(PHOTON_SPECS_DIR) \ |
40 | 41 |
-r $(PHOTON_RPMS_DIR) \ |
41 | 42 |
-o $(PHOTON_SRCS_DIR) \ |
... | ... |
@@ -1,16 +1,13 @@ |
1 | 1 |
Summary: The package automatically configure source code |
2 | 2 |
Name: autoconf |
3 | 3 |
Version: 2.69 |
4 |
-Release: 3%{?dist} |
|
4 |
+Release: 1%{?dist} |
|
5 | 5 |
License: GPLv2 |
6 | 6 |
URL: http://www.gnu.org/software/autoconf |
7 | 7 |
Group: System Environment/Base |
8 | 8 |
Vendor: VMware, Inc. |
9 |
-Distribution: Photon |
|
10 |
-Source0: http://ftp.gnu.org/gnu/autoconf/%{name}-%{version}.tar.xz |
|
11 |
-Requires: perl |
|
12 |
-BuildRequires: m4 |
|
13 |
-Requires: m4 |
|
9 |
+Distribution: Photon |
|
10 |
+Source0: http://ftp.gnu.org/gnu/autoconf/%{name}-%{version}.tar.xz |
|
14 | 11 |
%description |
15 | 12 |
The package contains programs for producing shell scripts that can |
16 | 13 |
automatically configure source code. |
... | ... |
@@ -30,9 +27,5 @@ rm -rf %{buildroot}%{_infodir} |
30 | 30 |
%{_mandir}/*/* |
31 | 31 |
%{_datarootdir}/autoconf/* |
32 | 32 |
%changelog |
33 |
-* Fri Jun 5 2015 Divya Thaluru <dthaluru@vmware.com> 2.69-3 |
|
34 |
-- Adding m4 package to build and run time required package |
|
35 |
-* Wed Jun 3 2015 Divya Thaluru <dthaluru@vmware.com> 2.69-2 |
|
36 |
-- Adding perl packages to required packages |
|
37 | 33 |
* Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 2.69-1 |
38 | 34 |
- Initial build. First version |
... | ... |
@@ -1,14 +1,13 @@ |
1 | 1 |
Summary: Programs for generating Makefiles |
2 | 2 |
Name: automake |
3 | 3 |
Version: 1.14.1 |
4 |
-Release: 2%{?dist} |
|
4 |
+Release: 1%{?dist} |
|
5 | 5 |
License: GPLv2+ |
6 | 6 |
URL: http://www.gnu.org/software/automake/ |
7 | 7 |
Group: System Environment/Base |
8 | 8 |
Vendor: VMware, Inc. |
9 |
-Distribution: Photon |
|
10 |
-Source0: http://ftp.gnu.org/gnu/automake/%{name}-%{version}.tar.xz |
|
11 |
-BuildRequires: autoconf |
|
9 |
+Distribution: Photon |
|
10 |
+Source0: http://ftp.gnu.org/gnu/automake/%{name}-%{version}.tar.xz |
|
12 | 11 |
%description |
13 | 12 |
Contains programs for generating Makefiles for use with Autoconf. |
14 | 13 |
%prep |
... | ... |
@@ -34,7 +33,5 @@ rm -rf %{buildroot}%{_infodir} |
34 | 34 |
%{_defaultdocdir}/%{name}-%{version}/* |
35 | 35 |
%{_mandir}/*/* |
36 | 36 |
%changelog |
37 |
-* Wed Jun 3 2015 Divya Thaluru <dthaluru@vmware.com> 1.14.1-2 |
|
38 |
-- Adding autoconf package to build time requires packages |
|
39 | 37 |
* Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 1.14.1-1 |
40 | 38 |
- Initial build. First version |
... | ... |
@@ -1,17 +1,13 @@ |
1 | 1 |
Summary: Contains a parser generator |
2 | 2 |
Name: bison |
3 | 3 |
Version: 3.0.2 |
4 |
-Release: 2%{?dist} |
|
4 |
+Release: 1%{?dist} |
|
5 | 5 |
License: GPLv3+ |
6 | 6 |
URL: http://www.gnu.org/software/bison |
7 | 7 |
Group: System Environment/Base |
8 | 8 |
Vendor: VMware, Inc. |
9 | 9 |
Distribution: Photon |
10 | 10 |
Source0: http://ftp.gnu.org/gnu/bison/%{name}-%{version}.tar.xz |
11 |
-BuildRequires: m4 |
|
12 |
-Requires: m4 |
|
13 |
-BuildRequires: flex |
|
14 |
-Requires: flex |
|
15 | 11 |
%description |
16 | 12 |
This package contains a parser generator |
17 | 13 |
%prep |
... | ... |
@@ -73,7 +69,5 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck} |
73 | 73 |
%lang(zh_TW) %{_datarootdir}/locale/zh_TW/LC_MESSAGES/bison-runtime.mo |
74 | 74 |
%{_mandir}/*/* |
75 | 75 |
%changelog |
76 |
-* Fri Jun 5 2015 Divya Thaluru <dthaluru@vmware.com> 3.0.2-2 |
|
77 |
-- Adding m4, flex package to build and run time required package |
|
78 | 76 |
* Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 3.0.2-1 |
79 | 77 |
- Initial build. First version. |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
Summary: Contains programs for compressing and decompressing files |
2 | 2 |
Name: bzip2 |
3 | 3 |
Version: 1.0.6 |
4 |
-Release: 3%{?dist} |
|
4 |
+Release: 2%{?dist} |
|
5 | 5 |
License: BSD |
6 | 6 |
URL: http://www.bzip.org/ |
7 | 7 |
Group: System Environment/Base |
... | ... |
@@ -15,7 +15,6 @@ decompressing files. Compressing text files with bzip2 yields a much better |
15 | 15 |
compression percentage than with the traditional gzip. |
16 | 16 |
%package devel |
17 | 17 |
Summary: Header and development files for bzip2 |
18 |
-Requires: bzip2 |
|
19 | 18 |
%description devel |
20 | 19 |
It contains the libraries and header files to create applications |
21 | 20 |
%prep |
... | ... |
@@ -73,9 +72,7 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck} |
73 | 73 |
%files devel |
74 | 74 |
%{_includedir}/bzlib.h |
75 | 75 |
%changelog |
76 |
-* Fri Jun 5 2015 Divya Thaluru <dthaluru@vmware.com> 1.0.6-3 |
|
77 |
-- Adding bzip2 package run time required package for bzip2-devel package |
|
78 |
-* Mon May 18 2015 Touseef Liaqat <tliaqat@vmware.com> 1.0.6-2 |
|
79 |
-- Update according to UsrMove. |
|
76 |
+* Mon May 18 2015 Touseef Liaqat <tliaqat@vmware.com> 1.0.6-2 |
|
77 |
+- Update according to UsrMove. |
|
80 | 78 |
* Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 1.0.6-1 |
81 | 79 |
- Initial build. First version |
... | ... |
@@ -1,14 +1,13 @@ |
1 | 1 |
Summary: Programs that show the differences between files or directories |
2 | 2 |
Name: diffutils |
3 | 3 |
Version: 3.3 |
4 |
-Release: 2%{?dist} |
|
4 |
+Release: 1%{?dist} |
|
5 | 5 |
License: GPLv3+ |
6 | 6 |
URL: http://www.gnu.org/software/diffutils |
7 | 7 |
Group: System Environment/Base |
8 | 8 |
Vendor: VMware, Inc. |
9 |
-Distribution: Photon |
|
10 |
-Source0: http://ftp.gnu.org/gnu/diffutils/%{name}-%{version}.tar.xz |
|
11 |
-BuildRequires: coreutils |
|
9 |
+Distribution: Photon |
|
10 |
+Source0: http://ftp.gnu.org/gnu/diffutils/%{name}-%{version}.tar.xz |
|
12 | 11 |
%description |
13 | 12 |
The Diffutils package contains programs that show the |
14 | 13 |
differences between files or directories. |
... | ... |
@@ -31,7 +30,5 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck} |
31 | 31 |
%{_bindir}/* |
32 | 32 |
%{_mandir}/*/* |
33 | 33 |
%changelog |
34 |
-* Wed Jun 3 2015 Divya Thaluru <dthaluru@vmware.com> 3.3-2 |
|
35 |
-- Adding coreutils package to build requires |
|
36 | 34 |
* Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 3.3-1 |
37 | 35 |
- Initial build. First version |
... | ... |
@@ -1,15 +1,13 @@ |
1 | 1 |
Summary: A utility for generating programs that recognize patterns in text |
2 | 2 |
Name: flex |
3 | 3 |
Version: 2.5.38 |
4 |
-Release: 2%{?dist} |
|
4 |
+Release: 1%{?dist} |
|
5 | 5 |
License: BSD |
6 | 6 |
URL: http://flex.sourceforge.net |
7 | 7 |
Group: Applications/System |
8 | 8 |
Vendor: VMware, Inc. |
9 | 9 |
Distribution: Photon |
10 | 10 |
Source0: http://prdownloads.sourceforge.net/flex/%{name}-%{version}.tar.bz2 |
11 |
-BuildRequires: m4 |
|
12 |
-Requires: m4 |
|
13 | 11 |
%description |
14 | 12 |
The Flex package contains a utility for generating programs |
15 | 13 |
that recognize patterns in text. |
... | ... |
@@ -51,7 +49,5 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck} |
51 | 51 |
%{_defaultdocdir}/%{name}-%{version}/* |
52 | 52 |
%{_mandir}/*/* |
53 | 53 |
%changelog |
54 |
-* Fri Jun 5 2015 Divya Thaluru <dthaluru@vmware.com> 2.5.38-2 |
|
55 |
-- Adding m4 package to build and run time required package |
|
56 | 54 |
* Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 2.5.38-1 |
57 | 55 |
- Initial build. First version |
... | ... |
@@ -75,8 +75,8 @@ cp -v -R doc/* %{buildroot}%{_defaultdocdir}/%{name}-%{version} |
75 | 75 |
%{_mandir}/man5/* |
76 | 76 |
%{_mandir}/man3/* |
77 | 77 |
%{_datadir}/terminfo/* |
78 |
-%{_libdir}/libncursesw.so.5 |
|
79 |
-%{_libdir}/libncursesw.so.5.9 |
|
78 |
+%{_lib}/libncursesw.so.5 |
|
79 |
+%{_lib}/libncursesw.so.5.9 |
|
80 | 80 |
%{_libdir}/libncurses.so |
81 | 81 |
%{_libdir}/libform.so |
82 | 82 |
%{_libdir}/libcursesw.so |
... | ... |
@@ -73,8 +73,8 @@ find %{buildroot} -name '*.la' -delete |
73 | 73 |
%{_mandir}/man1/watch.1.gz |
74 | 74 |
%{_mandir}/man1/ps.1.gz |
75 | 75 |
%{_mandir}/man5/sysctl.conf.5.gz |
76 |
-%{_libdir}/libprocps.so.3 |
|
77 |
-%{_libdir}/libprocps.so.3.0.0 |
|
76 |
+%{_lib}/libprocps.so.3 |
|
77 |
+%{_lib}/libprocps.so.3.0.0 |
|
78 | 78 |
/sbin/sysctl |
79 | 79 |
%files devel |
80 | 80 |
%{_includedir}/proc/sig.h |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
Summary: A high-level scripting language |
2 | 2 |
Name: python2 |
3 | 3 |
Version: 2.7.9 |
4 |
-Release: 2%{?dist} |
|
4 |
+Release: 1%{?dist} |
|
5 | 5 |
License: PSF |
6 | 6 |
URL: http://www.python.org/ |
7 | 7 |
Group: System Environment/Programming |
... | ... |
@@ -31,7 +31,6 @@ Requires: sqlite-autoconf |
31 | 31 |
Requires: expat >= 2.1.0 |
32 | 32 |
Requires: libffi >= 3.0.13 |
33 | 33 |
Requires: ncurses |
34 |
-Requires: coreutils |
|
35 | 34 |
BuildRequires: expat >= 2.1.0 |
36 | 35 |
BuildRequires: libffi >= 3.0.13 |
37 | 36 |
BuildRequires: sqlite-autoconf |
... | ... |
@@ -184,7 +183,5 @@ rm -rf %{buildroot}/* |
184 | 184 |
%{_bindir}/idle* |
185 | 185 |
|
186 | 186 |
%changelog |
187 |
-* Wed Jun 3 2015 Divya Thaluru <dthaluru@vmware.com> 2.7.9-2 |
|
188 |
-- Adding coreutils package to run time required package |
|
189 | 187 |
* Mon Apr 6 2015 Divya Thaluru <dthaluru@vmware.com> 2.7.9-1 |
190 | 188 |
- Initial build. First version |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
Summary: Command-line editing and history capabilities |
2 | 2 |
Name: readline |
3 | 3 |
Version: 6.3 |
4 |
-Release: 3%{?dist} |
|
4 |
+Release: 2%{?dist} |
|
5 | 5 |
License: GPLv3+ |
6 | 6 |
URL: http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html |
7 | 7 |
Group: Applications/System |
... | ... |
@@ -10,7 +10,6 @@ Distribution: Photon |
10 | 10 |
Source0: http://ftp.gnu.org/gnu/readline/%{name}-%{version}.tar.gz |
11 | 11 |
Patch: http://www.linuxfromscratch.org/patches/lfs/development/readline-6.3-upstream_fixes-3.patch |
12 | 12 |
BuildRequires: ncurses-devel |
13 |
-Requires: ncurses |
|
14 | 13 |
%description |
15 | 14 |
The Readline package is a set of libraries that offers command-line |
16 | 15 |
editing and history capabilities. |
... | ... |
@@ -41,10 +40,10 @@ rm -rf %{buildroot}%{_infodir} |
41 | 41 |
%postun -p /sbin/ldconfig |
42 | 42 |
%files |
43 | 43 |
%defattr(-,root,root) |
44 |
-%{_libdir}/libreadline.so.6 |
|
45 |
-%{_libdir}/libhistory.so.6 |
|
46 |
-%{_libdir}/libhistory.so.6.3 |
|
47 |
-%{_libdir}/libreadline.so.6.3 |
|
44 |
+%{_lib}/libreadline.so.6 |
|
45 |
+%{_lib}/libhistory.so.6 |
|
46 |
+%{_lib}/libhistory.so.6.3 |
|
47 |
+%{_lib}/libreadline.so.6.3 |
|
48 | 48 |
%{_datadir}/%{name}/hist_purgecmd.c |
49 | 49 |
%{_datadir}/%{name}/rltest.c |
50 | 50 |
%{_datadir}/%{name}/rlversion.c |
... | ... |
@@ -92,9 +91,7 @@ rm -rf %{buildroot}%{_infodir} |
92 | 92 |
%{_libdir}/libhistory.so |
93 | 93 |
%{_libdir}/libreadline.so |
94 | 94 |
%changelog |
95 |
-* Wed Jun 3 2015 Divya Thaluru <dthaluru@vmware.com> 6.3-3 |
|
96 |
-- Adding ncurses to run time require package |
|
97 |
-* Mon May 18 2015 Touseef Liaqat <tliaqat@vmware.com> 6.3-2 |
|
98 |
-- Update according to UsrMove. |
|
95 |
+* Mon May 18 2015 Touseef Liaqat <tliaqat@vmware.com> 6.3-2 |
|
96 |
+- Update according to UsrMove. |
|
99 | 97 |
* Wed Oct 22 2014 Divya Thaluru <dthaluru@vmware.com> 6.3-1 |
100 | 98 |
- Initial build. First version |
... | ... |
@@ -13,6 +13,7 @@ Source2: rpm-system-configuring-scripts-2.0.tar.gz |
13 | 13 |
#Requires: nspr |
14 | 14 |
Requires: nss |
15 | 15 |
Requires: popt |
16 |
+Requires: perl-Module-ScanDeps |
|
16 | 17 |
Requires: lua |
17 | 18 |
Requires: elfutils-libelf |
18 | 19 |
BuildRequires: python2 |
... | ... |
@@ -107,7 +108,5 @@ rm -rf %{buildroot} |
107 | 107 |
%{_libdir}/librpm.so |
108 | 108 |
|
109 | 109 |
%changelog |
110 |
-* Wed Jun 3 2015 Divya Thaluru <dthaluru@vmware.com> 4.11.2-2 |
|
111 |
-- Removing perl-module-scandeps package from run time required packages |
|
112 | 110 |
* Tue Jan 13 2015 Divya Thaluru <dthaluru@vmware.com> 4.11.2-1 |
113 | 111 |
- Initial build. First version |
... | ... |
@@ -1,13 +1,14 @@ |
1 | 1 |
Summary: Reading, writing, and converting info pages |
2 | 2 |
Name: texinfo |
3 | 3 |
Version: 5.2 |
4 |
-Release: 2%{?dist} |
|
4 |
+Release: 1%{?dist} |
|
5 | 5 |
License: GPLv3+ |
6 | 6 |
URL: http://www.gnu.org/software/texinfo/ |
7 | 7 |
Group: Applications/System |
8 | 8 |
Vendor: VMware, Inc. |
9 | 9 |
Distribution: Photon |
10 | 10 |
Source0: %{name}-%{version}.tar.xz |
11 |
+Requires: perl-libintl |
|
11 | 12 |
%description |
12 | 13 |
The Texinfo package contains programs for reading, writing, |
13 | 14 |
and converting info pages. |
... | ... |
@@ -45,7 +46,5 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck} |
45 | 45 |
%lang(pt.us-ascii) %{_datarootdir}/locale/pt.us-ascii/LC_MESSAGES/texinfo_document.mo |
46 | 46 |
%lang(pt_BR.us-ascii) %{_datarootdir}/locale/pt_BR.us-ascii/LC_MESSAGES/texinfo_document.mo |
47 | 47 |
%changelog |
48 |
-* Wed Jun 3 2015 Divya Thaluru <dthaluru@vmware.com> 5.2-2 |
|
49 |
-- Removing perl-libintl package from run-time required packages |
|
50 | 48 |
* Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 5.2-1 |
51 | 49 |
- Upgrade version |
... | ... |
@@ -60,8 +60,8 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck} |
60 | 60 |
%{_bindir}/lzmainfo |
61 | 61 |
%{_bindir}/xzgrep |
62 | 62 |
%{_bindir}/xzdec |
63 |
-%{_libdir}/liblzma.so.5.0.5 |
|
64 |
-%{_libdir}/liblzma.so.5 |
|
63 |
+%{_lib}/liblzma.so.5.0.5 |
|
64 |
+%{_lib}/liblzma.so.5 |
|
65 | 65 |
%{_mandir}/man1/* |
66 | 66 |
%{_defaultdocdir}/%{name}-%{version}/* |
67 | 67 |
%files devel |
... | ... |
@@ -33,8 +33,8 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck} |
33 | 33 |
%files |
34 | 34 |
%defattr(-,root,root) |
35 | 35 |
%{_mandir}/man3/zlib.3.gz |
36 |
-%{_libdir}/libz.so.1 |
|
37 |
-%{_libdir}/libz.so.1.2.8 |
|
36 |
+%{_lib}/libz.so.1 |
|
37 |
+%{_lib}/libz.so.1.2.8 |
|
38 | 38 |
%files devel |
39 | 39 |
%{_includedir}/zconf.h |
40 | 40 |
%{_includedir}/zlib.h |
... | ... |
@@ -34,7 +34,7 @@ PHOTON_PKG_BUILDER_DIR=$(SRCROOT)/support/package-builder |
34 | 34 |
PHOTON_PULL_SOURCES_DIR=$(SRCROOT)/support/pullsources |
35 | 35 |
PHOTON_INSTALLER_DIR=$(SRCROOT)/installer |
36 | 36 |
PHOTON_INSTALLER=$(PHOTON_INSTALLER_DIR)/photonInstaller.py |
37 |
-PHOTON_PACKAGE_BUILDER=$(PHOTON_PKG_BUILDER_DIR)/builder.py |
|
37 |
+PHOTON_PACKAGE_BUILDER=$(PHOTON_PKG_BUILDER_DIR)/build_package.py |
|
38 | 38 |
PHOTON_PULL_SOURCES=$(PHOTON_PULL_SOURCES_DIR)/pullsources.py |
39 | 39 |
PHOTON_CHROOT_CLEANER=$(PHOTON_PKG_BUILDER_DIR)/cleanup-build-root.sh |
40 | 40 |
PHOTON_RPMS_DIR_NOARCH=$(PHOTON_RPMS_DIR)/noarch |
41 | 41 |
deleted file mode 100644 |
... | ... |
@@ -1,47 +0,0 @@ |
1 |
-from Logger import Logger |
|
2 |
-from CommandUtils import CommandUtils |
|
3 |
-from constants import constants |
|
4 |
-import os.path |
|
5 |
- |
|
6 |
-class ChrootUtils(object): |
|
7 |
- |
|
8 |
- def __init__(self,logName=None,logPath=None): |
|
9 |
- if logName is None: |
|
10 |
- logName = "ChrootUtils" |
|
11 |
- if logPath is None: |
|
12 |
- logPath = constants.logPath |
|
13 |
- self.logName=logName |
|
14 |
- self.logPath=logPath |
|
15 |
- self.logger=Logger.getLogger(logName,logPath) |
|
16 |
- |
|
17 |
- def createChroot(self,chrootName): |
|
18 |
- chrootID=constants.buildRootPath+"/"+chrootName |
|
19 |
- if os.path.isdir(chrootID): |
|
20 |
- if not self.destroyChroot(chrootID): |
|
21 |
- self.logger.error("Given chroot "+chrootID+" is already exists. unable to destroy it ") |
|
22 |
- return False,None |
|
23 |
- # need to add timeout for this step |
|
24 |
- # http://stackoverflow.com/questions/1191374/subprocess-with-timeout |
|
25 |
- cmdUtils=CommandUtils() |
|
26 |
- returnVal=cmdUtils.runCommandInShell("mkdir -p "+chrootID) |
|
27 |
- if not returnVal: |
|
28 |
- self.logger.error("Unable to create chroot:"+ chrootID +".Unknown error.") |
|
29 |
- return False,None |
|
30 |
- return True,chrootID |
|
31 |
- |
|
32 |
- def destroyChroot(self,chrootID): |
|
33 |
- # need to add timeout for this step |
|
34 |
- # http://stackoverflow.com/questions/1191374/subprocess-with-timeout |
|
35 |
- cmdUtils=CommandUtils() |
|
36 |
- returnVal=cmdUtils.runCommandInShell("./cleanup-build-root.sh "+chrootID) |
|
37 |
- if not returnVal: |
|
38 |
- self.logger.error("Unable to destroy chroot:"+ chrootID +".Unknown error.") |
|
39 |
- return False |
|
40 |
- |
|
41 |
- returnVal=cmdUtils.runCommandInShell("rm -rf "+chrootID) |
|
42 |
- if not returnVal: |
|
43 |
- self.logger.error("Unable to destroy chroot:"+ chrootID +".Unknown error.") |
|
44 |
- return False |
|
45 |
- self.logger.info("Successfully destroyed chroot:"+chrootID) |
|
46 |
- return True |
|
47 |
- |
|
48 | 1 |
\ No newline at end of file |
49 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,42 +0,0 @@ |
1 |
-import subprocess |
|
2 |
-import os |
|
3 |
- |
|
4 |
-class CommandUtils(object): |
|
5 |
- def __init__(self): |
|
6 |
- self.findBinary = "find" |
|
7 |
- |
|
8 |
- def findFile (self, filename, sourcePath): |
|
9 |
- process = subprocess.Popen([self.findBinary, sourcePath, "-name", filename], stdout=subprocess.PIPE) |
|
10 |
- returnVal = process.wait() |
|
11 |
- if returnVal != 0: |
|
12 |
- return None |
|
13 |
- result=process.communicate()[0] |
|
14 |
- if result is None: |
|
15 |
- return None |
|
16 |
- return result.split() |
|
17 |
- |
|
18 |
- def runCommandInShell(self,cmd,logfilePath=None,chrootCmd=None): |
|
19 |
- if chrootCmd is not None: |
|
20 |
- cmd = chrootCmd+" "+cmd |
|
21 |
- if logfilePath is None: |
|
22 |
- logfilePath=os.devnull |
|
23 |
- logfile=open(logfilePath,"w") |
|
24 |
- process = subprocess.Popen("%s" %cmd,shell=True,stdout=logfile,stderr=logfile) |
|
25 |
- retval = process.wait() |
|
26 |
- logfile.close() |
|
27 |
- if retval==0: |
|
28 |
- return True |
|
29 |
- return False |
|
30 |
- |
|
31 |
- def runCommandInShell2(self,cmd,chrootCmd=None): |
|
32 |
- if chrootCmd is not None: |
|
33 |
- cmd = chrootCmd+" "+cmd |
|
34 |
- process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE) |
|
35 |
- retval = process.wait() |
|
36 |
- if retval != 0: |
|
37 |
- return None |
|
38 |
- result = process.communicate()[0] |
|
39 |
- if result is None: |
|
40 |
- return None |
|
41 |
- return result.split() |
|
42 |
- |
43 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,41 +0,0 @@ |
1 |
-import logging |
|
2 |
-import os |
|
3 |
- |
|
4 |
-class Logger(object): |
|
5 |
- @staticmethod |
|
6 |
- def getLogger (mymodule, logpath=None): |
|
7 |
- logfile=mymodule+".log" |
|
8 |
- if logpath is not None: |
|
9 |
- if not os.path.isdir(logpath): |
|
10 |
- os.makedirs(logpath) |
|
11 |
- logfile=logpath+"/"+logfile |
|
12 |
- logger=logging.getLogger(mymodule) |
|
13 |
- if len(logger.handlers) == 0: |
|
14 |
- #creating file handler |
|
15 |
- fhandler=logging.FileHandler(logfile) |
|
16 |
- # create console handler |
|
17 |
- ch=logging.StreamHandler() |
|
18 |
- formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') |
|
19 |
- # add formatter to handler |
|
20 |
- fhandler.setFormatter(formatter) |
|
21 |
- ch.setFormatter(formatter) |
|
22 |
- |
|
23 |
- logger.addHandler(ch) |
|
24 |
- logger.addHandler(fhandler) |
|
25 |
- logger.setLevel(logging.DEBUG) |
|
26 |
- logger.info("--------------------------------------------------------------------------") |
|
27 |
- logger.info("Staring Log") |
|
28 |
- logger.info("--------------------------------------------------------------------------") |
|
29 |
- return logger |
|
30 |
- |
|
31 |
-if __name__ == "__main__": |
|
32 |
- #Logger.getLogger("my module") |
|
33 |
- t1 = Logger.getLogger("my module") |
|
34 |
- t1.info("test1") |
|
35 |
- t2 = Logger.getLogger("my module") |
|
36 |
- t2.info("test2") |
|
37 |
- t1.info("test3") |
|
38 |
- |
|
39 |
- |
|
40 |
- |
|
41 |
- |
42 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,36 +0,0 @@ |
1 |
-import os.path |
|
2 |
- |
|
3 |
-class MiscUtils(object): |
|
4 |
- |
|
5 |
- @staticmethod |
|
6 |
- def isOutdated(listInputFiles,listOutputFiles): |
|
7 |
- thresholdTimeStamp=None |
|
8 |
- if len(listInputFiles) == 0: |
|
9 |
- return False |
|
10 |
- if len(listOutputFiles) == 0: |
|
11 |
- return True |
|
12 |
- for f in listOutputFiles: |
|
13 |
- t=os.path.getmtime(f) |
|
14 |
- if thresholdTimeStamp is None: |
|
15 |
- thresholdTimeStamp = t |
|
16 |
- if t < thresholdTimeStamp: |
|
17 |
- thresholdTimeStamp = t |
|
18 |
- for f in listInputFiles: |
|
19 |
- t=os.path.getmtime(f) |
|
20 |
- if t > thresholdTimeStamp: |
|
21 |
- return True |
|
22 |
- return False |
|
23 |
- |
|
24 |
- @staticmethod |
|
25 |
- def getListSpecFiles(listSpecFiles,path): |
|
26 |
- for dirEntry in os.listdir(path): |
|
27 |
- dirEntryPath = os.path.join(path, dirEntry) |
|
28 |
- if os.path.isfile(dirEntryPath) and dirEntryPath.endswith(".spec"): |
|
29 |
- listSpecFiles.append(dirEntryPath) |
|
30 |
- elif os.path.isdir(dirEntryPath): |
|
31 |
- MiscUtils.getListSpecFiles(listSpecFiles,dirEntryPath) |
|
32 |
- |
|
33 |
-if __name__=="__main__": |
|
34 |
- listInputFiles=["SpecParser.py","Logger.py"] |
|
35 |
- listOutputFiles=["builder.py"] |
|
36 |
- print MiscUtils.isOutdated(listInputFiles, listOutputFiles) |
|
37 | 1 |
\ No newline at end of file |
38 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,287 +0,0 @@ |
1 |
-from Logger import Logger |
|
2 |
-from constants import constants |
|
3 |
-from sets import Set |
|
4 |
-import copy |
|
5 |
- |
|
6 |
- |
|
7 |
- |
|
8 |
-def removeDuplicateEntriesInList(myList): |
|
9 |
- myListCopy=[] |
|
10 |
- for p in myList: |
|
11 |
- if p not in myListCopy: |
|
12 |
- myListCopy.append(p) |
|
13 |
- return myListCopy |
|
14 |
- |
|
15 |
-class PackageBuildDataGenerator(object): |
|
16 |
- |
|
17 |
- cycleCount=0 |
|
18 |
- |
|
19 |
- def __init__(self,logName=None,logPath=None): |
|
20 |
- if logName is None: |
|
21 |
- logName = "PackageBuildDataGenerator" |
|
22 |
- if logPath is None: |
|
23 |
- logPath = constants.logPath |
|
24 |
- self.logName=logName |
|
25 |
- self.logPath=logPath |
|
26 |
- self.logger=Logger.getLogger(logName,logPath) |
|
27 |
- self.__mapCyclesToPackageList={} |
|
28 |
- self.__mapPackageToCycle={} |
|
29 |
- self.__buildDependencyGraph={} |
|
30 |
- self.__runTimeDependencyGraph={} |
|
31 |
- self.__sortedPackageList=[] |
|
32 |
- self.__sortedBuildDependencyGraph={} |
|
33 |
- |
|
34 |
- def getPackageBuildData(self,listPackages): |
|
35 |
- self.__readDependencyGraphAndCyclesForGivenPackages(listPackages) |
|
36 |
- self.__getSortedBuildOrderListForGivenPackages(listPackages) |
|
37 |
- return self.__mapCyclesToPackageList, self.__mapPackageToCycle, self.__sortedPackageList |
|
38 |
- |
|
39 |
- #todo |
|
40 |
- def findCompleteListOfPackagesRequiredToBuildGivenPackages(self,listPackages): |
|
41 |
- return self.__buildDependencyGraph.keys() |
|
42 |
- |
|
43 |
- def createSortListForPkg(self,pkg): |
|
44 |
- runTimeDepPkgList=self.__runTimeDependencyGraph[pkg] |
|
45 |
- runTimeDepPkgList.append(pkg) |
|
46 |
- sortListForPkg=[] |
|
47 |
- |
|
48 |
- for p in runTimeDepPkgList: |
|
49 |
- basePkg=constants.specData.getSpecName(p) |
|
50 |
- for bPkg in self.__sortedBuildDependencyGraph[basePkg]: |
|
51 |
- if bPkg not in sortListForPkg: |
|
52 |
- sortListForPkg.append(bPkg) |
|
53 |
- |
|
54 |
- return sortListForPkg |
|
55 |
- |
|
56 |
- def getCircularDependentPackages(self,pkg): |
|
57 |
- circularDependentPackages=[] |
|
58 |
- if self.__mapPackageToCycle.has_key(pkg): |
|
59 |
- circularDependentPackages.extend(self.__mapCyclesToPackageList[self.__mapPackageToCycle[pkg]]) |
|
60 |
- circularDependentPackages.remove(pkg) |
|
61 |
- return circularDependentPackages |
|
62 |
- |
|
63 |
- def __getSortedBuildOrderListForGivenPackages(self,listPackages): |
|
64 |
- |
|
65 |
- alreadyProcessedPackages=[] |
|
66 |
- sortedList=[] |
|
67 |
- completeListPackagesToBuild=self.findCompleteListOfPackagesRequiredToBuildGivenPackages(listPackages) |
|
68 |
- packageIndexInSortedList = 0 |
|
69 |
- prevSortListLen=0 |
|
70 |
- |
|
71 |
- while completeListPackagesToBuild: |
|
72 |
- |
|
73 |
- # find next package to process |
|
74 |
- pkg=None |
|
75 |
- index=-1 |
|
76 |
- lenList=len(sortedList) |
|
77 |
- for i in range(lenList): |
|
78 |
- if sortedList[i] in alreadyProcessedPackages: |
|
79 |
- continue |
|
80 |
- pkg = sortedList[i] |
|
81 |
- packageIndexInSortedList = i |
|
82 |
- break |
|
83 |
- |
|
84 |
- if pkg is None: |
|
85 |
- pkg = completeListPackagesToBuild.pop() |
|
86 |
- packageIndexInSortedList = len(sortedList) |
|
87 |
- |
|
88 |
- #creating sort list for package |
|
89 |
- sortListForPkg=self.createSortListForPkg(pkg) |
|
90 |
- |
|
91 |
- #remove any cyclic packages in sortListForPkg if they already exists in sortedList |
|
92 |
- circularDependentPackages=self.getCircularDependentPackages(pkg) |
|
93 |
- for p in circularDependentPackages: |
|
94 |
- if p in sortedList and p in sortListForPkg: |
|
95 |
- sortListForPkg.remove(p) |
|
96 |
- |
|
97 |
- # insert sort list of package in global sorted list |
|
98 |
- index=packageIndexInSortedList |
|
99 |
- subList=[] |
|
100 |
- if packageIndexInSortedList > 0: |
|
101 |
- subList=sortedList[:packageIndexInSortedList] |
|
102 |
- for p in sortListForPkg: |
|
103 |
- if p not in subList: |
|
104 |
- sortedList.insert(index, p) |
|
105 |
- index = index + 1 |
|
106 |
- |
|
107 |
- alreadyProcessedPackages.append(p) |
|
108 |
- |
|
109 |
- # Remove duplicate entries in sorted list in intervals |
|
110 |
- if (len(sortedList)-prevSortListLen) > 100 : |
|
111 |
- self.logger.info("Removing duplicates in sortedList") |
|
112 |
- sortedList = removeDuplicateEntriesInList(sortedList) |
|
113 |
- else: |
|
114 |
- prevSortListLen=len(sortedList) |
|
115 |
- |
|
116 |
- self.logger.info("Removing duplicates in sorted list") |
|
117 |
- sortedList = removeDuplicateEntriesInList(sortedList) |
|
118 |
- |
|
119 |
- self.logger.info("Sorted list:") |
|
120 |
- self.logger.info(sortedList) |
|
121 |
- self.__sortedPackageList=sortedList |
|
122 |
- |
|
123 |
- def __constructBuildAndRunTimeDependencyGraph(self,package): |
|
124 |
- |
|
125 |
- basePackage=constants.specData.getSpecName(package) |
|
126 |
- |
|
127 |
- addBuildTimeGraph=True |
|
128 |
- addRunTimeGraph=True |
|
129 |
- if self.__buildDependencyGraph.has_key(basePackage): |
|
130 |
- addBuildTimeGraph = False |
|
131 |
- if self.__runTimeDependencyGraph.has_key(basePackage): |
|
132 |
- addRunTimeGraph=False |
|
133 |
- |
|
134 |
- nextPackagesToConstructGraph=[] |
|
135 |
- if addBuildTimeGraph: |
|
136 |
- listDependentRpmPackages=constants.specData.getBuildRequiresForPackage(basePackage) |
|
137 |
- listDependentPackages=[] |
|
138 |
- for rpmPkg in listDependentRpmPackages: |
|
139 |
- basePkg=constants.specData.getSpecName(rpmPkg) |
|
140 |
- if basePkg not in listDependentPackages: |
|
141 |
- listDependentPackages.append(basePkg) |
|
142 |
- self.__buildDependencyGraph[basePackage]=listDependentPackages |
|
143 |
- nextPackagesToConstructGraph.extend(listDependentPackages) |
|
144 |
- |
|
145 |
- if addRunTimeGraph: |
|
146 |
- listRpmPackages=constants.specData.getPackages(basePackage) |
|
147 |
- for rpmPkg in listRpmPackages: |
|
148 |
- listDependentRpmPackages=constants.specData.getRequiresAllForPackage(rpmPkg) |
|
149 |
- self.__runTimeDependencyGraph[rpmPkg]=listDependentRpmPackages[:] |
|
150 |
- nextPackagesToConstructGraph.extend(listDependentRpmPackages) |
|
151 |
- |
|
152 |
- for pkg in nextPackagesToConstructGraph: |
|
153 |
- self.__constructBuildAndRunTimeDependencyGraph(pkg) |
|
154 |
- |
|
155 |
- def __readDependencyGraphAndCyclesForGivenPackages(self,listPackages): |
|
156 |
- for pkg in listPackages: |
|
157 |
- self.__constructBuildAndRunTimeDependencyGraph(pkg) |
|
158 |
- |
|
159 |
- packagesToBUild=self.__buildDependencyGraph.keys() |
|
160 |
- for pkg in packagesToBUild: |
|
161 |
- sortedPackageList,circularDependentPackages = self.topologicalSortPackages(self.__buildDependencyGraph,pkg) |
|
162 |
- if len(circularDependentPackages) > 0 : |
|
163 |
- self.logger.error("Found circular dependency") |
|
164 |
- self.logger.error(circularDependentPackages) |
|
165 |
- raise Exception("Build Time Circular Dependency") |
|
166 |
- self.__sortedBuildDependencyGraph[pkg]=sortedPackageList |
|
167 |
- sortedPackageList,circularDependentPackages = self.topologicalSortPackages(self.__runTimeDependencyGraph) |
|
168 |
- if len(circularDependentPackages) > 0 : |
|
169 |
- self.__findCircularDependencies(circularDependentPackages) |
|
170 |
- |
|
171 |
- def topologicalSortPackages(self, dependencyGraph, package=None): |
|
172 |
- noDepPackages = Set() |
|
173 |
- sortedPackageList = [] |
|
174 |
- dependentOfPackage = dict() |
|
175 |
- |
|
176 |
- dependentPackages={} |
|
177 |
- if package is None: |
|
178 |
- dependentPackages=copy.deepcopy(dependencyGraph) |
|
179 |
- else: |
|
180 |
- listDepPkgs= Set() |
|
181 |
- listDepPkgs.add(package) |
|
182 |
- while listDepPkgs: |
|
183 |
- pkg = listDepPkgs.pop() |
|
184 |
- if dependentPackages.has_key(pkg): |
|
185 |
- continue |
|
186 |
- dependentPackages[pkg]=dependencyGraph[pkg][:] |
|
187 |
- for depPkg in dependencyGraph[pkg]: |
|
188 |
- listDepPkgs.add(depPkg) |
|
189 |
- |
|
190 |
- #Find packages with no dependencies and generate dependentof_package edge list |
|
191 |
- for pkg in dependentPackages: |
|
192 |
- if len(dependentPackages[pkg]) == 0: |
|
193 |
- noDepPackages.add(pkg) |
|
194 |
- else: |
|
195 |
- for depPkg in dependentPackages[pkg]: |
|
196 |
- if not dependentOfPackage.has_key(depPkg): |
|
197 |
- dependentOfPackage[depPkg]=[pkg] |
|
198 |
- else: |
|
199 |
- if pkg not in dependentOfPackage[depPkg]: |
|
200 |
- dependentOfPackage[depPkg].append(pkg) |
|
201 |
- |
|
202 |
- while noDepPackages: |
|
203 |
- pkg = noDepPackages.pop() |
|
204 |
- sortedPackageList.append(pkg) |
|
205 |
- if dependentOfPackage.get(pkg) is not None: |
|
206 |
- for childPkg in list(dependentOfPackage.get(pkg)): |
|
207 |
- dependentOfPackage.get(pkg).remove(childPkg) |
|
208 |
- dependentPackages[childPkg].remove(pkg) |
|
209 |
- if len(dependentPackages[childPkg])==0: |
|
210 |
- noDepPackages.add(childPkg) |
|
211 |
- |
|
212 |
- # creating circular dependency graph for given dependency graph |
|
213 |
- circularDependencyGraph={} |
|
214 |
- listCircularPkg = dependentPackages.keys() |
|
215 |
- for pkg in listCircularPkg: |
|
216 |
- if len(dependentPackages[pkg]) != 0: |
|
217 |
- circularDependencyGraph[pkg]=dependentPackages[pkg] |
|
218 |
- |
|
219 |
- #return (non-circular dependent package in sorted order and circular dependent package list in a dependencyGraph) |
|
220 |
- return sortedPackageList,circularDependencyGraph |
|
221 |
- |
|
222 |
- |
|
223 |
- def __constructDependencyMap(self,cyclicDependencyGraph): |
|
224 |
- self.logger.info("Constructing dependency map from circular dependency graph.....") |
|
225 |
- constructDependencyMap={} |
|
226 |
- listNodes=cyclicDependencyGraph.keys() |
|
227 |
- for node in listNodes: |
|
228 |
- tmpDepNodeList=[] |
|
229 |
- tmpDepNodeList.append(node) |
|
230 |
- depNodeList=[] |
|
231 |
- while len(tmpDepNodeList)!=0: |
|
232 |
- currentNode = tmpDepNodeList.pop() |
|
233 |
- addDepNodeList = cyclicDependencyGraph[currentNode] |
|
234 |
- depNodeList.append(currentNode) |
|
235 |
- for depNode in addDepNodeList: |
|
236 |
- if depNode in depNodeList: |
|
237 |
- continue |
|
238 |
- else: |
|
239 |
- if depNode not in tmpDepNodeList: |
|
240 |
- tmpDepNodeList.append(depNode) |
|
241 |
- depNodeList.remove(node) |
|
242 |
- constructDependencyMap[node]=depNodeList |
|
243 |
- self.logger.info("Dependency Map:") |
|
244 |
- self.logger.info(constructDependencyMap) |
|
245 |
- return constructDependencyMap |
|
246 |
- |
|
247 |
- |
|
248 |
- def __findCircularDependencies(self,cyclicDependencyGraph): |
|
249 |
- if len(cyclicDependencyGraph) == 0: |
|
250 |
- return |
|
251 |
- #step1: construct dependency map from dependency graph |
|
252 |
- constructDependencyMap=self.__constructDependencyMap(cyclicDependencyGraph) |
|
253 |
- |
|
254 |
- #step2: find cycles in dependency map |
|
255 |
- self.logger.info("Finding and adding cycles using constructed dependency map......") |
|
256 |
- cycleCount=0 |
|
257 |
- listNodes=cyclicDependencyGraph.keys() |
|
258 |
- for node in listNodes: |
|
259 |
- listDepPkg=constructDependencyMap[node] |
|
260 |
- cycPkgs=[] |
|
261 |
- if not self.__mapPackageToCycle.has_key(node): |
|
262 |
- for depPkg in listDepPkg: |
|
263 |
- x = constructDependencyMap[depPkg] |
|
264 |
- if node in x: |
|
265 |
- cycPkgs.append(depPkg) |
|
266 |
- |
|
267 |
- if len(cycPkgs) != 0: |
|
268 |
- cycPkgs.append(node) |
|
269 |
- cycleName="cycle"+str(PackageBuildDataGenerator.cycleCount) |
|
270 |
- PackageBuildDataGenerator.cycleCount=PackageBuildDataGenerator.cycleCount+1 |
|
271 |
- for x in cycPkgs: |
|
272 |
- self.__mapPackageToCycle[x]=cycleName |
|
273 |
- self.__mapCyclesToPackageList[cycleName]=cycPkgs |
|
274 |
- self.logger.info("New circular dependency found:") |
|
275 |
- self.logger.info(cycleName+" "+ ",".join(cycPkgs)) |
|
276 |
- cycleCount = cycleCount + 1 |
|
277 |
- |
|
278 |
- if cycleCount > 0 : |
|
279 |
- self.logger.info("Found "+str(cycleCount) + " cycles.") |
|
280 |
- self.logger.info("Successfully added all detected circular dependencies to list.") |
|
281 |
- else: |
|
282 |
- self.logger.info("No circular dependencies found.") |
|
283 |
- |
|
284 |
- |
|
285 |
- |
|
286 |
- |
|
287 |
- |
|
288 | 1 |
\ No newline at end of file |
289 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,160 +0,0 @@ |
1 |
-from PackageUtils import PackageUtils |
|
2 |
-from Logger import Logger |
|
3 |
-from ChrootUtils import ChrootUtils |
|
4 |
-from ToolChainUtils import ToolChainUtils |
|
5 |
-from CommandUtils import CommandUtils |
|
6 |
-import os.path |
|
7 |
-from constants import constants |
|
8 |
-import shutil |
|
9 |
- |
|
10 |
-class PackageBuilder(object): |
|
11 |
- |
|
12 |
- def __init__(self,mapPackageToCycles,listAvailableCyclicPackages,logName=None,logPath=None): |
|
13 |
- if logName is None: |
|
14 |
- logName = "PackageBuilder" |
|
15 |
- if logPath is None: |
|
16 |
- logPath = constants.logPath |
|
17 |
- self.logName=logName |
|
18 |
- self.logPath=logPath |
|
19 |
- self.logger=Logger.getLogger(logName,logPath) |
|
20 |
- self.mapPackageToCycles = mapPackageToCycles |
|
21 |
- self.listAvailableCyclicPackages = listAvailableCyclicPackages |
|
22 |
- self.listNodepsPackages = ["glibc","gmp","zlib","file","binutils","mpfr","mpc","gcc","ncurses","util-linux","groff","perl","texinfo","rpm","openssl","go"] |
|
23 |
- self.runInChrootCommand="./run-in-chroot.sh" |
|
24 |
- self.adjustGCCSpecScript="adjust-gcc-specs.sh" |
|
25 |
- |
|
26 |
- def prepareBuildRoot(self,chrootName,isToolChainPackage=False): |
|
27 |
- chrootID=None |
|
28 |
- try: |
|
29 |
- chrUtils = ChrootUtils(self.logName,self.logPath) |
|
30 |
- returnVal,chrootID = chrUtils.createChroot(chrootName) |
|
31 |
- if not returnVal: |
|
32 |
- raise Exception("Unable to prepare build root") |
|
33 |
- tUtils=ToolChainUtils(self.logName,self.logPath) |
|
34 |
- if isToolChainPackage: |
|
35 |
- tUtils.installCoreToolChainPackages(chrootID) |
|
36 |
- else: |
|
37 |
- tUtils.installToolChain(chrootID) |
|
38 |
- except Exception as e: |
|
39 |
- if chrootID is not None: |
|
40 |
- chrUtils.destroyChroot(chrootID) |
|
41 |
- raise e |
|
42 |
- return chrootID |
|
43 |
- |
|
44 |
- def findPackageNameFromRPMFile(self,rpmfile): |
|
45 |
- rpmfile=os.path.basename(rpmfile) |
|
46 |
- releaseindex=rpmfile.rfind("-") |
|
47 |
- if releaseindex == -1: |
|
48 |
- self.logger.error("Invalid rpm file:"+rpmfile) |
|
49 |
- return None |
|
50 |
- versionindex=rpmfile[0:releaseindex].rfind("-") |
|
51 |
- if versionindex == -1: |
|
52 |
- self.logger.error("Invalid rpm file:"+rpmfile) |
|
53 |
- return None |
|
54 |
- packageName=rpmfile[0:versionindex] |
|
55 |
- return packageName |
|
56 |
- |
|
57 |
- def findInstalledPackages(self,chrootID): |
|
58 |
- pkgUtils = PackageUtils(self.logName,self.logPath) |
|
59 |
- listInstalledRPMs=pkgUtils.findInstalledRPMPackages(chrootID) |
|
60 |
- listInstalledPackages=[] |
|
61 |
- for installedRPM in listInstalledRPMs: |
|
62 |
- packageName=self.findPackageNameFromRPMFile(installedRPM) |
|
63 |
- if packageName is not None: |
|
64 |
- listInstalledPackages.append(packageName) |
|
65 |
- return listInstalledPackages |
|
66 |
- |
|
67 |
- def buildPackageThreadAPI(self,package,outputMap, threadName,): |
|
68 |
- try: |
|
69 |
- self.buildPackage(package) |
|
70 |
- outputMap[threadName]=True |
|
71 |
- except Exception as e: |
|
72 |
- self.logger.error(e) |
|
73 |
- outputMap[threadName]=False |
|
74 |
- |
|
75 |
- def buildPackage(self,package): |
|
76 |
- #should initialize a logger based on package name |
|
77 |
- chrUtils = ChrootUtils(self.logName,self.logPath) |
|
78 |
- chrootName="build-"+package |
|
79 |
- chrootID=None |
|
80 |
- isToolChainPackage=False |
|
81 |
- if package in constants.listToolChainPackages: |
|
82 |
- isToolChainPackage=True |
|
83 |
- try: |
|
84 |
- chrootID = self.prepareBuildRoot(chrootName,isToolChainPackage) |
|
85 |
- destLogPath=constants.logPath+"/build-"+package |
|
86 |
- if not os.path.isdir(destLogPath): |
|
87 |
- cmdUtils = CommandUtils() |
|
88 |
- cmdUtils.runCommandInShell("mkdir -p "+destLogPath) |
|
89 |
- |
|
90 |
- listInstalledPackages=self.findInstalledPackages(chrootID) |
|
91 |
- self.logger.info("List of installed packages") |
|
92 |
- self.logger.info(listInstalledPackages) |
|
93 |
- listDependentPackages=self.findBuildTimeRequiredPackages(package) |
|
94 |
- |
|
95 |
- if len(listDependentPackages) != 0: |
|
96 |
- self.logger.info("Installing the build time dependent packages......") |
|
97 |
- for pkg in listDependentPackages: |
|
98 |
- self.installPackage(pkg,chrootID,destLogPath,listInstalledPackages) |
|
99 |
- self.logger.info("Finished installing the build time dependent packages......") |
|
100 |
- self.adjustGCCSpecs(package, chrootID, destLogPath) |
|
101 |
- pkgUtils = PackageUtils(self.logName,self.logPath) |
|
102 |
- pkgUtils.buildRPMSForGivenPackage(package,chrootID,destLogPath) |
|
103 |
- self.logger.info("Successfully built the package:"+package) |
|
104 |
- except Exception as e: |
|
105 |
- self.logger.error("Failed while building package:"+package) |
|
106 |
- raise e |
|
107 |
- finally: |
|
108 |
- if chrootID is not None: |
|
109 |
- chrUtils.destroyChroot(chrootID) |
|
110 |
- |
|
111 |
- |
|
112 |
- def findRunTimeRequiredRPMPackages(self,rpmPackage): |
|
113 |
- listRequiredPackages=constants.specData.getRequiresForPackage(rpmPackage) |
|
114 |
- return listRequiredPackages |
|
115 |
- |
|
116 |
- def findBuildTimeRequiredPackages(self,package): |
|
117 |
- listRequiredPackages=constants.specData.getBuildRequiresForPackage(package) |
|
118 |
- return listRequiredPackages |
|
119 |
- |
|
120 |
- def installPackage(self,package,chrootID,destLogPath,listInstalledPackages): |
|
121 |
- if package in listInstalledPackages: |
|
122 |
- return |
|
123 |
- self.installDependentRunTimePackages(package,chrootID,destLogPath,listInstalledPackages) |
|
124 |
- pkgUtils = PackageUtils(self.logName,self.logPath) |
|
125 |
- noDeps=False |
|
126 |
- if self.mapPackageToCycles.has_key(package): |
|
127 |
- noDeps = True |
|
128 |
- if package in self.listNodepsPackages: |
|
129 |
- noDeps=True |
|
130 |
- if package in constants.noDepsPackageList: |
|
131 |
- noDeps=True |
|
132 |
- pkgUtils.installRPM(package,chrootID,noDeps,destLogPath) |
|
133 |
- listInstalledPackages.append(package) |
|
134 |
- self.logger.info("Installed the package:"+package) |
|
135 |
- |
|
136 |
- def installDependentRunTimePackages(self,package,chrootID,destLogPath,listInstalledPackages): |
|
137 |
- listRunTimeDependentPackages=self.findRunTimeRequiredRPMPackages(package) |
|
138 |
- if len(listRunTimeDependentPackages) != 0: |
|
139 |
- for pkg in listRunTimeDependentPackages: |
|
140 |
- if self.mapPackageToCycles.has_key(pkg) and pkg not in self.listAvailableCyclicPackages: |
|
141 |
- continue |
|
142 |
- if pkg in listInstalledPackages: |
|
143 |
- continue |
|
144 |
- self.installPackage(pkg,chrootID,destLogPath,listInstalledPackages) |
|
145 |
- |
|
146 |
- def adjustGCCSpecs(self, package, chrootID, logPath): |
|
147 |
- opt = "" |
|
148 |
- # linux package does not require sec gcc options |
|
149 |
- if package == "linux" or package == "glibc": |
|
150 |
- opt = " clean" |
|
151 |
- |
|
152 |
- shutil.copy2(self.adjustGCCSpecScript, chrootID+"/tmp/"+self.adjustGCCSpecScript) |
|
153 |
- cmdUtils=CommandUtils() |
|
154 |
- cmd = "/tmp/"+self.adjustGCCSpecScript+opt |
|
155 |
- logFile = logPath+"/adjustGCCSpecScript.log" |
|
156 |
- chrootCmd=self.runInChrootCommand+" "+chrootID |
|
157 |
- returnVal = cmdUtils.runCommandInShell(cmd, logFile, chrootCmd) |
|
158 |
- if not returnVal: |
|
159 |
- self.logger.error("Failed while adjusting gcc specs") |
|
160 |
- raise "Failed while adjusting gcc specs" |
|
161 | 1 |
\ No newline at end of file |
162 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,185 +0,0 @@ |
1 |
-from PackageBuildDataGenerator import PackageBuildDataGenerator |
|
2 |
-from Logger import Logger |
|
3 |
-import threading |
|
4 |
-from constants import constants |
|
5 |
-import os |
|
6 |
-from PackageUtils import PackageUtils |
|
7 |
-from ToolChainUtils import ToolChainUtils |
|
8 |
-from Scheduler import Scheduler |
|
9 |
-from ThreadPool import ThreadPool |
|
10 |
-import subprocess |
|
11 |
- |
|
12 |
-class PackageManager(object): |
|
13 |
- |
|
14 |
- def __init__(self,logName=None,logPath=None): |
|
15 |
- if logName is None: |
|
16 |
- logName = "PackageManager" |
|
17 |
- if logPath is None: |
|
18 |
- logPath = constants.logPath |
|
19 |
- self.logName=logName |
|
20 |
- self.logPath=logPath |
|
21 |
- self.logger=Logger.getLogger(logName,logPath) |
|
22 |
- self.mapCyclesToPackageList={} |
|
23 |
- self.mapPackageToCycle={} |
|
24 |
- self.sortedPackageList=[] |
|
25 |
- self.listOfPackagesAlreadyBuilt = [] |
|
26 |
- self.listThreads={} |
|
27 |
- self.mapOutputThread={} |
|
28 |
- self.mapThreadsLaunchTime={} |
|
29 |
- self.listAvailableCyclicPackages=[] |
|
30 |
- self.listPackagesToBuild=[] |
|
31 |
- |
|
32 |
- def readPackageBuildData(self, listPackages): |
|
33 |
- try: |
|
34 |
- pkgBuildDataGen = PackageBuildDataGenerator(self.logName,self.logPath) |
|
35 |
- self.mapCyclesToPackageList,self.mapPackageToCycle,self.sortedPackageList = pkgBuildDataGen.getPackageBuildData(listPackages) |
|
36 |
- except: |
|
37 |
- self.logger.error("unable to get sorted list") |
|
38 |
- return False |
|
39 |
- return True |
|
40 |
- |
|
41 |
- def readAlreadyAvailablePackages(self): |
|
42 |
- listAvailablePackages=[] |
|
43 |
- listRPMFiles=[] |
|
44 |
- listDirectorys=[] |
|
45 |
- listDirectorys.append(constants.rpmPath) |
|
46 |
- |
|
47 |
- while len(listDirectorys) > 0: |
|
48 |
- dirPath=listDirectorys.pop() |
|
49 |
- for dirEntry in os.listdir(dirPath): |
|
50 |
- dirEntryPath = os.path.join(dirPath, dirEntry) |
|
51 |
- if os.path.isfile(dirEntryPath) and dirEntryPath.endswith(".rpm"): |
|
52 |
- listRPMFiles.append(dirEntryPath) |
|
53 |
- elif os.path.isdir(dirEntryPath): |
|
54 |
- listDirectorys.append(dirEntryPath) |
|
55 |
- pkgUtils = PackageUtils(self.logName,self.logPath) |
|
56 |
- for rpmfile in listRPMFiles: |
|
57 |
- package = pkgUtils.findPackageNameFromRPMFile(rpmfile) |
|
58 |
- listAvailablePackages.append(package) |
|
59 |
- return listAvailablePackages |
|
60 |
- |
|
61 |
- def calculateParams(self,listPackages): |
|
62 |
- self.listThreads.clear() |
|
63 |
- self.mapOutputThread.clear() |
|
64 |
- self.mapThreadsLaunchTime.clear() |
|
65 |
- self.listAvailableCyclicPackages=[] |
|
66 |
- self.mapCyclesToPackageList.clear() |
|
67 |
- self.mapPackageToCycle.clear() |
|
68 |
- self.sortedPackageList=[] |
|
69 |
- self.listPackagesToBuild=[] |
|
70 |
- |
|
71 |
- if not self.readPackageBuildData(listPackages): |
|
72 |
- return False |
|
73 |
- |
|
74 |
- self.listOfPackagesAlreadyBuilt = self.readAlreadyAvailablePackages() |
|
75 |
- |
|
76 |
- self.listPackagesToBuild=self.sortedPackageList[:] |
|
77 |
- for pkg in self.sortedPackageList: |
|
78 |
- if pkg in self.listOfPackagesAlreadyBuilt: |
|
79 |
- self.listPackagesToBuild.remove(pkg) |
|
80 |
- |
|
81 |
- self.logger.info(self.listPackagesToBuild) |
|
82 |
- self.logger.info(listPackages) |
|
83 |
- |
|
84 |
- return True |
|
85 |
- |
|
86 |
- def buildToolChain(self): |
|
87 |
- try: |
|
88 |
- tUtils=ToolChainUtils() |
|
89 |
- tUtils.buildCoreToolChainPackages() |
|
90 |
- except Exception as e: |
|
91 |
- self.logger.error("Unable to build tool chain") |
|
92 |
- self.logger.error(e) |
|
93 |
- return False |
|
94 |
- |
|
95 |
- return True |
|
96 |
- |
|
97 |
- def calculatePossibleNumWorkerThreads(self): |
|
98 |
- process = subprocess.Popen(["df" ,constants.buildRootPath],shell=True,stdout=subprocess.PIPE) |
|
99 |
- retval = process.wait() |
|
100 |
- if retval != 0: |
|
101 |
- self.logger.error("Unable to check free space. Unknown error.") |
|
102 |
- return False |
|
103 |
- output = process.communicate()[0] |
|
104 |
- device, size, used, available, percent, mountpoint = output.split("\n")[1].split() |
|
105 |
- c = int(available)/600000 |
|
106 |
- numChroots=int(c) |
|
107 |
- self.logger.info("Possible number of worker threads:"+str(numChroots)) |
|
108 |
- return numChroots |
|
109 |
- |
|
110 |
- def buildToolChainPackages(self): |
|
111 |
- if not self.buildToolChain(): |
|
112 |
- return False |
|
113 |
- return self.buildGivenPackages(constants.listToolChainPackages) |
|
114 |
- |
|
115 |
- def buildPackages(self,listPackages): |
|
116 |
- if not self.buildToolChainPackages(): |
|
117 |
- return False |
|
118 |
- return self.buildGivenPackages(listPackages) |
|
119 |
- |
|
120 |
- def initializeThreadPool(self,statusEvent): |
|
121 |
- ThreadPool.clear() |
|
122 |
- ThreadPool.mapPackageToCycle=self.mapPackageToCycle |
|
123 |
- ThreadPool.listAvailableCyclicPackages=self.listAvailableCyclicPackages |
|
124 |
- ThreadPool.logger=self.logger |
|
125 |
- ThreadPool.statusEvent=statusEvent |
|
126 |
- |
|
127 |
- def initializeScheduler(self,statusEvent): |
|
128 |
- Scheduler.setLog(self.logName, self.logPath) |
|
129 |
- Scheduler.setParams(self.sortedPackageList, self.listOfPackagesAlreadyBuilt) |
|
130 |
- Scheduler.setEvent(statusEvent) |
|
131 |
- Scheduler.stopScheduling=False |
|
132 |
- |
|
133 |
- def buildGivenPackages (self, listPackages): |
|
134 |
- returnVal=self.calculateParams(listPackages) |
|
135 |
- if not returnVal: |
|
136 |
- self.logger.error("Unable to set paramaters. Terminating the package manager.") |
|
137 |
- return False |
|
138 |
- |
|
139 |
- statusEvent=threading.Event() |
|
140 |
- numWorkerThreads=self.calculatePossibleNumWorkerThreads() |
|
141 |
- if numWorkerThreads > 8: |
|
142 |
- numWorkerThreads = 8 |
|
143 |
- if numWorkerThreads == 0: |
|
144 |
- return False |
|
145 |
- |
|
146 |
- self.initializeScheduler(statusEvent) |
|
147 |
- self.initializeThreadPool(statusEvent) |
|
148 |
- |
|
149 |
- i=0 |
|
150 |
- while i < numWorkerThreads: |
|
151 |
- workerName="WorkerThread"+str(i) |
|
152 |
- ThreadPool.addWorkerThread(workerName) |
|
153 |
- ThreadPool.startWorkerThread(workerName) |
|
154 |
- i = i + 1 |
|
155 |
- |
|
156 |
- statusEvent.wait() |
|
157 |
- Scheduler.stopScheduling=True |
|
158 |
- self.logger.info("Waiting for all remaining worker threads") |
|
159 |
- listWorkerObjs=ThreadPool.getAllWorkerObjects() |
|
160 |
- for w in listWorkerObjs: |
|
161 |
- w.join() |
|
162 |
- |
|
163 |
- setFailFlag=False |
|
164 |
- allPackagesBuilt=False |
|
165 |
- |
|
166 |
- if Scheduler.isAnyPackagesFailedToBuild(): |
|
167 |
- setFailFlag=True |
|
168 |
- |
|
169 |
- if Scheduler.isAllPackagesBuilt(): |
|
170 |
- allPackagesBuilt=True |
|
171 |
- |
|
172 |
- if setFailFlag: |
|
173 |
- self.logger.error("Some of the packages failed:") |
|
174 |
- self.logger.error(Scheduler.listOfFailedPackages) |
|
175 |
- return False |
|
176 |
- |
|
177 |
- if not setFailFlag: |
|
178 |
- if allPackagesBuilt: |
|
179 |
- self.logger.info("All packages built successfully") |
|
180 |
- else: |
|
181 |
- self.logger.error("Build stopped unexpectedly.Unknown error.") |
|
182 |
- return False |
|
183 |
- |
|
184 |
- self.logger.info("Terminated") |
|
185 |
- return True |
186 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,176 +0,0 @@ |
1 |
-from CommandUtils import CommandUtils |
|
2 |
-from Logger import Logger |
|
3 |
-import os |
|
4 |
-import shutil |
|
5 |
-from constants import constants |
|
6 |
-import re |
|
7 |
- |
|
8 |
- |
|
9 |
-class PackageUtils(object): |
|
10 |
- |
|
11 |
- def __init__(self,logName=None,logPath=None): |
|
12 |
- if logName is None: |
|
13 |
- self.logName = "PackageUtils" |
|
14 |
- if logPath is None: |
|
15 |
- logPath = constants.logPath |
|
16 |
- self.logName=logName |
|
17 |
- self.logPath=logPath |
|
18 |
- self.logger=Logger.getLogger(logName,logPath) |
|
19 |
- self.runInChrootCommand="./run-in-chroot.sh" |
|
20 |
- self.rpmBinary = "rpm" |
|
21 |
- self.installRPMPackageOptions = "-Uvh" |
|
22 |
- self.nodepsRPMPackageOptions = "--nodeps" |
|
23 |
- |
|
24 |
- self.rpmbuildBinary = "rpmbuild" |
|
25 |
- self.rpmbuildBuildallOption = "-ba" |
|
26 |
- self.rpmbuildNocheckOption = "--nocheck" |
|
27 |
- self.queryRpmPackageOptions = "-qa" |
|
28 |
- self.forceRpmPackageOptions = "--force" |
|
29 |
- |
|
30 |
- def getRPMDestDir(self,rpmName,rpmDir): |
|
31 |
- arch="" |
|
32 |
- if rpmName.find("x86_64") != -1: |
|
33 |
- arch='x86_64' |
|
34 |
- elif rpmName.find("noarch") != -1: |
|
35 |
- arch="noarch" |
|
36 |
- rpmDestDir=rpmDir+"/"+arch |
|
37 |
- return rpmDestDir |
|
38 |
- |
|
39 |
- def copyRPM(self,rpmFile,destDir): |
|
40 |
- cmdUtils = CommandUtils() |
|
41 |
- rpmName=os.path.basename(rpmFile) |
|
42 |
- rpmDestDir=self.getRPMDestDir(rpmName,destDir) |
|
43 |
- if not os.path.isdir(rpmDestDir): |
|
44 |
- cmdUtils.runCommandInShell("mkdir -p "+rpmDestDir) |
|
45 |
- rpmDestPath=rpmDestDir+"/"+rpmName |
|
46 |
- shutil.copyfile(rpmFile, rpmDestPath) |
|
47 |
- return rpmDestPath |
|
48 |
- |
|
49 |
- def installRPM(self,package,chrootID,noDeps=False,destLogPath=None): |
|
50 |
- self.logger.info("Installing rpm for package:"+package) |
|
51 |
- self.logger.debug("No deps:"+str(noDeps)) |
|
52 |
- |
|
53 |
- rpmfile=self.findRPMFileForGivenPackage(package) |
|
54 |
- if rpmfile is None: |
|
55 |
- self.logger.error("No rpm file found for package:"+package) |
|
56 |
- raise Exception("Missing rpm file") |
|
57 |
- |
|
58 |
- rpmDestFile = self.copyRPM(rpmfile, chrootID+constants.topDirPath+"/RPMS") |
|
59 |
- rpmFile=rpmDestFile.replace(chrootID,"") |
|
60 |
- chrootCmd=self.runInChrootCommand+" "+chrootID |
|
61 |
- logFile=chrootID+constants.topDirPath+"/LOGS"+"/"+package+".completed" |
|
62 |
- |
|
63 |
- rpmInstallcmd=self.rpmBinary+" "+ self.installRPMPackageOptions |
|
64 |
- if noDeps: |
|
65 |
- rpmInstallcmd+=" "+self.nodepsRPMPackageOptions |
|
66 |
- rpmInstallcmd+=" "+rpmFile |
|
67 |
- |
|
68 |
- cmdUtils = CommandUtils() |
|
69 |
- returnVal = cmdUtils.runCommandInShell(rpmInstallcmd, logFile, chrootCmd) |
|
70 |
- if destLogPath is not None: |
|
71 |
- shutil.copy2(logFile, destLogPath) |
|
72 |
- if not returnVal: |
|
73 |
- self.logger.error("Unable to install rpm:"+ rpmFile) |
|
74 |
- raise Exception("RPM installation failed") |
|
75 |
- |
|
76 |
- def copySourcesTobuildroot(self,listSourceFiles,package,destDir): |
|
77 |
- cmdUtils = CommandUtils() |
|
78 |
- for source in listSourceFiles: |
|
79 |
- sourcePath = cmdUtils.findFile(source,constants.sourcePath) |
|
80 |
- if sourcePath is None or len(sourcePath) == 0: |
|
81 |
- sourcePath = cmdUtils.findFile(source,constants.specPath) |
|
82 |
- if sourcePath is None or len(sourcePath) == 0: |
|
83 |
- self.logger.error("Missing source: "+source+". Cannot find sources for package: "+package) |
|
84 |
- raise Exception("Missing source") |
|
85 |
- if len(sourcePath) > 1: |
|
86 |
- self.logger.error("Multiple sources found for source:"+source+"\n"+ ",".join(sourcePath) +"\nUnable to determine one.") |
|
87 |
- raise Exception("Multiple sources found") |
|
88 |
- self.logger.info("Source path :" + source + " Source filename: " + sourcePath[0]) |
|
89 |
- shutil.copy2(sourcePath[0], destDir) |
|
90 |
- |
|
91 |
- def buildRPMSForGivenPackage(self,package, chrootID,destLogPath=None): |
|
92 |
- self.logger.info("Building rpm's for package:"+package) |
|
93 |
- |
|
94 |
- listSourcesFiles = constants.specData.getSources(package) |
|
95 |
- listPatchFiles = constants.specData.getPatches(package) |
|
96 |
- specFile = constants.specData.getSpecFile(package) |
|
97 |
- specName = constants.specData.getSpecName(package) + ".spec" |
|
98 |
- |
|
99 |
- chrootSourcePath=chrootID+constants.topDirPath+"/SOURCES/" |
|
100 |
- chrootSpecPath=constants.topDirPath+"/SPECS/" |
|
101 |
- chrootLogsFilePath=chrootID+constants.topDirPath+"/LOGS/"+package+".log" |
|
102 |
- chrootCmd=self.runInChrootCommand+" "+chrootID |
|
103 |
- shutil.copyfile(specFile, chrootID+chrootSpecPath+specName ) |
|
104 |
- |
|
105 |
- self.copySourcesTobuildroot(listSourcesFiles,package,chrootSourcePath) |
|
106 |
- self.copySourcesTobuildroot(listPatchFiles,package,chrootSourcePath) |
|
107 |
- |
|
108 |
- listRPMFiles=[] |
|
109 |
- try: |
|
110 |
- listRPMFiles = self.buildRPM(chrootSpecPath+"/"+specName,chrootLogsFilePath, chrootCmd) |
|
111 |
- except Exception as e: |
|
112 |
- self.logger.error("Failed while building rpm:"+package) |
|
113 |
- raise e |
|
114 |
- finally: |
|
115 |
- if destLogPath is not None: |
|
116 |
- shutil.copy2(chrootLogsFilePath, destLogPath) |
|
117 |
- |
|
118 |
- for rpmFile in listRPMFiles: |
|
119 |
- self.copyRPM(chrootID+"/"+rpmFile, constants.rpmPath) |
|
120 |
- |
|
121 |
- def buildRPM(self,specFile,logFile,chrootCmd): |
|
122 |
- |
|
123 |
- rpmBuildcmd= self.rpmbuildBinary+" "+self.rpmbuildBuildallOption+" "+self.rpmbuildNocheckOption |
|
124 |
- rpmBuildcmd+=" "+specFile |
|
125 |
- |
|
126 |
- cmdUtils = CommandUtils() |
|
127 |
- returnVal = cmdUtils.runCommandInShell(rpmBuildcmd, logFile, chrootCmd) |
|
128 |
- if not returnVal: |
|
129 |
- self.logger.error("Building rpm is failed "+specFile) |
|
130 |
- raise Exception("RPM Build failed") |
|
131 |
- |
|
132 |
- #Extracting rpms created from log file |
|
133 |
- logfile=open(logFile,'r') |
|
134 |
- fileContents=logfile.readlines() |
|
135 |
- logfile.close() |
|
136 |
- listRPMFiles=[] |
|
137 |
- for i in range(0,len(fileContents)): |
|
138 |
- if re.search("^Wrote:",fileContents[i]): |
|
139 |
- listcontents=fileContents[i].split() |
|
140 |
- if (len(listcontents) == 2) and listcontents[1].strip()[-4:] == ".rpm" and listcontents[1].find("/RPMS/") != -1: |
|
141 |
- listRPMFiles.append(listcontents[1]) |
|
142 |
- |
|
143 |
- return listRPMFiles |
|
144 |
- |
|
145 |
- def findRPMFileForGivenPackage(self,package): |
|
146 |
- cmdUtils = CommandUtils() |
|
147 |
- version = constants.specData.getVersion(package) |
|
148 |
- release = constants.specData.getRelease(package) |
|
149 |
- listFoundRPMFiles = cmdUtils.findFile(package+"-"+version+"-"+release+"*.rpm",constants.rpmPath) |
|
150 |
- if len(listFoundRPMFiles) == 1 : |
|
151 |
- return listFoundRPMFiles[0] |
|
152 |
- if len(listFoundRPMFiles) == 0 : |
|
153 |
- return None |
|
154 |
- if len(listFoundRPMFiles) > 1 : |
|
155 |
- self.logger.error("Found multiple rpm files for given package in rpm directory.Unable to determine the rpm file for package:"+package) |
|
156 |
- raise Exception("Multiple rpm files found") |
|
157 |
- |
|
158 |
- def findPackageNameFromRPMFile(self,rpmfile): |
|
159 |
- rpmfile=os.path.basename(rpmfile) |
|
160 |
- releaseindex=rpmfile.rfind("-") |
|
161 |
- if releaseindex == -1: |
|
162 |
- self.logger.error("Invalid rpm file:"+rpmfile) |
|
163 |
- raise Exception("Invalid RPM") |
|
164 |
- versionindex=rpmfile[0:releaseindex].rfind("-") |
|
165 |
- if versionindex == -1: |
|
166 |
- self.logger.error("Invalid rpm file:"+rpmfile) |
|
167 |
- raise Exception("Invalid RPM") |
|
168 |
- packageName=rpmfile[0:versionindex] |
|
169 |
- return packageName |
|
170 |
- |
|
171 |
- def findInstalledRPMPackages(self, chrootID): |
|
172 |
- cmd = self.rpmBinary+" "+self.queryRpmPackageOptions |
|
173 |
- chrootCmd=self.runInChrootCommand+" "+chrootID |
|
174 |
- cmdUtils=CommandUtils() |
|
175 |
- result=cmdUtils.runCommandInShell2(cmd, chrootCmd) |
|
176 |
- return result |
177 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,133 +0,0 @@ |
1 |
-import ThreadPool |
|
2 |
-from constants import constants |
|
3 |
-from Logger import Logger |
|
4 |
-import threading |
|
5 |
- |
|
6 |
-class Scheduler(object): |
|
7 |
- |
|
8 |
- lock=threading.Lock() |
|
9 |
- listOfAlreadyBuiltPackages=[] |
|
10 |
- listOfPackagesToBuild=[] |
|
11 |
- listOfPackagesCurrentlyBuilding=[] |
|
12 |
- sortedList=[] |
|
13 |
- listOfPackagesNextToBuild=[] |
|
14 |
- listOfFailedPackages=[] |
|
15 |
- logger=None |
|
16 |
- event=None |
|
17 |
- stopScheduling=False |
|
18 |
- |
|
19 |
- @staticmethod |
|
20 |
- def setEvent(event): |
|
21 |
- Scheduler.event=event |
|
22 |
- |
|
23 |
- @staticmethod |
|
24 |
- def setLog(logName,logPath): |
|
25 |
- Scheduler.logger = Logger.getLogger(logName, logPath) |
|
26 |
- |
|
27 |
- @staticmethod |
|
28 |
- def setParams(sortedList,listOfAlreadyBuiltPackages): |
|
29 |
- Scheduler.sortedList=sortedList |
|
30 |
- Scheduler.listOfAlreadyBuiltPackages=listOfAlreadyBuiltPackages |
|
31 |
- for x in Scheduler.sortedList: |
|
32 |
- if x not in Scheduler.listOfAlreadyBuiltPackages: |
|
33 |
- Scheduler.listOfPackagesToBuild.append(x) |
|
34 |
- Scheduler.listOfPackagesCurrentlyBuilding=[] |
|
35 |
- Scheduler.listOfPackagesNextToBuild=[] |
|
36 |
- Scheduler.listOfFailedPackages=[] |
|
37 |
- |
|
38 |
- @staticmethod |
|
39 |
- def getRequiredPackages(package): |
|
40 |
- listRequiredRPMPackages=[] |
|
41 |
- listRequiredRPMPackages.extend(constants.specData.getBuildRequiresForPackage(package)) |
|
42 |
- listRequiredRPMPackages.extend(constants.specData.getRequiresAllForPackage(package)) |
|
43 |
- |
|
44 |
- listRequiredPackages=[] |
|
45 |
- for pkg in listRequiredRPMPackages: |
|
46 |
- basePkg=constants.specData.getSpecName(pkg) |
|
47 |
- if basePkg not in listRequiredPackages: |
|
48 |
- listRequiredPackages.append(basePkg) |
|
49 |
- |
|
50 |
- return listRequiredPackages |
|
51 |
- |
|
52 |
- @staticmethod |
|
53 |
- def __getListNextPackagesReadyToBuild(): |
|
54 |
- listOfPackagesNextToBuild=[] |
|
55 |
- Scheduler.logger.info("Checking for next possible packages to build") |
|
56 |
- for pkg in Scheduler.listOfPackagesToBuild: |
|
57 |
- if pkg in Scheduler.listOfPackagesCurrentlyBuilding: |
|
58 |
- continue |
|
59 |
- listRequiredPackages=Scheduler.getRequiredPackages(pkg) |
|
60 |
- canBuild=True |
|
61 |
- Scheduler.logger.info("Required packages for "+ pkg + " are:") |
|
62 |
- Scheduler.logger.info(listRequiredPackages) |
|
63 |
- for reqPkg in listRequiredPackages: |
|
64 |
- if reqPkg not in Scheduler.listOfAlreadyBuiltPackages: |
|
65 |
- canBuild=False |
|
66 |
- Scheduler.logger.info(reqPkg+" is not available. So we cannot build "+ pkg +" at this moment.") |
|
67 |
- break |
|
68 |
- if canBuild: |
|
69 |
- listOfPackagesNextToBuild.append(pkg) |
|
70 |
- Scheduler.logger.info("Adding "+ pkg +" to the schedule list") |
|
71 |
- return listOfPackagesNextToBuild |
|
72 |
- |
|
73 |
- @staticmethod |
|
74 |
- def getNextPackageToBuild(): |
|
75 |
- Scheduler.logger.info("Waiting to acquire scheduler lock") |
|
76 |
- Scheduler.lock.acquire() |
|
77 |
- |
|
78 |
- if Scheduler.stopScheduling: |
|
79 |
- Scheduler.logger.info("Released scheduler lock") |
|
80 |
- Scheduler.lock.release() |
|
81 |
- return None |
|
82 |
- |
|
83 |
- if len(Scheduler.listOfPackagesToBuild) == 0: |
|
84 |
- if Scheduler.event is not None: |
|
85 |
- Scheduler.event.set() |
|
86 |
- |
|
87 |
- if len(Scheduler.listOfPackagesNextToBuild) == 0: |
|
88 |
- listOfPackagesNextToBuild=Scheduler.__getListNextPackagesReadyToBuild() |
|
89 |
- Scheduler.listOfPackagesNextToBuild=listOfPackagesNextToBuild |
|
90 |
- |
|
91 |
- if len(Scheduler.listOfPackagesNextToBuild) == 0: |
|
92 |
- Scheduler.logger.info("Released scheduler lock") |
|
93 |
- Scheduler.lock.release() |
|
94 |
- return None |
|
95 |
- |
|
96 |
- package=Scheduler.listOfPackagesNextToBuild.pop(0) |
|
97 |
- |
|
98 |
- if len(Scheduler.listOfPackagesNextToBuild) > 0: |
|
99 |
- ThreadPool.ThreadPool.activateWorkerThreads(len(Scheduler.listOfPackagesNextToBuild)) |
|
100 |
- Scheduler.logger.info("Released scheduler lock") |
|
101 |
- Scheduler.lock.release() |
|
102 |
- Scheduler.listOfPackagesCurrentlyBuilding.append(package) |
|
103 |
- Scheduler.listOfPackagesToBuild.remove(package) |
|
104 |
- return package |
|
105 |
- |
|
106 |
- #can be synchronized TODO |
|
107 |
- @staticmethod |
|
108 |
- def notifyPackageBuildCompleted(package): |
|
109 |
- if package in Scheduler.listOfPackagesCurrentlyBuilding: |
|
110 |
- Scheduler.listOfPackagesCurrentlyBuilding.remove(package) |
|
111 |
- Scheduler.listOfAlreadyBuiltPackages.append(package) |
|
112 |
- |
|
113 |
- |
|
114 |
- #can be synchronized TODO |
|
115 |
- @staticmethod |
|
116 |
- def notifyPackageBuildFailed(package): |
|
117 |
- if package in Scheduler.listOfPackagesCurrentlyBuilding: |
|
118 |
- Scheduler.listOfPackagesCurrentlyBuilding.remove(package) |
|
119 |
- Scheduler.listOfFailedPackages.append(package) |
|
120 |
- |
|
121 |
- @staticmethod |
|
122 |
- def isAllPackagesBuilt(): |
|
123 |
- if len(Scheduler.listOfPackagesToBuild) == 0 : |
|
124 |
- return True |
|
125 |
- return False |
|
126 |
- |
|
127 |
- @staticmethod |
|
128 |
- def isAnyPackagesFailedToBuild(): |
|
129 |
- if len(Scheduler.listOfFailedPackages) != 0: |
|
130 |
- return True |
|
131 |
- return False |
|
132 |
- |
|
133 |
- |
|
134 | 1 |
\ No newline at end of file |
135 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,173 +0,0 @@ |
1 |
-from SpecUtils import Specutils |
|
2 |
-import os |
|
3 |
-from Logger import Logger |
|
4 |
- |
|
5 |
-class SerializableSpecObject(object): |
|
6 |
- def __init__(self): |
|
7 |
- self.listPackages=[] |
|
8 |
- self.name="" |
|
9 |
- self.version="" |
|
10 |
- self.release="" |
|
11 |
- self.buildRequirePackages=[] |
|
12 |
- self.installRequiresAllPackages=[] |
|
13 |
- self.installRequiresPackages={} |
|
14 |
- self.specFile="" |
|
15 |
- self.listSources=[] |
|
16 |
- self.listPatches=[] |
|
17 |
- |
|
18 |
-class SerializableSpecObjectsUtils(object): |
|
19 |
- |
|
20 |
- def __init__(self,logPath): |
|
21 |
- self.mapSerializableSpecObjects={} |
|
22 |
- self.mapPackageToSpec={} |
|
23 |
- self.logger=Logger.getLogger("Serializable Spec objects", logPath ) |
|
24 |
- |
|
25 |
- def readSpecsAndConvertToSerializableObjects(self,specFilesPath): |
|
26 |
- listSpecFiles=[] |
|
27 |
- self.getListSpecFiles(listSpecFiles,specFilesPath) |
|
28 |
- for specFile in listSpecFiles: |
|
29 |
- spec=Specutils(specFile) |
|
30 |
- specName=os.path.basename(specFile) |
|
31 |
- specName=specName.replace(".spec","") |
|
32 |
- specObj=SerializableSpecObject() |
|
33 |
- specObj.name=specName |
|
34 |
- specObj.buildRequirePackages=spec.getBuildRequiresAllPackages() |
|
35 |
- specObj.installRequiresAllPackages=spec.getRequiresAllPackages() |
|
36 |
- specObj.listPackages=spec.getPackageNames() |
|
37 |
- specObj.specFile=specFile |
|
38 |
- specObj.version=spec.getVersion() |
|
39 |
- specObj.release=spec.getRelease() |
|
40 |
- specObj.listSources=spec.getSourceNames() |
|
41 |
- specObj.listPatches=spec.getPatchNames() |
|
42 |
- for specPkg in specObj.listPackages: |
|
43 |
- specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg) |
|
44 |
- self.mapPackageToSpec[specPkg]=specName |
|
45 |
- self.mapSerializableSpecObjects[specName]=specObj |
|
46 |
- |
|
47 |
- def getListSpecFiles(self,listSpecFiles,path): |
|
48 |
- for dirEntry in os.listdir(path): |
|
49 |
- dirEntryPath = os.path.join(path, dirEntry) |
|
50 |
- if os.path.isfile(dirEntryPath) and dirEntryPath.endswith(".spec"): |
|
51 |
- listSpecFiles.append(dirEntryPath) |
|
52 |
- elif os.path.isdir(dirEntryPath): |
|
53 |
- self.getListSpecFiles(listSpecFiles,dirEntryPath) |
|
54 |
- |
|
55 |
- def getBuildRequiresForPackage(self, package): |
|
56 |
- specName="" |
|
57 |
- if self.mapPackageToSpec.has_key(package): |
|
58 |
- specName=self.mapPackageToSpec[package] |
|
59 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
60 |
- return self.mapSerializableSpecObjects[specName].buildRequirePackages |
|
61 |
- return None |
|
62 |
- |
|
63 |
- def getRequiresAllForPackage(self, package): |
|
64 |
- specName="" |
|
65 |
- if self.mapPackageToSpec.has_key(package): |
|
66 |
- specName=self.mapPackageToSpec[package] |
|
67 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
68 |
- return self.mapSerializableSpecObjects[specName].installRequiresAllPackages |
|
69 |
- return None |
|
70 |
- |
|
71 |
- def getRequiresForPackage(self, package): |
|
72 |
- specName="" |
|
73 |
- if self.mapPackageToSpec.has_key(package): |
|
74 |
- specName=self.mapPackageToSpec[package] |
|
75 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
76 |
- if self.mapSerializableSpecObjects[specName].installRequiresPackages.has_key(package): |
|
77 |
- return self.mapSerializableSpecObjects[specName].installRequiresPackages[package] |
|
78 |
- return None |
|
79 |
- |
|
80 |
- def getRelease(self, package): |
|
81 |
- specName="" |
|
82 |
- if self.mapPackageToSpec.has_key(package): |
|
83 |
- specName=self.mapPackageToSpec[package] |
|
84 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
85 |
- return self.mapSerializableSpecObjects[specName].release |
|
86 |
- return None |
|
87 |
- |
|
88 |
- def getVersion(self, package): |
|
89 |
- specName="" |
|
90 |
- if self.mapPackageToSpec.has_key(package): |
|
91 |
- specName=self.mapPackageToSpec[package] |
|
92 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
93 |
- return self.mapSerializableSpecObjects[specName].version |
|
94 |
- return None |
|
95 |
- |
|
96 |
- def getSpecFile(self, package): |
|
97 |
- specName="" |
|
98 |
- if self.mapPackageToSpec.has_key(package): |
|
99 |
- specName=self.mapPackageToSpec[package] |
|
100 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
101 |
- return self.mapSerializableSpecObjects[specName].specFile |
|
102 |
- return None |
|
103 |
- |
|
104 |
- def getSpecName(self, package): |
|
105 |
- specName="" |
|
106 |
- if self.mapPackageToSpec.has_key(package): |
|
107 |
- specName=self.mapPackageToSpec[package] |
|
108 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
109 |
- return self.mapSerializableSpecObjects[specName].name |
|
110 |
- return None |
|
111 |
- |
|
112 |
- def getPatches(self, package): |
|
113 |
- specName="" |
|
114 |
- if self.mapPackageToSpec.has_key(package): |
|
115 |
- specName=self.mapPackageToSpec[package] |
|
116 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
117 |
- return self.mapSerializableSpecObjects[specName].listPatches |
|
118 |
- return None |
|
119 |
- |
|
120 |
- def getSources(self, package): |
|
121 |
- specName="" |
|
122 |
- if self.mapPackageToSpec.has_key(package): |
|
123 |
- specName=self.mapPackageToSpec[package] |
|
124 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
125 |
- return self.mapSerializableSpecObjects[specName].listSources |
|
126 |
- return None |
|
127 |
- |
|
128 |
- def getPackages(self, package): |
|
129 |
- specName="" |
|
130 |
- if self.mapPackageToSpec.has_key(package): |
|
131 |
- specName=self.mapPackageToSpec[package] |
|
132 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
133 |
- return self.mapSerializableSpecObjects[specName].listPackages |
|
134 |
- return None |
|
135 |
- |
|
136 |
- def isValidPackage(self,package): |
|
137 |
- if self.mapPackageToSpec.has_key(package): |
|
138 |
- return True |
|
139 |
- return False |
|
140 |
- |
|
141 |
- def printAllObjects(self): |
|
142 |
- listSpecs=self.mapSerializableSpecObjects.keys() |
|
143 |
- for spec in listSpecs: |
|
144 |
- specObj=self.mapSerializableSpecObjects[spec] |
|
145 |
- self.logger.info("-----------Spec:"+specObj.name+"--------------") |
|
146 |
- self.logger.info("Version:"+specObj.version) |
|
147 |
- self.logger.info("Release:"+specObj.release) |
|
148 |
- self.logger.info("SpecFile:"+specObj.specFile) |
|
149 |
- self.logger.info(" ") |
|
150 |
- self.logger.info("Source Files") |
|
151 |
- self.logger.info(specObj.listSources) |
|
152 |
- self.logger.info(" ") |
|
153 |
- self.logger.info("Patch Files") |
|
154 |
- self.logger.info(specObj.listPatches) |
|
155 |
- self.logger.info(" ") |
|
156 |
- self.logger.info(" ") |
|
157 |
- self.logger.info("List RPM packages") |
|
158 |
- self.logger.info(specObj.listPackages) |
|
159 |
- self.logger.info(" ") |
|
160 |
- self.logger.info(" ") |
|
161 |
- self.logger.info("Build require packages") |
|
162 |
- self.logger.info(specObj.buildRequirePackages) |
|
163 |
- self.logger.info(" ") |
|
164 |
- self.logger.info(" ") |
|
165 |
- self.logger.info("install require packages") |
|
166 |
- self.logger.info(specObj.installRequiresAllPackages) |
|
167 |
- self.logger.info(" ") |
|
168 |
- self.logger.info(specObj.installRequiresPackages) |
|
169 |
- self.logger.info("------------------------------------------------") |
|
170 |
- |
|
171 |
- |
|
172 |
- |
|
173 |
- |
|
174 | 1 |
\ No newline at end of file |
175 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,292 +0,0 @@ |
1 |
-import re |
|
2 |
-from StringUtils import StringUtils |
|
3 |
-from SpecStructures import * |
|
4 |
- |
|
5 |
-class SpecParser(object): |
|
6 |
- def __init__(self): |
|
7 |
- self.cleanMacro=rpmMacro().setName("clean") |
|
8 |
- self.prepMacro=rpmMacro().setName("prep") |
|
9 |
- self.buildMacro=rpmMacro().setName("build") |
|
10 |
- self.installMacro=rpmMacro().setName("install") |
|
11 |
- self.changelogMacro=rpmMacro().setName("changelog") |
|
12 |
- self.checkMacro=rpmMacro().setName("check") |
|
13 |
- self.packages={} |
|
14 |
- self.specAdditionalContent="" |
|
15 |
- |
|
16 |
- |
|
17 |
- def readPkgNameFromPackageMacro(self,data,basePkgName=None): |
|
18 |
- data=" ".join(data.split()) |
|
19 |
- pkgHeaderName=data.split(" ") |
|
20 |
- lenpkgHeaderName = len(pkgHeaderName) |
|
21 |
- |
|
22 |
- if (lenpkgHeaderName >= 3 and pkgHeaderName[1] != "-n"): |
|
23 |
- lenpkgHeaderName = 1 |
|
24 |
- if (lenpkgHeaderName == 2 or lenpkgHeaderName == 1 ) and basePkgName is None : |
|
25 |
- print "Invalid basePkgName" |
|
26 |
- return False,None |
|
27 |
- if lenpkgHeaderName == 3 : |
|
28 |
- return True,pkgHeaderName[2] |
|
29 |
- if lenpkgHeaderName == 2 : |
|
30 |
- return True,basePkgName + "-"+pkgHeaderName[1] |
|
31 |
- if lenpkgHeaderName == 1: |
|
32 |
- return True, basePkgName |
|
33 |
- |
|
34 |
- def parseSpecFile(self,specfile): |
|
35 |
- self.createDefaultPackage() |
|
36 |
- currentPkg="default" |
|
37 |
- specFile = open(specfile) |
|
38 |
- lines = specFile.readlines() |
|
39 |
- totalLines=len(lines) |
|
40 |
- i=0 |
|
41 |
- while i < totalLines: |
|
42 |
- line = lines[i].strip() |
|
43 |
- if self.isSpecMacro(line): |
|
44 |
- macro,i=self.readMacroFromFile(i, lines) |
|
45 |
- self.updateMacro(macro) |
|
46 |
- elif self.isPackageMacro(line): |
|
47 |
- defaultpkg = self.packages.get('default') |
|
48 |
- returnVal,packageName=self.readPkgNameFromPackageMacro(line, defaultpkg.name) |
|
49 |
- packageName=defaultpkg.decodeContents(packageName) |
|
50 |
- if not returnVal: |
|
51 |
- return False |
|
52 |
- if re.search('^'+'%package',line) : |
|
53 |
- pkg = Package(defaultpkg) |
|
54 |
- pkg.name=packageName |
|
55 |
- currentPkg=packageName |
|
56 |
- self.packages[pkg.name]=pkg |
|
57 |
- else: |
|
58 |
- if defaultpkg.name == packageName : |
|
59 |
- packageName = 'default' |
|
60 |
- if not self.packages.has_key(packageName): |
|
61 |
- return False |
|
62 |
- macro,i=self.readMacroFromFile(i, lines) |
|
63 |
- self.packages[packageName].updatePackageMacro(macro) |
|
64 |
- elif self.isPackageHeaders(line): |
|
65 |
- self.readPackageHeaders(line, self.packages[currentPkg]) |
|
66 |
- else: |
|
67 |
- self.specAdditionalContent+=line+"\n" |
|
68 |
- i=i+1 |
|
69 |
- specFile.close() |
|
70 |
- |
|
71 |
- def createDefaultPackage(self): |
|
72 |
- pkg = Package() |
|
73 |
- self.packages["default"]=pkg |
|
74 |
- |
|
75 |
- def readMacroFromFile(self,currentPos,lines): |
|
76 |
- macro = rpmMacro() |
|
77 |
- line = lines[currentPos] |
|
78 |
- macro.position = currentPos |
|
79 |
- macro.endposition=currentPos |
|
80 |
- endPos=len(lines) |
|
81 |
- line = " ".join(line.split()) |
|
82 |
- flagindex = line.find(" ") |
|
83 |
- if flagindex != -1: |
|
84 |
- macro.macroFlag=line[flagindex+1:] |
|
85 |
- macro.macroName=line[:flagindex] |
|
86 |
- else: |
|
87 |
- macro.macroName=line |
|
88 |
- |
|
89 |
- if currentPos+1 < len(lines) and self.isMacro(lines[currentPos+1]): |
|
90 |
- return macro,currentPos |
|
91 |
- |
|
92 |
- for j in range(currentPos+1,endPos): |
|
93 |
- content = lines[j] |
|
94 |
- if j+1 < endPos and self.isMacro(lines[j+1]): |
|
95 |
- return macro,j |
|
96 |
- macro.content += content +'\n' |
|
97 |
- macro.endposition=j |
|
98 |
- return macro,endPos |
|
99 |
- |
|
100 |
- |
|
101 |
- def updateMacro(self,macro): |
|
102 |
- if macro.macroName == "%clean": |
|
103 |
- self.cleanMacro=macro |
|
104 |
- return True |
|
105 |
- if macro.macroName == "%prep": |
|
106 |
- self.prepMacro=macro |
|
107 |
- return True |
|
108 |
- if macro.macroName == "%build": |
|
109 |
- self.buildMacro=macro |
|
110 |
- return True |
|
111 |
- if macro.macroName == "%install": |
|
112 |
- self.installMacro=macro |
|
113 |
- return True |
|
114 |
- if macro.macroName == "%changelog": |
|
115 |
- self.changelogMacro=macro |
|
116 |
- return True |
|
117 |
- if macro.macroName == "%check": |
|
118 |
- self.checkMacro=macro |
|
119 |
- return True |
|
120 |
- return False |
|
121 |
- |
|
122 |
- def isMacro(self,line): |
|
123 |
- return self.isPackageMacro(line) or self.isSpecMacro(line) |
|
124 |
- |
|
125 |
- def isSpecMacro(self,line): |
|
126 |
- if re.search('^'+'%clean',line) : |
|
127 |
- return True |
|
128 |
- elif re.search('^'+'%prep',line) : |
|
129 |
- return True |
|
130 |
- elif re.search('^'+'%build',line) : |
|
131 |
- return True |
|
132 |
- elif re.search('^'+'%install',line) : |
|
133 |
- return True |
|
134 |
- elif re.search('^'+'%changelog',line) : |
|
135 |
- return True |
|
136 |
- elif re.search('^'+'%check',line) : |
|
137 |
- return True |
|
138 |
- return False |
|
139 |
- |
|
140 |
- def isPackageMacro(self,line): |
|
141 |
- line=line.strip() |
|
142 |
- |
|
143 |
- if re.search('^'+'%post',line) : |
|
144 |
- return True |
|
145 |
- elif re.search('^'+'%postun',line) : |
|
146 |
- return True |
|
147 |
- elif re.search('^'+'%files',line) : |
|
148 |
- return True |
|
149 |
- elif re.search('^'+'%description',line) : |
|
150 |
- return True |
|
151 |
- elif re.search('^'+'%package',line) : |
|
152 |
- return True |
|
153 |
- return False |
|
154 |
- |
|
155 |
- def isPackageHeaders(self,line): |
|
156 |
- if re.search('^'+'summary:',line,flags=re.IGNORECASE) : |
|
157 |
- return True |
|
158 |
- elif re.search('^'+'name:',line,flags=re.IGNORECASE) : |
|
159 |
- return True |
|
160 |
- elif re.search('^'+'group:',line,flags=re.IGNORECASE) : |
|
161 |
- return True |
|
162 |
- elif re.search('^'+'license:',line,flags=re.IGNORECASE) : |
|
163 |
- return True |
|
164 |
- elif re.search('^'+'version:',line,flags=re.IGNORECASE) : |
|
165 |
- return True |
|
166 |
- elif re.search('^'+'release:',line,flags=re.IGNORECASE) : |
|
167 |
- return True |
|
168 |
- elif re.search('^'+'distribution:',line,flags=re.IGNORECASE) : |
|
169 |
- return True |
|
170 |
- elif re.search('^'+'requires:',line,flags=re.IGNORECASE) : |
|
171 |
- return True |
|
172 |
- elif re.search('^'+'provides:',line,flags=re.IGNORECASE) : |
|
173 |
- return True |
|
174 |
- elif re.search('^'+'obsoletes:',line,flags=re.IGNORECASE) : |
|
175 |
- return True |
|
176 |
- elif re.search('^'+'conflicts:',line,flags=re.IGNORECASE) : |
|
177 |
- return True |
|
178 |
- elif re.search('^'+'source[0-9]*:',line,flags=re.IGNORECASE) : |
|
179 |
- return True |
|
180 |
- elif re.search('^'+'patch[0-9]*:',line,flags=re.IGNORECASE) : |
|
181 |
- return True |
|
182 |
- elif re.search('^'+'buildrequires:',line,flags=re.IGNORECASE) : |
|
183 |
- return True |
|
184 |
- elif re.search('^'+'buildprovides:',line,flags=re.IGNORECASE) : |
|
185 |
- return True |
|
186 |
- elif re.search('^'+'buildarch:',line,flags=re.IGNORECASE) : |
|
187 |
- return True |
|
188 |
- return False |
|
189 |
- |
|
190 |
- def readHeader(self,line): |
|
191 |
- headerSplitIndex=line.find(":") |
|
192 |
- if(headerSplitIndex+1 == len(line) ): |
|
193 |
- print line |
|
194 |
- print "Error:Invalid header" |
|
195 |
- return False, None,None |
|
196 |
- headerName=line[0:headerSplitIndex].lower() |
|
197 |
- headerContent=line[headerSplitIndex+1:].strip() |
|
198 |
- return True,headerName,headerContent |
|
199 |
- |
|
200 |
- |
|
201 |
- def readDependentPackageData(self,line): |
|
202 |
- strUtils = StringUtils() |
|
203 |
- listPackages=line.split(",") |
|
204 |
- listdependentpkgs=[] |
|
205 |
- for line in listPackages: |
|
206 |
- line=strUtils.getStringInBrackets(line) |
|
207 |
- listContents=line.split() |
|
208 |
- totalContents = len(listContents) |
|
209 |
- i=0 |
|
210 |
- while i < totalContents: |
|
211 |
- dpkg = dependentPackageData() |
|
212 |
- compare=None |
|
213 |
- if i+2 < len(listContents): |
|
214 |
- if listContents[i+1] == ">=": |
|
215 |
- compare="gte" |
|
216 |
- elif listContents[i+1] == "<=": |
|
217 |
- compare="lte" |
|
218 |
- elif listContents[i+1] == "==": |
|
219 |
- compare="eq" |
|
220 |
- elif listContents[i+1] == "<": |
|
221 |
- compare="lt" |
|
222 |
- elif listContents[i+1] == ">": |
|
223 |
- compare="gt" |
|
224 |
- elif listContents[i+1] == "=": |
|
225 |
- compare="eq" |
|
226 |
- |
|
227 |
- if compare is not None: |
|
228 |
- dpkg.package=listContents[i] |
|
229 |
- dpkg.compare=compare |
|
230 |
- dpkg.version=listContents[i+2] |
|
231 |
- i=i+3 |
|
232 |
- else: |
|
233 |
- dpkg.package=listContents[i] |
|
234 |
- i=i+1 |
|
235 |
- listdependentpkgs.append(dpkg) |
|
236 |
- return listdependentpkgs |
|
237 |
- |
|
238 |
- def readPackageHeaders(self,line,pkg): |
|
239 |
- returnVal,headerName,headerContent=self.readHeader(line) |
|
240 |
- if not returnVal: |
|
241 |
- return False |
|
242 |
- |
|
243 |
- headerContent=pkg.decodeContents(headerContent) |
|
244 |
- if headerName == 'summary': |
|
245 |
- pkg.summary=headerContent |
|
246 |
- return True |
|
247 |
- if headerName == 'name': |
|
248 |
- pkg.name=headerContent |
|
249 |
- return True |
|
250 |
- if headerName == 'group': |
|
251 |
- pkg.group=headerContent |
|
252 |
- return True |
|
253 |
- if headerName == 'license': |
|
254 |
- pkg.license=headerContent |
|
255 |
- return True |
|
256 |
- if headerName == 'version': |
|
257 |
- pkg.version=headerContent |
|
258 |
- return True |
|
259 |
- if headerName == 'buildarch': |
|
260 |
- pkg.buildarch=headerContent |
|
261 |
- return True |
|
262 |
- if headerName == 'release': |
|
263 |
- pkg.release=headerContent |
|
264 |
- return True |
|
265 |
- if headerName == 'distribution': |
|
266 |
- pkg.distribution=headerContent |
|
267 |
- return True |
|
268 |
- if headerName.find('source') != -1: |
|
269 |
- pkg.sources.append(headerContent) |
|
270 |
- return True |
|
271 |
- if headerName.find('patch') != -1: |
|
272 |
- pkg.patches.append(headerContent) |
|
273 |
- return True |
|
274 |
- if headerName == 'requires' or headerName == 'provides' or headerName == 'obsoletes' or headerName == 'conflicts' or headerName == 'buildrequires' or headerName == 'buildprovides': |
|
275 |
- dpkg=self.readDependentPackageData(headerContent) |
|
276 |
- if dpkg is None: |
|
277 |
- return False |
|
278 |
- if headerName == 'requires': |
|
279 |
- pkg.requires.extend(dpkg) |
|
280 |
- if headerName == 'provides': |
|
281 |
- pkg.provides.extend(dpkg) |
|
282 |
- if headerName == 'obsoletes': |
|
283 |
- pkg.obsoletes.extend(dpkg) |
|
284 |
- if headerName == 'conflicts': |
|
285 |
- pkg.conflicts.extend(dpkg) |
|
286 |
- if headerName == 'buildrequires': |
|
287 |
- pkg.buildrequires.extend(dpkg) |
|
288 |
- if headerName == 'buildprovides': |
|
289 |
- pkg.buildprovides.extend(dpkg) |
|
290 |
- |
|
291 |
- return True |
|
292 |
- return False |
293 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,97 +0,0 @@ |
1 |
- |
|
2 |
-class rpmMacro(object): |
|
3 |
- |
|
4 |
- def __init__(self): |
|
5 |
- self.macroName="" |
|
6 |
- self.macroFlag="" |
|
7 |
- self.content="" |
|
8 |
- self.position=-1 |
|
9 |
- self.endposition=-1 |
|
10 |
- |
|
11 |
- def setName(self,name): |
|
12 |
- self.macroName=name |
|
13 |
- |
|
14 |
- def displayMacro(self): |
|
15 |
- print "Macro:\n", self.macroName, " ",self.macroFlag," ",self.position," ",self.endposition |
|
16 |
- print self.content |
|
17 |
- |
|
18 |
-class dependentPackageData(object): |
|
19 |
- |
|
20 |
- def __init__(self): |
|
21 |
- self.package="" |
|
22 |
- self.version="" |
|
23 |
- self.compare="" |
|
24 |
- |
|
25 |
-class Package(object): |
|
26 |
- def __init__(self, basePkg=None): |
|
27 |
- self.summary="" |
|
28 |
- self.name="" |
|
29 |
- self.group="" |
|
30 |
- self.license="" |
|
31 |
- self.version="" |
|
32 |
- self.release="" |
|
33 |
- self.buildarch="x86_64" |
|
34 |
- self.distribution="" |
|
35 |
- self.basePkgName="" |
|
36 |
- |
|
37 |
- self.sources=[] |
|
38 |
- self.patches=[] |
|
39 |
- self.buildrequires=[] |
|
40 |
- self.buildprovides=[] |
|
41 |
- |
|
42 |
- |
|
43 |
- self.requires=[] |
|
44 |
- self.provides=[] |
|
45 |
- self.obsoletes=[] |
|
46 |
- self.conflicts=[] |
|
47 |
- |
|
48 |
- self.descriptionMacro= None |
|
49 |
- self.postMacro=None |
|
50 |
- self.postunMacro=None |
|
51 |
- self.filesMacro=None |
|
52 |
- self.packageMacro=None |
|
53 |
- |
|
54 |
- if basePkg is not None: |
|
55 |
- self.basePkgName=basePkg.name |
|
56 |
- self.group=basePkg.group |
|
57 |
- self.license=basePkg.license |
|
58 |
- self.version=basePkg.version |
|
59 |
- self.buildarch=basePkg.buildarch |
|
60 |
- self.release=basePkg.release |
|
61 |
- self.distribution=basePkg.distribution |
|
62 |
- |
|
63 |
- def decodeContents(self,content): |
|
64 |
- if content.find("%{name}") != -1: |
|
65 |
- if self.basePkgName == "": |
|
66 |
- content = content.replace('%{name}',self.name) |
|
67 |
- else: |
|
68 |
- content = content.replace('%{name}',self.basePkgName) |
|
69 |
- |
|
70 |
- if content.find("%{release}") != -1: |
|
71 |
- content = content.replace('%{release}',self.release) |
|
72 |
- |
|
73 |
- if content.find("%{version}") != -1: |
|
74 |
- content = content.replace('%{version}',self.version) |
|
75 |
- |
|
76 |
- if content.find("%{?dist}") != -1: |
|
77 |
- content = content.replace('%{?dist}',self.distribution) |
|
78 |
- |
|
79 |
- if content.find("%{dist}") != -1: |
|
80 |
- content = content.replace('%{dist}',self.distribution) |
|
81 |
- |
|
82 |
- return content |
|
83 |
- |
|
84 |
- def updatePackageMacro(self,macro): |
|
85 |
- if macro.macroName == "%post": |
|
86 |
- self.postMacro=macro |
|
87 |
- return True |
|
88 |
- if macro.macroName == "%postun": |
|
89 |
- self.postunMacro=macro |
|
90 |
- return True |
|
91 |
- if macro.macroName == "%files": |
|
92 |
- self.filesMacro=macro |
|
93 |
- return True |
|
94 |
- if macro.macroName == "%description": |
|
95 |
- self.descriptionMacro = macro |
|
96 |
- return True |
|
97 |
- return False |
98 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,184 +0,0 @@ |
1 |
-from SpecParser import SpecParser |
|
2 |
-from StringUtils import StringUtils |
|
3 |
-import os |
|
4 |
- |
|
5 |
-class Specutils(object): |
|
6 |
- |
|
7 |
- def __init__(self,specfile): |
|
8 |
- self.specfile="" |
|
9 |
- self.spec = SpecParser() |
|
10 |
- if self.isSpecFile(specfile): |
|
11 |
- self.specfile=specfile |
|
12 |
- self.spec.parseSpecFile(self.specfile) |
|
13 |
- |
|
14 |
- def isSpecFile(self,specfile): |
|
15 |
- if os.path.isfile(specfile) and specfile[-5:] == ".spec": |
|
16 |
- return True |
|
17 |
- return False |
|
18 |
- |
|
19 |
- def getSourceNames(self): |
|
20 |
- sourceNames=[] |
|
21 |
- strUtils = StringUtils() |
|
22 |
- pkg = self.spec.packages.get('default') |
|
23 |
- if pkg is None: |
|
24 |
- return None |
|
25 |
- for source in pkg.sources: |
|
26 |
- sourceName=strUtils.getFileNameFromURL(source) |
|
27 |
- sourceNames.append(sourceName) |
|
28 |
- return sourceNames |
|
29 |
- |
|
30 |
- def getPatchNames(self): |
|
31 |
- patchNames=[] |
|
32 |
- strUtils = StringUtils() |
|
33 |
- pkg = self.spec.packages.get('default') |
|
34 |
- if pkg is None: |
|
35 |
- return None |
|
36 |
- for patch in pkg.patches: |
|
37 |
- patchName=strUtils.getFileNameFromURL(patch) |
|
38 |
- patchNames.append(patchName) |
|
39 |
- return patchNames |
|
40 |
- |
|
41 |
- def getPackageNames(self): |
|
42 |
- packageNames=[] |
|
43 |
- for key in self.spec.packages.keys(): |
|
44 |
- pkg = self.spec.packages.get(key) |
|
45 |
- packageNames.append(pkg.name) |
|
46 |
- return packageNames |
|
47 |
- |
|
48 |
- def getRPMNames(self): |
|
49 |
- rpmNames=[] |
|
50 |
- for key in self.spec.packages.keys(): |
|
51 |
- pkg = self.spec.packages.get(key) |
|
52 |
- rpmName=pkg.name+"-"+pkg.version+"-"+pkg.release |
|
53 |
- rpmNames.append(rpmName) |
|
54 |
- return rpmNames |
|
55 |
- |
|
56 |
- def getRPMName(self, pkgName): |
|
57 |
- rpmName=None |
|
58 |
- for key in self.spec.packages.keys(): |
|
59 |
- pkg = self.spec.packages.get(key) |
|
60 |
- if pkg.name == pkgName: |
|
61 |
- rpmName=pkg.name+"-"+pkg.version+"-"+pkg.release |
|
62 |
- break |
|
63 |
- return rpmName |
|
64 |
- |
|
65 |
- def getRPMVersion(self, pkgName): |
|
66 |
- version=None |
|
67 |
- for key in self.spec.packages.keys(): |
|
68 |
- pkg = self.spec.packages.get(key) |
|
69 |
- if pkg.name == pkgName: |
|
70 |
- version=pkg.version |
|
71 |
- break |
|
72 |
- return version |
|
73 |
- |
|
74 |
- def getRPMRelease(self, pkgName): |
|
75 |
- release=None |
|
76 |
- for key in self.spec.packages.keys(): |
|
77 |
- pkg = self.spec.packages.get(key) |
|
78 |
- if pkg.name == pkgName: |
|
79 |
- release=pkg.release |
|
80 |
- break |
|
81 |
- return release |
|
82 |
- |
|
83 |
- def getLicense(self, pkgName): |
|
84 |
- licenseInfo=None |
|
85 |
- for key in self.spec.packages.keys(): |
|
86 |
- pkg = self.spec.packages.get(key) |
|
87 |
- if pkg.name == pkgName: |
|
88 |
- licenseInfo=pkg.license |
|
89 |
- break |
|
90 |
- return licenseInfo |
|
91 |
- |
|
92 |
- def getBuildArch(self, pkgName): |
|
93 |
- buildArch="x86_64" |
|
94 |
- for key in self.spec.packages.keys(): |
|
95 |
- pkg = self.spec.packages.get(key) |
|
96 |
- if pkg.name == pkgName: |
|
97 |
- buildArch=pkg.buildarch |
|
98 |
- break |
|
99 |
- return buildArch |
|
100 |
- |
|
101 |
- def getRequiresAllPackages(self): |
|
102 |
- depedentPackages=[] |
|
103 |
- for key in self.spec.packages.keys(): |
|
104 |
- pkg = self.spec.packages.get(key) |
|
105 |
- for dpkg in pkg.requires: |
|
106 |
- depedentPackages.append(dpkg.package) |
|
107 |
- depedentPackages=list(set(depedentPackages)) |
|
108 |
- packageNames=self.getPackageNames() |
|
109 |
- for pkgName in packageNames: |
|
110 |
- if pkgName in depedentPackages: |
|
111 |
- depedentPackages.remove(pkgName) |
|
112 |
- return depedentPackages |
|
113 |
- |
|
114 |
- def getBuildRequiresAllPackages(self): |
|
115 |
- depedentPackages=[] |
|
116 |
- for key in self.spec.packages.keys(): |
|
117 |
- pkg = self.spec.packages.get(key) |
|
118 |
- for dpkg in pkg.buildrequires: |
|
119 |
- depedentPackages.append(dpkg.package) |
|
120 |
- depedentPackages=list(set(depedentPackages)) |
|
121 |
- packageNames=self.getPackageNames() |
|
122 |
- for pkgName in packageNames: |
|
123 |
- if pkgName in depedentPackages: |
|
124 |
- depedentPackages.remove(pkgName) |
|
125 |
- return depedentPackages |
|
126 |
- |
|
127 |
- |
|
128 |
- def getRequires(self,pkgName): |
|
129 |
- dependentPackages=[] |
|
130 |
- for key in self.spec.packages.keys(): |
|
131 |
- pkg = self.spec.packages.get(key) |
|
132 |
- if pkg.name == pkgName: |
|
133 |
- for dpkg in pkg.requires: |
|
134 |
- dependentPackages.append(dpkg.package) |
|
135 |
- return dependentPackages |
|
136 |
- |
|
137 |
- def getBuildRequires(self,pkgName): |
|
138 |
- dependentPackages=[] |
|
139 |
- for key in self.spec.packages.keys(): |
|
140 |
- pkg = self.spec.packages.get(key) |
|
141 |
- if pkg.name == pkgName: |
|
142 |
- for dpkg in pkg.buildrequires: |
|
143 |
- dependentPackages.append(dpkg.package) |
|
144 |
- return dependentPackages |
|
145 |
- |
|
146 |
- def getProvides(self,packageName): |
|
147 |
- depedentPackages=[] |
|
148 |
- defaultPkgName=self.spec.packages['default'].name |
|
149 |
- pkg = None |
|
150 |
- if self.spec.packages.has_key(packageName): |
|
151 |
- pkg = self.spec.packages.get(packageName) |
|
152 |
- if defaultPkgName == packageName: |
|
153 |
- pkg=self.spec.packages['default'] |
|
154 |
- if pkg is not None: |
|
155 |
- for dpkg in pkg.provides: |
|
156 |
- depedentPackages.append(dpkg.package) |
|
157 |
- else: |
|
158 |
- print "package not found" |
|
159 |
- return depedentPackages |
|
160 |
- |
|
161 |
- def getVersion(self): |
|
162 |
- pkg = self.spec.packages.get('default') |
|
163 |
- return pkg.version |
|
164 |
- |
|
165 |
- def getRelease(self): |
|
166 |
- pkg = self.spec.packages.get('default') |
|
167 |
- return pkg.release |
|
168 |
- |
|
169 |
-def main(): |
|
170 |
- spec = Specutils("/workspace1/myrepos/photon/SPECS/docker/docker.spec") |
|
171 |
- print "packages",spec.getPackageNames() |
|
172 |
- print "packages",spec.getRPMNames() |
|
173 |
- print "sources",spec.getSourceNames() |
|
174 |
- print "patches",spec.getPatchNames() |
|
175 |
- print "requires",spec.getRequires('libltdl-devel') |
|
176 |
- print "requires",spec.getRequires('libtool') |
|
177 |
- |
|
178 |
- print "provides",spec.getProvides('libtool') |
|
179 |
- print "all-requires",spec.getRequiresAllPackages() |
|
180 |
- print "all-build-requires",spec.getBuildRequiresAllPackages() |
|
181 |
- |
|
182 |
-if __name__ == '__main__': |
|
183 |
- main() |
|
184 |
- |
185 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,14 +0,0 @@ |
1 |
-import re |
|
2 |
- |
|
3 |
-class StringUtils(object): |
|
4 |
- |
|
5 |
- def getStringInBrackets(self, inputstring): |
|
6 |
- inputstring=inputstring.strip() |
|
7 |
- m = re.search(r"^\(([A-Za-z0-9_.-]+)\)", inputstring) |
|
8 |
- if m is None: |
|
9 |
- return inputstring |
|
10 |
- return m.group(1) |
|
11 |
- |
|
12 |
- def getFileNameFromURL(self,inputstring): |
|
13 |
- index=inputstring.rfind("/") |
|
14 |
- return inputstring[index+1:] |
|
15 | 1 |
\ No newline at end of file |
16 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,62 +0,0 @@ |
1 |
- |
|
2 |
-import WorkerThread |
|
3 |
-class ThreadPool(object): |
|
4 |
- |
|
5 |
- mapWorkerThreads={} |
|
6 |
- activeWorkerThreads=[] |
|
7 |
- inactiveWorkerThreads=[] |
|
8 |
- mapPackageToCycle={} |
|
9 |
- listAvailableCyclicPackages=[] |
|
10 |
- logger=None |
|
11 |
- statusEvent=None |
|
12 |
- |
|
13 |
- @staticmethod |
|
14 |
- def clear(): |
|
15 |
- ThreadPool.mapWorkerThreads.clear() |
|
16 |
- ThreadPool.activeWorkerThreads=[] |
|
17 |
- ThreadPool.inactiveWorkerThreads=[] |
|
18 |
- |
|
19 |
- @staticmethod |
|
20 |
- def getAllWorkerObjects(): |
|
21 |
- listWorkerObjs=[] |
|
22 |
- listWorkerKeys = ThreadPool.mapWorkerThreads.keys() |
|
23 |
- for x in listWorkerKeys: |
|
24 |
- xobj=ThreadPool.mapWorkerThreads[x] |
|
25 |
- listWorkerObjs.append(xobj) |
|
26 |
- return listWorkerObjs |
|
27 |
- |
|
28 |
- @staticmethod |
|
29 |
- def addWorkerThread(workerThreadName): |
|
30 |
- workerThread = WorkerThread.WorkerThread(ThreadPool.statusEvent,workerThreadName,ThreadPool.mapPackageToCycle,ThreadPool.listAvailableCyclicPackages,ThreadPool.logger) |
|
31 |
- ThreadPool.mapWorkerThreads[workerThreadName]=workerThread |
|
32 |
- |
|
33 |
- @staticmethod |
|
34 |
- def makeWorkerThreadActive(threadName): |
|
35 |
- if threadName in ThreadPool.inactiveWorkerThreads: |
|
36 |
- ThreadPool.inactiveWorkerThreads.remove(threadName) |
|
37 |
- ThreadPool.activeWorkerThreads.append(threadName) |
|
38 |
- |
|
39 |
- @staticmethod |
|
40 |
- def makeWorkerThreadInActive(threadName): |
|
41 |
- if threadName in ThreadPool.activeWorkerThreads: |
|
42 |
- ThreadPool.activeWorkerThreads.remove(threadName) |
|
43 |
- ThreadPool.inactiveWorkerThreads.append(threadName) |
|
44 |
- |
|
45 |
- @staticmethod |
|
46 |
- def startWorkerThread(threadName): |
|
47 |
- ThreadPool.mapWorkerThreads[threadName].start() |
|
48 |
- |
|
49 |
- @staticmethod |
|
50 |
- def getListInactiveWorkerThreads(): |
|
51 |
- return ThreadPool.inactiveWorkerThreads |
|
52 |
- |
|
53 |
- @staticmethod |
|
54 |
- def activateWorkerThreads(numOfThreadsToActivate): |
|
55 |
- while len(ThreadPool.inactiveWorkerThreads) > 0 and numOfThreadsToActivate > 0: |
|
56 |
- threadName=ThreadPool.inactiveWorkerThreads.pop() |
|
57 |
- ThreadPool.addWorkerThread(threadName) |
|
58 |
- ThreadPool.startWorkerThread(threadName) |
|
59 |
- ThreadPool.makeWorkerThreadActive(threadName) |
|
60 |
- numOfThreadsToActivate = numOfThreadsToActivate -1 |
|
61 |
- |
|
62 |
- |
63 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,157 +0,0 @@ |
1 |
-from CommandUtils import CommandUtils |
|
2 |
-from ChrootUtils import ChrootUtils |
|
3 |
-from Logger import Logger |
|
4 |
-from PackageUtils import PackageUtils |
|
5 |
-from constants import constants |
|
6 |
-import subprocess |
|
7 |
-import os.path |
|
8 |
- |
|
9 |
-class ToolChainUtils(object): |
|
10 |
- __built_successfull=False |
|
11 |
- |
|
12 |
- def __init__(self,logName=None,logPath=None): |
|
13 |
- if logName is None: |
|
14 |
- logName = "Toolchain Utils" |
|
15 |
- if logPath is None: |
|
16 |
- logPath = constants.logPath |
|
17 |
- self.logName=logName |
|
18 |
- self.logPath=logPath |
|
19 |
- self.logger=Logger.getLogger(logName,logPath) |
|
20 |
- self.adjustToolChainScript = "adjust-tool-chain.sh" |
|
21 |
- self.localegenScript = "./locale-gen.sh" |
|
22 |
- self.localegenConfig = "./locale-gen.conf" |
|
23 |
- self.prepareBuildRootCmd="./prepare-build-root.sh" |
|
24 |
- |
|
25 |
- #Tool chain should be built before calling this method |
|
26 |
- def installToolChain(self,chrootID): |
|
27 |
- self.logger.info("Installing toolchain.....") |
|
28 |
- self.logger.info("Preparing build environment") |
|
29 |
- previousVersionRPMSPath="/workspace1/testTP1RPMS/RPMS" |
|
30 |
- cmdUtils = CommandUtils() |
|
31 |
- prepareChrootCmd=self.prepareBuildRootCmd+" "+chrootID+" "+constants.specPath+" "+constants.rpmPath+" "+constants.logPath |
|
32 |
- logFile=constants.logPath+"/prepareBuildRoot.log" |
|
33 |
- returnVal=cmdUtils.runCommandInShell(prepareChrootCmd,logFile) |
|
34 |
- if not returnVal: |
|
35 |
- self.logger.error("Prepare build root script failed.Unable to prepare chroot.") |
|
36 |
- raise Exception("Prepare build root script failed") |
|
37 |
- |
|
38 |
- for package in constants.listToolChainRPMPkgsToInstall: |
|
39 |
- pkgUtils=PackageUtils(self.logName,self.logPath) |
|
40 |
- rpmFile=pkgUtils.findRPMFileForGivenPackage(package) |
|
41 |
- if rpmFile is None: |
|
42 |
- rpmFile=self.findRPMFileInGivenLocation(package, previousVersionRPMSPath) |
|
43 |
- if rpmFile is None: |
|
44 |
- self.logger.error("Unable to find rpm "+ package +" in current and previous versions") |
|
45 |
- raise "Input Error" |
|
46 |
- self.logger.debug("Installing rpm:"+rpmFile) |
|
47 |
- cmd="rpm -i --nodeps --root "+chrootID+" --define \'_dbpath /var/lib/rpm\' "+ rpmFile |
|
48 |
- process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE) |
|
49 |
- retval = process.wait() |
|
50 |
- if retval != 0: |
|
51 |
- self.logger.error("Installing tool chain package "+package+" failed") |
|
52 |
- raise "RPM installation failed" |
|
53 |
- |
|
54 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS") |
|
55 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS/x86_64") |
|
56 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS/noarch") |
|
57 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/SOURCES") |
|
58 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/SPECS") |
|
59 |
- self.logger.info("Successfully prepared chroot:"+chrootID) |
|
60 |
- self.logger.info("Installed tool chain successfully on chroot:"+chrootID) |
|
61 |
- |
|
62 |
- def installCoreToolChainPackages(self,chrootID): |
|
63 |
- self.logger.info("Installing toolchain.....") |
|
64 |
- self.prepareBuildEnvironmentChroot(chrootID) |
|
65 |
- #cmdUtils=CommandUtils() |
|
66 |
- #cmdUtils.runCommandInShell("rm "+ chrootID+"/"+constants.topDirPath+"/RPMS/x86_64/*") |
|
67 |
- #cmdUtils.runCommandInShell("rm "+ chrootID+"/"+constants.topDirPath+"/RPMS/noarch/*") |
|
68 |
- self.logger.info("Installed core tool chain packages successfully on chroot:"+chrootID) |
|
69 |
- |
|
70 |
- |
|
71 |
- |
|
72 |
- def findRPMFileInGivenLocation(self,package,rpmdirPath): |
|
73 |
- cmdUtils = CommandUtils() |
|
74 |
- listFoundRPMFiles = cmdUtils.findFile(package+"-*.rpm",rpmdirPath) |
|
75 |
- listFilterRPMFiles=[] |
|
76 |
- for f in listFoundRPMFiles: |
|
77 |
- f1=f.replace(package,"") |
|
78 |
- print f1 |
|
79 |
- l = f1.split("-") |
|
80 |
- print l |
|
81 |
- if len(l) == 3: |
|
82 |
- listFilterRPMFiles.append(f) |
|
83 |
- if len(listFilterRPMFiles) == 1 : |
|
84 |
- return listFilterRPMFiles[0] |
|
85 |
- if len(listFilterRPMFiles) == 0 : |
|
86 |
- return None |
|
87 |
- if len(listFilterRPMFiles) > 1 : |
|
88 |
- print("Found multiple rpm files for given package in rpm directory.Unable to determine the rpm file for package:"+package) |
|
89 |
- return None |
|
90 |
- |
|
91 |
- def buildCoreToolChainPackages(self): |
|
92 |
- self.logger.info("Building core tool chain packages.....") |
|
93 |
- chrootID=None |
|
94 |
- try: |
|
95 |
- pkgUtils=PackageUtils(self.logName,self.logPath) |
|
96 |
- for package in constants.listCoreToolChainRPMPackages: |
|
97 |
- rpmPkg=pkgUtils.findRPMFileForGivenPackage(package) |
|
98 |
- if rpmPkg is not None: |
|
99 |
- continue |
|
100 |
- chrUtils = ChrootUtils(self.logName,self.logPath) |
|
101 |
- chrootName="build-core-toolchain" |
|
102 |
- destLogPath=constants.logPath+"/build-"+package |
|
103 |
- if not os.path.isdir(destLogPath): |
|
104 |
- cmdUtils = CommandUtils() |
|
105 |
- cmdUtils.runCommandInShell("mkdir -p "+destLogPath) |
|
106 |
- returnVal,chrootID = chrUtils.createChroot(chrootName) |
|
107 |
- if not returnVal: |
|
108 |
- self.logger.error("Creating chroot failed") |
|
109 |
- raise Exception("creating chroot failed") |
|
110 |
- self.prepareBuildEnvironmentChroot(chrootID) |
|
111 |
- #rpmPkg=pkgUtils.findRPMFileForGivenPackage(package) |
|
112 |
- #if rpmPkg is None: |
|
113 |
- pkgUtils.buildRPMSForGivenPackage(package, chrootID,destLogPath) |
|
114 |
- chrUtils.destroyChroot(chrootID) |
|
115 |
- chrootID=None |
|
116 |
- self.logger.info("Successfully built toolchain") |
|
117 |
- except Exception as e: |
|
118 |
- self.logger.error("Unable to build tool chain.") |
|
119 |
- raise e |
|
120 |
- finally: |
|
121 |
- if chrootID is not None: |
|
122 |
- chrUtils.destroyChroot(chrootID) |
|
123 |
- |
|
124 |
- def prepareBuildEnvironmentChroot(self,chrootID): |
|
125 |
- self.logger.info("Preparing build environment") |
|
126 |
- previousVersionRPMSPath="/workspace1/testTP1RPMS/RPMS" |
|
127 |
- cmdUtils = CommandUtils() |
|
128 |
- prepareChrootCmd=self.prepareBuildRootCmd+" "+chrootID+" "+constants.specPath+" "+constants.rpmPath+" "+constants.logPath |
|
129 |
- logFile=constants.logPath+"/prepareBuildRoot.log" |
|
130 |
- returnVal=cmdUtils.runCommandInShell(prepareChrootCmd,logFile) |
|
131 |
- if not returnVal: |
|
132 |
- self.logger.error("Prepare build root script failed.Unable to prepare chroot.") |
|
133 |
- raise Exception("Prepare build root script failed") |
|
134 |
- |
|
135 |
- for package in constants.listToolChainRPMPkgsToBuild: |
|
136 |
- pkgUtils=PackageUtils(self.logName,self.logPath) |
|
137 |
- rpmFile=pkgUtils.findRPMFileForGivenPackage(package) |
|
138 |
- if rpmFile is None: |
|
139 |
- rpmFile=self.findRPMFileInGivenLocation(package, previousVersionRPMSPath) |
|
140 |
- if rpmFile is None: |
|
141 |
- self.logger.error("Unable to find rpm "+ package +" in current and previous versions") |
|
142 |
- raise "Input Error" |
|
143 |
- self.logger.debug("Installing rpm:"+rpmFile) |
|
144 |
- cmd="rpm -i --nodeps --force --root "+chrootID+" --define \'_dbpath /var/lib/rpm\' "+ rpmFile |
|
145 |
- process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE) |
|
146 |
- retval = process.wait() |
|
147 |
- if retval != 0: |
|
148 |
- self.logger.error("Installing tool chain package "+package+" failed") |
|
149 |
- raise "RPM installation failed" |
|
150 |
- |
|
151 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS") |
|
152 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS/x86_64") |
|
153 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS/noarch") |
|
154 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/SOURCES") |
|
155 |
- cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/SPECS") |
|
156 |
- self.logger.info("Successfully prepared chroot:"+chrootID) |
|
157 |
- |
158 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,54 +0,0 @@ |
1 |
-from PackageBuilder import PackageBuilder |
|
2 |
-import threading |
|
3 |
-import Scheduler |
|
4 |
-import ThreadPool |
|
5 |
- |
|
6 |
-class WorkerThread(threading.Thread): |
|
7 |
- |
|
8 |
- def __init__(self,event,name,mapPackageToCycle,listAvailableCyclicPackages,logger): |
|
9 |
- threading.Thread.__init__(self) |
|
10 |
- self.statusEvent=event |
|
11 |
- self.name=name |
|
12 |
- self.mapPackageToCycle=mapPackageToCycle |
|
13 |
- self.listAvailableCyclicPackages=listAvailableCyclicPackages |
|
14 |
- self.logger=logger |
|
15 |
- |
|
16 |
- def run(self): |
|
17 |
- buildThreadFailed=False |
|
18 |
- ThreadPool.ThreadPool.makeWorkerThreadActive(self.name) |
|
19 |
- self.logger.info("Thread "+self.name +" is starting now") |
|
20 |
- while True: |
|
21 |
- outputMap={} |
|
22 |
- pkg = Scheduler.Scheduler.getNextPackageToBuild() |
|
23 |
- if pkg is None: |
|
24 |
- break |
|
25 |
- self.logger.info("Thread "+self.name+" is building package:"+ pkg) |
|
26 |
- pkgBuilder = PackageBuilder(self.mapPackageToCycle,self.listAvailableCyclicPackages,"build-"+pkg) |
|
27 |
- t = threading.Thread(target=pkgBuilder.buildPackageThreadAPI,args=(pkg,outputMap,pkg)) |
|
28 |
- t.start() |
|
29 |
- t.join() |
|
30 |
- if outputMap.has_key(pkg): |
|
31 |
- if outputMap[pkg] == False: |
|
32 |
- buildThreadFailed = True |
|
33 |
- Scheduler.Scheduler.notifyPackageBuildFailed(pkg) |
|
34 |
- self.logger.info("Thread "+self.name +" stopped building the "+pkg +" package") |
|
35 |
- break |
|
36 |
- else: |
|
37 |
- buildThreadFailed = True |
|
38 |
- Scheduler.Scheduler.notifyPackageBuildFailed(pkg) |
|
39 |
- self.logger.info("Thread "+self.name +" stopped building the "+pkg +" package") |
|
40 |
- break |
|
41 |
- |
|
42 |
- Scheduler.Scheduler.notifyPackageBuildCompleted(pkg) |
|
43 |
- |
|
44 |
- if buildThreadFailed: |
|
45 |
- self.statusEvent.set() |
|
46 |
- |
|
47 |
- ThreadPool.ThreadPool.makeWorkerThreadInActive(self.name) |
|
48 |
- self.logger.info("Thread "+self.name +" is going to rest") |
|
49 |
- |
|
50 |
- |
|
51 |
- |
|
52 |
- |
|
53 |
- |
|
54 |
- |
|
55 | 1 |
\ No newline at end of file |
56 | 2 |
deleted file mode 100755 |
... | ... |
@@ -1,70 +0,0 @@ |
1 |
-#!/usr/bin/env python |
|
2 |
- |
|
3 |
-from optparse import OptionParser |
|
4 |
-import os.path |
|
5 |
-from CommandUtils import CommandUtils |
|
6 |
-from Logger import Logger |
|
7 |
-from constants import constants |
|
8 |
-from PackageManager import PackageManager |
|
9 |
-from ChrootUtils import ChrootUtils |
|
10 |
- |
|
11 |
-def main(): |
|
12 |
- usage = "Usage: %prog [options] <package name>" |
|
13 |
- parser = OptionParser(usage) |
|
14 |
- parser.add_option("-s", "--spec-path", dest="specPath", default="/workspace1/myrepos/photon/SPECS") |
|
15 |
- parser.add_option("-o", "--source-path", dest="sourcePath", default="/workspace1/mysources") |
|
16 |
- parser.add_option("-r", "--rpm-path", dest="rpmPath", default="/workspace1/mystage/RPMS") |
|
17 |
- parser.add_option("-t", "--install-tool-chain", dest="installToolChain", default=False, action ="store_true") |
|
18 |
- parser.add_option("-i", "--install-package", dest="installPackage", default=False, action ="store_true") |
|
19 |
- parser.add_option("-c", "--clean-build", dest="cleanBuild", default=False, action ="store_true") |
|
20 |
- parser.add_option("-p", "--tools-path", dest="toolsPath", default="/workspace1/mystage") |
|
21 |
- parser.add_option("-l", "--log-path", dest="logPath", default="/workspace1/LOGS") |
|
22 |
- parser.add_option("-a", "--build-all", dest="buildAll", default=False, action ="store_true") |
|
23 |
- parser.add_option("-f", "--force", dest="forceBuild", default=False, action ="store_true") |
|
24 |
- parser.add_option("-x", "--incremental-build", dest="incrementalBuild", default=True, action ="store_true") |
|
25 |
- parser.add_option("-z", "--top-dir-path", dest="topDirPath", default="/usr/src/photon") |
|
26 |
- |
|
27 |
- |
|
28 |
- (options, args) = parser.parse_args() |
|
29 |
- |
|
30 |
- cmdUtils=CommandUtils() |
|
31 |
- if not os.path.isdir(options.logPath): |
|
32 |
- cmdUtils.runCommandInShell("mkdir -p "+options.logPath) |
|
33 |
- |
|
34 |
- if not os.path.isdir(options.rpmPath): |
|
35 |
- cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/x86_64") |
|
36 |
- cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/noarch") |
|
37 |
- |
|
38 |
- logger=Logger.getLogger(options.logPath+"/Main") |
|
39 |
- logger.info("Source Path :"+options.sourcePath) |
|
40 |
- logger.info("Spec Path :" + options.specPath) |
|
41 |
- logger.info("Rpm Path :" + options.rpmPath) |
|
42 |
- logger.info("Tools Path :" + options.toolsPath) |
|
43 |
- logger.info("Log Path :" + options.logPath) |
|
44 |
- logger.info("Top Dir Path :" + options.topDirPath) |
|
45 |
- |
|
46 |
- |
|
47 |
- listPackages=["acl","attr","autoconf","automake","bash","bc","bindutils","binutils","bison","boost","btrfs-progs","bzip2","ca-certificates","cdrkit","check", |
|
48 |
- "cloud-init","cmake","coreutils","cpio","cracklib","createrepo","curl","cyrus-sasl","db","dbus","deltarpm","diffutils","docbook-xml","docbook-xsl", |
|
49 |
- "docker","dparted","dracut","e2fsprogs","elfutils","etcd","expat","file","filesystem","findutils","flex","gawk","gcc","gdb","gdbm","gettext","git", |
|
50 |
- "glib","glibc","glibmm","gmp","go","gobject-introspection","google-daemon","google-startup-scripts","gperf","gpgme","gptfdisk","grep","groff", |
|
51 |
- "grub","gtk-doc","gzip","haveged","hawkey","iana-etc","inetutils","intltool","iproute2","iptables","itstool","json-glib","kbd","kmod","krb5", |
|
52 |
- "kubernetes","less","libaio","libassuan","libcap","libdnet","libffi","libgpg-error","libgsystem","libhif","libmspack","libpcap","libpipeline", |
|
53 |
- "librepo","libselinux","libsepol","libsigc++","libsolv","libtool","libxml2","libxslt","libyaml","linux","linux-api-headers","Linux-PAM","lua", |
|
54 |
- "lvm2","lzo","m4","make","man-db","man-pages","mercurial","mpc","mpfr","nano","ncurses","nspr","nss","ntp","openldap","openssh","openssl", |
|
55 |
- "open-vm-tools","ostree","parted","patch","pcre","perl","perl-common-sense","perl-Config-IniFiles","perl-DBD-SQLite","perl-DBI","perl-DBIx-Simple", |
|
56 |
- "perl-Exporter-Tiny","perl-JSON-XS","perl-libintl","perl-List-MoreUtils","perl-Module-Install","perl-Module-ScanDeps","perl-Types-Serialiser", |
|
57 |
- "perl-WWW-Curl","perl-YAML","perl-YAML-Tiny","photon-release","pkg-config","popt","procps-ng","psmisc","pycurl","pygobject","python2", |
|
58 |
- "python-configobj","python-iniparse","python-jsonpatch","python-jsonpointer","python-prettytable","python-requests","python-setuptools", |
|
59 |
- "python-six","PyYAML","readline","rocket","rpm","rpm-ostree","rpm-ostree-toolbox","ruby","sed","shadow","sqlite-autoconf","strace","sudo", |
|
60 |
- "swig","systemd","tar","tcpdump","tcsh","tdnf","texinfo","thin-provisioning-tools","tzdata","unzip","urlgrabber","util-linux","vim","wget", |
|
61 |
- "which","xerces-c","XML-Parser","xml-security-c","xz","yum","yum-metadata-parser","zlib"] |
|
62 |
- |
|
63 |
- constants.initialize(options) |
|
64 |
- |
|
65 |
- pkgManager = PackageManager() |
|
66 |
- pkgManager.buildPackages(listPackages) |
|
67 |
- |
|
68 |
- |
|
69 |
-if __name__=="__main__": |
|
70 |
- main() |
|
71 | 1 |
\ No newline at end of file |
72 | 2 |
deleted file mode 100644 |
... | ... |
@@ -1,65 +0,0 @@ |
1 |
-from SpecData import SerializableSpecObjectsUtils |
|
2 |
- |
|
3 |
-class constants(object): |
|
4 |
- specPath="" |
|
5 |
- sourcePath="" |
|
6 |
- rpmPath="" |
|
7 |
- toolsPath="" |
|
8 |
- logPath="" |
|
9 |
- incrementalBuild=False |
|
10 |
- topDirPath="" |
|
11 |
- specData=None |
|
12 |
- testPath="test" |
|
13 |
- buildRootPath="/mnt" |
|
14 |
- noDepsPackageList=["texinfo","bzip2","gettext","man-db","nspr","xz","bison"] |
|
15 |
- listToolChainPackages=["linux-api-headers", "glibc","zlib", "file", |
|
16 |
- "binutils","gmp","mpfr", "mpc","gcc", "pkg-config", "ncurses", "bash", "bzip2", "sed","procps-ng","coreutils", "m4","grep", |
|
17 |
- "readline", "diffutils","gawk", "findutils", "gettext", "gzip","make", "patch","util-linux", |
|
18 |
- "tar", "xz","libtool", "flex", "bison", "lua","popt","nspr","sqlite-autoconf","nss", |
|
19 |
- "elfutils", "expat","libffi","libpipeline", "gdbm","perl","texinfo","autoconf","automake", |
|
20 |
- "openssl","python2","rpm", "groff", "man-db", "man-pages","cpio"] |
|
21 |
- |
|
22 |
- listCoreToolChainRPMPackages=["linux-api-headers", "glibc","glibc-devel", "zlib","zlib-devel", "file", |
|
23 |
- "binutils","binutils-devel", "gmp","gmp-devel", "mpfr", "mpfr-devel", "mpc", |
|
24 |
- "libgcc","libgcc-devel","libstdc++","libstdc++-devel","libgomp","libgomp-devel","gcc", |
|
25 |
- "pkg-config","bash"] |
|
26 |
- |
|
27 |
- listToolChainRPMPkgsToInstall=["linux-api-headers", "glibc","glibc-devel", "zlib","zlib-devel", "file", |
|
28 |
- "binutils","binutils-devel", "gmp","gmp-devel", "mpfr", "mpfr-devel", "mpc", |
|
29 |
- "libgcc","libgcc-devel","libstdc++","libstdc++-devel","libgomp","libgomp-devel","gcc", |
|
30 |
- "pkg-config", "ncurses", "bash", "bzip2", "sed","procps-ng","coreutils", "m4","grep", |
|
31 |
- "readline","diffutils","gawk", "findutils", "gettext", "gzip","make", "patch", |
|
32 |
- "util-linux", "tar", "xz","libtool", "flex", "bison", |
|
33 |
- "lua","popt","nspr","sqlite-autoconf","nss","elfutils-libelf", |
|
34 |
- "libpipeline", "gdbm","perl","texinfo","rpm", |
|
35 |
- "autoconf","automake", "groff", "man-db", "man-pages","elfutils","cpio"] |
|
36 |
- |
|
37 |
- listToolChainRPMPkgsToBuild=["linux-api-headers", "glibc","glibc-devel", "zlib","zlib-devel", "file", |
|
38 |
- "binutils","binutils-devel", "gmp","gmp-devel", "mpfr", "mpfr-devel", "mpc", |
|
39 |
- "libgcc","libgcc-devel","libstdc++","libstdc++-devel","libgomp","libgomp-devel","gcc", |
|
40 |
- "pkg-config", "ncurses", "bash", "bzip2", "sed","ncurses-devel","procps-ng","coreutils", "m4","grep", |
|
41 |
- "readline", "diffutils","gawk", "findutils", "gettext", "gzip","make", "patch", |
|
42 |
- "util-linux", "tar", "xz","libtool", "flex", "bison", |
|
43 |
- "readline-devel", "lua","lua-devel","popt","popt-devel","nspr","sqlite-autoconf","nss","nss-devel", |
|
44 |
- "bzip2-devel","elfutils-libelf","elfutils","elfutils-libelf-devel","elfutils-devel", |
|
45 |
- "expat","libffi","libpipeline", "gdbm","perl","texinfo","autoconf","automake", |
|
46 |
- "openssl","openssl-devel","python2","python2-libs","python2-devel","rpm", |
|
47 |
- "groff", "man-db", "man-pages","cpio"] |
|
48 |
- |
|
49 |
- |
|
50 |
- @staticmethod |
|
51 |
- def initialize(options): |
|
52 |
- constants.specPath = options.specPath |
|
53 |
- constants.sourcePath = options.sourcePath |
|
54 |
- constants.rpmPath = options.rpmPath |
|
55 |
- constants.toolsPath = options.toolsPath |
|
56 |
- constants.incrementalBuild = options.incrementalBuild |
|
57 |
- constants.topDirPath = options.topDirPath |
|
58 |
- constants.logPath = options.logPath |
|
59 |
- constants.specData = SerializableSpecObjectsUtils(constants.logPath) |
|
60 |
- constants.specData.readSpecsAndConvertToSerializableObjects(constants.specPath) |
|
61 |
- |
|
62 |
- |
|
63 |
- |
|
64 |
- |
|
65 |
- |
|
66 | 1 |
\ No newline at end of file |
... | ... |
@@ -10,27 +10,50 @@ set -o nounset |
10 | 10 |
set +h |
11 | 11 |
source common.inc |
12 | 12 |
|
13 |
+LOGFILE="$(date +%Y-%m-%d).log" |
|
14 |
+LOG_PATH=../../stage/LOGS |
|
13 | 15 |
PRGNAME=${0##*/} |
14 |
- |
|
16 |
+LOGFILE=$LOG_PATH/"${PRGNAME}-${LOGFILE}" |
|
15 | 17 |
if [ $# -lt 4 ]; then |
16 |
- fail "${PRGNAME}: No build root specified. Usage : ${PRGNAME} <build-root> <spec-path> <rpm-path> <log-path>" |
|
18 |
+ fail "${PRGNAME}: No build root specified. Usage : ${PRGNAME} <build-root> <spec-path> <rpm-path> <tools-path>" |
|
17 | 19 |
fi |
18 | 20 |
|
19 | 21 |
#Clean up our build root first |
20 | 22 |
BUILDROOT=$1 |
21 | 23 |
SPEC_PATH=$2 |
22 | 24 |
RPM_PATH=$3 |
23 |
-LOG_PATH=$4 |
|
25 |
+TOOLS_PATH=$4 |
|
26 |
+TOOLS_ARCHIVE=$5 |
|
24 | 27 |
PARENT=/usr/src/photon |
28 |
+rm -rf ${BUILDROOT}/* |
|
25 | 29 |
|
26 |
-LOGFILE="$(date +%Y-%m-%d).log" |
|
27 |
-LOGFILE=$LOG_PATH/"${PRGNAME}-${LOGFILE}" |
|
30 |
+#LOGFILE=/dev/null # uncomment to disable log file |
|
31 |
+[ ${EUID} -eq 0 ] || fail "${PRGNAME}: Need to be root user: FAILURE" |
|
32 |
+[ -z ${PARENT} ] && fail "${PRGNAME}: PARENT not set: FAILURE" |
|
33 |
+ |
|
34 |
+if [ ! -d ${BUILDROOT} ] ; then |
|
35 |
+ echo "Creating directory: ${BUILDROOT}" |
|
36 |
+ mkdir -p ${BUILDROOT} |
|
37 |
+fi |
|
28 | 38 |
|
29 | 39 |
if mountpoint ${BUILDROOT}/run >/dev/null 2>&1; then umount ${BUILDROOT}/run; fi |
30 | 40 |
if mountpoint ${BUILDROOT}/sys >/dev/null 2>&1; then umount ${BUILDROOT}/sys; fi |
31 | 41 |
if mountpoint ${BUILDROOT}/proc >/dev/null 2>&1; then umount ${BUILDROOT}/proc; fi |
32 | 42 |
if mountpoint ${BUILDROOT}/dev/pts >/dev/null 2>&1; then umount ${BUILDROOT}/dev/pts; fi |
33 | 43 |
if mountpoint ${BUILDROOT}/dev >/dev/null 2>&1; then umount ${BUILDROOT}/dev; fi |
44 |
+[ ${EUID} -eq 0 ] || fail "${PRGNAME}: Need to be root user: FAILURE" |
|
45 |
+ |
|
46 |
+# |
|
47 |
+#Untar tools build to buildroot |
|
48 |
+# |
|
49 |
+ |
|
50 |
+if [ "x$TOOLS_ARCHIVE" = "xminimal" ] ; then |
|
51 |
+ echo "Uncompressing the tools tar (minimal)" |
|
52 |
+ tar -C ${BUILDROOT} -xzf $TOOLS_PATH/tools.tar.gz >/dev/null |
|
53 |
+else |
|
54 |
+ echo "Uncompressing the tools tar" |
|
55 |
+ tar -C ${BUILDROOT} -xf $TOOLS_PATH/tools-build.tar >/dev/null |
|
56 |
+fi |
|
34 | 57 |
|
35 | 58 |
mkdir -p ${BUILDROOT}/tmp |
36 | 59 |
mkdir -p ${BUILDROOT}${PARENT} |
... | ... |
@@ -40,29 +63,40 @@ mkdir -p ${BUILDROOT}${PARENT}/BUILDROOT |
40 | 40 |
mkdir -p ${BUILDROOT}${PARENT}/LOGS |
41 | 41 |
mkdir -p ${BUILDROOT}${PARENT}/SOURCES |
42 | 42 |
mkdir -p ${BUILDROOT}${PARENT}/SPECS |
43 |
- |
|
44 | 43 |
#copy localegen files. |
45 | 44 |
cp ./locale* ${BUILDROOT}${PARENT}/ |
46 | 45 |
#copy kernel config files |
47 | 46 |
cp ./config* ${BUILDROOT}${PARENT}/ |
48 | 47 |
|
48 |
+ |
|
49 |
+ |
|
49 | 50 |
#copy our macros and set the processor count |
50 |
-#NUMPROCS=`nproc` |
|
51 |
-#let NUMPROCS=$NUMPROCS+1 |
|
52 |
-#echo "%_smp_mflags -j${NUMPROCS}" >> ${BUILDROOT}/tools/etc/rpm/macros |
|
51 |
+NUMPROCS=`nproc` |
|
52 |
+let NUMPROCS=$NUMPROCS+1 |
|
53 |
+echo "%_smp_mflags -j${NUMPROCS}" >> ${BUILDROOT}/tools/etc/rpm/macros |
|
54 |
+ |
|
53 | 55 |
|
54 | 56 |
# Setup the filesystem for chapter 06 |
55 | 57 |
RPMPKG="$(find $RPM_PATH -name 'filesystem*.rpm' -print)" |
56 | 58 |
if [ -z ${RPMPKG} ] ; then |
57 | 59 |
run_command " Extracting filesystem spec" "cp ${SPEC_PATH}/filesystem/filesystem.spec ${BUILDROOT}/${PARENT}/SPECS" "$LOG_PATH/filesystem.log" |
58 |
-run_command "Building filesystem rpm" "rpmbuild -ba --nocheck --define \"_topdir ${BUILDROOT}/${PARENT}\" --define \"_dbpath ${BUILDROOT}/var/lib/rpm\" ${SPEC_PATH}/filesystem/filesystem.spec" "$LOG_PATH/filesystem.log" |
|
59 |
-#run_command " Building filesystem rpm " "rpmbuild -ba --nocheck --root ${BUILDROOT} --define '_topdir ${PARENT}' --define '_dbpath /var/lib/rpm' ${BUILDROOT}${PARENT}/SPECS/filesystem.spec" "$LOG_PATH/filesystem.log" |
|
60 |
+# rpmbuild requires /bin/bash |
|
61 |
+run_command " Creating symlink: /tools/bin /bin" "ln -fsv /tools/bin ${BUILDROOT}/bin" "$LOG_PATH/filesystem.completed" |
|
62 |
+run_command " Building filesystem rpm (in chroot)" "./run-in-chroot.sh ${BUILDROOT} rpmbuild -ba --nocheck --define \\\"_topdir ${PARENT}\\\" ${PARENT}/SPECS/filesystem.spec" "$LOG_PATH/filesystem.log" |
|
63 |
+run_command " Removing symlink: /tools/bin /bin" "rm -f ${BUILDROOT}/bin" "$LOG_PATH/filesystem.completed" |
|
60 | 64 |
run_command " Extracting filesystem rpm" "cp ${BUILDROOT}/${PARENT}/RPMS/x86_64/filesystem*.rpm ${RPM_PATH}/x86_64/" "$LOG_PATH/filesystem.log" |
61 | 65 |
fi |
62 | 66 |
RPMPKGFILE="$(find ${RPM_PATH} -name 'filesystem*.rpm' -printf %f)" |
63 | 67 |
[ -z ${RPMPKGFILE} ] && fail " Filesystem rpm package missing: Can not continue" |
64 |
-run_command " Installing filesystem " "rpm -Uvh --nodeps --root ${BUILDROOT} ${RPM_PATH}/x86_64/${RPMPKGFILE}" "$LOG_PATH/filesystem.completed" |
|
65 |
- |
|
68 |
+run_command " Copying filesystem rpm" "cp ${RPM_PATH}/x86_64/${RPMPKGFILE} ${BUILDROOT}/${PARENT}/RPMS/x86_64" "$LOG_PATH/filesystem.log" |
|
69 |
+run_command " Installing filesystem (in chroot)" "./run-in-chroot.sh ${BUILDROOT} rpm -Uvh --nodeps ${PARENT}/RPMS/x86_64/${RPMPKGFILE}" "$LOG_PATH/filesystem.completed" |
|
70 |
+run_command " Creating symlinks: /tools/bin/{bash,cat,echo,pwd,stty}" "ln -fsv /tools/bin/{bash,cat,echo,pwd,stty} ${BUILDROOT}/bin" "$LOG_PATH/filesystem.completed" |
|
71 |
+run_command " Creating symlinks: /tools/bin/perl /usr/bin" "ln -fsv /tools/bin/perl ${BUILDROOT}/usr/bin" "$LOG_PATH/filesystem.completed" |
|
72 |
+run_command " Creating symlinks: /tools/lib/libgcc_s.so{,.1}" "ln -fsv /tools/lib/libgcc_s.so{,.1} ${BUILDROOT}/usr/lib" "$LOG_PATH/filesystem.completed" |
|
73 |
+run_command " Creating symlinks: /tools/lib/libstdc++.so{,.6} /usr/lib" "ln -fsv /tools/lib/libstdc++.so{,.6} ${BUILDROOT}/usr/lib" "$LOG_PATH/filesystem.completed" |
|
74 |
+[ -z $TOOLS_ARCHIVE ] && \ |
|
75 |
+ run_command " Sed: /usr/lib/libstdc++.la" "sed 's/tools/usr/' ${BUILDROOT}/tools/lib/libstdc++.la > ${BUILDROOT}/usr/lib/libstdc++.la" "$LOG_PATH/filesystem.completed" |
|
76 |
+run_command " Creating symlinks: bash /bin/sh" "ln -fsv bash ${BUILDROOT}/bin/sh" "$LOG_PATH/filesystem.completed" |
|
66 | 77 |
|
67 | 78 |
# Ommited in the filesystem.spec file - not needed for booting |
68 | 79 |
[ -e ${BUILDROOT}/dev/console ] || mknod -m 600 ${BUILDROOT}/dev/console c 5 1 |