Skip to content

Commit

Permalink
Added download_latest.php as a tool to download the latest version.
Browse files Browse the repository at this point in the history
  • Loading branch information
arendvw committed Jul 21, 2016
1 parent 3da00a8 commit f37b22f
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,24 @@ Build scripts to easily create a `.deb` package for PhpStorm.
Dependencies
------------

You will need the `devscripts` and the `debhelper` packages installed in order to build the PhpStorm `.deb` file:
You will need the `devscripts` `debhelper` `php` and `php-curl` packages installed in order to build the PhpStorm `.deb` file:

```sh
apt-get install devscripts debhelper
apt-get install devscripts debhelper php php-curl
```

Build (Automatic)
----------------
* Run the `download_latest.php` file
```sh
php download_latest.php
```

This will execute all steps described below.


Building
--------
Building (Manuallly)
--------------------

* Download the `.tar.gz` file from [PhpStorm's download page](https://www.jetbrains.com/phpstorm/download/index.html) and place it in the root directory of this repo.

Expand Down
67 changes: 67 additions & 0 deletions download_latest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env php
<?php
$dir = dirname(__FILE__);

echo "Cleaning up old installs\n";
array_map('unlink', glob("*.tar.gz"));
array_map('unlink', glob("*.sha256"));

echo "Downloading new version\n";
$url = "https://data.services.jetbrains.com/products/releases?code=PS&latest=true";
$result = curlDownload($url);

$data = json_decode($result, true);
$link = $data["PS"][0]["downloads"]["linux"]["link"];
$md5sum = $data["PS"][0]["downloads"]["linux"]["checksumLink"];

echo "Downloading $link\n";

$filename = basename($link);
$checksumName = basename($md5sum);

curlDownload($link, $dir."/".$filename);
echo "Downloading $md5sum\n";
curlDownload($md5sum, $dir."/".$checksumName);

echo "Verifying checksum";
$exitcode = "";
$output = "";
exec ("sha256sum -c $dir/$checksumName", $output, $exitcode);

if ((int)$exitcode !== 0)
{
echo "Checksum failed!";
exit;
}

shell_exec($dir."/update.sh");
echo "Download and update complete. Execute the following commands to build and update the new php version\n";

echo "Building latest version.. \n";
chdir ($dir);
exec("debuild -us -uc -b");

$debname = str_replace("-","_",strtolower(basename($filename,".tar.gz"))."_all.deb");
echo "Build complete. Install the new version by using \n";
echo "sudo dpkg -i ../$debname";

function curlDownload($url, $destination = null)
{
$ch = curl_init();
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result=curl_exec($ch);

// Closing
curl_close($ch);
if ($destination)
{
$file = fopen($destination, "w+");
fputs($file, $result);
fclose($file);
}

return $result;
}

0 comments on commit f37b22f

Please sign in to comment.