2 $dist = dirname(__DIR__).'/dist';
6 if (file_exists($dist.'/random_compat.phar')) {
7 unlink($dist.'/random_compat.phar');
10 $dist.'/random_compat.phar',
11 FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME,
15 dirname(__DIR__).'/lib/random.php',
16 dirname(__DIR__).'/lib/index.php'
18 $phar->buildFromDirectory(dirname(__DIR__).'/lib');
20 dirname(__DIR__).'/lib/index.php',
21 dirname(__DIR__).'/lib/random.php'
25 * If we pass an (optional) path to a private key as a second argument, we will
26 * sign the Phar with OpenSSL.
28 * If you leave this out, it will produce an unsigned .phar!
31 if (!@is_readable($argv[1])) {
32 echo 'Could not read the private key file:', $argv[1], "\n";
35 $pkeyFile = file_get_contents($argv[1]);
37 $private = openssl_get_privatekey($pkeyFile);
38 if ($private !== false) {
40 openssl_pkey_export($private, $pkey);
41 $phar->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
44 * Save the corresponding public key to the file
46 if (!@is_readable($dist.'/random_compat.phar.pubkey')) {
47 $details = openssl_pkey_get_details($private);
49 $dist.'/random_compat.phar.pubkey',
54 echo 'An error occurred reading the private key from OpenSSL.', "\n";