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

Diff for: .gitignore

+11-1
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

Diff for: .travis.yml

+10-1
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

Diff for: autoload.php

-68
This file was deleted.

Diff for: composer.json

+11-4
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"

Diff for: dist/Makefile

+37
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+

Diff for: dist/box.json

+24
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+
}

Diff for: dist/defuse-crypto.phar

-121 KB
Binary file not shown.

Diff for: dist/defuse-crypto.phar.sig

-17
This file was deleted.
File renamed without changes.

Diff for: docs/InstallingAndVerifying.md

+14-17
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).

Diff for: docs/InternalDeveloperDocs.md

+28-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ following tools installed:
1616

1717
- `php` (with OpenSSL enabled, if you're compiling from source).
1818
- `gpg`
19+
- `composer`
1920

2021
Running the Tests
2122
------------------
2223

23-
Simply run `./test.sh`. This will download a PHPUnit PHAR, verify its
24-
cryptographic signatures, and then use it to run the tests in `test/unit`.
24+
First do `composer install` and then you can run the tests by running
25+
`./test.sh`. This will download a PHPUnit PHAR, verify its cryptographic
26+
signatures, and then use it to run the tests in `test/unit`.
2527

2628
Reporting Bugs
2729
---------------
@@ -72,6 +74,14 @@ This library is developed around several core values:
7274
Publishing Releases
7375
--------------------
7476

77+
To make a release, you will need to install [composer](https://getcomposer.org/)
78+
and [box](https://github.com/box-project/box2) on your system. They will need to
79+
be available in your `$PATH` so that running the commands `composer` and `box`
80+
in your terminal run them, respectively. You will also need the private key for
81+
signing (ID: 7B4B2D98) available.
82+
83+
Once you have those tools installed and the key available follow these steps:
84+
7585
Make a fresh clone of the repository:
7686

7787
```
@@ -84,11 +94,23 @@ Check out the branch you want to release:
8494
git checkout <branchname>
8595
```
8696

87-
Run the sign-release script (note this will make a commit on your current
88-
branch):
97+
Generate and sign the `.phar`:
8998

9099
```
91-
./other/sign-release.sh <tagname> <tagmessage>
100+
cd dist
101+
make
92102
```
93103

94-
Push the branch and tag up to GitHub.
104+
Tag the release:
105+
106+
```
107+
git -c user.signingkey=7B4B2D98 tag -s "<TAG NAME>" -m "<TAG MESSAGE>"
108+
```
109+
110+
`<TAG NAME>` should be in the format `v2.0.0` and `<TAG MESSAGE>` should look
111+
like "Release of v2.0.0."
112+
113+
Push the tag to github, then use the
114+
[releases](https://github.com/defuse/php-encryption/releases) page to draft
115+
a new release for that tag. Upload the `.phar` and the `.phar.sig` file to be
116+
included as part of that release.

Diff for: other/build-phar.sh

-10
This file was deleted.

Diff for: other/build_phar.php

-51
This file was deleted.

0 commit comments

Comments
 (0)