AppImg packaging

This commit is contained in:
Richard Ramos 2020-05-14 16:19:01 -04:00 committed by Iuri Matias
parent c1d1b60f46
commit ce41388a51
13 changed files with 85 additions and 334 deletions

4
.gitignore vendored
View File

@ -8,4 +8,6 @@ noBackup/
*.pro.user
*.pro.autosave
.vscode
bin/
bin/
vendor/.nimble
*.AppImage

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "vendor/nim-stew"]
path = vendor/nim-stew
url = https://github.com/status-im/nim-stew/
[submodule "vendor/status-go"]
path = vendor/status-go
url = https://github.com/status-im/status-go

View File

@ -59,6 +59,12 @@ deps: | deps-common
update: | update-common
DEPLOYQT := linuxdeployqt-continuous-x86_64.AppImage
$(DEPLOYQT):
wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/$(DEPLOYQT)
chmod +x $(DEPLOYQT)
DOTHERSIDE := vendor/DOtherSide/build/lib/libDOtherSideStatic.a
$(DOTHERSIDE): | deps
@ -69,15 +75,37 @@ $(DOTHERSIDE): | deps
cmake -DCMAKE_BUILD_TYPE=Release .. $(HANDLE_OUTPUT) && \
$(MAKE) # IF WE WANT TO USE LIBDOTHERSIDE AS STATIC LIBRARY, USE `$(MAKE) DOtherSideStatic` INSTEAD
build-linux: $(DOTHERSIDE) src/nim_status_client.nim | deps
echo -e $(BUILD_MSG) "$@" && \
$(ENV_SCRIPT) nim c -L:lib/libstatus.a -d:ssl -L:-lm -L:-Lvendor/DOtherSide/build/lib/ $(NIM_PARAMS) --outdir:./bin src/nim_status_client.nim
STATUSGO := vendor/status-go/build/bin/libstatus.a
build-macos: $(DOTHERSIDE) src/nim_status_client.nim | deps
$(STATUSGO): | deps
echo -e $(BUILD_MSG) "status-go"
+ cd vendor/status-go && \
$(MAKE) setup-dev && \
$(MAKE) statusgo-library
build-linux: $(DOTHERSIDE) $(STATUSGO) src/nim_status_client.nim | deps
echo -e $(BUILD_MSG) "$@" && \
$(ENV_SCRIPT) nim c -L:lib/libstatus.a -d:ssl -L:-lm -L:"-framework Foundation -framework Security -framework IOKit -framework CoreServices" -L:-Lvendor/DOtherSide/build/lib/ $(NIM_PARAMS) --outdir:./bin src/nim_status_client.nim
$(ENV_SCRIPT) nim c -L:$(STATUSGO) -d:ssl -L:-lm -L:-Lvendor/DOtherSide/build/lib/ $(NIM_PARAMS) --outdir:./bin src/nim_status_client.nim
build-macos: $(DOTHERSIDE) $(STATUSGO) src/nim_status_client.nim | deps
echo -e $(BUILD_MSG) "$@" && \
$(ENV_SCRIPT) nim c -L:$(STATUSGO) -d:ssl -L:-lm -L:"-framework Foundation -framework Security -framework IOKit -framework CoreServices" -L:-Lvendor/DOtherSide/build/lib/ $(NIM_PARAMS) --outdir:./bin src/nim_status_client.nim
APPIMAGE := NimStatusClient-x86_64.AppImage
$(APPIMAGE): $(DEFAULT_TARGET) $(DEPLOYQT) nim-status.desktop
rm -rf tmp/dist
mkdir -p tmp/dist/usr/bin
cp bin/nim_status_client tmp/dist/usr/bin
cp nim-status.desktop tmp/dist/.
cp status.svg tmp/dist/status.svg
cp -R ui tmp/dist/usr/.
echo -e $(BUILD_MSG) "AppImage"
./$(DEPLOYQT) tmp/dist/nim-status.desktop -no-translations -no-copy-copyright-files -appimage
appimage: $(APPIMAGE)
clean: | clean-common
rm -rf vendor/DOtherSide/build tmp/dist
rm -rf $(APPIMAGE) bin/* vendor/DOtherSide/build tmp/dist vendor/status-go/build/bin
endif # "variables.mk" was not included

View File

@ -2,17 +2,8 @@
Experiments calling status-go from nim, inspired in [nim-stratus](https://github.com/status-im/nim-stratus) by [@arnetheduck](https://github.com/arnetheduck)
### 1. Install nim 1.2.0
```
# linux
apt-get install nim
# macos
brew install nim
```
### 2. Install QT, and add it to the PATH
### 1. Install QT, and add it to the PATH
```
# Linux
@ -22,34 +13,24 @@ export PATH=$PATH:/path/to/Qt/5.14.2/gcc_64/bin
export PATH=$PATH:/path/to/Qt/5.14.2/clang_64/bin
```
### 3. Clone the repo
```
git clone https://github.com/status-im/nim-status-client/ --recurse-submodules
```
### 4. Copy libstatus to repo
Copy `libstatus.a` to the `./lib` folder. Can be obtained from `status-react/result` by executing `make status-go-desktop`.
**macos:** rename `libstatus.a` to `libstatus.dylib` _before_ copying over. Alternatively, modify `desktop/default.nix` to output `libstatus.dylib` before copying over.
### 5. Build `nim-status-client`
### 2. Clone the repo and build `nim-status-client`
```
git clone https://github.com/status-im/nim-status-client/
make
```
### 6. Setup Library Path
### 3. Setup Library Path
```
export LD_LIBRARY_PATH=vendor/DOtherSide/build/lib/
```
### 7. Run the app
### 4. Run the app
```
./bin/nim_status_client
```
### 8. "Cold" reload using VSCode
### 5. "Cold" reload using VSCode
We can setup a "cold" reload, whereby the app will be rebuilt and restarted when changes in the source are saved. This will not save state, as the app will be restarted, but it will save us some time from manually restarting the app. We can handily force an app rebuild/relaunch with the shortcut `Cmd+Shift+b` (execute the default build task, which we'll setup below).

29
build-in-docker.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
# Probably should be part of a dockerfile
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt update
sudo apt install -y --fix-missing cmake build-essential git libpcre3-dev libssl-dev git
rm -Rf tmp
make -j2 clean
# Installing GO
# Probably should be part of a dockerfile
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.2.linux-amd64.tar.gz
rm ./go1.14.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
# the minor Qt version keeps getting updated inside the Docker image
cd /nim-status-client/
export PKG_CONFIG_PATH="$(echo /opt/qt/*/gcc_64/lib/pkgconfig)"
export LD_LIBRARY_PATH="$(echo /opt/qt/*/gcc_64/lib/)"
make appimage
rm -f linuxdeployqt-continuous-x86_64.AppImage
rm -Rf tmp

