From 7dac5bd9194ce95d9958981da141d03480816a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 11 May 2016 19:35:31 +0300 Subject: [PATCH 01/10] add box.json and utility to build phar --- .gitignore | 6 +++++- Makefile | 19 +++++++++++++++++++ box.json | 27 +++++++++++++++++++++++++++ composer.json | 7 ++++--- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 Makefile create mode 100644 box.json diff --git a/.gitignore b/.gitignore index 2d0575c..272a652 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -test/unit/File/big-generated-file +*~ +/test/unit/File/big-generated-file +/composer.lock +/vendor +/defuse-crypto.phar diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..87436c1 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +TARGETS := defuse-crypto.phar + +define find_tool +$(shell PATH=$$PATH:. which $1.phar 2>/dev/null || which $1 2>/dev/null || echo false) +endef + +box := $(call find_tool, box) +php := php + +phar: $(TARGETS) + +%.phar: Makefile box.json + $(php) -d phar.readonly=0 $(box) build -v + +box.phar: + curl -LSs https://box-project.github.io/box2/installer.php | php + +clean: + rm -vf $(TARGETS) diff --git a/box.json b/box.json new file mode 100644 index 0000000..9acd514 --- /dev/null +++ b/box.json @@ -0,0 +1,27 @@ +{ + "chmod": "0755", + "finder": [ + { + "in": "src", + "name": "*.php", + "exclude": "random_compat" + }, + { + "in": "vendor/composer", + "name": "*.php", + "exclude": "other" + }, + { + "in": "vendor/paragonie", + "name": "*.php", + "exclude": "other" + } + ], + "compactors": [ + "Herrera\\Box\\Compactor\\Php" + ], + "compression": "GZ", + "main": "vendor/autoload.php", + "output": "defuse-crypto.phar", + "stub": true +} diff --git a/composer.json b/composer.json index 62d4f88..eafe87d 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,12 @@ } ], "autoload": { - "files": ["autoload.php"] + "classmap": ["src"] }, "require": { - "php": ">=5.4.0", - "ext-openssl": "*" + "paragonie/random_compat": "~2.0", + "ext-openssl": "*", + "php": ">=5.4.0" }, "require-dev": { "nikic/php-parser": "^2.0" From b27a40042eaffa36b98daca08d2ae792b398df9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 11 May 2016 19:42:49 +0300 Subject: [PATCH 02/10] phar build needs composer run --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 87436c1..e4872e8 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,15 @@ $(shell PATH=$$PATH:. which $1.phar 2>/dev/null || which $1 2>/dev/null || echo endef box := $(call find_tool, box) -php := php +composer := $(call find_tool, composer) +php := $(call find_tool, php) phar: $(TARGETS) -%.phar: Makefile box.json +composer.lock: + $(composer) install --no-dev + +%.phar: Makefile box.json composer.lock $(php) -d phar.readonly=0 $(box) build -v box.phar: From 146b529937be85e6b3c0925cc6313c4c1e500cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 11 May 2016 19:46:05 +0300 Subject: [PATCH 03/10] add composer install instruction --- .gitignore | 2 ++ Makefile | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 272a652..f3b59a2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /composer.lock /vendor /defuse-crypto.phar +/composer.phar +/box.phar diff --git a/Makefile b/Makefile index e4872e8..07af970 100644 --- a/Makefile +++ b/Makefile @@ -19,5 +19,8 @@ composer.lock: box.phar: curl -LSs https://box-project.github.io/box2/installer.php | php +composer.phar: + curl -sS https://getcomposer.org/installer | php + clean: rm -vf $(TARGETS) From 4357073cdd7f7b176053f5586c789e180a8cd67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 12 May 2016 08:02:38 +0300 Subject: [PATCH 04/10] do not download missing tools, point to docs instead --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 07af970..05f76e1 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ TARGETS := defuse-crypto.phar define find_tool -$(shell PATH=$$PATH:. which $1.phar 2>/dev/null || which $1 2>/dev/null || echo false) +$(shell PATH=$$PATH:. which $1.phar 2>/dev/null || which $1 2>/dev/null || $(error Required tool `$1' not installed, see docs/InstallingAndVerifying.md)) endef -box := $(call find_tool, box) -composer := $(call find_tool, composer) -php := $(call find_tool, php) +box := $(call find_tool,box) +composer := $(call find_tool,composer) +php := $(call find_tool,php) phar: $(TARGETS) @@ -17,10 +17,10 @@ composer.lock: $(php) -d phar.readonly=0 $(box) build -v box.phar: - curl -LSs https://box-project.github.io/box2/installer.php | php + @echo Required tool $@ not installed, see docs/InstallingAndVerifying.md composer.phar: - curl -sS https://getcomposer.org/installer | php + @echo Required tool $@ not installed, see docs/InstallingAndVerifying.md clean: rm -vf $(TARGETS) From deca1ef76ec371dd45dd3511eed9ea1787d54602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 12 May 2016 08:25:05 +0300 Subject: [PATCH 05/10] roll back to shell version make condition was always evaluated true --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 05f76e1..96f622b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ TARGETS := defuse-crypto.phar +define install_tool + @echo 'Required tool \"$1\" not installed, see docs/InstallingAndVerifying.md'; false +endef +define which + $(shell PATH=$$PATH:. which $1.phar 2>/dev/null || which $1 2>/dev/null || { echo "$(call install_tool,$(1))"; }) +endef define find_tool -$(shell PATH=$$PATH:. which $1.phar 2>/dev/null || which $1 2>/dev/null || $(error Required tool `$1' not installed, see docs/InstallingAndVerifying.md)) + $(call which,$1) endef box := $(call find_tool,box) From 94c9fcb6ccb7fcd1ba467f5fbb221b2a29bb0a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 12 May 2016 08:27:08 +0300 Subject: [PATCH 06/10] cleanup unused make rules --- Makefile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Makefile b/Makefile index 96f622b..0370580 100644 --- a/Makefile +++ b/Makefile @@ -22,11 +22,5 @@ composer.lock: %.phar: Makefile box.json composer.lock $(php) -d phar.readonly=0 $(box) build -v -box.phar: - @echo Required tool $@ not installed, see docs/InstallingAndVerifying.md - -composer.phar: - @echo Required tool $@ not installed, see docs/InstallingAndVerifying.md - clean: rm -vf $(TARGETS) From 9d42ba2e07322863b398392722bf208feaa596df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 12 May 2016 08:28:51 +0300 Subject: [PATCH 07/10] create phar in clean tree --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 0370580..de4b912 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,8 @@ box := $(call find_tool,box) composer := $(call find_tool,composer) php := $(call find_tool,php) +all: dist-phar + phar: $(TARGETS) composer.lock: @@ -22,5 +24,13 @@ composer.lock: %.phar: Makefile box.json composer.lock $(php) -d phar.readonly=0 $(box) build -v +# ensure we run in clean tree. export git tree and run there. +dist-phar: + rm -rf worktree + install -d worktree + git archive HEAD | tar -x -C worktree + $(MAKE) -f $(CURDIR)/Makefile -C worktree phar + rm -rf worktree + clean: rm -vf $(TARGETS) From 1c2c314742ae07bff4a8dba2e5458a6a26a8a217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 12 May 2016 08:30:34 +0300 Subject: [PATCH 08/10] move dist scripts to subdir --- .gitignore | 6 +++--- Makefile => dist/Makefile | 2 +- box.json => dist/box.json | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename Makefile => dist/Makefile (93%) rename box.json => dist/box.json (100%) diff --git a/.gitignore b/.gitignore index f3b59a2..087d255 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ /test/unit/File/big-generated-file /composer.lock /vendor -/defuse-crypto.phar -/composer.phar -/box.phar +defuse-crypto.phar +composer.phar +box.phar diff --git a/Makefile b/dist/Makefile similarity index 93% rename from Makefile rename to dist/Makefile index de4b912..9957434 100644 --- a/Makefile +++ b/dist/Makefile @@ -28,7 +28,7 @@ composer.lock: dist-phar: rm -rf worktree install -d worktree - git archive HEAD | tar -x -C worktree + (cd $(CURDIR)/..; git archive HEAD) | tar -x -C worktree $(MAKE) -f $(CURDIR)/Makefile -C worktree phar rm -rf worktree diff --git a/box.json b/dist/box.json similarity index 100% rename from box.json rename to dist/box.json From 3c4d53f11cf616cd8dc48579dd830cc827f967b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 12 May 2016 08:32:34 +0300 Subject: [PATCH 09/10] preserve phar that got built :) --- dist/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/Makefile b/dist/Makefile index 9957434..4136868 100644 --- a/dist/Makefile +++ b/dist/Makefile @@ -30,6 +30,7 @@ dist-phar: install -d worktree (cd $(CURDIR)/..; git archive HEAD) | tar -x -C worktree $(MAKE) -f $(CURDIR)/Makefile -C worktree phar + mv worktree/*.phar . rm -rf worktree clean: From 23425f5338b925f6f9f98460480c6b611f427c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 12 May 2016 08:38:25 +0300 Subject: [PATCH 10/10] fix phar build in git export tree --- dist/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/Makefile b/dist/Makefile index 4136868..01dd2c1 100644 --- a/dist/Makefile +++ b/dist/Makefile @@ -21,8 +21,9 @@ phar: $(TARGETS) composer.lock: $(composer) install --no-dev -%.phar: Makefile box.json composer.lock - $(php) -d phar.readonly=0 $(box) build -v +%.phar: dist/Makefile dist/box.json composer.lock + cp dist/box.json . + $(php) -d phar.readonly=0 $(box) build -c box.json -v # ensure we run in clean tree. export git tree and run there. dist-phar: