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
|
<?php
header("Content-Type: application/json");
require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
exec("bash -c \"sudo apt-get upgrade -s| grep ^Inst\"", $ret);
$data = [];
$data["count"] = count($ret);
$data["packages"] = [];
foreach ($ret as $package) {
$parts = explode(" ", trim($package));
$pkg = [
"name" => trim($parts[1]),
"version" => [
"local" => trim(explode("]", explode("[", $parts[2])[1])[0]),
"remote" => trim(explode("(", $parts[3])[1]),
],
"repos" => trim(explode(":", explode("(", explode("[", trim($package))[1])[1])[1]),
"architecture" => trim(explode("]", explode("[", trim($package))[2])[0])
];
$data["packages"][] = $pkg;
}
echo(json_encode($data, JSON_PRETTY_PRINT));
|