MadelineProto/tests/makephar.sh

139 lines
4.4 KiB
Bash
Raw Normal View History

2018-02-23 20:30:56 +01:00
#!/bin/bash -e
2019-06-18 12:31:44 +02:00
# Configure
PHP_MAJOR_VERSION=$(php -r 'echo PHP_MAJOR_VERSION;')
PHP_MINOR_VERSION=$(php -r 'echo PHP_MINOR_VERSION;')
# Download converters
2019-06-19 11:18:51 +02:00
composer global require spatie/7to5 dev-master#e03b18903c45b01546c2984cc3c54e4750c71e3a
2018-02-21 12:55:42 +01:00
[ -f $HOME/.composer/vendor/bin/php7to5 ] && php7to5=$HOME/.composer/vendor/bin/php7to5
[ -f $HOME/.config/composer/vendor/bin/php7to5 ] && php7to5=$HOME/.config/composer/vendor/bin/php7to5
composer global require danog/7to70
[ -f $HOME/.composer/vendor/bin/php7to70 ] && php7to70=$HOME/.composer/vendor/bin/php7to70
[ -f $HOME/.config/composer/vendor/bin/php7to70 ] && php7to70=$HOME/.config/composer/vendor/bin/php7to70
2019-06-18 12:31:44 +02:00
# Clean up
2018-02-21 12:55:42 +01:00
rm -rf phar7 phar5 MadelineProtoPhar
madelinePath=$PWD
cd
rm -rf phar7 phar5 MadelineProtoPhar
2018-02-21 12:55:42 +01:00
mkdir phar7
cd phar7
2019-06-18 12:31:44 +02:00
# Install
2018-02-21 12:55:42 +01:00
echo '{
"name": "danog/madelineprototests",
"minimum-stability":"dev",
"require": {
2019-06-12 18:48:05 +02:00
"danog/madelineproto": "dev-master",
"amphp/dns": "dev-master#aa1892bd as 0.9"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/danog/phpseclib"
},
{
"type": "path",
"url": "'$madelinePath'",
"options": {
"symlink": false
}
}
],
"authors": [
{
"name": "Daniil Gentili",
"email": "daniil@daniil.it"
}
]
}' > composer.json
2019-06-18 14:39:31 +02:00
composer config platform.php "7.4"
[ $PHP_MAJOR_VERSION -eq 5 ] && composer require dstuecken/php7ify
composer clearcache
2018-02-21 12:55:42 +01:00
composer update
2019-06-06 15:57:21 +02:00
cp -a $madelinePath/src vendor/danog/madelineproto/
2018-02-21 12:55:42 +01:00
cd ..
[ $PHP_MAJOR_VERSION -eq 5 ] && {
2019-06-18 18:27:26 +02:00
#git clone https://github.com/php-build/php-build $(phpenv root)/plugins/php-build
2019-06-18 17:34:25 +02:00
#git clone -b rel-1-5-1 https://github.com/nih-at/libzip.git
#cd libzip
#cmake -DCMAKE_INSTALL_PREFIX=$HOME/.phpenv/versions/7.3.6 .
#make -j11
#make install
2019-06-18 18:13:24 +02:00
#phpenv install 7.3.6
2019-06-18 15:04:13 +02:00
2019-06-18 18:13:24 +02:00
php7.3 $php7to5 convert --copy-all phar7 phar5 >/dev/null
sed 's/^Loop::set.*;//g' -i phar5/vendor/amphp/amp/lib/Loop.php
echo 'Loop::set((new DriverFactory())->create());' >> phar5/vendor/amphp/amp/lib/Loop.php
2019-06-18 18:27:26 +02:00
cp $madelinePath/tests/random.php phar5/vendor/paragonie/random_compat/lib/random.php
cp phar5/vendor/danog/madelineproto/src/danog/MadelineProto/Coroutine.php phar5/vendor/amphp/amp/lib/Coroutine.php
sed 's/namespace danog\\MadelineProto;/namespace Amp;/g' -i phar5/vendor/amphp/amp/lib/Coroutine.php
2019-06-18 18:52:17 +02:00
sed 's/public static function echo/public static function echo_/g' -i phar5/vendor/danog/madelineproto/src/danog/MadelineProto/Tools.php
2019-06-18 15:04:13 +02:00
php -v
php=5
}
[ $PHP_MAJOR_VERSION -eq 7 ] && {
[ $PHP_MINOR_VERSION -eq 0 ] && {
$php7to70 convert --copy-all phar7 phar5 >/dev/null
php=70
} || {
cp -a phar7 phar5
}
}
2018-06-22 13:28:33 +02:00
find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} +
2018-02-21 12:55:42 +01:00
2019-06-19 11:18:51 +02:00
# Make sure conversion worked
for f in $(find . -type f -name '*.php'); do php -l $f | grep -v 'No syntax errors';done
#[ "$TRAVIS_BRANCH" != "master" ] && branch="-$TRAVIS_BRANCH" || branch=""
branch="-$TRAVIS_BRANCH"
cd $madelinePath
php makephar.php $HOME/phar5 "madeline$php$branch.phar" $TRAVIS_COMMIT
2018-02-21 12:55:42 +01:00
export TRAVIS_PHAR="madeline$php$branch.phar"
2019-06-16 21:20:29 +02:00
export TEST_SECRET_CHAT=test
export TEST_USERNAME=danogentili
2019-06-17 12:19:46 +02:00
export TEST_DESTINATION_GROUPS='["@danogentili"]'
2019-06-16 21:20:29 +02:00
2019-06-17 12:19:46 +02:00
tests/testing.php <<EOF
m
$API_ID
$API_HASH
b
$BOT_TOKEN
n
n
n
EOF
2019-06-16 21:20:29 +02:00
2018-02-21 13:05:35 +01:00
eval "$(ssh-agent -s)"
echo -e "$private_key" > madeline_rsa
chmod 600 madeline_rsa
2018-02-21 13:05:35 +01:00
ssh-add madeline_rsa
2018-02-21 12:55:42 +01:00
git clone git@github.com:danog/MadelineProtoPhar
cd MadelineProtoPhar
cp "../madeline$php$branch.phar" .
2018-05-10 11:38:51 +02:00
cp ../phar.php ../mtproxyd .
2019-06-18 19:02:31 +02:00
echo -n $TRAVIS_COMMIT > release$php$branch
2018-02-21 12:55:42 +01:00
git add -A
Merge alpha into master (async, huge bugfixes and more) (#546) * Implement async and lots of bugfixes * Implement more async * Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr * Apply fixes from StyleCI * Bugfixes * Apply fixes from StyleCI * Bugfixes, implement combined promises * Apply fixes from StyleCI * Support passing method arguments as callable * Starting to write async upload logic * Apply fixes from StyleCI * Start implementing async file upload * Apply fixes from StyleCI * bugfix * Apply fixes from StyleCI * Start rewriting connection module * Add PHP file docblocks for all classes * Start working on new async stream API * Finish writing stream API * More stream API fixes * Apply fixes from StyleCI * Rewrite DataCenter and Connection modules * Clean up stream API documentation * Fixes * Apply fixes from StyleCI * Add referenced parameter to get length of buffer to read in getReadBuffer API * Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar * Start fixing reads * Fix all protocol stream wrappers * Apply fixes from StyleCI * Implement disconnection, and remove end function * Working async RPC * Implement async file upload * Bugfix * Method recall bugfixes * Bugfixes * Trait bugfixes * Fix FIFO buffer * Bugfixes and speedtests * Async logging * Implement websocket streams * Implement loop API, signal API, clean closing and start changing layer * Small magna, websocket and HTTP fixes * Clean up loop API * Improved stack traces, 2FA and async * Login fixes * Added instructions for manual verification * Small fixes * More app info improvements * More app info improvements * TL and 2FA fixes * Update to layer 89 * More bugfixes * Implement broken media reporting * Remove debug comments * PHP 7.2 backwards compatibility * Bugfixes * Async key generation * Some simplifications * Transport fixes * Cleanup * async API * Performance fixes * Fixes to async API * Bugfixes * Implement one-time async loop * Authorization and logging fixes * Update to layer 91 * 7to5 fix * Null coalesce conversion * Implement socks5 proxy * Implement HTTP proxy * Fixes to HTTP proxy * MTProxy and socks5 fixes * Disable PHP 5 conversion * Proxies have higher priority * Avoid error handling in vendor * Override composer dependencies * Fix travis build * Final composer fixes * Proxy logic fixes * Fix get_updates update handling * Do not use parallel file driver if not supported * Refactor loader and implement HTTP fixes * Suppress errors in loader * HTTP and authorization fixes * HTTP fixes * Improved peer management * Use HTTP protocol on altervista * Small bugfixes * Minor fixes * Docufix * Docufix * Legacy fixes * Fix message queue * Avoid updating if using MTProxy * Improve logs and examples * Trim final newlines while converting parse mode * Reimplement noResponse flag * Async combined event handler and APIFactory fixes * Actually return config * Case-insensitive methods * Bugfix * Apply fixes from StyleCI (#545) * MTProxy fixes * PHP 5 warning * Improved PHP 5 warning * Use <br> along with newlines in web logs * Update docs
2018-12-26 20:51:14 +01:00
git commit -am "Release $TRAVIS_BRANCH - $TRAVIS_COMMIT_MESSAGE"
2018-02-21 12:55:42 +01:00
git push origin master
cd ..
echo "$TRAVIS_COMMIT_MESSAGE" | grep "Apply fixes from StyleCI" && exit
2018-02-20 13:15:32 +01:00
[ -d JSON.sh ] || git clone https://github.com/dominictarr/JSON.sh
for chat_id in $destinations;do
2019-06-17 13:09:40 +02:00
ID=$(curl -s https://api.telegram.org/bot$BOT_TOKEN/sendMessage -F disable_web_page_preview=1 -F text=" <b>Recent Commits to MadelineProto:$TRAVIS_BRANCH</b>
2019-06-18 19:02:31 +02:00
<a href=\"https://github.com/danog/MadelineProto/commit/$TRAVIS_COMMIT\">$TRAVIS_COMMIT_MESSAGE (PHP $PHP_MAJOR_VERSION.$PHP_MINOR_VERSION)</a>
2018-02-20 13:15:32 +01:00
$TRAVIS_COMMIT_MESSAGE" -F parse_mode="HTML" -F chat_id=$chat_id | JSON.sh/JSON.sh -s | egrep '\["result","message_id"\]' | cut -f 2 | cut -d '"' -f 2)
2018-02-20 13:33:29 +01:00
2018-02-20 13:15:32 +01:00
done