summaryrefslogtreecommitdiffstats
path: root/install.txt
blob: 65a6a6753f1e9f62da392506920aec245a56d35e (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<HTML><HEAD>
	<TITLE>Installation Base pour RPM-PHP</TITLE>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</HEAD><BODY><font face="Helvetica">
<H1>Installation Base pour RPM-PHP</H1>
<?php
require "config.inc.php";

function Action($Sql, $AbortIfError=false) 
{
	global $db;

	printf("<pre>%s</pre>\n", $Sql);
	$nb=$db->exec($Sql);
	if ($nb === false) {
		$err=$db->errorInfo();
		printf("<b>Erreur SQL</b> : %s\n", $err[2]);
		if ($AbortIfError) die("<br />** Abandon **");
	} 
	else  {
		$ret = $db->lastInsertId();
		if ($nb) printf("Nombre de rangées affectées : %d</p>\n", $nb);
		else if ($ret) printf("Valeur de l'index : %d</p>\n", $ret);
		return ($ret);
		}
//	else 	echo "OK.</p>\n";
	return 0;

}
function Query ($Sql)
{
	global $db;

	printf("<pre>%s</pre>\n", $Sql);
	$res=$db->query($Sql);
	if (!$res) {
		$err=$db->errorInfo();
		printf("<b>Erreur SQL</b> : %s\n", $err[2]);
	} else {
		echo "<table border='1' cellpadding='2'><tr>";
		for ($i=0 ; $i<$res->columnCount() ; $i++) {
			$meta=$res->getColumnMeta($i);
			//echo "<th><pre>"; print_r($meta); echo "</pre></th>";
			printf("<th>%s</th>", $meta["name"]);
		}
		while ($row = $res->fetch()) {
			echo "<tr>";
			// echo "<td><pre>"; print_r($row); echo "</pre></td>";
			for ($i=0 ; $i<$res->columnCount() ; $i++) {
				printf("<td>%s&nbsp;</td>", $row[$i]);
		}
			echo "</tr>";
		} 
		echo "</tr>\n";
		echo "</table>\n";
	}			
}
try {
$db = new PDO ("mysql:host=" .MYHOST, MYUSER, MYPASS);
	
printf("<p>Verion PHP : <b>%s</b><br />\n", phpversion());
foreach ($db->query("SELECT VERSION() AS Version") as $Row)
	printf ("Version du serveur : <b>%s</b></p>\n", $Row["Version"]);

echo "<hr /><h3>Création du SCHEMA</h3>";

Action("SET NAMES UTF8");
Action("DROP DATABASE IF EXISTS " . MYBASE);
Action("CREATE DATABASE " . MYBASE . " DEFAULT CHARACTER SET utf8");
Action("USE " . MYBASE);

$distros=array(
	array("main"=>"EL-4", "sub"=>"base",    "repo"=>"http://download.fedora.redhat.com/pub/epel/4/x86_64/"),
	array("main"=>"EL-4", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/epel/testing/4/x86_64/"),

	array("main"=>"EL-5", "sub"=>"base",    "repo"=>"http://download.fedora.redhat.com/pub/epel/5/x86_64/"),
	array("main"=>"EL-5", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/epel/testing/5/x86_64/"),

	array("main"=>"F-8", "sub"=>"base",    "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/releases/8/Everything/x86_64/os/"),
	array("main"=>"F-8", "sub"=>"updates", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/8/x86_64/"),
	array("main"=>"F-8", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/testing/8/x86_64/"),

	array("main"=>"F-9", "sub"=>"base",    "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Everything/x86_64/os/"),
	array("main"=>"F-9", "sub"=>"updates", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/9/x86_64/"),
	array("main"=>"F-9", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/testing/9/x86_64/"),

	array("main"=>"rawhide", "sub"=>"",   "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/development/x86_64/os/")
	);

Action("CREATE TABLE `repo` (
	`ID` INT NOT NULL ,
	`main` VARCHAR( 16 ) NOT NULL ,
	`sub` VARCHAR( 16 ) NOT NULL ,
	`url` VARCHAR( 200 ) NOT NULL ,
	`stamp` int(11) DEFAULT NULL,
	PRIMARY KEY ( `ID` )
	) ENGINE = MYISAM");

Action("CREATE TABLE `rpm` (
  	`ID` int(11) NOT NULL AUTO_INCREMENT,
  	`name` varchar(100) NOT NULL,
  	`arch` varchar(20) NOT NULL,
  	`epoch` varchar(20) NOT NULL,
  	`ver` varchar(20) NOT NULL,
  	`rel` varchar(20) NOT NULL,
  	`summary` varchar(200) NOT NULL,
  	`url` varchar(200) NOT NULL,
  	`location` varchar(200) NOT NULL,
  	`repo_main` varchar(16) NOT NULL,
  	`repo_sub` varchar(16) NOT NULL,
  	PRIMARY KEY (`ID`),
  	KEY `name` (`name`),
  	KEY `repo_main` (`repo_main`),
  	KEY `repo_sub` (`repo_sub`)
) ENGINE=MyISAM");

$id=1;
foreach ($distros as $distro) {
	Action("INSERT INTO repo SET ID=$id, main='".$distro["main"]."', sub='".$distro["sub"]."', url='".$distro["repo"]."'");
	$id++;
}
Query("SELECT * FROM repo");
}
catch(PDOException $e) {
	printf("ERREUR : %s\n", $e->getMessage());
}
?>