Skip to content

Commit 7c409ee

Browse files
committed
Merge pull request #264 from defuse/phar-create
Phar Building
2 parents e20527e + e42d3a9 commit 7c409ee

25 files changed

+137
-1360
lines changed

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
test/unit/File/big-generated-file
1+
*~
2+
/test/unit/File/big-generated-file
3+
/composer.lock
4+
/vendor
5+
defuse-crypto.phar
6+
defuse-crypto.phar.sig
7+
composer.phar
8+
box.phar
9+
phpunit.phar
10+
phpunit.phar.asc
11+
test/unit/File/tmp

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@ sudo: false
1010
matrix:
1111
fast_finish: true
1212

13-
script: ./test.sh
13+
install:
14+
- composer install
15+
- curl -LSs https://box-project.github.io/box2/installer.php | php
16+
- mkdir ~/box
17+
- mv box.phar ~/box/box
18+
19+
script:
20+
- ./test.sh
21+
- PATH=$PATH:~/box/ make -C dist/ build-phar
22+
- ./test.sh dist/defuse-crypto.phar

autoload.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

composer.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77
"authors": [
88
{
99
"name": "Taylor Hornby",
10-
"email": "[email protected]"
10+
"email": "[email protected]",
11+
"homepage": "https://defuse.ca/"
12+
},
13+
{
14+
"name": "Scott Arciszewski",
15+
"email": "[email protected]",
16+
"homepage": "https://paragonie.com"
1117
}
1218
],
1319
"autoload": {
14-
"files": ["autoload.php"]
20+
"classmap": ["src"]
1521
},
1622
"require": {
17-
"php": ">=5.4.0",
18-
"ext-openssl": "*"
23+
"paragonie/random_compat": "~2.0",
24+
"ext-openssl": "*",
25+
"php": ">=5.4.0"
1926
},
2027
"require-dev": {
2128
"nikic/php-parser": "^2.0"

dist/Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This builds defuse-crypto.phar. To run this Makefile, `box` and `composer`
2+
# must be installed and in your $PATH. Run it from inside the dist/ directory.
3+
4+
box := $(shell which box)
5+
composer := "composer"
6+
7+
.PHONY: all
8+
all: sign-phar
9+
10+
.PHONY: sign-phar
11+
sign-phar: build-phar
12+
gpg -u 7B4B2D98 --armor --output defuse-crypto.phar.sig --detach-sig defuse-crypto.phar
13+
14+
# ensure we run in clean tree. export git tree and run there.
15+
.PHONY: build-phar
16+
build-phar:
17+
@echo "Creating .phar from revision $(shell git rev-parse HEAD)."
18+
rm -rf worktree
19+
install -d worktree
20+
(cd $(CURDIR)/..; git archive HEAD) | tar -x -C worktree
21+
$(MAKE) -f $(CURDIR)/Makefile -C worktree defuse-crypto.phar
22+
mv worktree/*.phar .
23+
rm -rf worktree
24+
25+
.PHONY: clean
26+
clean:
27+
rm -vf defuse-crypto.phar defuse-crypto.phar.sig
28+
29+
# Inside workdir/:
30+
31+
defuse-crypto.phar: dist/box.json composer.lock
32+
cp dist/box.json .
33+
php -d phar.readonly=0 $(box) build -c box.json -v
34+
35+
composer.lock:
36+
$(composer) install --no-dev
37+

dist/box.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"chmod": "0755",
3+
"finder": [
4+
{
5+
"in": "src",
6+
"name": "*.php"
7+
},
8+
{
9+
"in": "vendor/composer",
10+
"name": "*.php"
11+
},
12+
{
13+
"in": "vendor/paragonie",
14+
"name": "*.php",
15+
"exclude": "other"
16+
}
17+
],
18+
"compactors": [
19+
"Herrera\\Box\\Compactor\\Php"
20+
],
21+
"main": "vendor/autoload.php",
22+
"output": "defuse-crypto.phar",
23+
"stub": true
24+
}

dist/defuse-crypto.phar

-121 KB
Binary file not shown.

dist/defuse-crypto.phar.sig

Lines changed: 0 additions & 17 deletions
This file was deleted.
File renamed without changes.

docs/InstallingAndVerifying.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Getting The Code
44
There are two ways to use this library in your applications. You can either:
55

66
1. Use [Composer](https://getcomposer.org/), or
7-
2. `require_once()` a single `.phar` file in your application.
7+
2. `require_once` a single `.phar` file in your application.
88

99
Option 1: Using Composer
1010
-------------------------
@@ -23,16 +23,20 @@ Option 2: Including a PHAR
2323
----------------------------
2424

2525
The `.phar` option lets you include this library into your project simply by
26-
calling `require_once()` on a single file. Simply check out the tag with the
27-
version you want, for example for version 2.0.0 you would do:
28-
29-
```
30-
git checkout v2.0.0
31-
```
26+
calling `require_once` on a single file. Download `defuse-crypto.phar` and
27+
`defuse-crypto.phar.sig` from this project's
28+
[releases](https://github.com/defuse/php-encryption/releases) page.
29+
30+
You should verify the integrity of the `.phar`. The `defuse-crypto.phar.sig`
31+
contains the signature of `defuse-crypto.phar`. It is signed with Taylor
32+
Hornby's PGP key. You can find Taylor's public key in `dist/signingkey.asc`. You
33+
can verify the public key's fingerprint against the Taylor Hornby's [contact
34+
page](https://defuse.ca/contact.htm) and
35+
[twitter](https://twitter.com/DefuseSec/status/723741424253059074).
3236

33-
You'll find the `.phar` file for that release in `dist/defuse-crypto.phar`.
34-
Install it to somewhere on your filesystem, e.g.
35-
`/var/www/lib/defuse-crypto.phar`. You can now use it in your code like this:
37+
Once you have verified the signature, it is safe to use the `.phar`. Place it
38+
somewhere in your file system, e.g. `/var/www/lib/defuse-crypto.phar`, and then
39+
pass that path to `require_once`.
3640

3741
```php
3842
<?php
@@ -45,10 +49,3 @@ Install it to somewhere on your filesystem, e.g.
4549
// ...
4650
```
4751

48-
You should verify the integrity of the `.phar`. It is signed with Taylor
49-
Hornby's PGP key. The signature file is `dist/defuse-crypto.phar.sig`. You can
50-
find Taylor's public key in `other/signingkey.asc.
51-
52-
You can verify the public key's fingerprint against the Taylor Hornby's [contact
53-
page](https://defuse.ca/contact.htm) and
54-
[twitter](https://twitter.com/DefuseSec/status/723741424253059074).

0 commit comments

Comments
 (0)