View File

@ -1,293 +0,0 @@
/* Code generated by cmd/cgo; DO NOT EDIT. */
/* package github.com/status-im/status-go/lib */
#line 1 "cgo-builtin-export-prolog"
#include <stddef.h> /* for ptrdiff_t below */
#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H
#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
#endif
#endif
/* Start of preamble from import "C" comments. */
#line 3 "library.go"
#include <stdlib.h>
#line 1 "cgo-generated-wrapper"
#line 3 "multiaccount.go"
#include <stdlib.h>
#line 1 "cgo-generated-wrapper"
/* End of preamble from import "C" comments. */
/* Start of boilerplate cgo prologue. */
#line 1 "cgo-gcc-export-header-prolog"
#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H
typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef __SIZE_TYPE__ GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
/*
static assertion to make sure the file is being used on architecture
at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef _GoString_ GoString;
#endif
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
#endif
/* End of boilerplate cgo prologue. */
#ifdef __cplusplus
extern "C" {
#endif
// OpenAccounts opens database and returns accounts list.
extern char* OpenAccounts(char* p0);
// ExtractGroupMembershipSignatures extract public keys from tuples of content/signature
extern char* ExtractGroupMembershipSignatures(char* p0);
// Sign signs a string containing group membership information
extern char* SignGroupMembership(char* p0);
//ValidateNodeConfig validates config for status node
extern char* ValidateNodeConfig(char* p0);
//ResetChainData remove chain data from data directory
extern char* ResetChainData();
//CallRPC calls public APIs via RPC
extern char* CallRPC(char* p0);
//CallPrivateRPC calls both public and private APIs via RPC
extern char* CallPrivateRPC(char* p0);
//CreateAccount is equivalent to creating an account from the command line,
// just modified to handle the function arg passing
extern char* CreateAccount(char* p0);
//RecoverAccount re-creates master key using given details
extern char* RecoverAccount(char* p0, char* p1);
// StartOnboarding initialize the onboarding with n random accounts
extern char* StartOnboarding(int p0, int p1);
// ImportOnboardingAccount re-creates and imports an account created during onboarding.
extern char* ImportOnboardingAccount(char* p0, char* p1);
// RemoveOnboarding resets the current onboarding removing from memory all the generated keys.
extern void RemoveOnboarding();
//VerifyAccountPassword verifies account password
extern char* VerifyAccountPassword(char* p0, char* p1, char* p2);
//StartNode - start Status node
extern char* StartNode(char* p0);
//StopNode - stop status node
extern char* StopNode();
//Login loads a key file (for a given address), tries to decrypt it using the password, to verify ownership
// if verified, purges all the previous identities from Whisper, and injects verified key as shh identity
extern char* Login(char* p0, char* p1);
// SaveAccountAndLogin saves account in status-go database..
extern char* SaveAccountAndLogin(char* p0, char* p1, char* p2, char* p3, char* p4);
// InitKeystore initialize keystore before doing any operations with keys.
extern char* InitKeystore(char* p0);
// LoginWithKeycard initializes an account with a chat key and encryption key used for PFS.
// It purges all the previous identities from Whisper, and injects the key as shh identity.
extern char* LoginWithKeycard(char* p0, char* p1);
//Logout is equivalent to clearing whisper identities
extern char* Logout();
// SignMessage unmarshals rpc params {data, address, password} and passes
// them onto backend.SignMessage
extern char* SignMessage(char* p0);
// Recover unmarshals rpc params {signDataString, signedData} and passes
// them onto backend.
extern char* Recover(char* p0);
// SendTransaction converts RPC args and calls backend.SendTransaction
extern char* SendTransaction(char* p0, char* p1);
// SendTransactionWithSignature converts RPC args and calls backend.SendTransactionWithSignature
extern char* SendTransactionWithSignature(char* p0, char* p1);
// HashTransaction validate the transaction and returns new txArgs and the transaction hash.
extern char* HashTransaction(char* p0);
// HashMessage calculates the hash of a message to be safely signed by the keycard
// The hash is calulcated as
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
// This gives context to the signed message and prevents signing of transactions.
extern char* HashMessage(char* p0);
// SignTypedData unmarshall data into TypedData, validate it and signs with selected account,
// if password matches selected account.
extern char* SignTypedData(char* p0, char* p1, char* p2);
// HashTypedData unmarshalls data into TypedData, validates it and hashes it.
extern char* HashTypedData(char* p0);
//StartCPUProfile runs pprof for cpu
extern char* StartCPUProfile(char* p0);
//StopCPUProfiling stops pprof for cpu
extern char* StopCPUProfiling();
//WriteHeapProfile starts pprof for heap
extern char* WriteHeapProfile(char* p0);
// AddPeer adds an enode as a peer.
extern char* AddPeer(char* p0);
// ConnectionChange handles network state changes as reported
// by ReactNative (see https://facebook.github.io/react-native/docs/netinfo.html)
extern void ConnectionChange(char* p0, int p1);
// AppStateChange handles app state changes (background/foreground).
extern void AppStateChange(char* p0);
// SetSignalEventCallback setup geth callback to notify about new signal
extern void SetSignalEventCallback(void* p0);
// ExportNodeLogs reads current node log and returns content to a caller.
extern char* ExportNodeLogs();
// ChaosModeUpdate changes the URL of the upstream RPC client.
extern char* ChaosModeUpdate(int p0);
// GetNodesFromContract returns a list of nodes from a contract
extern char* GetNodesFromContract(char* p0, char* p1);
// SignHash exposes vanilla ECDSA signing required for Swarm messages
extern char* SignHash(char* p0);
// GenerateAlias returns a 3 random name words given the pk string 0x prefixed
extern char* GenerateAlias(GoString p0);
// Identicon returns the base64 identicon
extern char* Identicon(GoString p0);
// MultiAccountGenerate generates account in memory without storing them.
extern char* MultiAccountGenerate(char* p0);
// MultiAccountGenerateAndDeriveAddresses combines Generate and DeriveAddresses in one call.
extern char* MultiAccountGenerateAndDeriveAddresses(char* p0);
// MultiAccountDeriveAddresses derive addresses from an account selected by ID, without storing them.
extern char* MultiAccountDeriveAddresses(char* p0);
// MultiAccountStoreDerivedAccounts derive accounts from the specified key and store them encrypted with the specified password.
extern char* MultiAccountStoreDerivedAccounts(char* p0);
// MultiAccountImportPrivateKey imports a raw private key without storing it.
extern char* MultiAccountImportPrivateKey(char* p0);
// MultiAccountImportMnemonic imports an account derived from the mnemonic phrase and the Bip39Passphrase storing it.
extern char* MultiAccountImportMnemonic(char* p0);
// MultiAccountStoreAccount stores the select account.
extern char* MultiAccountStoreAccount(char* p0);
// MultiAccountLoadAccount loads in memory the account specified by address unlocking it with password.
extern char* MultiAccountLoadAccount(char* p0);
// MultiAccountReset remove all the multi-account keys from memory.
extern char* MultiAccountReset();
#ifdef __cplusplus
}
#endif

