1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 19:24:42 +01:00

Improve phar self-update mechanism

This commit is contained in:
Daniil Gentili 2018-03-01 13:28:16 +01:00
parent 5741acc9a3
commit 16e0fb4a57
3 changed files with 5 additions and 8 deletions

View File

@ -29,9 +29,7 @@ if (basename($backtrace[0]["file"]) === "phar.php") {
chdir(dirname($backtrace[1]["file"]));
if (!isset($phar_debug)) file_put_contents($backtrace[0]["file"], file_get_contents("https://phar.madelineproto.xyz/phar.php?v=new"));
}
if ((new Phar(__FILE__))[".git/refs/heads/master"]->getContent() !== file_get_contents("https://phar.madelineproto.xyz/release?v=new") && !isset($phar_debug)) {
file_put_contents(__FILE__, file_get_contents("https://phar.madelineproto.xyz/madeline.phar?v=new"));
}
Phar::interceptFileFuncs();
Phar::mapPhar("'.$argv[2].'");
require_once "phar://'.$argv[2].'/vendor/autoload.php";

View File

@ -1,10 +1,8 @@
<?php
if (!file_exists('madeline.phar')) {
if (!file_exists('madeline.phar') || !file_exists('madeline.phar.version') || file_get_contents('madeline.phar.version') !== file_get_contents('https://phar.madelineproto.xyz/release?v=new')) {
file_put_contents('madeline.phar', file_get_contents('https://phar.madelineproto.xyz/madeline.phar?v=new'));
file_put_contents('madeline.phar.version', file_get_contents('https://phar.madelineproto.xyz/release?v=new'));
}
require 'madeline.phar';
if (trim(file_get_contents('phar://madeline.phar/.git/refs/heads/master')) !== trim(file_get_contents('https://phar.madelineproto.xyz/release?v=new'))) {
file_put_contents('madeline.phar', file_get_contents('https://phar.madelineproto.xyz/madeline.phar?v=new'));
}
require 'madeline.phar';

View File

@ -41,6 +41,7 @@ ssh-add madeline_rsa
git clone git@github.com:danog/MadelineProtoPhar
cd MadelineProtoPhar
cp ../madeline.phar .
cp ../phar.php .
echo -n $TRAVIS_COMMIT > release
git add -A
git commit -am "Release $TRAVIS_COMMIT"