diff --git a/.gitignore b/.gitignore index b4872679e..5d1853872 100644 --- a/.gitignore +++ b/.gitignore @@ -65,7 +65,6 @@ db4 *.pyc *.o *.o-* -*.patch *.a *.pb.cc *.pb.h @@ -120,9 +119,12 @@ test/cache/* libbitcoinconsensus.pc contrib/devtools/split-debug.sh -*/.vscode/* -.vscode - cov-int -configure~ \ No newline at end of file +configure~ + +# flatpak +.flatpak-builder +*.flatpak +/repo/ +/build/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..5564005a2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.watcherExclude": { + "**/.flatpak-builder/**": true, + "**/build/**": true, + "**/repo/**": true + } +} \ No newline at end of file diff --git a/README.md b/README.md index cfe4391cc..7dbf65cb4 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,15 @@ Our major observation for decentralized apps is that data is significantly more Take a look at [awesome-kevacoin](https://github.com/kvazar-network/awesome-kevacoin) catalog, also you're welcome to share new service there! +## Install + +Please refer the [Releases](https://github.com/kvazar-network/kevacoin/releases) page to get the latest stable version and precompiled binaries! + ## Build +> [!TIP] +> See also the [Flatpak](https://github.com/kvazar-network/kevacoin/blob/kvazar/doc/build-flatpak.md) build instructions! + * [Fedora](https://github.com/kvazar-network/kevacoin/blob/kvazar/doc/build-fedora.md) * [NetBSD](https://github.com/kvazar-network/kevacoin/blob/kvazar/doc/build-netbsd.md) * [OpenBSD](https://github.com/kvazar-network/kevacoin/blob/kvazar/doc/build-openbsd.md) diff --git a/doc/build-flatpak.md b/doc/build-flatpak.md new file mode 100644 index 000000000..fcb344c5f --- /dev/null +++ b/doc/build-flatpak.md @@ -0,0 +1,48 @@ +# The Flatpak bundle + +> [!TIP] +> Check out latest [Releases](https://github.com/kvazar-network/kevacoin/releases) to get the precompiled bundle! + +## Build + +> [!NOTE] +> * the `libdb` module (a.k.a. Berkeley DB) requires the `CFLAGS=-Wno-error=implicit-function-declaration` to disable warnings in the recent runtime version `24.08`. This option is not yet necessary for `23.08`, but that version is not in use as deprecated; +> * at this moment, the newer versions of `boost` and `miniupnpc` than defined in the manifest are not compatible and require an update to the `kevacoin-core` API (see [dependencies](https://github.com/kvazar-network/kevacoin/blob/kvazar/doc/dependencies.md) for details) + +### Get source + +``` bash +git clone https://github.com/kvazar-network/kevacoin.git && cd kevacoin +``` + +### Compile and install + +``` bash +flatpak-builder --force-clean build\ + --install-deps-from=flathub\ + --install\ + --repo=repo\ + --user\ + io.github.kvazar_network.kevacoin-qt.json +``` + +### Launch + +Find and launch `KevaCoin` from the application menu or use the following command to launch with CLI: + +``` bash +flatpak run io.github.kvazar_network.kevacoin-qt +``` + +### Share the bundle + +Follow these steps if you want to build the latest `.flatpak` file from the repository and share it with others: + +* `cd kevacoin` - navigate to the project source directory +* `git pull` - make sure the source is up to date +* `flatpak build-bundle repo kevacoin-qt.flatpak io.github.kvazar_network.kevacoin-qt` - create the bundle (`kevacoin-qt.flatpak`) +* `flatpak install --user kevacoin-qt.flatpak` - install from the `kevacoin-qt.flatpak` bundle + +### Feedback + +Please, create new [Issue](https://github.com/kvazar-network/kevacoin/issues) if you have any questions or feel free to contribute! \ No newline at end of file diff --git a/io.github.kvazar_network.kevacoin-qt.json b/io.github.kvazar_network.kevacoin-qt.json new file mode 100644 index 000000000..8de7f67ed --- /dev/null +++ b/io.github.kvazar_network.kevacoin-qt.json @@ -0,0 +1,157 @@ +{ + "id": "io.github.kvazar_network.kevacoin-qt", + "runtime": "org.kde.Platform", + "sdk": "org.kde.Sdk", + "runtime-version": "5.15-24.08", + "command": "kevacoin-qt", + "finish-args": [ + "--persist=.kevacoin", + "--device=dri", + "--share=ipc", + "--share=network", + "--socket=x11" + ], + "cleanup": [ + "/include", + "/lib/*.a", + "/lib/*.la", + "/lib/cmake", + "/lib/pkgconfig", + "/share/cmake", + "/share/man" + ], + "modules": [ + { + "name": "boost", + "buildsystem": "simple", + "build-commands": [ + "./bootstrap.sh --prefix=/app", + "./b2 install -j $FLATPAK_BUILDER_N_JOBS" + ], + "sources": [ + { + "type": "archive", + "url": "https://archives.boost.io/release/1.83.0/source/boost_1_83_0.tar.bz2", + "sha256": "6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e" + } + ] + }, + { + "name": "libdb", + "buildsystem": "simple", + "build-commands": [ + "cd build_unix && ../dist/configure --prefix=/app --enable-cxx CFLAGS=-Wno-error=implicit-function-declaration && make -j $FLATPAK_BUILDER_N_JOBS && make install" + ], + "sources": [ + { + "type": "archive", + "url": "https://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz", + "sha256": "12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef" + }, + { + "type": "patch", + "path": "libdb.patch", + "options": [ + "-p2" + ] + } + ] + }, + { + "name": "libsodium", + "buildsystem": "simple", + "build-commands": [ + "./configure --prefix=/app && make -j $FLATPAK_BUILDER_N_JOBS && make install" + ], + "sources": [ + { + "type": "archive", + "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.20.tar.gz", + "sha256": "ebb65ef6ca439333c2bb41a0c1990587288da07f6c7fd07cb3a18cc18d30ce19" + } + ] + }, + { + "name": "libprotobuf", + "buildsystem": "simple", + "build-commands": [ + "./autogen.sh", + "./configure --prefix=/app", + "make -j $FLATPAK_BUILDER_N_JOBS && make install" + ], + "sources": [ + { + "type": "archive", + "url": "https://github.com/protocolbuffers/protobuf/releases/download/v2.6.0/protobuf-2.6.0.tar.gz", + "sha256": "cd087148a8651aaaf49e6e47df9491f3cd4cc58d3add0ac7d7b834ad808f4f13" + } + ] + }, + { + "name": "libevent", + "buildsystem": "simple", + "build-commands": [ + "./autogen.sh", + "./configure --prefix=/app", + "make -j $FLATPAK_BUILDER_N_JOBS && make install" + ], + "sources": [ + { + "type": "archive", + "url": "https://github.com/libevent/libevent/archive/refs/tags/release-2.1.12-stable.tar.gz", + "sha256": "7180a979aaa7000e1264da484f712d403fcf7679b1e9212c4e3d09f5c93efc24" + } + ] + }, + { + "name": "libzeromq", + "buildsystem": "simple", + "build-commands": [ + "./autogen.sh", + "./configure --prefix=/app", + "make -j $FLATPAK_BUILDER_N_JOBS && make install" + ], + "sources": [ + { + "type": "archive", + "url": "https://github.com/zeromq/libzmq/releases/download/v4.3.5/zeromq-4.3.5.tar.gz", + "sha256": "6653ef5910f17954861fe72332e68b03ca6e4d9c7160eb3a8de5a5a913bfab43" + } + ] + }, + { + "name": "miniupnpc", + "buildsystem": "simple", + "build-commands": [ + "make -j $FLATPAK_BUILDER_N_JOBS && make install INSTALLPREFIX=/app" + ], + "sources": [ + { + "type": "archive", + "url": "https://github.com/miniupnp/miniupnp/releases/download/miniupnpc_2_2_1/miniupnpc-2.2.1.tar.gz", + "sha256": "3a3167e57727bf1d2a7b4861f7c7b57a663f58b9cf68227762ed2fc64e8ea11f" + } + ] + }, + { + "name": "core", + "buildsystem": "simple", + "build-commands": [ + "./autogen.sh", + "./configure --prefix=/app --with-boost=/app --with-libdb=/app --with-gui", + "make -j $FLATPAK_BUILDER_N_JOBS && make install" + ], + "post-install": [ + "install -D share/icons/hicolor/scalable/apps/${FLATPAK_ID}.svg -t /app/share/icons/hicolor/symbolic/apps", + "install -D share/applications/${FLATPAK_ID}.desktop -t /app/share/applications" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/kvazar-network/kevacoin.git", + "commit": "4bc3dde6a0cd27b3f3d297f7b80b0547f387d61b" + } + ] + } + ] +} \ No newline at end of file diff --git a/libdb.patch b/libdb.patch new file mode 100644 index 000000000..e244aea1a --- /dev/null +++ b/libdb.patch @@ -0,0 +1,143 @@ +# Apply a patch necessary when building with clang and c++11 (see https://community.oracle.com/thread/3952592) +# source: https://gist.githubusercontent.com/LnL7/5153b251fd525fe15de69b67e63a6075/raw/7778e9364679093a32dec2908656738e16b6bdcb/clang.patch +diff --git a/dbinc/atomic.h b/dbinc/atomic.h +index 6a858f7..9f338dc 100644 +--- a/dbinc/atomic.h ++++ b/dbinc/atomic.h +@@ -70,7 +70,7 @@ typedef struct { + * These have no memory barriers; the caller must include them when necessary. + */ + #define atomic_read(p) ((p)->value) +-#define atomic_init(p, val) ((p)->value = (val)) ++#define atomic_init_db(p, val) ((p)->value = (val)) + + #ifdef HAVE_ATOMIC_SUPPORT + +@@ -144,7 +144,7 @@ typedef LONG volatile *interlocked_val; + #define atomic_inc(env, p) __atomic_inc(p) + #define atomic_dec(env, p) __atomic_dec(p) + #define atomic_compare_exchange(env, p, o, n) \ +- __atomic_compare_exchange((p), (o), (n)) ++ __atomic_compare_exchange_db((p), (o), (n)) + static inline int __atomic_inc(db_atomic_t *p) + { + int temp; +@@ -176,7 +176,7 @@ static inline int __atomic_dec(db_atomic_t *p) + * http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html + * which configure could be changed to use. + */ +-static inline int __atomic_compare_exchange( ++static inline int __atomic_compare_exchange_db( + db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval) + { + atomic_value_t was; +@@ -206,7 +206,7 @@ static inline int __atomic_compare_exchange( + #define atomic_dec(env, p) (--(p)->value) + #define atomic_compare_exchange(env, p, oldval, newval) \ + (DB_ASSERT(env, atomic_read(p) == (oldval)), \ +- atomic_init(p, (newval)), 1) ++ atomic_init_db(p, (newval)), 1) + #else + #define atomic_inc(env, p) __atomic_inc(env, p) + #define atomic_dec(env, p) __atomic_dec(env, p) +diff --git a/mp/mp_fget.c b/mp/mp_fget.c +index 16de695..d0dcc29 100644 +--- a/mp/mp_fget.c ++++ b/mp/mp_fget.c +@@ -649,7 +649,7 @@ alloc: /* Allocate a new buffer header and data space. */ + + /* Initialize enough so we can call __memp_bhfree. */ + alloc_bhp->flags = 0; +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + #ifdef DIAGNOSTIC + if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) { + __db_errx(env, DB_STR("3025", +@@ -955,7 +955,7 @@ alloc: /* Allocate a new buffer header and data space. */ + MVCC_MPROTECT(bhp->buf, mfp->pagesize, + PROT_READ); + +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + MUTEX_LOCK(env, alloc_bhp->mtx_buf); + alloc_bhp->priority = bhp->priority; + alloc_bhp->pgno = bhp->pgno; +diff --git a/mp/mp_mvcc.c b/mp/mp_mvcc.c +index 770bad8..e28cce0 100644 +--- a/mp/mp_mvcc.c ++++ b/mp/mp_mvcc.c +@@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp) + #else + memcpy(frozen_bhp, bhp, SSZA(BH, buf)); + #endif +- atomic_init(&frozen_bhp->ref, 0); ++ atomic_init_db(&frozen_bhp->ref, 0); + if (mutex != MUTEX_INVALID) + frozen_bhp->mtx_buf = mutex; + else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH, +@@ -428,7 +428,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_bhp, alloc_bhp) + #endif + alloc_bhp->mtx_buf = mutex; + MUTEX_LOCK(env, alloc_bhp->mtx_buf); +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + F_CLR(alloc_bhp, BH_FROZEN); + } + +diff --git a/mp/mp_region.c b/mp/mp_region.c +index 4952030..47645f8 100644 +--- a/mp/mp_region.c ++++ b/mp/mp_region.c +@@ -245,7 +245,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg) + MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0) + return (ret); + SH_TAILQ_INIT(&htab[i].hash_bucket); +- atomic_init(&htab[i].hash_page_dirty, 0); ++ atomic_init_db(&htab[i].hash_page_dirty, 0); + } + + /* +@@ -302,7 +302,7 @@ no_prealloc: + } else + hp->mtx_hash = mtx_base + (i % dbenv->mp_mtxcount); + SH_TAILQ_INIT(&hp->hash_bucket); +- atomic_init(&hp->hash_page_dirty, 0); ++ atomic_init_db(&hp->hash_page_dirty, 0); + #ifdef HAVE_STATISTICS + hp->hash_io_wait = 0; + hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0; +diff --git a/mutex/mut_method.c b/mutex/mut_method.c +index 09353b0..177353c 100644 +--- a/mutex/mut_method.c ++++ b/mutex/mut_method.c +@@ -474,7 +474,7 @@ atomic_compare_exchange(env, v, oldval, newval) + MUTEX_LOCK(env, mtx); + ret = atomic_read(v) == oldval; + if (ret) +- atomic_init(v, newval); ++ atomic_init_db(v, newval); + MUTEX_UNLOCK(env, mtx); + + return (ret); +diff --git a/mutex/mut_tas.c b/mutex/mut_tas.c +index 106b161..fc4de9d 100644 +--- a/mutex/mut_tas.c ++++ b/mutex/mut_tas.c +@@ -47,7 +47,7 @@ __db_tas_mutex_init(env, mutex, flags) + + #ifdef HAVE_SHARED_LATCHES + if (F_ISSET(mutexp, DB_MUTEX_SHARED)) +- atomic_init(&mutexp->sharecount, 0); ++ atomic_init_db(&mutexp->sharecount, 0); + else + #endif + if (MUTEX_INIT(&mutexp->tas)) { +@@ -536,7 +536,7 @@ __db_tas_mutex_unlock(env, mutex) + F_CLR(mutexp, DB_MUTEX_LOCKED); + /* Flush flag update before zeroing count */ + MEMBAR_EXIT(); +- atomic_init(&mutexp->sharecount, 0); ++ atomic_init_db(&mutexp->sharecount, 0); + } else { + DB_ASSERT(env, sharecount > 0); + MEMBAR_EXIT(); \ No newline at end of file