View File

@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
Name=Nim Status Client
Exec=nim %F
Exec=nim_status_client
Icon=status
Comment=Hello World
Terminal=true

8
start-docker.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
docker run -it --rm --device /dev/fuse \
-v $PWD:/nim-status-client:Z \
-w /nim-status-client \
--cap-add SYS_ADMIN \
--privileged \
a12e/docker-qt:5.12-gcc_64 \
sh build-in-docker.sh

View File

@ -1,2 +0,0 @@
/home/richard/status/nim-status-client/vendor/nim-nat-traversal
/home/richard/status/nim-status-client/vendor/nim-nat-traversal

View File

@ -1,2 +0,0 @@
/home/richard/status/nim-status-client/vendor/nim-stew
/home/richard/status/nim-status-client/vendor/nim-stew

View File

@ -1,2 +0,0 @@
/home/richard/status/nim-status-client/vendor/nim-stint
/home/richard/status/nim-status-client/vendor/nim-stint

View File

@ -1,2 +0,0 @@
/home/richard/status/nim-status-client/vendor/nimqml/src
/home/richard/status/nim-status-client/vendor/nimqml/src

1
vendor/status-go vendored Submodule

@ -0,0 +1 @@
Subproject commit be683556ffb1ece9ff88ed8e2f12277dde75ee08