blob: c6456381af6f02388db52bb3e4e7eb8dd9c76a2d (
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
|
<?
require_once 'header.php';
if(!$tree) {
$tree =& PortageTree::singleton();
}
require_once 'class.portage.category.php';
require_once 'class.portage.package.php';
require_once 'class.portage.ebuild.php';
// Get the arches
$arr_licenses = $tree->getLicenses();
// Find all the ebuilds that are missing ebuild arch
$sql = "SELECT ebuild, metadata FROM missing_license;";
$arr_missing_license = $db->getAssoc($sql);
if($verbose)
shell::msg(count($arr)." ebuilds to check");
// Get the licenses from the database
$db_licenses = $db->getAssoc("SELECT name, id FROM license;");
if(count($arr_missing_license)) {
foreach($arr_missing_license as $ebuild => $str) {
if(!empty($str)) {
$arr = arrLicenses($str, $arr_licenses);
if(count($arr)) {
foreach($arr as $str) {
if($db_licenses[$str]) {
$arr_insert = array(
'ebuild' => $ebuild,
'license' => $db_licenses[$str],
);
$db->autoExecute('ebuild_license', $arr_insert, MDB2_AUTOQUERY_INSERT);
}
}
}
}
}
}
/**
* Create an array of the ebuild's licenses
*
* @param string licenses
* @return array
*/
function arrLicenses($str, $licenses) {
$arr = explode(' ', $str);
$arr_licenses = array();
if(count($arr)) {
foreach($arr as $str) {
if(in_array($str, $licenses))
$arr_licenses[] = $str;
}
$arr_licenses = array_unique($arr_licenses);
}
return $arr_licenses;
}
?>
|