diff --git a/.gitignore b/.gitignore index 91222638..232cc006 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ testfile # misc .neofs-cli.yml + +# debhelpers +**/.debhelper diff --git a/Makefile b/Makefile index a6fe4555..b6b63fd2 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,14 @@ DIRS = $(BIN) $(RELEASE) CMDS = $(notdir $(basename $(wildcard cmd/*))) BINS = $(addprefix $(BIN)/, $(CMDS)) -.PHONY: help all images dep clean fmts fmt imports test lint docker/lint prepare-release +# .deb package versioning +OS_RELEASE = $(shell lsb_release -cs) +PACK_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \ + sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \ + sed "s/-/~/")-$(OS_RELEASE) + +.PHONY: help all images dep clean fmts fmt imports test lint docker/lint + prepare-release debpackage # To build a specific binary, use it's name prefix with bin/ as a target # For example `make bin/neofs-node` will build only storage node binary @@ -142,3 +149,22 @@ clean: rm -rf .cache rm -rf $(BIN) rm -rf $(RELEASE) + +# Package for Debian +debpackage: + rm -f debian/changelog + dch --create --package neofs-node -M -v $(PACK_VERSION) \ + -D $(OS_RELEASE) \ + "Please see CHANGELOG.md for code changes for "$(VERSION) + dpkg-buildpackage --no-sign -b + +docker/debpackage: + docker run --rm -t \ + -v `pwd`:/src \ + -w /src \ + -u "$$(id -u):$$(id -g)" \ + --env HOME=/src \ + golang:$(GO_VERSION) apt update && apt install debhelper-compat dh-sequence-bash-completion devscripts && make debpackage + +debclean: + dh clean diff --git a/config/example/ir-control.yaml b/config/example/ir-control.yaml new file mode 100644 index 00000000..4de957e8 --- /dev/null +++ b/config/example/ir-control.yaml @@ -0,0 +1,6 @@ +--- + +endpoint: 'localhost:8090' +wallet: '/etc/neofs/ir/wallet.json' +password: '' +#ir: true diff --git a/config/example/node-control.yaml b/config/example/node-control.yaml new file mode 100644 index 00000000..5e82b7d2 --- /dev/null +++ b/config/example/node-control.yaml @@ -0,0 +1,5 @@ +--- + +endpoint: 'localhost:8091' +wallet: '/etc/neofs/storage/wallet.json' +password: '' diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 00000000..9890f7dc --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,2 @@ +changelog +*debhelper* diff --git a/debian/clean b/debian/clean new file mode 100644 index 00000000..f3824914 --- /dev/null +++ b/debian/clean @@ -0,0 +1,2 @@ +man/ +debian/*.bash-completion diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..b0cff223 --- /dev/null +++ b/debian/control @@ -0,0 +1,37 @@ +Source: neofs-node +Section: misc +Priority: optional +Maintainer: NeoSPCC +Build-Depends: debhelper-compat (= 13), dh-sequence-bash-completion, devscripts +Standards-Version: 4.5.1 +Homepage: https://fs.neo.org/ +Vcs-Git: https://github.com/nspcc-dev/neofs-node.git +Vcs-Browser: https://github.com/nspcc-dev/neofs-node + +Package: neofs-node-storage +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Storage service for neofs-node + NeoFS is a decentralized distributed object storage integrated with the NEO Blockchain. + NeoFS Nodes are organized in a peer-to-peer network that takes care of storing and distributing user's data. + Any Neo user may participate in the network and get paid for providing storage resources to other users or + store their data in NeoFS and pay a competitive price for it. + +Package: neofs-node-ir +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: InnerRing service for neofs-node + NeoFS is a decentralized distributed object storage integrated with the NEO Blockchain. + NeoFS Nodes are organized in a peer-to-peer network that takes care of storing and distributing user's data. + Any Neo user may participate in the network and get paid for providing storage resources to other users or + store their data in NeoFS and pay a competitive price for it. + +Package: neofs-node-cli +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: cli tools for neofs-node + NeoFS is a decentralized distributed object storage integrated with the NEO Blockchain. + NeoFS Nodes are organized in a peer-to-peer network that takes care of storing and distributing user's data. + Any Neo user may participate in the network and get paid for providing storage resources to other users or + store their data in NeoFS and pay a competitive price for it. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..d2c4dc5b --- /dev/null +++ b/debian/copyright @@ -0,0 +1,21 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: neofs-node +Upstream-Contact: tech@nspcc.ru +Source: https://github.com/nspcc-dev/neofs-node + +Files: * +Copyright: 2018-2022 NeoSPCC (@nspcc-dev), contributors of neofs-node project + (https://github.com/nspcc-dev/neofs-node/blob/master/CREDITS.md) + +License: GPL-3 + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; version 3. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . diff --git a/debian/neofs-node-cli.docs b/debian/neofs-node-cli.docs new file mode 100644 index 00000000..1bb1b2dc --- /dev/null +++ b/debian/neofs-node-cli.docs @@ -0,0 +1,4 @@ +CONTRIBUTING.md +CREDITS.md +README.md +cmd/neofs-adm/docs diff --git a/debian/neofs-node-cli.install b/debian/neofs-node-cli.install new file mode 100644 index 00000000..b8dfc7be --- /dev/null +++ b/debian/neofs-node-cli.install @@ -0,0 +1,3 @@ +bin/neofs-adm usr/bin +bin/neofs-cli usr/bin +bin/neofs-lens usr/bin diff --git a/debian/neofs-node-cli.manpages b/debian/neofs-node-cli.manpages new file mode 100644 index 00000000..85c5e001 --- /dev/null +++ b/debian/neofs-node-cli.manpages @@ -0,0 +1 @@ +man/* diff --git a/debian/neofs-node-ir.dirs b/debian/neofs-node-ir.dirs new file mode 100644 index 00000000..41d146ff --- /dev/null +++ b/debian/neofs-node-ir.dirs @@ -0,0 +1,2 @@ +/etc/neofs/ir +/var/lib/neofs/ir diff --git a/debian/neofs-node-ir.docs b/debian/neofs-node-ir.docs new file mode 100644 index 00000000..38b0cef2 --- /dev/null +++ b/debian/neofs-node-ir.docs @@ -0,0 +1,3 @@ +CONTRIBUTING.md +CREDITS.md +README.md diff --git a/debian/neofs-node-ir.install b/debian/neofs-node-ir.install new file mode 100644 index 00000000..fc34c24f --- /dev/null +++ b/debian/neofs-node-ir.install @@ -0,0 +1 @@ +bin/neofs-ir usr/bin diff --git a/debian/neofs-node-ir.neofs-ir.service b/debian/neofs-node-ir.neofs-ir.service new file mode 100644 index 00000000..c7b0f1bd --- /dev/null +++ b/debian/neofs-node-ir.neofs-ir.service @@ -0,0 +1,16 @@ +[Unit] +Description=NeoFS InnerRing node +Requires=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/neofs-ir --config /etc/neofs/ir/config.yml +User=neofs-ir +Group=neofs-ir +WorkingDirectory=/var/lib/neofs/ir +Restart=always +RestartSec=5 +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/debian/neofs-node-ir.postinst b/debian/neofs-node-ir.postinst new file mode 100644 index 00000000..55418e2d --- /dev/null +++ b/debian/neofs-node-ir.postinst @@ -0,0 +1,48 @@ +#!/bin/sh +# +# 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) + USERNAME=ir + id -u neofs-ir >/dev/null 2>&1 || useradd -s /usr/sbin/nologin -d /var/lib/neofs/ir --system -M -U -c "NeoFS InnerRing node" neofs-ir + if ! dpkg-statoverride --list /etc/neofs/$USERNAME >/dev/null; then + chown -f -R root:neofs-$USERNAME /etc/neofs/$USERNAME + chmod -f 0750 /etc/neofs/$USERNAME + chmod -f u=rwX,g=rX,o= /etc/neofs/$USERNAME/* || true + fi + USERDIR=$(getent passwd "neofs-$USERNAME" | cut -d: -f6) + if ! dpkg-statoverride --list neofs-$USERDIR >/dev/null; then + chown -f -R neofs-$USERNAME: $USERDIR + fi + ;; + + 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/debian/neofs-node-ir.postrm b/debian/neofs-node-ir.postrm new file mode 100644 index 00000000..44236495 --- /dev/null +++ b/debian/neofs-node-ir.postrm @@ -0,0 +1,40 @@ +#!/bin/sh +# +# 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) + rm -rf /var/lib/neofs/ir/* + ;; + + 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/debian/neofs-node-ir.preinst b/debian/neofs-node-ir.preinst new file mode 100644 index 00000000..37f95253 --- /dev/null +++ b/debian/neofs-node-ir.preinst @@ -0,0 +1,34 @@ +#!/bin/sh +# +# 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/debian/neofs-node-ir.prerm b/debian/neofs-node-ir.prerm new file mode 100644 index 00000000..0da369d7 --- /dev/null +++ b/debian/neofs-node-ir.prerm @@ -0,0 +1,37 @@ +#!/bin/sh +# +# 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/debian/neofs-node-storage.dirs b/debian/neofs-node-storage.dirs new file mode 100644 index 00000000..8a686a98 --- /dev/null +++ b/debian/neofs-node-storage.dirs @@ -0,0 +1,2 @@ +/etc/neofs/storage +/srv/neofs diff --git a/debian/neofs-node-storage.docs b/debian/neofs-node-storage.docs new file mode 100644 index 00000000..cd1f5f23 --- /dev/null +++ b/debian/neofs-node-storage.docs @@ -0,0 +1,4 @@ +docs/storage-node-configuration.md +CONTRIBUTING.md +CREDITS.md +README.md diff --git a/debian/neofs-node-storage.install b/debian/neofs-node-storage.install new file mode 100644 index 00000000..92f1f0c8 --- /dev/null +++ b/debian/neofs-node-storage.install @@ -0,0 +1 @@ +bin/neofs-node usr/bin diff --git a/debian/neofs-node-storage.neofs-storage.service b/debian/neofs-node-storage.neofs-storage.service new file mode 100644 index 00000000..882dc297 --- /dev/null +++ b/debian/neofs-node-storage.neofs-storage.service @@ -0,0 +1,16 @@ +[Unit] +Description=NeoFS Storage node +Requires=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/neofs-node --config /etc/neofs/storage/config.yml +User=neofs-storage +Group=neofs-storage +WorkingDirectory=/srv/neofs +Restart=always +RestartSec=5 +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/debian/neofs-node-storage.postinst b/debian/neofs-node-storage.postinst new file mode 100644 index 00000000..f1bf80ba --- /dev/null +++ b/debian/neofs-node-storage.postinst @@ -0,0 +1,48 @@ +#!/bin/sh +# +# 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) + USERNAME=storage + id -u neofs-storage >/dev/null 2>&1 || useradd -s /usr/sbin/nologin -d /srv/neofs --system -M -U -c "NeoFS Storage node" neofs-storage + if ! dpkg-statoverride --list /etc/neofs/$USERNAME >/dev/null; then + chown -f -R root:neofs-$USERNAME /etc/neofs/$USERNAME + chmod -f 0750 /etc/neofs/$USERNAME + chmod -f u=rwX,g=rX,o= /etc/neofs/$USERNAME/* || true + fi + USERDIR=$(getent passwd "neofs-$USERNAME" | cut -d: -f6) + if ! dpkg-statoverride --list neofs-$USERDIR >/dev/null; then + chown -f -R neofs-$USERNAME: $USERDIR + fi + ;; + + 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/debian/neofs-node-storage.postrm b/debian/neofs-node-storage.postrm new file mode 100644 index 00000000..244ca748 --- /dev/null +++ b/debian/neofs-node-storage.postrm @@ -0,0 +1,40 @@ +#!/bin/sh +# +# 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) + rm -rf /srv/neofs/* + ;; + + 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/debian/neofs-node-storage.preinst b/debian/neofs-node-storage.preinst new file mode 100644 index 00000000..37f95253 --- /dev/null +++ b/debian/neofs-node-storage.preinst @@ -0,0 +1,34 @@ +#!/bin/sh +# +# 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/debian/neofs-node-storage.prerm b/debian/neofs-node-storage.prerm new file mode 100644 index 00000000..0da369d7 --- /dev/null +++ b/debian/neofs-node-storage.prerm @@ -0,0 +1,37 @@ +#!/bin/sh +# +# 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/debian/rules b/debian/rules new file mode 100755 index 00000000..cd98895e --- /dev/null +++ b/debian/rules @@ -0,0 +1,41 @@ +#!/usr/bin/make -f + +# Do not try to strip Go binaries +export DEB_BUILD_OPTIONS := nostrip + +%: + dh $@ --with bash-completion + +override_dh_auto_test: + +override_dh_auto_install: + echo $(DEB_BUILD_OPTIONS) + dh_auto_install + + bin/neofs-adm gendoc -t man man/ + bin/neofs-cli gendoc -t man man/ + + bin/neofs-adm completion bash > debian/neofs-adm.bash-completion + bin/neofs-cli completion bash > debian/neofs-cli.bash-completion + install -m 0755 -d debian/neofs-node-cli/usr/share/fish/completions + install -m 0755 -d debian/neofs-node-cli/usr/share/zsh/vendor-completions/ + bin/neofs-adm completion fish > debian/neofs-node-cli/usr/share/fish/completions/neofs-adm.fish + bin/neofs-adm completion zsh > debian/neofs-node-cli/usr/share/zsh/vendor-completions/_neofs-adm + bin/neofs-cli completion fish > debian/neofs-node-cli/usr/share/fish/completions/neofs-cli.fish + bin/neofs-cli completion zsh > debian/neofs-node-cli/usr/share/zsh/vendor-completions/_neofs-cli + + install -T config/example/ir.yaml debian/neofs-node-ir/etc/neofs/ir/config.yml + install -T config/example/ir-control.yaml debian/neofs-node-ir/etc/neofs/ir/control.yml + install -T config/example/node.yaml debian/neofs-node-storage/etc/neofs/storage/config.yml + install -T config/example/node-control.yaml debian/neofs-node-storage/etc/neofs/storage/control.yml + +override_dh_installsystemd: + dh_installsystemd --no-enable --no-start --name=neofs-ir + dh_installsystemd --no-enable --no-start --name=neofs-storage + +override_dh_installchangelogs: + dh_installchangelogs -k CHANGELOG.md + +override_dh_installdocs: + dh_installdocs + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/docs/building-deb-package.md b/docs/building-deb-package.md new file mode 100644 index 00000000..7e0a006c --- /dev/null +++ b/docs/building-deb-package.md @@ -0,0 +1,52 @@ +# Building Debian package on host + +## Prerequisites + +For now, we're assuming building for Debian 11 (stable) x86_64 on Debian 11 x86_64. + +Go version 18.4 or later should be installed from official Go repos binaries should be buildable, i.e. this should run successfully: + +* `make all` + +## Installing packaging dependencies + +```shell +$ sudo apt install debhelper-compat dh-sequence-bash-completion devscripts +``` + +Warining: number of package installed is pretty large considering dependecies. + +## Package building + +```shell +$ make debpackage +``` + +## Leftovers cleaning + +```shell +$ make debclean +``` +or +```shell +$ dh clean +``` + +# Building in container + +Build dependencies will be added to Go container and package will be built. + +```shell +$ sudo make docker/debpackage +``` + +# Package versioning + +By default, package version is based on product version and may also contain +git tags and hashes. +Package version could be overwritten by setting PACK_VERSION variable before +build, Debian package versioining rules should be respected. + +```shell +$ PACK_VERSION=0.32 make debpackge +``` diff --git a/locode_db.tar.gz b/locode_db.tar.gz new file mode 100644 index 00000000..0702b3db Binary files /dev/null and b/locode_db.tar.gz differ