Browse Source

Makefile: correct dependencies and general cleanup

master
Arian Sanusi 3 years ago
committed by Arian Sanusi (p≡p Foundation)
parent
commit
4681363e00
No known key found for this signature in database GPG Key ID: 49B08FCFF6BC3B2
7 changed files with 38 additions and 262 deletions
  1. +35
    -44
      Makefile
  2. +3
    -0
      README.md
  3. +0
    -12
      engine_Makefile.conf.patch
  4. +0
    -25
      enigmail_enigmail.js.patch
  5. +0
    -100
      enigmail_pEp.jsm.patch
  6. +0
    -72
      enigmail_pEpAdapter.jsm.patch
  7. +0
    -9
      pep-json-server_start.sh

+ 35
- 44
Makefile View File

@ -6,7 +6,10 @@ ENIG_ID=$(ID)-$(VERSION_ID)-$(ID_POSTFIX)
ENIG_ID_DARWIN=macos-$(ID_POSTFIX)
ENIG_ID_WIN=windows-x86-$(shell date --rfc-3339=date)
.PHONY: all foreign
ENGINEREV?=2400
JSONREV?=default
.PHONY: all zip xpis
all: build/bin/pep-json-server build/enigmail-$(ENIG_ID).zip build/share/pEp/system.db
xpis: build/enigmail-$(ENIG_ID).xpi build/enigmail-$(ENIG_ID_DARWIN).xpi build/enigmail-$(ENIG_ID_WIN).xpi
@ -21,14 +24,14 @@ clean:
distclean: clean
rm -rf yml2 libetpan asn1c pepengine libevent pepjsonserveradapter enigmail
yml2: build
.PHONY: yml2
yml2:
hg clone https://cacert.pep.foundation/dev/repos/yml2/ yml2 || ( cd yml2 ; hg pull ; hg update )
build/include/libetpan.h: | build
git clone https://github.com/fdik/libetpan libetpan || ( cd libetpan ; git pull )
cd libetpan ; ./autogen.sh --prefix="$$HOME/build"
$(MAKE) -C libetpan install
# touch $@
build/bin/asn1c: | build
git clone https://github.com/vlm/asn1c.git asn1c || true
@ -37,66 +40,54 @@ build/bin/asn1c: | build
cd asn1c ; ./configure --prefix="$$HOME/build"
$(MAKE) -C asn1c install
pepengine: build/include/libetpan.h build/bin/asn1c
hg clone https://cacert.pep.foundation/dev/repos/pEpEngine/ pepengine || ( cd pepengine ; hg pull ; hg update )
# pepengine/Makefile.conf: pepengine
# cd pepengine ; hg revert Makefile.conf
# patch $@ common/engine_Makefile.conf.patch
.PHONY: pepengine
pepengine: build/include/libetpan.h | build/bin/asn1c
hg clone -r $(ENGINEREV) https://cacert.pep.foundation/dev/repos/pEpEngine/ pepengine || ( cd $@ ; hg pull ; hg update -r $(ENGINEREV) )
pepengine/local.conf: | pepengine
cp /build/common/local.conf $@
pepengine/local.conf: ~/common/local.conf pepengine
cp $< $@
.PHONY: engine-make engine-install
engine-make: pepengine/local.conf | yml2 build/include/libetpan.h build/bin/asn1c pepengine
make -C pepengine all db #test
pepengine/src/libpEpEngine.so: pepengine/local.conf yml2 build/include/libetpan.h build/bin/asn1c pepengine
$(MAKE) -C pepengine all db #test
engine-install: engine-make build
make -C pepengine install
build/lib/libpEpEngine.so: pepengine/src/libpEpEngine.so
$(MAKE) -C pepengine install
libevent/made: | build
git clone https://github.com/libevent/libevent.git $(dir $@) -b release-2.1.8-stable || true
mkdir -p $(dir $@)/
cd $(dir $@)/ ; cmake .. ; $(MAKE) DESTDIR=$$HOME install
touch libevent/made
build/share/pEp/system.db: pepengine/src/libpEpEngine.so
mkdir -p $(dir $@)
cp pepengine/db/system.db $@
build/bin/pep-json-server: engine-install
hg clone -r 302 https://cacert.pep.foundation/dev/repos/pEpJSONServerAdapter pepjsonserveradapter || ( cd pepjsonserveradapter ; hg revert --all ; hg pull ; hg update -r 302)
.PHONY: pepjsonserveradapter
pepjsonserveradapter:
hg clone -r $(JSONREV) https://cacert.pep.foundation/dev/repos/pEpJSONServerAdapter pepjsonserveradapter || ( cd $@ ; hg pull ; hg update -r $(JSONREV) )
-cd pepjsonserveradapter/server ; patch -N < ~/common/pepjsonserveradapter.Makefile.conf.patch
-cd pepjsonserveradapter/server ; patch -N < ~/common/pep-json-server-adapter_cstring.patch
sed -i "s/\techo '/\techo -e '/" pepjsonserveradapter/server/Makefile
cd pepjsonserveradapter/server ; patch -N < ~/common/pepjsonserveradapter.Makefile.conf.patch || true
cd pepjsonserveradapter/server ; patch -N < ~/common/pep-json-server-adapter_cstring.patch
build/bin/pep-json-server: build/lib/libpEpEngine.so pepjsonserveradapter
$(MAKE) -C pepjsonserveradapter/server prefix-config.cc
sed -i 's/^-e //g' pepjsonserveradapter/server/prefix-config.cc
make -C pepjsonserveradapter/server all
$(MAKE) -C pepjsonserveradapter/server all
cp pepjsonserveradapter/server/pep-json-server $@
build/pepmda: build/bin/pep-json-server build/share/pEp/system.db
mkdir -p $@
build/enigmail-$(ENIG_ID).zip: build/bin/pep-json-server build/share/pEp/system.db
mkdir -p build/pepmda
bash -e common/prepareEnigmailTree.sh build/pepmda build/bin/pep-json-server build/share/pEp/system.db `which gpg` common/vanilla
build/enigmail-$(ENIG_ID).zip: build/pepmda
cd build ; zip -r ~/$@ pepmda
build/enigmail-$(ENIG_ID).xpi: build/pepmda
git clone https://git.code.sf.net/p/enigmail/source enigmail || true # ( cd enigmail ; git pull )
-rm -rf enigmail/build/dist/pepmda
mkdir -p ~/enigmail/build/dist
cp -rfp ~/build/pepmda enigmail/build/dist
cd enigmail ; git checkout -- util/genxpi package/pEpAdapter.jsm # package/pEp.jsm package/enigmail.js
patch -N enigmail/util/genxpi common/enigmail.genxpi.patch
patch -N enigmail/package/pEpAdapter.jsm common/enigmail_pEpAdapter_extensionRelative.patch
enigmail enigmail/build/enigmail-2.0.xpi: build/enigmail-$(ENIG_ID).zip
git clone https://git.code.sf.net/p/enigmail/source enigmail || cd enigmail ; git pull
cd enigmail ; ./configure --prefix ~/build
-patch -N enigmail/util/genxpi common/enigmail.genxpi.patch
-patch -N enigmail/package/pEpAdapter.jsm common/enigmail_pEpAdapter_extensionRelative.patch
$(MAKE) -C enigmail
cp enigmail/build/enigmail-2.0.xpi $@
build/enigmail-$(ENIG_ID_DARWIN).xpi: MDA_ZIP=pepmda-darwin-x86_64.zip
build/enigmail-$(ENIG_ID_WIN).xpi: MDA_ZIP=pepmda-winnt-x86.zip
build/enigmail-$(ENIG_ID_DARWIN).xpi build/enigmail-$(ENIG_ID_WIN).xpi: $(MDA_ZIP) build/enigmail-$(ENIG_ID).xpi #pepmda-darwin-x86_64.zip pepmda-winnt-x86.zip build/enigmail-$(ENIG_ID).xpi
rm -rf enigmail/build/dist/pepmda
build/enigmail-$(ENIG_ID).xpi: MDA_ZIP=build/enigmail-$(ENIG_ID).zip
build/enigmail-$(ENIG_ID_DARWIN).xpi build/enigmail-$(ENIG_ID_WIN).xpi build/enigmail-$(ENIG_ID).xpi: $(MDA_ZIP) enigmail/build/enigmail-2.0.xpi
-rm -rf enigmail/build/dist/pepmda
unzip $(MDA_ZIP) -d enigmail/build/dist
$(MAKE) -C enigmail
cp enigmail/build/enigmail-2.0.xpi $@
build/share/pEp/system.db: build pepengine/local.conf
mkdir -p $(dir $@)
cp pepengine/db/system.db $@

