pts-core: Just mention PHP 5.3 as the new base requirement. Code still should largely...
[phoronix-test-suite.git] / deploy / rpm-package / build-package-rpm.php
blob9a8c2491794b66a8354437e099ef7ae413228568
1 <?php
3 /*
4 Phoronix Test Suite
5 URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
6 Copyright (C) 2008 - 2015, Phoronix Media
7 Copyright (C) 2008, Andrew Schofield
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 if(!is_file("phoronix-test-suite") || !is_dir("pts-core/"))
25 echo "\nYou must run this script from the root directory of the phoronix-test-suite/ folder!\n";
26 echo "Example: php5 deploy/rpm-package/build-package-rpm.php\n";
27 exit(0);
29 if(!is_executable('/usr/bin/rpmbuild'))
31 echo PHP_EOL . "rpmbuild must be present on the system. Try: yum install rpm-build." . PHP_EOL . PHP_EOL;
32 exit;
35 @require("pts-core/pts-core.php");
37 if(!defined("PTS_VERSION"))
39 echo "\nERROR: The Phoronix Test Suite version wasn't found!\n";
40 exit(0);
43 $rpm_v = PTS_VERSION . '.' . date('YmdHi');
45 shell_exec("rm -rf /tmp/pts-rpm-builder/");
46 shell_exec("mkdir -p /tmp/pts-rpm-builder/{BUILD,RPMS,S{OURCE,PEC,RPM}S,phoronix-test-suite-" . $rpm_v . "}");
47 shell_exec("cp -R ./ /tmp/pts-rpm-builder/phoronix-test-suite-" . $rpm_v . "/");
48 shell_exec("tar --exclude=.git -C /tmp/pts-rpm-builder/ -cjvf /tmp/pts-rpm-builder/SOURCES/phoronix-test-suite-" . $rpm_v . ".tar.bz2 phoronix-test-suite-" . $rpm_v . "/");
50 $spec_file = "Summary: A Comprehensive Linux Benchmarking System\n";
51 $spec_file .= "Name: phoronix-test-suite\n";
52 $spec_file .= "Version: " . $rpm_v . "\n";
53 $spec_file .= "Release: 1\n";
54 $spec_file .= "License: GPL\n";
55 $spec_file .= "Group: Utilities\n";
56 $spec_file .= "URL: http://www.phoronix-test-suite.com/\n";
57 $spec_file .= "Source: phoronix-test-suite-" . $rpm_v . ".tar.bz2\n";
58 $spec_file .= "Packager: Phoronix Media <trondheim-pts@phoronix-test-suite.com>\n";
59 $spec_file .= "Requires: php-cli, php-xml\n";
60 $spec_file .= "BuildArch: noarch\n";
61 $spec_file .= "BuildRoot: %{_tmppath}/%{name}-%{version}-root\n";
62 $spec_file .= "%description\n";
63 $spec_file .= @file_get_contents("pts-core/static/short-description.txt") . "\n";
64 $spec_file .= "%prep\n";
65 $spec_file .= "%setup -q\n";
66 $spec_file .= "%build\n";
67 $spec_file .= "%install\n";
68 $spec_file .= "rm -rf %{buildroot}\n";
69 $spec_file .= "./install-sh %{buildroot}/usr\n";
70 $spec_file .= "sed -i 's|%buildroot||g' %buildroot%_bindir/phoronix-test-suite\n";
71 $spec_file .= "%clean\n";
72 $spec_file .= "rm -rf %{buildroot}\n";
73 $spec_file .= "%files\n";
74 $spec_file .= "%{_bindir}/phoronix-test-suite\n";
75 $spec_file .= "%{_datadir}/phoronix-test-suite/*\n";
76 $spec_file .= "%{_datadir}/applications/*\n";
77 $spec_file .= "%{_datadir}/icons/hicolor/*\n";
78 $spec_file .= "%{_datadir}/appdata/%{name}.appdata.xml\n";
79 $spec_file .= "%{_datadir}/doc/*\n";
80 $spec_file .= "%{_mandir}/man1/%{name}.1*\n";
81 $spec_file .= "%config(noreplace) %{_sysconfdir}/bash_completion.d\n";
82 $spec_file .= "%config(noreplace) %{_sysconfdir}/../usr/lib/systemd/system/*\n";
83 //$spec_file .= "%config(noreplace) %{_sysconfdir}/init/*\n";
84 $spec_file .= "%changelog\n";
85 $spec_file .= "* " . date('D M d Y') . " Phoronix Media <phoronix@phoronix.com>\n";
86 $spec_file .= "- Initial release.";
88 file_put_contents("/tmp/pts-rpm-builder/SPECS/pts.spec", $spec_file);
89 shell_exec("mv -f " . getenv('HOME') . "/.rpmmacros /tmp/pts-rpm-builder 2>&1");
90 file_put_contents(getenv('HOME') ."/.rpmmacros", "%_topdir /tmp/pts-rpm-builder");
91 shell_exec("rpmbuild -ba --verbose /tmp/pts-rpm-builder/SPECS/pts.spec");
92 shell_exec("cp /tmp/pts-rpm-builder/RPMS/noarch/phoronix-test-suite-" . $rpm_v . "-1.noarch.rpm ./");
93 shell_exec("rm -f " . getenv('HOME') . "/.rpmmacros");
94 shell_exec("mv -f /tmp/pts-rpm-builder/.rpmmacros " . getenv('HOME') . ' 2>1');
95 shell_exec("rm -rf /tmp/pts-rpm-builder");