pts-core: Just mention PHP 5.3 as the new base requirement. Code still should largely...
[phoronix-test-suite.git] / deploy / deb-package / build-package-deb.php
blob66088c100d4172affbe613487cefe7ed4825ef17
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 - 2015, Michael Larabel
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_executable("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/deb-package/build-package-deb.php\n";
27 exit(0);
29 if(!is_executable('/usr/bin/dpkg'))
31 echo PHP_EOL . "dpkg must be present on the system to generate the phoronix-test-suite Debian package." . PHP_EOL . PHP_EOL;
32 exit;
34 if(!is_executable('/usr/bin/fakeroot'))
36 echo PHP_EOL . "fakeroot must be present on the system to generate the phoronix-test-suite Debian package." . PHP_EOL . PHP_EOL;
37 exit;
40 @require("pts-core/pts-core.php");
42 if(!defined("PTS_VERSION"))
44 echo "\nERROR: The Phoronix Test Suite version wasn't found!\n";
45 exit(0);
48 shell_exec("rm -rf /tmp/pts-deb-builder/");
49 shell_exec("mkdir -p /tmp/pts-deb-builder/DEBIAN/");
50 shell_exec("mkdir -p /tmp/pts-deb-builder/usr/");
51 shell_exec("./install-sh /tmp/pts-deb-builder/usr");
53 $pts_version = str_replace("a", "~a", str_replace("b", "~b", PTS_VERSION)); // Fix version
55 $phoronix_test_suite_bin = file_get_contents("phoronix-test-suite");
56 $phoronix_test_suite_bin = str_replace("export PTS_DIR=`pwd`", "export PTS_DIR='/usr/share/phoronix-test-suite/'", $phoronix_test_suite_bin);
57 file_put_contents("/tmp/pts-deb-builder/usr/bin/phoronix-test-suite", $phoronix_test_suite_bin);
58 shell_exec("chmod +x /tmp/pts-deb-builder/usr/bin/phoronix-test-suite");
60 $control_file = "Package: phoronix-test-suite\n";
61 $control_file .= "Version: " . $pts_version . "\n";
62 $control_file .= "Section: Utilities\n";
63 $control_file .= "Installed-Size: " . shell_exec("cd /tmp/pts-deb-builder/; du -s | cut -f 1");
64 $control_file .= "Priority: optional\n";
65 $control_file .= "Architecture: all\n";
66 $control_file .= "Depends: php5-cli, php5-gd, php5-json\n";
67 $control_file .= "Recommends: build-essential\n";
68 $control_file .= "Maintainer: Phoronix Media <trondheim-pts@phoronix-test-suite.com>\n";
69 $control_file .= "Description: An Automated, Open-Source Testing Framework\n " . @str_replace("\n", " ", file_get_contents('pts-core/static/short-description.txt')) . "\n";
70 $control_file .= "Homepage: http://www.phoronix-test-suite.com/ \n";
71 file_put_contents("/tmp/pts-deb-builder/DEBIAN/control", $control_file);
73 shell_exec("fakeroot dpkg --build /tmp/pts-deb-builder ../phoronix-test-suite_" . $pts_version . "_all.deb");
74 shell_exec("rm -rf /tmp/pts-deb-builder");