+ 3
- 0
README.md View File

@ -27,3 +27,6 @@ For each actual build, create a user solely for this purpose. On Debian:
### Fedora
on fedora the libtool shipped with and used by libetpan is broken, therefore use the system one:
``` cd libetpan; ln -s `which libtool` libtool```
## testing the pep-json-server
test.py contains a very basic test of the pep-json-server: query its version via json

+ 0
- 12
engine_Makefile.conf.patch View File

@ -1,12 +0,0 @@
diff -r 326bdd83df88 Makefile.conf
--- a/Makefile.conf Wed Oct 11 15:46:04 2017 +0200
+++ b/Makefile.conf Thu Oct 12 13:52:50 2017 +0200
@@ -46,7 +46,7 @@
# If empty, create a release build.
# Otherwise, create a debug build.
# This variable is ineffective in your local.conf file.
-DEBUG=YES
+DEBUG=
# If empty, suppress compiler warnings.
# Otherwise, print warnings.

+ 0
- 25
enigmail_enigmail.js.patch View File

@ -1,25 +0,0 @@
diff --git a/package/enigmail.js b/package/enigmail.js
index 52a1ad1f..b1ff306e 100644
--- a/package/enigmail.js
+++ b/package/enigmail.js
@@ -63,6 +63,12 @@ const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "quit-application";
var gPreferredGpgPath = null;
var gOverwriteEnvVar = [];
+
+// avoid splitbrains between enigmail classic and enigmail+pEp: start pEp now, busylooping 2s
+EnigmailPEPAdapter.initialize();
+let start = new Date().getTime();
+while ( new Date().getTime() - start < 2000 ){};
+
///////////////////////////////////////////////////////////////////////////////
// Enigmail encryption/decryption service
///////////////////////////////////////////////////////////////////////////////
@@ -398,7 +404,6 @@ EnigmailURIs.registerOn(Enigmail.prototype);
EnigmailVerifyAttachment.registerOn(Enigmail.prototype);
EnigmailVerify.registerContentTypeHandler();
EnigmailWksMimeHandler.registerContentTypeHandler();
-EnigmailPEPAdapter.initialize();
// This variable is exported implicitly and should not be refactored or removed
const NSGetFactory = XPCOMUtils.generateNSGetFactory([Enigmail, EnigmailProtocolHandler, EnigmailCommandLine.Handler]);

