Compare commits

..

37 Commits

Author SHA1 Message Date
Anatol Belski
422073f540 note about ConEmu 2016-10-30 12:19:51 +01:00
Anatol Belski
08fbbc7cd2 improve phrase 2016-10-29 23:45:00 +02:00
Anatol Belski
182f988f92 rework readme with more info 2016-10-29 23:43:47 +02:00
Anatol Belski
022eaba41e yet more edits 2016-10-29 23:01:44 +02:00
Anatol Belski
2a403e1820 some edits to the readme 2016-10-29 22:18:02 +02:00
Anatol Belski
07efa67e87 remove more unrelated tools 2016-10-29 22:01:42 +02:00
Anatol Belski
e74a98e253 add fixme 2016-10-28 16:13:24 +02:00
Anatol Belski
04aaf65cda accumulate return value 2016-10-28 15:18:36 +02:00
Anatol Belski
33c82a766f fix wording again 2016-10-28 14:14:27 +02:00
Anatol Belski
efb77f4589 add some vim folds 2016-10-28 14:09:01 +02:00
Anatol Belski
cddbe84fe3 add vim mode configs 2016-10-28 14:03:17 +02:00
Anatol Belski
6326bba7a1 rework pkg update msg 2016-10-28 13:27:38 +02:00
Anatol Belski
fdf6827c51 add FileOps trait and rework the deps update routine 2016-10-28 13:24:35 +02:00
Anatol Belski
feb2b675cb unset temp var 2016-10-28 02:18:57 +02:00
Anatol Belski
b60fd588d5 it's alpha4 now 2016-10-28 02:13:27 +02:00
Anatol Belski
4af7617b84 separate dumpenv out 2016-10-28 02:13:01 +02:00
Anatol Belski
7395237e33 edit error msg 2016-10-28 01:59:25 +02:00
Anatol Belski
2bd2595a16 add phpsdk-local example 2016-10-28 01:52:13 +02:00
Anatol Belski
3c204136a2 don't allow to append arbitrary code, but just a local file - that's
enough
2016-10-27 22:28:19 +02:00
Anatol Belski
ac205e153f do necessary followup ns renames 2016-10-27 16:08:29 +02:00
Anatol Belski
71f60852f8 move cache into the config space 2016-10-27 16:02:43 +02:00
Anatol Belski
5999098add check infos also in other scripts if run outside starter shell 2016-10-26 17:18:35 +02:00
Anatol Belski
9f8cf17928 fix phpsdk_deps dies when called with no SdK setup 2016-10-26 17:09:54 +02:00
Anatol Belski
496a4498a1 bump version 2016-10-26 16:49:48 +02:00
Anatol Belski
1162213596 fix order 2016-10-26 16:11:50 +02:00
Anatol Belski
c8e1563cd4 separate list and do it shorter 2016-10-26 16:10:00 +02:00
Anatol Belski
9b139a61c8 remove unnecessary sentence 2016-10-26 16:07:29 +02:00
Anatol Belski
bf84962182 more readme rework 2016-10-26 16:06:10 +02:00
Anatol Belski
d87c132a7e improve note 2016-10-26 16:04:35 +02:00
Anatol Belski
c781649433 add more readme notes 2016-10-26 15:59:05 +02:00
Anatol Belski
bd8b82579f fix starter arg passing, handle error from setshell script 2016-10-26 15:30:00 +02:00
Anatol Belski
d6b76e7f7d split out the phpsdk-starter part and make possible to append scripts 2016-10-26 15:19:03 +02:00
Anatol Belski
7f0015a68c rework the buildtree script 2016-10-26 13:40:14 +02:00
Anatol Belski
23a3eb2473 set console title when run from the starter script 2016-10-26 02:07:10 +02:00
Anatol Belski
296be1b3b4 make the prompt a bit more user friendly 2016-10-26 02:00:53 +02:00
Anatol Belski
3ec0ac9d0b extend .gitignore 2016-10-26 01:20:18 +02:00
Anatol Belski
baf09da395 remove unsupported branches 2016-10-26 01:17:33 +02:00
29 changed files with 518 additions and 203 deletions

4
.gitignore vendored
View File

@@ -14,3 +14,7 @@ logs
PFTT
\.tmp
\.cache
oracle
# either these two become submodules, or uncomment them
#pgo-build
#rmtools*

