merge grind_and_cleanup
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 21 Feb 2020 19:28:30 +0100
branchgrind_and_cleanup
changeset 4439e83131d4854e
parent 4438 a2ff430b15dd
parent 4434 629607a94d28
merge
Makefile
     1.1 --- a/Makefile	Fri Feb 21 19:27:39 2020 +0100
     1.2 +++ b/Makefile	Fri Feb 21 19:28:30 2020 +0100
     1.3 @@ -25,7 +25,8 @@
     1.4  	$(MAKE) -C src
     1.5  
     1.6  all: build
     1.7 -	make -C test
     1.8 +# `make all` is not for tests, that's what `make test` is for
     1.9 +#	$(MAKE) -C test
    1.10  
    1.11  sync:
    1.12  	$(MAKE) -C sync
     2.1 --- a/Makefile.conf	Fri Feb 21 19:27:39 2020 +0100
     2.2 +++ b/Makefile.conf	Fri Feb 21 19:28:30 2020 +0100
     2.3 @@ -48,7 +48,7 @@
     2.4  # necessary
     2.5  
     2.6  #PER_USER_DIRECTORY=.pEp
     2.7 -PER_MACHINE_DIRECTORY:=/usr/local/share/pEp
     2.8 +PER_MACHINE_DIRECTORY=/usr/local/share/pEp
     2.9  
    2.10  # Filename of the pEpEngine library
    2.11  ifeq ($(BUILD_FOR),Linux)
     3.1 --- a/build-mac/pEpEngine.xcodeproj/project.pbxproj	Fri Feb 21 19:27:39 2020 +0100
     3.2 +++ b/build-mac/pEpEngine.xcodeproj/project.pbxproj	Fri Feb 21 19:28:30 2020 +0100
     3.3 @@ -929,7 +929,7 @@
     3.4  			isa = PBXNativeTarget;
     3.5  			buildConfigurationList = 64796A531B455AA5004B1C24 /* Build configuration list for PBXNativeTarget "pEpEngine" */;
     3.6  			buildPhases = (
     3.7 -				43D47B08225DEBD600E97C5B /* ShellScript */,
     3.8 +				43D47B08225DEBD600E97C5B /* Generate src files */,
     3.9  				64796A3B1B455AA5004B1C24 /* Sources */,
    3.10  				64796A3C1B455AA5004B1C24 /* Frameworks */,
    3.11  				64796A3D1B455AA5004B1C24 /* CopyFiles */,
    3.12 @@ -1024,7 +1024,7 @@
    3.13  /* End PBXResourcesBuildPhase section */
    3.14  
    3.15  /* Begin PBXShellScriptBuildPhase section */
    3.16 -		43D47B08225DEBD600E97C5B /* ShellScript */ = {
    3.17 +		43D47B08225DEBD600E97C5B /* Generate src files */ = {
    3.18  			isa = PBXShellScriptBuildPhase;
    3.19  			buildActionMask = 2147483647;
    3.20  			files = (
    3.21 @@ -1033,6 +1033,7 @@
    3.22  			);
    3.23  			inputPaths = (
    3.24  			);
    3.25 +			name = "Generate src files";
    3.26  			outputFileListPaths = (
    3.27  				"$(SRCROOT)/generated-files-asn1.txt",
    3.28  				"$(SRCROOT)/generated-files-sync.txt",
     4.1 --- a/build-windows/generate_code.cmd	Fri Feb 21 19:27:39 2020 +0100
     4.2 +++ b/build-windows/generate_code.cmd	Fri Feb 21 19:28:30 2020 +0100
     4.3 @@ -1,32 +1,76 @@
     4.4 -pushd .
     4.5 -set pwd=%cd%
     4.6 -cd %pwd%\sync
     4.7 +@ECHO OFF
     4.8 +PUSHD .
     4.9 +SET pwd=%cd%
    4.10 +CD %pwd%\sync
    4.11  
    4.12 -if not exist generated mkdir generated
    4.13 +IF NOT EXIST generated MKDIR generated
    4.14  
    4.15 +ECHO py "%YML_PATH%\yml2proc" -E utf-8 -y gen_actions.ysl2 sync.fsm
    4.16  py "%YML_PATH%\yml2proc" -E utf-8 -y gen_actions.ysl2 sync.fsm
    4.17 +IF %ERRORLEVEL% NEQ 0 (
    4.18 +	POPD
    4.19 +	EXIT /B 1
    4.20 +	)
    4.21 +ECHO py "%YML_PATH%\yml2proc" -E utf-8 -y gen_codec.ysl2 distribution.fsm
    4.22  py "%YML_PATH%\yml2proc" -E utf-8 -y gen_codec.ysl2 distribution.fsm
    4.23 +IF %ERRORLEVEL% NEQ 0 (
    4.24 +	POPD
    4.25 +	EXIT /B 1
    4.26 +	)
    4.27 +ECHO py "%YML_PATH%\yml2proc" -E utf-8 -y gen_codec.ysl2 sync.fsm
    4.28  py "%YML_PATH%\yml2proc" -E utf-8 -y gen_codec.ysl2 sync.fsm
    4.29 +IF %ERRORLEVEL% NEQ 0 (
    4.30 +	POPD
    4.31 +	EXIT /B 1
    4.32 +	)
    4.33 +ECHO py "%YML_PATH%\yml2proc" -E utf-8 -y gen_messages.ysl2 sync.fsm
    4.34  py "%YML_PATH%\yml2proc" -E utf-8 -y gen_messages.ysl2 sync.fsm
    4.35 +IF %ERRORLEVEL% NEQ 0 (
    4.36 +	POPD
    4.37 +	EXIT /B 1
    4.38 +	)
    4.39 +ECHO py "%YML_PATH%\yml2proc" -E utf-8 -y gen_messages.ysl2 distribution.fsm
    4.40  py "%YML_PATH%\yml2proc" -E utf-8 -y gen_messages.ysl2 distribution.fsm
    4.41 +IF %ERRORLEVEL% NEQ 0 (
    4.42 +	POPD
    4.43 +	EXIT /B 1
    4.44 +	)
    4.45 +ECHO py "%YML_PATH%\yml2proc" -E utf-8 -y gen_message_func.ysl2 sync.fsm
    4.46  py "%YML_PATH%\yml2proc" -E utf-8 -y gen_message_func.ysl2 sync.fsm
    4.47 +IF %ERRORLEVEL% NEQ 0 (
    4.48 +	POPD
    4.49 +	EXIT /B 1
    4.50 +	)
    4.51 +ECHO py "%YML_PATH%\yml2proc" -E utf-8 -y gen_statemachine.ysl2 sync.fsm
    4.52  py "%YML_PATH%\yml2proc" -E utf-8 -y gen_statemachine.ysl2 sync.fsm
    4.53 +IF %ERRORLEVEL% NEQ 0 (
    4.54 +	POPD
    4.55 +	EXIT /B 1
    4.56 +	)
    4.57  
    4.58  xcopy /y generated\*.asn1 ..\asn.1\
    4.59  xcopy /y generated\*.c ..\src\
    4.60  xcopy /y generated\*.h ..\src\
    4.61  
    4.62 -cd %pwd%\asn.1
    4.63 +CD %pwd%\asn.1
    4.64  
    4.65 -del *.h
    4.66 -del *.c
    4.67 +DEL *.h
    4.68 +DEL *.c
    4.69  
    4.70  ..\..\Tools\asn1c\bin\asn1c -S ../../Tools/asn1c/share/asn1c -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keysync.asn1 sync.asn1
    4.71 +IF %ERRORLEVEL% NEQ 0 (
    4.72 +	POPD
    4.73 +	EXIT /B 1
    4.74 +	)
    4.75  ..\..\Tools\asn1c\bin\asn1c -S ../../Tools/asn1c/share/asn1c -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keyreset.asn1 distribution.asn1
    4.76 +IF %ERRORLEVEL% NEQ 0 (
    4.77 +	POPD
    4.78 +	EXIT /B 1
    4.79 +	)
    4.80  
    4.81 -del *-sample.c
    4.82 +DEL *-sample.c
    4.83  
    4.84 -cd %pwd%\..
    4.85 -if not exist pEp mklink /d pEp pEpEngine\src
    4.86 +CD %pwd%\..
    4.87 +IF NOT EXIST pEp mklink /d pEp pEpEngine\src
    4.88  
    4.89 -popd
    4.90 +POPD
     5.1 --- a/build-windows/libpEpasn1/libpEpasn1.vcxproj	Fri Feb 21 19:27:39 2020 +0100
     5.2 +++ b/build-windows/libpEpasn1/libpEpasn1.vcxproj	Fri Feb 21 19:28:30 2020 +0100
     5.3 @@ -82,7 +82,7 @@
     5.4        <OptimizeReferences>true</OptimizeReferences>
     5.5      </Link>
     5.6      <PreBuildEvent>
     5.7 -      <Command>"$(ProjectDir)..\generate_code.cmd" "$(ProjectDir)..\.."</Command>
     5.8 +      <Command>cd "$(ProjectDir)..\.." &amp;&amp; "$(ProjectDir)..\generate_code.cmd"</Command>
     5.9        <Message>Generating Code for pEp Sync</Message>
    5.10      </PreBuildEvent>
    5.11    </ItemDefinitionGroup>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/doc/build-fedora.md	Fri Feb 21 19:28:30 2020 +0100
     6.3 @@ -0,0 +1,104 @@
     6.4 +<!-- Copyright 2015-2020, pEp foundation, Switzerland
     6.5 +This file is part of the pEp Engine
     6.6 +This file may be used under the terms of the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) License
     6.7 +See CC_BY-SA.txt -->
     6.8 +
     6.9 +# Build instructions for Fedora 31
    6.10 +
    6.11 +# Installing package dependencies
    6.12 +
    6.13 +~~~
    6.14 +# Version control
    6.15 +dnf install -y mercurial git
    6.16 +
    6.17 +# build dependencies (YML2, libetpan, asn1c)
    6.18 +dnf install -y python-lxml automake libtool autoconf
    6.19 +
    6.20 +# build-essentials equivalent for rpm based systems
    6.21 +dnf groupinstall -y "Development Tools"
    6.22 +
    6.23 +# other engine dependencies (uuid, gpg, sqlite)
    6.24 +dnf install -y uuid-devel gpgme-devel libsqlite3x-devel libsqlite3x sqlite
    6.25 +
    6.26 +# asn1c
    6.27 +dnf -y install asn1c
    6.28 +~~~
    6.29 +
    6.30 +# Installing unpackaged dependencies
    6.31 +## YML2
    6.32 +
    6.33 +~~~
    6.34 +mkdir -p ~/code/yml2
    6.35 +hg clone https://pep.foundation/dev/repos/yml2/ ~/code/yml2
    6.36 +~~~
    6.37 +
    6.38 +## libetpan (pEp Engine requires libetpan with a set of patches that have not been upstreamed yet)
    6.39 +
    6.40 +~~~
    6.41 +mkdir -p ~/code/libetpan
    6.42 +git clone https://github.com/fdik/libetpan ~/code/libetpan
    6.43 +cd ~/code/libetpan
    6.44 +mkdir ~/code/libetpan/build
    6.45 +./autogen.sh --prefix="$HOME/code/libetpan/build"
    6.46 +make
    6.47 +make install
    6.48 +~~~
    6.49 +
    6.50 +# pEp Engine
    6.51 +
    6.52 +~~~
    6.53 +mkdir -p ~/code/pep-engine
    6.54 +hg clone https://pep.foundation/dev/repos/pEpEngine/ ~/code/pep-engine
    6.55 +cd ~/code/pep-engine
    6.56 +hg update sync
    6.57 +mkdir ~/code/pep-engine/build
    6.58 +~~~
    6.59 +
    6.60 +Edit the build configuration to your needs in `Makefile.conf`, or create a `local.conf` that sets any of the make variables documented in `Makefile.conf`. All the default values for the build configuration variables on each platform are documented in `Makefile.conf`.
    6.61 +
    6.62 +If a dependency is not found in your system's default include or library paths, you will have to specify the according paths in a make variable. Typically, this has to be done at least for YML2, and libetpan.
    6.63 +
    6.64 +For a more detailed explanation of the mechanics of these build configuration files, and overriding defaults, see the comments in `Makefile.conf`.
    6.65 +
    6.66 +Below is a sample `./local.conf` file, for orientation.
    6.67 +
    6.68 +~~~
    6.69 +PREFIX=$(HOME)/code/pep-engine/build
    6.70 +PER_MACHINE_DIRECTORY=$(PREFIX)/share/pEp
    6.71 +
    6.72 +YML2_PATH=$(HOME)/code/yml2
    6.73 +
    6.74 +ETPAN_LIB=-L$(HOME)/code/libetpan/build/lib
    6.75 +ETPAN_INC=-I$(HOME)/code/libetpan/build/include
    6.76 +
    6.77 +LIBGPGME=libgpgme.so
    6.78 +~~~
    6.79 +
    6.80 +The engine is built as follows:
    6.81 +
    6.82 +~~~
    6.83 +make all
    6.84 +make db
    6.85 +~~~
    6.86 +
    6.87 +Installation:
    6.88 +
    6.89 +~~~
    6.90 +make dbinstall
    6.91 +make install
    6.92 +~~~
    6.93 +
    6.94 +The unit tests can be run without the engine library being installed, however `system.db` must be installed:
    6.95 +
    6.96 +~~~
    6.97 +make dbinstall
    6.98 +~~~
    6.99 +
   6.100 +Since `system.db` rarely changes, its installation is not needed for every build.
   6.101 +
   6.102 +Tests can be compiled and executed with the following commands:
   6.103 +
   6.104 +~~~
   6.105 +make -C test compile
   6.106 +make test
   6.107 +~~~
     7.1 --- a/sync/cond_act_sync.yml2	Fri Feb 21 19:27:39 2020 +0100
     7.2 +++ b/sync/cond_act_sync.yml2	Fri Feb 21 19:28:30 2020 +0100
     7.3 @@ -455,18 +455,22 @@
     7.4  
     7.5  action backupOwnKeys
     7.6  ||
     7.7 -    identity_list *il = identity_list_dup(session->sync_state.own.identities);
     7.8 -    if (!il)
     7.9 +    if (session->sync_state.own.backup)
    7.10 +        free_stringlist(session->sync_state.own.backup);
    7.11 +
    7.12 +    session->sync_state.own.backup = stringlist_dup(session->sync_state.own.keys);
    7.13 +    if (session->sync_state.own.backup == NULL)
    7.14          return PEP_OUT_OF_MEMORY;
    7.15 -
    7.16 -    free_identity_list(session->sync_state.own.backup);
    7.17 -    session->sync_state.own.backup = il;
    7.18  ||
    7.19  
    7.20  action prepareOwnKeysFromBackup
    7.21  ||
    7.22 -    IdentityList_from_identity_list(session->sync_state.own.backup,
    7.23 -            &session->sync_state.keysync.ownIdentities);
    7.24 +    if (session->sync_state.own.keys)
    7.25 +        free_stringlist(session->sync_state.own.keys);
    7.26 +
    7.27 +    session->sync_state.own.keys = stringlist_dup(session->sync_state.own.backup);
    7.28 +    if (session->sync_state.own.keys == NULL)
    7.29 +        return PEP_OUT_OF_MEMORY;
    7.30  ||
    7.31  
    7.32  action receivedKeysAreDefaultKeys
     8.1 --- a/sync/gen_message_func.ysl2	Fri Feb 21 19:27:39 2020 +0100
     8.2 +++ b/sync/gen_message_func.ysl2	Fri Feb 21 19:28:30 2020 +0100
     8.3 @@ -43,8 +43,8 @@
     8.4  
     8.5      struct own_«@name»_state_s {
     8.6          stringlist_t *keys;
     8.7 +        stringlist_t *backup;
     8.8          identity_list *identities;
     8.9 -        identity_list *backup;
    8.10  
    8.11          // TIDs we're using ourselves
    8.12          `` for "func:distinctName(fsm/message/field[@type='TID'])" |>> «func:ctype()» «@name»;
     9.1 --- a/sync/sync.fsm	Fri Feb 21 19:27:39 2020 +0100
     9.2 +++ b/sync/sync.fsm	Fri Feb 21 19:28:30 2020 +0100
     9.3 @@ -454,6 +454,7 @@
     9.4          state JoiningGroup {
     9.5              on Init {
     9.6                  // we need to keep in memory which keys we have before joining
     9.7 +                do prepareOwnKeys;
     9.8                  do backupOwnKeys;
     9.9              }
    9.10              on GroupKeysForNewMember {