dreambox mediaportal downloader

raw

update.php

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
<?php
//look for new enigma2-plugin-extensions-mediaportal versions
// download + add source to git
// http://git.cweiske.de/enigma2-mediaportal.git/
$data = file('http://dhwz.github.io/e2-mediaportal/version.txt');
$debUrl = trim($data[3]);
 
function err($msg) {
    file_put_contents('php://stderr', $msg . "\n");
    exit(1);
}
if (substr($debUrl, -4) !== '.deb') {
    err('e2-mediaportal update script broken');
}
$filename = substr($debUrl, strrpos($debUrl, '/') + 1);
$version  = preg_replace('#^.+_([^_]+)_.+$#', '\\1', $filename);
 
$dlPath = __DIR__ . '/download/' . $filename;
if (file_exists($dlPath)) {
    echo "No update.\n";
    exit(0);
}
 
echo "Download new version $version\n";
exec(
    'wget --quiet'
    . ' -O ' . escapeshellarg($dlPath)
    . ' ' . escapeshellarg($debUrl),
    $output,
    $retval
);
if ($retval != 0) {
    err('Failed to download new version from ' . $debUrl);
}
 
echo "Add to git\n";
chdir(__DIR__);
exec(
    'cd source'
    . ' && rm -r *'
    . '; dpkg-deb -x ' . escapeshellarg($dlPath) . ' .'
    . ' && git add . '
    . ' && git commit'
    . ' -m ' . escapeshellarg(
        'import enigma2-plugin-extensions-mediaportal ' . $version
    )
    . ' && git tag ' . escapeshellarg('v' . $version),
    $out,
    $retval
);
if ($retval != 0) {
    err('Failed to add new version to git: ' . $version);
}
 
exec('cd source && git push && git push --tags', $out, $retval);
if ($retval != 0) {
    err('Failed to push to git remote');
}
 
echo "Done\n";
?>
Christian Weiske Christian Weiske
owner

History