+ 0
- 100
enigmail_pEp.jsm.patch View File

@ -1,100 +0,0 @@
diff --git a/package/pEp.jsm b/package/pEp.jsm
index 39765876..0ed6135e 100644
--- a/package/pEp.jsm
+++ b/package/pEp.jsm
@@ -25,7 +25,7 @@ var gPepServerPath = null;
var gLogFunction = null;
var gShuttingDown = false;
-const pepSecurityInfo = "/pEp-json-token-";
+const pepSecurityInfo = "json-token";
const Cu = Components.utils;
const Cc = Components.classes;
@@ -36,6 +36,7 @@ Cu.import("resource://gre/modules/PromiseUtils.jsm"); /* global PromiseUtils: fa
Cu.import("resource://enigmail/timer.jsm"); /*global EnigmailTimer: false */
Cu.import("resource://enigmail/files.jsm"); /*global EnigmailFiles: false */
Cu.import("resource://enigmail/core.jsm"); /*global EnigmailCore: false */
+Cu.import("resource://enigmail/os.jsm"); /*global EnigmailOS: false */
var gRequestId = 1;
var gConnectionInfo = null;
@@ -94,14 +95,16 @@ var EnigmailpEp = {
if (!gConnectionInfo) {
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
- let tmpDir = env.get("TEMP");
- let userName = env.get("USER");
-
- let fileName = (tmpDir !== "" ? tmpDir : "/tmp") +
- pepSecurityInfo + (userName !== "" ? userName : "XXX");
-
let fileHandle = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
- EnigmailFiles.initPath(fileHandle, fileName);
+ if (!EnigmailOS.isDosLike) {
+ fileHandle.initWithPath(env.get("HOME"));
+ fileHandle.append(".pEp");
+ } else {
+ fileHandle.initWithPath(env.get("LocalAppData"));
+ fileHandle.append("pEp");
+ }
+ fileHandle.append(pepSecurityInfo)
+ DEBUG_LOG("getConnectionInfo() try token at"+fileHandle.path);
let jsonData = EnigmailFiles.readBinaryFile(fileHandle);
if (jsonData.length > 0) {
@@ -111,8 +114,9 @@ var EnigmailpEp = {
if (gConnectionInfo.address === "0.0.0.0") {
gConnectionInfo.address = "127.0.0.1";
}
+ DEBUG_LOG("getConnectionInfo(): success");
}
- catch (ex) {}
+ catch (ex) {DEBUG_LOG("getConnectionInfo(): exception");}
}
}
@@ -944,10 +948,9 @@ var EnigmailpEp = {
},
- setServerPath: function(pathName) {
+ setServerPath: function(NSIpath) {
DEBUG_LOG("setServerPath()");
-
- gPepServerPath = pathName;
+ gPepServerPath = NSIpath.clone();
},
/******************* internal (private) methods *********************/
@@ -1067,23 +1070,26 @@ var EnigmailpEp = {
deferred.reject(makeError("PEP-unavailable", null, "Cannot find JSON-PEP executable"));
}
- let exec = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+ let exec = gPepServerPath;
try {
- exec.initWithPath(gPepServerPath);
if ((!exec.exists()) || (!exec.isExecutable())) {
DEBUG_LOG("_startPepServer: executable not available");
deferred.reject(makeError("PEP-unavailable", null, "Cannot find JSON-PEP executable"));
return;
}
- EnigmailCore.getService(null, true);
-
+ let workdir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+ workdir.initWithPath(exec.parent.parent.path);
+ workdir.append("share");
+ workdir.append("pEp");
+ DEBUG_LOG("_startPepServer: workdir: "+workdir.path);
let process = subprocess.call({
command: exec,
charset: null,
environment: EnigmailCore.getEnvList(),
mergeStderr: false,
+ workdir: workdir.path,
stdin: function(stdin) {
// do nothing
},

+ 0
- 72
enigmail_pEpAdapter.jsm.patch View File

@ -1,72 +0,0 @@
diff --git a/package/pEpAdapter.jsm b/package/pEpAdapter.jsm
index f7d87f74..47fef479 100644
--- a/package/pEpAdapter.jsm
+++ b/package/pEpAdapter.jsm
@@ -101,6 +101,35 @@ var EnigmailPEPAdapter = {
filter: EnigmailPEPFilter,
+ /** locate pEp JSON server executable
+ * @return Ci.nsIfile
+ * - null if not found
+ */
+ getPepJsonServerExecutable() {
+ let pepmdaPath = getFiles().resolvePathWithEnv(PEP_SERVER_EXECUTABLE);
+ if (!pepmdaPath || !pepmdaPath.exists() || !pepmdaPath.isExecutable()) {
+ // pepmdaPath = EnigmailApp.getProfileDirectory();
+ // ^ not reliable at startup, ask mozilla directly
+ pepmdaPath = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
+ pepmdaPath.append("extensions");
+ pepmdaPath.append("{847b3a00-7ab1-11d4-8f02-006008948af5}");
+ pepmdaPath.append("pepmda");
+ pepmdaPath.append("bin");
+ pepmdaPath.append(PEP_SERVER_EXECUTABLE);
+ }
+ if (!pepmdaPath || !pepmdaPath.exists() || !pepmdaPath.isExecutable()) {
+ pepmdaPath = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
+ pepmdaPath.append("pepmda");
+ pepmdaPath.append("bin");
+ pepmdaPath.append(PEP_SERVER_EXECUTABLE);
+ }
+ if (!pepmdaPath || !pepmdaPath.exists() || !pepmdaPath.isExecutable()){
+ pepmdaPath = null;
+ }
+ EnigmailLog.DEBUG("pEpAdapter.jsm: getPepJsonServerExecutable() -> "+pepmdaPath.path+"\n");
+ return pepmdaPath;
+ },
+
/**
* Get the pEp JSON server version number.
*
@@ -140,8 +169,8 @@ var EnigmailPEPAdapter = {
if (gPepAvailable === null) {
gPepAvailable = false;
- let execFile = getFiles().resolvePathWithEnv(PEP_SERVER_EXECUTABLE);
- if (execFile && execFile.exists() && execFile.isExecutable()) {
+ let execFile = this.getPepJsonServerExecutable();
+ if (execFile !== null) {
EnigmailCore.getService(null, true);
let pepVersionStr = "";
@@ -166,6 +195,7 @@ var EnigmailPEPAdapter = {
EnigmailLog.DEBUG("pEpAdapter.jsm: isPepAvailable: got version '" + pepVersionStr + "'\n");
if (pepVersionStr.search(/pEp JSON/i) >= 0) {
gPepAvailable = true;
+ EnigmailLog.DEBUG("pEpAdapter.jsm: gPepAvailable=True\n");
}
}
else if (attemptInstall) {
@@ -299,8 +329,10 @@ var EnigmailPEPAdapter = {
// automatic mode, with Crypto enabled (do not use pEp)
if (this.isAccountCryptEnabled() && pEpMode !== 2) return;
- let execFile = getFiles().resolvePathWithEnv(PEP_SERVER_EXECUTABLE);
- if (execFile) EnigmailpEp.setServerPath(execFile.path);
+ // find pEpJSONAdapter or do not use pEp
+ let execFile = this.getPepJsonServerExecutable();
+ if (execFile) EnigmailpEp.setServerPath(execFile);
+ else return;
try {
EnigmailpEp.getPepVersion().then(function _success(data) {

+ 0
- 9
pep-json-server_start.sh View File

@ -1,9 +0,0 @@
#!/bin/sh
#/usr/bin/env >> /tmp/pepjson.call
/bin/pwd >> /tmp/pepjson.call
echo "$0 $@ " >> /tmp/pepjson.call
cd `dirname $0`
/bin/pwd >> /tmp/pepjson.call
../libexec/pep-json-server $@
echo "---
" >> /tmp/pepjson.call

Loading…
Cancel
Save