From 749f2ee743f2892059bed85529095e2cb8f8f088 Mon Sep 17 00:00:00 2001 From: jahway603 Date: Sun, 24 Oct 2021 01:39:15 -0400 Subject: [PATCH] new lightwalletd deb build script --- Makefile | 11 ++- cmd/server/main.go | 2 +- contrib/debian/changelog | 5 + contrib/debian/control | 13 +++ contrib/debian/copyright | 6 ++ contrib/debian/examples/HUSH3.conf | 141 +++++++++++++++++++++++++++++ contrib/debian/files | 1 + contrib/debian/postinst | 39 ++++++++ contrib/debian/postrm | 37 ++++++++ contrib/debian/preinst | 35 +++++++ contrib/debian/prerm | 38 ++++++++ util/build-debian-package.sh | 98 ++++++++++++++++++++ 12 files changed, 424 insertions(+), 2 deletions(-) create mode 100644 contrib/debian/changelog create mode 100644 contrib/debian/control create mode 100644 contrib/debian/copyright create mode 100644 contrib/debian/examples/HUSH3.conf create mode 100644 contrib/debian/files create mode 100644 contrib/debian/postinst create mode 100644 contrib/debian/postrm create mode 100644 contrib/debian/preinst create mode 100644 contrib/debian/prerm create mode 100755 util/build-debian-package.sh diff --git a/Makefile b/Makefile index 6e396ff..5dec468 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,15 @@ build: # Build binary ./util/build.sh +# Stop the hushd process in the hushdlwd container +#docker_img_stop_hushd: +# docker exec -i hushdlwd hush-cli stop + +# Remove and delete ALL images and containers in Docker; assumes containers are stopped +#docker_remove_all: +# docker system prune -f + clean: - @echo "clean project..." + @echo "Cleaning project $(PROJECT_NAME) files..." rm -f $(PROJECT_NAME) + rm -rf /tmp/$(PROJECT_NAME)-* diff --git a/cmd/server/main.go b/cmd/server/main.go index fb4be3a..209c267 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -91,7 +91,7 @@ func main() { var version = "0.1.1" // set version number opts := &Options{} - flag.StringVar(&opts.bindAddr, "bind-addr", "127.0.0.1:9069", "the address to listen on") + flag.StringVar(&opts.bindAddr, "bind-addr", "127.0.0.1:9067", "the address to listen on") flag.StringVar(&opts.tlsCertPath, "tls-cert", "", "the path to a TLS certificate (optional)") flag.StringVar(&opts.tlsKeyPath, "tls-key", "", "the path to a TLS key file (optional)") flag.BoolVar(&opts.noTLS, "no-tls", false, "Disable TLS, serve un-encrypted traffic.") diff --git a/contrib/debian/changelog b/contrib/debian/changelog new file mode 100644 index 0000000..e74afbe --- /dev/null +++ b/contrib/debian/changelog @@ -0,0 +1,5 @@ +lightwalletd (0.1.1) stable; urgency=medium + + * 0.1.1 release. + + -- Hush Core Sunday, 24 Oct 2021 13:40:30 -0700 diff --git a/contrib/debian/control b/contrib/debian/control new file mode 100644 index 0000000..1ba4da8 --- /dev/null +++ b/contrib/debian/control @@ -0,0 +1,13 @@ +Source: lightwalletd +Section: utils +Priority: optional +Maintainer: Jahway603 +Homepage: https://hush.is +Build-Depends: go +Vcs-Git: https://git.hush.is/hush/lightwalletd.git +Vcs-Browser: https://git.hush.is/hush/lightwalletd + +Package: lightwalletd +Architecture: amd64 +Depends: ${shlibs:Depends} +Description: Hush lightwallet daemon to run a Silent Dragon Lite server. Speak And Transact Freely. Hush inherits from Bitcoin Protocol and Zcash Protocol and is focused on private communications. diff --git a/contrib/debian/copyright b/contrib/debian/copyright new file mode 100644 index 0000000..dd64ecf --- /dev/null +++ b/contrib/debian/copyright @@ -0,0 +1,6 @@ +Files: * +Copyright: 2019-2021, The Hush developers + 2018-2019, The Zcash developers +License: GPLv3 +Comment: https://hush.is/developers + diff --git a/contrib/debian/examples/HUSH3.conf b/contrib/debian/examples/HUSH3.conf new file mode 100644 index 0000000..5d6c0fe --- /dev/null +++ b/contrib/debian/examples/HUSH3.conf @@ -0,0 +1,141 @@ +## HUSH3.conf configuration file. Lines beginning with # are comments. + +# Network-related settings: + +# Run a regression test network +#regtest=0 + +# Connect via a SOCKS5 proxy +#proxy=127.0.0.1:9050 + +# Bind to given address and always listen on it. Use [host]:port notation for IPv6 +#bind= + +# Bind to given address and allowlist peers connecting to it. Use [host]:port notation for IPv6 +#allowbind= + +############################################################## +## Quick Primer on addnode vs connect ## +## Let's say for instance you use addnode=4.2.2.4 ## +## addnode will connect you to and tell you about the ## +## nodes connected to 4.2.2.4. In addition it will tell ## +## the other nodes connected to it that you exist so ## +## they can connect to you. ## +## connect will not do the above when you 'connect' to it. ## +## It will *only* connect you to 4.2.2.4 and no one else.## +## ## +## So if you're behind a firewall, or have other problems ## +## finding nodes, add some using 'addnode'. ## +## ## +## If you want to stay private, use 'connect' to only ## +## connect to "trusted" nodes. ## +## ## +## If you run multiple nodes on a LAN, there's no need for ## +## all of them to open lots of connections. Instead ## +## 'connect' them all to one node that is port forwarded ## +## and has lots of connections. ## +## Thanks goes to [Noodle] on Freenode. ## +############################################################## + +# Use as many addnode= settings as you like to connect to specific peers +#addnode=69.164.218.197 +#addnode=10.0.0.2:8233 + +# Alternatively use as many connect= settings as you like to connect ONLY to specific peers +#connect=69.164.218.197 +#connect=10.0.0.1:8233 + +# Listening mode, enabled by default except when 'connect' is being used +#listen=1 + +# Maximum number of inbound+outbound connections. +#maxconnections= + +# +# JSON-RPC options (for controlling a running hushd process) +# + +# server=1 tells node to accept JSON-RPC commands (set as default if not specified) +#server=1 + +# Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. +# This option can be specified multiple times (default: bind to all interfaces) +#rpcbind= + +# You must set rpcuser and rpcpassword to secure the JSON-RPC api +#rpcuser=Ulysses +#rpcpassword=YourSuperGreatPasswordNumber_DO_NOT_USE_THIS_OR_YOU_WILL_GET_ROBBED_385593 + +# How many seconds node will wait for a complete RPC HTTP request. +# after the HTTP connection is established. +#rpcclienttimeout=30 + +# By default, only RPC connections from localhost are allowed. +# Specify as many rpcallowip= settings as you like to allow connections from other hosts, +# either as a single IPv4/IPv6 or with a subnet specification. + +# NOTE: opening up the RPC port to hosts outside your local trusted network is NOT RECOMMENDED, +# because the rpcpassword is transmitted over the network unencrypted and also because anyone +# that can authenticate on the RPC port can steal your keys + take over the account running hushd + +#rpcallowip=10.1.1.34/255.255.255.0 +#rpcallowip=1.2.3.4/24 +#rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96 + +# Listen for RPC connections on this TCP port (default 18031): +#rpcport=18031 + +# You can use hushd to send commands to hushd +# running on another host using this option: +#rpcconnect=127.0.0.1 + +# Do not see these options listed in here, but it is in my production lightwalletd config file +#rpcworkqueue=256 +#rpcbind=127.0.0.1 + +# Transaction Fee + +# Send transactions as zero-fee transactions if possible (default: 0) +#sendfreetransactions=0 + +# Create transactions that have enough fees (or priority) so they are likely to # begin confirmation within n blocks (default: 1). +# This setting is overridden by the -paytxfee option. +#txconfirmtarget=n + +# Miscellaneous options + +# Enable attempt to mine HUSH +#gen=0 + +# Set the number of threads to be used for mining (-1 = all cores). +#genproclimit=1 + +# Specify a different Equihash solver (e.g. "tromp") to try to mine +# faster when gen=1. +#equihashsolver=default + +# Pre-generate this many public/private key pairs, so wallet backups will be valid for +# both prior transactions and several dozen future transactions. +#keypool=100 + +# Pay an optional transaction fee every time you send a tx. Transactions with fees +# are more likely than free transactions to be included in generated blocks, so may +# be validated sooner. This setting does not affect private transactions created with +# 'z_sendmany'. +#paytxfee=0.00 + +#Rewind the chain to specific block height. This is useful for creating snapshots at a given block height. +#rewind=777777 + +#Stop the chain a specific block height. This is useful for creating snapshots at a given block height. +#stopat=1000000 + +#Set an address to use as change address for all transactions. This value must be set to a 33 byte pubkey. All mined coins will also be sent to this address. +#pubkey=027dc7b5cfb5efca96674b45e9fda18df069d040b9fd9ff32c35df56005e330392 + +#Forfeit all user rewards to miners. Set this to explicitly not claim user rewards. +#exchange=1 + +#Donate all user rewards to a a specific address. This value must be set to a 33 byte pubkey. +#donation=027dc7b5cfb5efca96674b45e9fda18df069d040b9fd9ff32c35df56005e330392 + diff --git a/contrib/debian/files b/contrib/debian/files new file mode 100644 index 0000000..15b50e2 --- /dev/null +++ b/contrib/debian/files @@ -0,0 +1 @@ +lightwalletd_0.1.1_amd64.deb utils optional diff --git a/contrib/debian/postinst b/contrib/debian/postinst new file mode 100644 index 0000000..e841dc3 --- /dev/null +++ b/contrib/debian/postinst @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for lightwalletd +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/contrib/debian/postrm b/contrib/debian/postrm new file mode 100644 index 0000000..b65e402 --- /dev/null +++ b/contrib/debian/postrm @@ -0,0 +1,37 @@ +#!/bin/sh +# postrm script for lightwalletd +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/contrib/debian/preinst b/contrib/debian/preinst new file mode 100644 index 0000000..f066674 --- /dev/null +++ b/contrib/debian/preinst @@ -0,0 +1,35 @@ +#!/bin/sh +# preinst script for lightwalletd + +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/contrib/debian/prerm b/contrib/debian/prerm new file mode 100644 index 0000000..a2eb73a --- /dev/null +++ b/contrib/debian/prerm @@ -0,0 +1,38 @@ +#!/bin/sh +# prerm script for lightwalletd +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/util/build-debian-package.sh b/util/build-debian-package.sh new file mode 100755 index 0000000..a8d695a --- /dev/null +++ b/util/build-debian-package.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Copyright (c) 2021 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html + +## Usage: ./util/build-debian-package.sh + +echo "Let's see who read the README.md or not..." +echo "" + +# Check if lightwalletd is already built on system and exit if it is not +if ! [ -x "$(command -v ./lightwalletd)" ]; then + echo 'Error: lightwalletd is not compiled yet. Run "make build" and try again.' >&2 + echo "" + exit 1 +fi + +# Check if lintian is installed and exit if it is not +#if ! [ -x "$(command -v lintian)" ]; then +# echo 'Error: lintian is not installed yet. Consult your Linux version package manager...' >&2 +# echo "" +# exit 1 +#fi + +echo "Let There Be Hush Lightwalletd Debian Packages!" +echo "" +echo "((_,...,_))" +echo " |o o|" +echo " \ /" +echo " ^_^ cp97" +echo "" + +set -e +set -x + +BUILD_PATH="/tmp/lightwalletd-debian-$$" +PACKAGE_NAME="lightwalletd" +SRC_PATH=`pwd` +SRC_DEB=$SRC_PATH/contrib/debian +SRC_DOC=$SRC_PATH/doc +ARCH="amd64" + +umask 022 + +if [ ! -d $BUILD_PATH ]; then + mkdir $BUILD_PATH +fi + +PACKAGE_VERSION=0.1.1 +DEBVERSION=$(echo $PACKAGE_VERSION) +BUILD_DIR="$BUILD_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH" + +if [ -d $BUILD_DIR ]; then + rm -R $BUILD_DIR +fi + +DEB_BIN=$BUILD_DIR/usr/bin +DEB_CMP=$BUILD_DIR/usr/share/bash-completion/completions +DEB_DOC=$BUILD_DIR/usr/share/doc/$PACKAGE_NAME +DEB_MAN=$BUILD_DIR/usr/share/man/man1 +DEB_SHR=$BUILD_DIR/usr/share/hush +mkdir -p $BUILD_DIR/DEBIAN $DEB_CMP $DEB_BIN $DEB_DOC $DEB_MAN $DEB_SHR +chmod 0755 -R $BUILD_DIR/* + +# Package maintainer scripts (currently empty) +#cp $SRC_DEB/postinst $BUILD_DIR/DEBIAN +#cp $SRC_DEB/postrm $BUILD_DIR/DEBIAN +#cp $SRC_DEB/preinst $BUILD_DIR/DEBIAN +#cp $SRC_DEB/prerm $BUILD_DIR/DEBIAN + +# Copy binary +cp $SRC_PATH/lightwalletd $DEB_BIN/lightwalletd +strip $DEB_BIN/lightwalletd +cp $SRC_DEB/changelog $DEB_DOC +cp $SRC_DEB/copyright $DEB_DOC +cp -r $SRC_DEB/examples $DEB_DOC +# Copy manpage +cp $SRC_DOC/man/lightwalletd.1 $DEB_MAN/lightwalletd.1 + +# Gzip files +gzip --best -n $DEB_MAN/lightwalletd.1 + +cd $SRC_PATH/contrib + +# Create the control file +# had to comment line below to move forward in this build script... +#dpkg-shlibdeps $DEB_BIN/lightwalletd +dpkg-gencontrol -P$BUILD_DIR -v$DEBVERSION + +# Create the Debian package +fakeroot dpkg-deb --build $BUILD_DIR +cp $BUILD_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb $SRC_PATH +shasum -a 256 $SRC_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb +# Analyze with Lintian, reporting bugs and policy violations +# Arch does not have lintian, as it's a Debian package, so commenting this out +# To-DO - test on Debian/Ubuntu, create AUR lintian package +#lintian -i $SRC_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb +exit 0