diff --git a/.rpmmacros b/.rpmmacros new file mode 100644 index 000000000..1af8248c6 --- /dev/null +++ b/.rpmmacros @@ -0,0 +1 @@ +%_topdir %(echo $HOME)/rpmbuild diff --git a/Makefile b/Makefile index 9331f1a2f..1bc052b8b 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,11 @@ export LD_LIBRARY_PATH:=$(TOP)/bls/lib:$(TOP)/mcl/lib:/usr/local/opt/openssl/lib export LIBRARY_PATH:=$(LD_LIBRARY_PATH) export DYLD_FALLBACK_LIBRARY_PATH:=$(LD_LIBRARY_PATH) export GO111MODULE:=on +PKGNAME=harmony +VERSION=2.3.4 +RPMBUILD=$(HOME)/rpmbuild -.PHONY: all help libs exe race trace-pointer debug debug-kill test test-go test-api test-api-attach linux_static +.PHONY: all help libs exe race trace-pointer debug debug-kill test test-go test-api test-api-attach linux_static rpm all: libs bash ./scripts/go_executable_build.sh -S @@ -25,6 +28,8 @@ help: @echo "test-api - run the Node API test" @echo "test-api-attach - attach onto the Node API testing docker container for inspection" @echo "linux_static - static build the harmony binary & bootnode along with the MCL & BLS libs (for linux)" + @echo "arm_static - static build the harmony binary & bootnode on ARM64 platform" + @echo "rpm - build a harmony RPM pacakge" libs: make -C $(TOP)/mcl -j8 @@ -51,6 +56,7 @@ clean: rm -rf ./db-* rm -rf ./latest rm -f ./*.rlp + rm -rf ~/rpmbuild test: bash ./test/all.sh @@ -76,3 +82,25 @@ arm_static: make -C $(TOP)/bls minimised_static BLS_SWAP_G=1 -j8 bash ./scripts/go_executable_build.sh -a arm64 -s git checkout go.mod + +deb_package: rpm + fpm -s dir -t deb -n $(PKGNAME) -v $(VERSION)-$(COMMIT) --prefix /usr/local bin/harmony + fpm -s pleaserun -t deb -n $(PKGNAME)-service -v $(VERSION) /usr/local/bin/harmony + +rpm_init: + rm -rf $(RPMBUILD) + mkdir -p $(RPMBUILD)/{SOURCES,SPECS,BUILD,RPMS,BUILDROOT,SRPMS} + mkdir -p $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION) + cp -f bin/harmony $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION) + cp -f scripts/rpm/harmony.service $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION) + cp -f scripts/rpm/harmony-sysctl.conf $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION) + cp -f scripts/rpm/harmony.spec $(RPMBUILD)/SPECS + (cd $(RPMBUILD)/SOURCES; tar cvf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION)) + +rpm_build: + rpmbuild --target x86_64 -bb scripts/rpm/harmony.spec + +rpm: rpm_init rpm_build + +rpm_test: rpm + echo "sudo docker run -it -v $(RPMBUILD):/mnt/rpmbuild tqhh/rpmtest" diff --git a/scripts/rpm/harmony-sysctl.conf b/scripts/rpm/harmony-sysctl.conf new file mode 100644 index 000000000..be5571ae6 --- /dev/null +++ b/scripts/rpm/harmony-sysctl.conf @@ -0,0 +1,31 @@ +fs.file-max=2097152 +vm.swappiness=10 +vm.dirty_ratio=60 +vm.dirty_background_ratio=2 +kernel.sched_migration_cost_ns=5000000 +net.ipv4.tcp_synack_retries=2 +net.ipv4.ip_local_port_range=2000 65535 +net.ipv4.tcp_rfc1337=1 +net.ipv4.tcp_syncookies=1 +net.ipv4.tcp_fin_timeout=15 +net.ipv4.tcp_keepalive_time=300 +net.ipv4.tcp_keepalive_probes=5 +net.ipv4.tcp_keepalive_intvl=15 +net.core.rmem_default=31457280 +net.core.rmem_max=33554432 +net.core.wmem_default=31457280 +net.core.wmem_max=33554432 +net.core.somaxconn=8096 +net.core.netdev_max_backlog=65536 +net.core.optmem_max=25165824 +net.ipv4.tcp_max_syn_backlog=8192 +net.ipv4.tcp_mem=786432 1048576 26777216 +net.ipv4.udp_mem=65536 131072 262144 +net.ipv4.tcp_rmem=8192 87380 33554432 +net.ipv4.udp_rmem_min=16384 +net.ipv4.tcp_wmem=8192 65536 33554432 +net.ipv4.udp_wmem_min=16384 +net.ipv4.tcp_max_tw_buckets=1440000 +net.ipv4.tcp_tw_reuse=1 +net.ipv4.tcp_fastopen=3 +net.ipv4.tcp_window_scaling=1 diff --git a/scripts/rpm/harmony.service b/scripts/rpm/harmony.service new file mode 100644 index 000000000..7b5875eb7 --- /dev/null +++ b/scripts/rpm/harmony.service @@ -0,0 +1,19 @@ +[Unit] +Description=harmony validator node service +After=network.target + +[Service] +Type=simple +Restart=on-failure +RestartSec=1 +User=harmony +WorkingDirectory=/home/harmony +ExecStart=harmony +StandardError=syslog +SyslogIdentifier=harmony +StartLimitInterval=0 +LimitNOFILE=65536 +LimitNPROC=65536 + +[Install] +WantedBy=multi-user.target diff --git a/scripts/rpm/harmony.spec b/scripts/rpm/harmony.spec new file mode 100644 index 000000000..18591777e --- /dev/null +++ b/scripts/rpm/harmony.spec @@ -0,0 +1,79 @@ +# SPEC file overview: +# https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages/#con_rpm-spec-file-overview +# Fedora packaging guidelines: +# https://docs.fedoraproject.org/en-US/packaging-guidelines/ + + +Name: harmony +Version: 2.3.4 +Release: 0%{?dist} +Summary: harmony blockchain validator node program + +License: MIT +URL: https://harmony.one +Source0: %{name}-%{version}.tar +BuildArch: x86_64 +Packager: Leo Chen +Requires(pre): shadow-utils +Requires: bash +Requires: systemd-rpm-macros + +BuildRequires: info +Requires: info +BuildRoot: ~/rpmbuild/ + +%description +Harmony is a sharded, fast finality, low fee, PoS public blockchain. +This is the validator node program for harmony blockchain. + +%global debug_package %{nil} + +%prep +%setup -q + +%build +echo make %{?_smp_mflags} +exit 0 + + +%check +./harmony --version +exit + +%pre +getent group harmony >/dev/null || groupadd -r harmony +getent passwd harmony >/dev/null || \ + useradd -r -g harmony -d /home/harmony -m -s /sbin/nologin \ + -c "Harmony validator node account" harmony +exit 0 + + +%install +install -m 0755 -d ${RPM_BUILD_ROOT}/usr/local/sbin ${RPM_BUILD_ROOT}/etc/systemd/system ${RPM_BUILD_ROOT}/etc/sysctl.d +install -m 0755 harmony ${RPM_BUILD_ROOT}/usr/local/sbin/ +install -m 0644 harmony.service ${RPM_BUILD_ROOT}/etc/systemd/system/ +install -m 0644 harmony-sysctl.conf ${RPM_BUILD_ROOT}/etc/sysctl.d/ +exit 0 + +%post +%systemd_post %{name}.service + +%preun +%systemd_preun %{name}.service + +%postun +%systemd_postun_with_restart ${name}.service + +%files +/usr/local/sbin/harmony +/etc/sysctl.d/harmony-sysctl.conf +/etc/systemd/system/harmony.service + +%doc +%license + + + +%changelog +* Tue Aug 18 2020 Leo Chen 2.3.4 + - init version of the harmony node program