summaryrefslogtreecommitdiffstats
path: root/pts-core/options/install_test.php
blob: 726563ace6e7b4f8c8a3bbd1d4f3e75a7b10b647 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php

/*
	Phoronix Test Suite
	URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
	Copyright (C) 2008, Phoronix Media
	Copyright (C) 2008, Michael Larabel

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

class install_test implements pts_option_interface
{
	public static function run($items_to_install)
	{
		pts_load_function_set("install");

		if(count($items_to_install) == 0)
		{
			echo "\nThe test, suite name, or saved identifier must be supplied.\n";
		}
		else
		{
			if(IS_SCTP_MODE)
			{
				$items_to_install[0] = basename($items_to_install[0]);
			}

			$items_to_install = array_unique(array_map("strtolower", $items_to_install));

			if(pts_read_assignment("COMMAND") == "force-install")
			{
				pts_set_assignment("PTS_FORCE_INSTALL", 1);
			}

			// TODO: Search $items_to_install and look for pcqs match instead of only first argument
			if(strpos($items_to_install[0], "pcqs") !== false && !is_file(XML_SUITE_LOCAL_DIR . "pcqs-license.txt"))
			{
				// Install the Phoronix Certification & Qualification Suite
				$agreement = wordwrap(file_get_contents("http://www.phoronix-test-suite.com/pcqs/pcqs-license.txt"), 65);

				if(strpos($agreement, "PCQS") == false)
				{
					echo pts_string_header("An error occurred while connecting to the Phoronix Test Suite server. Try again later.");
					return false;
				}

				echo "\n\n" . $agreement;
				$agree = pts_bool_question("Do you agree to these terms in full and wish to proceed (y/n)?", false);

				if($agree)
				{
					pts_download("http://www.phoronix-test-suite.com/pcqs/download-pcqs.php", XML_SUITE_LOCAL_DIR . "pcqs-suite.tar");
					pts_extract_file(XML_SUITE_LOCAL_DIR . "pcqs-suite.tar", true);
					echo pts_string_header("The Phoronix Certification & Qualification Suite is now installed.");
				}
				else
				{
					pts_string_header("In order to run PCQS you must agree to the listed terms.");
					return false;
				}
			}

			echo "\n";

			// Any external dependencies?
			pts_install_package_on_distribution($items_to_install);

			// Install tests
			pts_start_install($items_to_install);
		}
	}
}

?>