View File

@@ -4,53 +4,98 @@ PHP SDK is a tool kit for Windows PHP builds
# License
BSD
The PHP SDK itself and the SDK own tools are licensed under the BSD 2-Clause license. With the usage of the other tools, you accept the respective licenses.
# Notes
# Overview
This reworked SDK is compatible with PHP 7.0 and above. The compatibility with php-sdk-binary-tools-20110915.zip available from windows.php.net is kept, though some irrelevant tools was removed. Though, newer tools and workflows are now possible, and the work is in progress. The toolset consists on a mix of the hand written scripts, selected MSYS2 parts and standalone programs.
The PHP SDK 2.0 is compatible with PHP 7.0 and above. The compatibility with older versions, eq. php-sdk-binary-tools-20110915.zip available from windows.php.net previously, is kept. Though, some irrelevant tools was removed. Newer tools are now available, better workflows are now possible. The toolset consists on a mix of the hand written scripts, selected MSYS2 parts and standalone programs.
## SDK tools
# Requirements
- `Visual C++ 2015` must be installed prior SDK usage
- if `Cygwin` is installed, please read notes in the pitfalls section
- if a 64-bit build is intended, a 64-bit system is required. Cross compilation of 64-bit on 32-bit system is not supported at the moment
# Tools
All the tools included are either scripts or 32-bit binaries. They are therefore runable on any of x86 or x64 Windows system.
## SDK
- starter scripts, named phpsdk-<crt>-<arch>.bat
- `phpsdk_buildtree` - initialize the development filesystem structure
- `phpsdk_deps` - check and handle dependency libraries
- `phpsdk_deps` - handle dependency libraries
- `phpsdk_version` - show SDK version
- `phpsdk_dllmap` - create a JSON listing of DLLs contained in zip files
## Other available tools
## Other tools
- `bison` 3.0.2, `re2c` 0.15.3
- `awk`, `gawk`, `sed`, `grep`
- `diff`, `diff3`, `patch`
- `md5sum`, `sha1sum`, `sha224sum`, `sha256sum`, `sha384sum`, `sha512sum`
- `7za`, `zip`, `unzip`
- `7za`, `zip`, `unzip`, `unzipsfx`
- `wget`
## Not included
## Optional, not included
These are not included with the PHP SDK, but might be useful for the compilation and other tasks. While Visual C++ is the only required, the others might enable some additional functionality. Care yourself about making them available on your system.
These are not included with the PHP SDK, but might be useful. While Visual C++ is the only required, the others might enable some additional functionality. Care yourself about making them available on your system, if relevant.
- Visual C++
- clang
- ICC
- Git
- Cppcheck
- `Git` - useful for PHP source management
- `Cppcheck` - used for static analysis
- `clang` - useful for experimental builds and for static analysis
- `ICC` - useful for experimental builds
# Usage
## Basic usage
The PHP SDK should be unzipped into the shortest possible path, preferrably into the drive root.
Usually, the first step to start the PHP SDK is by invoking one of the suitable starter scripts. This automatically puts the console on the correct environment relevant for the desired PHP build configuration.
It is not required to hold the source in the PHP SDK directory. It could be useful, for example, to simplify the SDK updates.
## Basic usage example
- `git clone https://github.com/OSTC/php-sdk-binary-tools.git c:\php-sdk`
- `cd c:\php-sdk`
- `git checkout new_binary_tools`
- `cd` to c:\php-sdk and click one of the `phpsdk-*.bat` files in the SDK root, depending on the desired build parameters
- `phpsdk_buildtree && git clone https://github.com/php/php-src.git`, or fetch a zipball from windows.php.net
- while in php-src, run `phpsdk_deps --update --branch YOUR_BRANCH_NAME`
- either run or click on `phpsdk-vc14-x64.bat` in the PHP SDK root
- `cd` to c:\php-sdk and click on `phpsdk-vc14-x64.bat` in the PHP SDK root
- `phpsdk_buildtree phpmaster`
- `git clone https://github.com/php/php-src.git && cd php-src`, or fetch a zipball
- `phpsdk_deps --update --branch master`
- do the build, eg. `buildconf && configure --enable-cli && nmake`
TODO more extensive documentation on the wiki
TODO more extensive documentation on the wiki.
## Staying compatible with the older version of the SDK
## The old way
- `git clone https://github.com/OSTC/php-sdk-binary-tools.git c:\php-sdk`
- follow the instructions on the PHP [wiki page](https://wiki.php.net/internals/windows/stepbystepbuild "PHP wiki page")
# Customizing
A sript called phpsdk-local.bat has to be put into the PHP SDK root. If present, it will be automatically picked up by the starter script. A template for such a script is included with the PHP SDK. This allows to setup additional environment.
The starter scripts can be also easy integrated with the consoles other than standard cmd.exe. For the reference, here's an example ConEmu task
`C:\php-sdk\phpsdk-vc14-x64.bat -cur_console:d:C:\php-sdk\php70\vc14\x64\php-src`
# Upgrading
- backup phpsdk-local.bat
- backup the source trees, contained in the PHP SDK root
- move the PHP SDK folder into trash
- download, unpack and the new PHP SDK version under the same path
# Extending
The SDK tools are based on the KISS principle and should be kept so. Basic tools are implemented as simple batch script. The minimalistic `PHP` is available for internal SDK purposes. It can be used, if more complexity is required. If you have an idea for some useful tool or workflow, please open a ticket or PR, so it can be discussed, implemented and added to the SDK. By contributing an implementation, you should also accept the SDK license.
# Pitfalls
- SDK or PHP sources put into paths including spaces might cause issue.
- SDK or PHP sources put into too long paths, will cause an issue.
- If Cygwin is installed, it might cause issues. If it's unavoidable, to have Cygwin on the same machine, ensure SDK preceeds it on the PATH.
- Tools, based on MSYS2, only accept paths with forward slashes.

View File

@@ -1 +1 @@
2.0.0alpha2
2.0.0alpha4

View File

@@ -4,33 +4,29 @@ IF "%1" EQU "" GOTO Help
IF "%2" NEQ "" SET _=%2\%1
IF "%2" EQU "" SET _=%CD%\%1
MD %_%\vc9\x86\deps\bin
MD %_%\vc9\x86\deps\lib
MD %_%\vc9\x86\deps\include
MD %_%\vc9\x64\deps\bin
MD %_%\vc9\x64\deps\lib
MD %_%\vc9\x64\deps\include
rem if we're in the starter script shell, create the only struct that corresponds to the current env
rem otherwise - retain the old behavior, create structs for all the known build combinations and don't cd
MD %_%\vc11\x86\deps\bin
MD %_%\vc11\x86\deps\lib
MD %_%\vc11\x86\deps\include
MD %_%\vc11\x64\deps\bin
MD %_%\vc11\x64\deps\lib
MD %_%\vc11\x64\deps\include
if "%PHP_SDK_ARCH%" NEQ "" (
if "%PHP_SDK_VC%" NEQ "" (
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\bin
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\lib
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\include
cd %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%
goto exit
)
goto create_all
) else (
:create_all
MD %_%\vc14\x86\deps\bin
MD %_%\vc14\x86\deps\lib
MD %_%\vc14\x86\deps\include
MD %_%\vc14\x64\deps\bin
MD %_%\vc14\x64\deps\lib
MD %_%\vc14\x64\deps\include
)
MD %_%\vc12\x86\deps\bin
MD %_%\vc12\x86\deps\lib
MD %_%\vc12\x86\deps\include
MD %_%\vc12\x64\deps\bin
MD %_%\vc12\x64\deps\lib
MD %_%\vc12\x64\deps\include
MD %_%\vc14\x86\deps\bin
MD %_%\vc14\x86\deps\lib
MD %_%\vc14\x86\deps\include
MD %_%\vc14\x64\deps\bin
MD %_%\vc14\x64\deps\lib
MD %_%\vc14\x64\deps\include
set _=
GOTO EXIT

View File

@@ -1,8 +1,11 @@
@echo off
if "%PHP_SDK_PHP_CMD%"=="" (
echo PHP SDK is not setup
exit 3
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
call %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_deps.php %*

View File

@@ -224,3 +224,11 @@ function msg(string $s, int $code = 0) {
exit(0);
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -1,8 +1,11 @@
@echo off
if "%PHP_SDK_PHP_CMD%"=="" (
echo PHP SDK is not setup
exit 3
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
call %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_dllmap.php %*

View File

@@ -102,3 +102,11 @@ foreach ($dirs as $path) {
echo json_encode($out);
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -1,5 +1,10 @@
@echo off
if "%PHP_SDK_OS_ARCH%"=="" (
echo PHP SDK is not setup
exit /b 3
)
call %PHP_SDK_BIN_PATH%\phpsdk_version.bat
echo.

View File

@@ -1,7 +1,8 @@
@echo off
if not defined PHP_SDK_RUN_FROM_ROOT (
echo phpsdk_shell.bat should not be run directly, use starter scripts in the PHP SDK root
echo This script should not be run directly.
echo Use starter scripts looking like phpsdk-^<crt^>-^<arch^>.bat in the PHP SDK root instead.
goto out_error
)

View File

@@ -1,5 +1,13 @@
@echo off
if "%PHP_SDK_PHP_CMD%"=="" (
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
%PHP_SDK_PHP_CMD% -r "echo 'PHP SDK ' . file_get_contents(getenv('PHP_SDK_PATH') . '\\VERSION');"
exit /b

View File

@@ -1,8 +1,9 @@
<?php
namespace SDK\Dependency;
namespace SDK;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
class Cache
@@ -11,14 +12,14 @@ class Cache
protected $hash;
public function __construct(string $id)
{
{/*{{{*/
$this->id = $id;
$this->hash = md5($id);
/* XXX pass as arg, fine for now. */
}
}/*}}}*/
protected function getCacheablePath(string $path, bool $relative = false) : string
{
{/*{{{*/
if ($relative) {
$dir = Config::getCacheDir();
$name = $path;
@@ -28,15 +29,15 @@ class Cache
}
return $dir . DIRECTORY_SEPARATOR . $this->hash . "." . $name;
}
}/*}}}*/
public function fileIsCached(string $path, bool $relative = false) : bool
{
{/*{{{*/
return file_exists($this->getCacheablePath($path, $relative));
}
}/*}}}*/
public function cachedContentDiffers(string $path, string $content, bool $relative = false) : bool
{
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
if (!file_exists($p)) {
@@ -47,19 +48,19 @@ class Cache
$new_sum = md5($content);
return $old_sum != $new_sum;
}
}/*}}}*/
public function cacheContent(string $path, string $content, bool $relative = false)
{
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
if (strlen($content) !== file_put_contents($p, $content)) {
throw new Exception("Couldn't cache '$p'");
}
}
}/*}}}*/
public function getCachedContent(string $path, bool $relative = false)
{
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
if ($this->isFileCached($p)) {
@@ -67,6 +68,14 @@ class Cache
}
return "";
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -3,7 +3,7 @@
namespace SDK;
use SDK\Dependency\Fetcher;
use SDK\Dependency\Cache;
use SDK\Cache;
use SDK\Exception;
class Config
@@ -25,50 +25,52 @@ class Config
protected static $depsLocalPath = NULL;
public static function getDepsHost() : string
{
{/*{{{*/
return self::$depsHost;
}
}/*}}}*/
public static function getDepsPort() : string
{
{/*{{{*/
return self::$depsPort;
}
}/*}}}*/
public static function getDepsBaseUri() : string
{
{/*{{{*/
return self::$depsBaseUri;
}
}/*}}}*/
public static function setCurrentArchName(string $arch)
{
{/*{{{*/
self::$currentArchName = $arch;
}
} /*}}}*/
public static function getCurrentArchName()
{
{/*{{{*/
return self::$currentArchName;
}
} /*}}}*/
public static function setCurrentCrtName(string $crt)
{
{/*{{{*/
self::$currentCrtName = $crt;
}
} /*}}}*/
public static function getCurrentCrtName()
{
{/*{{{*/
return self::$currentCrtName;
}
} /*}}}*/
public static function setCurrentStabilityName(string $stability)
{
{/*{{{*/
self::$currentStabilityName = $stability;
}
} /*}}}*/
public static function getCurrentStabilityName()
{
{/*{{{*/
return self::$currentStabilityName;
}
} /*}}}*/
public static function getKnownBranches() : array
{
{/*{{{*/
if (empty(self::$knownBranches)) {
$cache_file = "known_branches.txt";
$cache = new Cache(self::getDepsLocalPath());
@@ -101,24 +103,24 @@ class Config
}
return self::$knownBranches;
}
}/*}}}*/
public static function setCurrentBranchName(string $name)
{
{/*{{{*/
if (!array_key_exists($name, self::getKnownBranches())) {
// throw new Exception("Unsupported branch '$name'");
}
self::$currentBranchName = $name;
}
}/*}}}*/
public static function getCurrentBranchName()
{
{/*{{{*/
return self::$currentBranchName;
}
}/*}}}*/
public static function getCurrentBranchData() : array
{
{/*{{{*/
$ret = array();
$branches = self::getKnownBranches();
@@ -166,15 +168,15 @@ class Config
}
return $ret;
}
}/*}}}*/
public static function getSdkNugetFeedUrl() : string
{
{/*{{{*/
return self::$sdkNugetFeedUrl;
}
}/*}}}*/
public static function getSdkPath()
{
{/*{{{*/
$path = getenv("PHP_SDK_PATH");
if (!$path) {
@@ -187,10 +189,10 @@ class Config
}
return $path;
}
}/*}}}*/
public static function getSdkVersion() : string
{
{/*{{{*/
$path = self::getSdkPath() . DIRECTORY_SEPARATOR . "VERSION";
if (!file_exists($path)) {
@@ -198,20 +200,20 @@ class Config
}
return file_get_contents($path);
}
}/*}}}*/
public static function getDepsLocalPath()
{
{/*{{{*/
return self::$depsLocalPath;
}
}/*}}}*/
public static function setDepsLocalPath(string $path)
{
{/*{{{*/
self::$depsLocalPath = $path;
}
}/*}}}*/
public static function getCacheDir() : string
{
{/*{{{*/
$path = self::getSdkPath() . DIRECTORY_SEPARATOR . ".cache";
if (!file_exists($path)) {
@@ -221,10 +223,10 @@ class Config
}
return $path;
}
}/*}}}*/
public static function getTmpDir() : string
{
{/*{{{*/
$path = self::getSdkPath() . DIRECTORY_SEPARATOR . ".tmp";
if (!file_exists($path)) {
@@ -234,6 +236,14 @@ class Config
}
return $path;
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -15,27 +15,27 @@ class Fetcher
public function __construct(string $host, int $port, string $arch = NULL, string $stability = NULL, Series $series = NULL)
{
{/*{{{*/
$this->stability = $stability;
$this->arch = $arch;
$this->host = $host;
$this->port = $port;
}
}/*}}}*/
public function getSeries() : Series
{
{/*{{{*/
return $this->series;
}
}/*}}}*/
public function setSeries(Series $series)
{
{/*{{{*/
$this->series = $series;
}
}/*}}}*/
/* TODO more robust implementation. */
/* TODO implement indicator. */
public function getByUri($uri) : string
{
{/*{{{*/
$url = "http://{$this->host}:{$this->port}$uri";
$s = file_get_contents($url);
@@ -44,7 +44,7 @@ class Fetcher
}
return $s;
}
}/*}}}*/
/*protected function fetch($uri) : string
{
@@ -80,3 +80,11 @@ class Fetcher
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -3,10 +3,14 @@
namespace SDK\Dependency;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
use SDK\FileOps;
class Manager
{
use FileOps;
protected $stability;
protected $arch;
protected $path;
@@ -14,7 +18,7 @@ class Manager
protected $fetcher;
public function __construct(string $path, string $stability, string $arch)
{
{/*{{{*/
$this->stability = $stability;
$this->arch = $arch;
$this->path = $path;
@@ -29,21 +33,22 @@ class Manager
$this->fetcher = $fetcher;
$this->series = $series;
}
}/*}}}*/
protected function getTmpSeriesPath()
{
{/*{{{*/
return Config::getTmpDir() . DIRECTORY_SEPARATOR . $this->series->getname();
}
}/*}}}*/
public function updatesAvailable() : bool
{
{/*{{{*/
return $this->series->updatesAvailable();
}
}/*}}}*/
/* TODO and implement --force. */
/* FIXME implement rollback */
public function performUpdate(string &$msg = NULL)
{
{/*{{{*/
if (!$this->updatesAvailable()) {
$msg = "No updates are available";
return;
@@ -51,12 +56,9 @@ class Manager
$series_data = $this->series->getData();
$tmp_dir = Config::getTmpDir() . DIRECTORY_SEPARATOR . md5(uniqid());
$tmp_dir_packs = $tmp_dir . DIRECTORY_SEPARATOR . "packs";
$tmp_dir_deps = $tmp_dir . DIRECTORY_SEPARATOR . "deps";
mkdir($tmp_dir);
mkdir($tmp_dir_packs);
mkdir($tmp_dir_deps);
$tmp_dir = $this->md("", true);
$tmp_dir_packs = $this->md($tmp_dir . DIRECTORY_SEPARATOR . "packs");
$tmp_dir_deps = $this->md($tmp_dir . DIRECTORY_SEPARATOR . "deps");
foreach ($series_data as $item) {
echo "Processing package $item", PHP_EOL;
@@ -69,46 +71,53 @@ class Manager
unset($pkg);
}
if (file_exists($this->path)) {
$suffix = date("YmdHi");
$new_path = "{$this->path}.$suffix";
if (!rename($this->path, $new_path)) {
throw new Exception("Unable to rename '{$this->path}' to '$new_path'");
}
} else {
$up = dirname($this->path);
if (!file_exists($up)) {
if (!mkdir($up, 0755, true)) {
throw new Exception("Unable to create '{$this->path}'");
}
}
}
/* Clear, it is an extra handling. So far it's the only case, doing it this way. And, we have
no package definitions ATM to handle it otherwise. */
$extra = $tmp_dir_deps . DIRECTORY_SEPARATOR . "openssl.cnf";
if (file_exists($extra)) {
$tdir = $tmp_dir_deps . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "ssl";
mkdir($tdir, 0755, true);
rename($extra, $tdir . DIRECTORY_SEPARATOR . "openssl.cnf");
$this->md($tdir);
$this->mv($extra, $tdir . DIRECTORY_SEPARATOR . "openssl.cnf");
}
if (!rename($tmp_dir_deps, $this->path)) {
throw new Exception("Unable to rename '$tmp_dir_deps' to '{$this->path}'");
if (file_exists($this->path)) {
$suffix = date("YmdHi");
$new_path = "{$this->path}.$suffix";
/* This is fine, it's gonna be on the same drive. */
if (!$this->mv($this->path, $new_path)) {
throw new Exception("Unable to rename '{$this->path}' to '$new_path'");
}
} else {
$up = dirname($this->path);
if (!file_exists($up)) {
if (!$this->md($up)) {
throw new Exception("Unable to create '{$this->path}'");
}
}
}
rmdir($tmp_dir_packs);
rmdir($tmp_dir);
$this->mv($tmp_dir_deps, $this->path);
$this->rm($tmp_dir_packs);
$this->rm($tmp_dir);
$this->series->cache();
/* save new series file, move the updated deps and backup the old ones, cleanup.*/
$msg = "Updates performed successfully. ";
$msg .= "Updated dependencies was saved to '{$this->path}'. ";
$msg = "Updates performed successfully. " . PHP_EOL;
if (isset($new_path)) {
$msg .= "Old dependencies dir is moved to '$new_path'.";
$msg .= "Old dependencies backed up into '$new_path'.";
}
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -13,23 +13,23 @@ class Package
protected $filepath;
public function __construct(string $name, Series $series, Fetcher $fetcher)
{
{/*{{{*/
$this->name = $name;
$this->series = $series;
$this->fetcher = $fetcher;
}
}/*}}}*/
public function getUri() : string
{
{/*{{{*/
$base = Config::getDepsBaseUri();
$branch_data = Config::getCurrentBranchData();
$arch = $this->series->getArch();
return "$base/{$branch_data['crt']}/$arch/{$this->name}";
}
}/*}}}*/
public function retrieve(string $path)
{
{/*{{{*/
$this->filepath = $path . DIRECTORY_SEPARATOR . $this->name;
$cont = $this->fetcher->getByUri($this->getUri());
@@ -37,10 +37,10 @@ class Package
$fd = fopen($this->filepath, "wb");
fwrite($fd, $cont);
fclose($fd);
}
}/*}}}*/
public function unpack(string $path)
{
{/*{{{*/
if (!$this->filepath || !file_exists($this->filepath)) {
throw new Exception("Invalid filepath '{$this->filepath}'");
}
@@ -53,11 +53,19 @@ class Package
} else {
throw new Exception("Failed to unpack, error code '$ret'");
}
}
}/*}}}*/
public function cleanup()
{
{/*{{{*/
unlink($this->filepath);
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -3,6 +3,7 @@
namespace SDK\Dependency;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
class Series
@@ -14,53 +15,53 @@ class Series
protected $cache;
public function __construct(string $stability, string $arch, Cache $cache, Fetcher $fetcher = NULL)
{
{/*{{{*/
$this->fetcher = $fetcher;
$this->stability = $stability;
$this->arch = $arch;
$this->cache = $cache;
}
}/*}}}*/
public function getFetcher() : Fetcher
{
{/*{{{*/
return $this->fetcher;
}
}/*}}}*/
public function setFetcher(Fetcher $fetcher)
{
{/*{{{*/
$this->fetcher = $fetcher;
}
}/*}}}*/
public function getArch() : string
{
{/*{{{*/
return $this->arch;
}
}/*}}}*/
public function setArch(string $arch)
{
{/*{{{*/
$this->arch = $arch;
}
}/*}}}*/
public function getName() : string
{
{/*{{{*/
$base = Config::getDepsBaseUri();
$branch_data = Config::getCurrentBranchData();
$file = "packages-" . Config::getCurrentBranchName() . "-{$branch_data['crt']}-{$this->arch}-{$this->stability}.txt";
return $file;
}
}/*}}}*/
protected function getUri() : string
{
{/*{{{*/
$base = Config::getDepsBaseUri();
$file = $this->getName();
return "$base/series/$file";
}
}/*}}}*/
public function getData(bool $raw = false, bool $cache = true)
{
{/*{{{*/
if ($cache && $this->rawData) {
$ret = $this->rawData;
} else {
@@ -76,28 +77,36 @@ class Series
}
return $ret;
}
}/*}}}*/
public function getSavePath()
{
{/*{{{*/
return Config::getCacheDir() . DIRECTORY_SEPARATOR . $this->getname();
}
}/*}}}*/
public function updatesAvailable()
{
{/*{{{*/
$series_data = $this->getData(true);
$series_file = $this->getSavePath();
return $this->cache->cachedContentDiffers($series_file, $series_data);
}
}/*}}}*/
public function cache(string $path = NULL)
{
{/*{{{*/
if (!$path) {
$path = $this->getSavePath();
}
$this->cache->cacheContent($path, $this->getData(true));
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -7,3 +7,11 @@ class Exception extends \Exception
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -0,0 +1,127 @@
<?php
namespace SDK;
use SDK\Config;
use SDK\Exception;
trait FileOps
{
protected function md(string $name = "", bool $tmp = false) : string
{/*{{{*/
$ret = $name;
if (!$name) {
if ($tmp) {
$pre = Config::getTmpDir();
$ret = $pre . DIRECTORY_SEPARATOR . md5(uniqid());
} else {
throw new Exception("Dir name is empty");
}
}
if (!is_dir($ret)) {
if (!mkdir($ret, 0755, true)) {
throw new Exception("Unable to create '$ret'");
}
}
return $ret;
}/*}}}*/
/* TODO is link and more checks. */
protected function rm(string $path) : bool
{/*{{{*/
if (!file_exists($path)) {
return false;
} else if (is_file($path)) {
return unlink($path);
}
$ret = true;
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$path,
\FilesystemIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $item) {
if ($item->isDir()) {
$ret = $ret && rmdir($item->getPathname());
} else {
$ret = $ret && unlink($item->getPathname());
}
}
return $ret && rmdir($path);
}/*}}}*/
/* TODO islink and more checks */
protected function cp_or_mv(string $src, string $dst, callable $cb) : bool
{/*{{{*/
if (!file_exists($src)) {
return false;
} else if (is_file($src)) {
return call_user_func($cb, $src, $dst);
}
if (!file_exists($dst)) {
$this->md($dst);
}
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$src,
\FilesystemIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::CHILD_FIRST
);
$cut_len = strlen($src)+1;
foreach ($iterator as $item) {
$src_path = $item->getPathname();
$sub = substr($src_path, $cut_len);
$dst_path = $dst . DIRECTORY_SEPARATOR . $sub;
$dst_parent = dirname($dst_path);
if (!is_dir($dst_parent)) {
if (!$this->md($dst_parent)) {
throw new Exception("Unable to create '$dst_parent'");
}
}
if ($item->isFile()) {
if (!call_user_func($cb, $src_path, $dst_path)) {
throw new Exception("Unable to $cb '$src_path' to '$dst_path'");
}
}
}
return true;
}/*}}}*/
protected function cp(string $src, string $dst) : bool
{/*{{{*/
return $this->cp_or_mv($src, $dst, "copy");
}/*}}}*/
protected function mv(string $src, string $dst) : bool
{/*{{{*/
$ret = $this->cp_or_mv($src, $dst, "rename");
$ret = $ret && $this->rm($src);
return $ret;
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -5,3 +5,11 @@ function __autoload($name)
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $name . ".php";
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

20
phpsdk-local.bat.example Normal file
View File

@@ -0,0 +1,20 @@
@echo off
set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=test password=test
set PDO_PGSQL_TEST_DSN=pgsql:host=127.0.0.1 port=5432 dbname=test user=test password=test
set PHP_SDK_FIREBIRD_PATH=
if "%PHP_SDK_ARCH%"=="x64" (
set PHP_SDK_FIREBIRD_PATH=E:\local_programs\Firebird-2.5.5.26952-0_x64\bin;
set PDO_FIREBIRD_TEST_DSN=firebird:dbname=127.0.0.1:E:\local_programs\Firebird-2.5.5.26952-0_x64\examples\empbuild\EMPLOYEE.FDB
set PDO_FIREBIRD_TEST_USER=SYSDBA
set PDO_FIREBIRD_TEST_PASS=masterkey
)
set PATH=%PHP_SDK_FIREBIRD_PATH%%PATH%
set ODBC_TEST_USER=php_test2
set ODBC_TEST_PASS=php_test2
set ODBC_TEST_DSN=Driver={SQL Server};Server={W530-PHP-DEV\TEST2014};Database={php_test2};uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS%
set PDOTEST_DSN=odbc:%ODBC_TEST_DSN%

34
phpsdk-starter.bat Normal file
View File

@@ -0,0 +1,34 @@
@echo off
setlocal enableextensions enabledelayedexpansion
if "%1" equ "" goto help
if "%2" equ "" goto help
goto skip_help
:help
echo Usage: phpsdk-starter ^<crt^> ^<arch^> [^<append_script.bat^>]
exit /b 0
:skip_help
set PHP_SDK_RUN_FROM_ROOT=1
title PHP SDK
call %~dp0bin\phpsdk_setshell.bat %1 %2
if errorlevel 3 (
exit /b %errorlevel%
)
if exist "%~dp0phpsdk-local.bat" (
cmd /k "!PHP_SDK_VC_SHELL_CMD! && %~dp0\bin\phpsdk_setvars.bat && %~dp0\bin\phpsdk_dumpenv.bat && %~dp0\phpsdk-local.bat && echo. && set prompt=$P$_$+$$$S"
) else (
cmd /k "!PHP_SDK_VC_SHELL_CMD! && %~dp0\bin\phpsdk_setvars.bat && %~dp0\bin\phpsdk_dumpenv.bat && set prompt=$P$_$+$$$S"
)
set PHP_SDK_RUN_FROM_ROOT=
exit /b

View File

@@ -1,14 +1,6 @@
@echo off
setlocal enableextensions enabledelayedexpansion
call %~dp0phpsdk-starter.bat vc14 x64 %*
set PHP_SDK_RUN_FROM_ROOT=1
call %~dp0bin\phpsdk_setshell.bat vc14 x64
cmd /k "%PHP_SDK_VC_SHELL_CMD% && %~dp0\bin\phpsdk_setvars.bat && %~dp0\bin\phpsdk_dumpenv.bat"
set PHP_SDK_RUN_FROM_ROOT=
exit
exit /b

View File

@@ -1,14 +1,6 @@
@echo off
setlocal enableextensions enabledelayedexpansion
call %~dp0phpsdk-starter.bat vc14 x86 %*
set PHP_SDK_RUN_FROM_ROOT=1
call %~dp0bin\phpsdk_setshell.bat vc14 x86
cmd /k "%PHP_SDK_VC_SHELL_CMD% && %~dp0\bin\phpsdk_setvars.bat && %~dp0\bin\phpsdk_dumpenv.bat"
set PHP_SDK_RUN_FROM_ROOT=
exit
exit /b