[#409] Debian packaging

Debian package building, including:

 - users creation if not exist;
 - dirs creation and ownership/ACLs set;
 - man/doc/examples installation;
 - shell completion generation;
 - locode DB binary download

Using:
	make debpackage

Signed-off-by: Dmitriy Zabolotskiy <d.zabolotskiy@yadro.com>
This commit is contained in:
Dmitriy Zabolotskiy 2022-09-19 21:10:14 +03:00 committed by Stanislav Bogatyrev
parent 846ff515e6
commit 92e9782c44
31 changed files with 568 additions and 1 deletions

3
.gitignore vendored
View file

@ -28,3 +28,6 @@ testfile
# misc
.neofs-cli.yml
# debhelpers
**/.debhelper

View file

@ -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

View file

@ -0,0 +1,6 @@
---
endpoint: 'localhost:8090'
wallet: '/etc/neofs/ir/wallet.json'
password: ''
#ir: true

View file

@ -0,0 +1,5 @@
---
endpoint: 'localhost:8091'
wallet: '/etc/neofs/storage/wallet.json'
password: ''

2
debian/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
changelog
*debhelper*

2
debian/clean vendored Normal file
View file

@ -0,0 +1,2 @@
man/
debian/*.bash-completion

37
debian/control vendored Normal file
View file

@ -0,0 +1,37 @@
Source: neofs-node
Section: misc
Priority: optional
Maintainer: NeoSPCC <tech@nspcc.ru>
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.

21
debian/copyright vendored Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.

4
debian/neofs-node-cli.docs vendored Normal file
View file

@ -0,0 +1,4 @@
CONTRIBUTING.md
CREDITS.md
README.md
cmd/neofs-adm/docs

3
debian/neofs-node-cli.install vendored Normal file
View file

@ -0,0 +1,3 @@
bin/neofs-adm usr/bin
bin/neofs-cli usr/bin
bin/neofs-lens usr/bin

1
debian/neofs-node-cli.manpages vendored Normal file
View file

@ -0,0 +1 @@
man/*

2
debian/neofs-node-ir.dirs vendored Normal file
View file

@ -0,0 +1,2 @@
/etc/neofs/ir
/var/lib/neofs/ir

3
debian/neofs-node-ir.docs vendored Normal file
View file

@ -0,0 +1,3 @@
CONTRIBUTING.md
CREDITS.md
README.md

1
debian/neofs-node-ir.install vendored Normal file
View file

@ -0,0 +1 @@
bin/neofs-ir usr/bin

16
debian/neofs-node-ir.neofs-ir.service vendored Normal file
View file

@ -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

48
debian/neofs-node-ir.postinst vendored Normal file
View file

@ -0,0 +1,48 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# 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

40
debian/neofs-node-ir.postrm vendored Normal file
View file

@ -0,0 +1,40 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# 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

34
debian/neofs-node-ir.preinst vendored Normal file
View file

@ -0,0 +1,34 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# 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

37
debian/neofs-node-ir.prerm vendored Normal file
View file

@ -0,0 +1,37 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# 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

2
debian/neofs-node-storage.dirs vendored Normal file
View file

@ -0,0 +1,2 @@
/etc/neofs/storage
/srv/neofs

4
debian/neofs-node-storage.docs vendored Normal file
View file

@ -0,0 +1,4 @@
docs/storage-node-configuration.md
CONTRIBUTING.md
CREDITS.md
README.md

1
debian/neofs-node-storage.install vendored Normal file
View file

@ -0,0 +1 @@
bin/neofs-node usr/bin

View file

@ -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

48
debian/neofs-node-storage.postinst vendored Normal file
View file

@ -0,0 +1,48 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# 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

40
debian/neofs-node-storage.postrm vendored Normal file
View file

@ -0,0 +1,40 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# 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

34
debian/neofs-node-storage.preinst vendored Normal file
View file

@ -0,0 +1,34 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# 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

37
debian/neofs-node-storage.prerm vendored Normal file
View file

@ -0,0 +1,37 @@
#!/bin/sh
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# 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

41
debian/rules vendored Executable file
View file

@ -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

1
debian/source/format vendored Normal file
View file

@ -0,0 +1 @@
3.0 (quilt)

View file

@ -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
```

BIN
locode_db.tar.gz Normal file

Binary file not shown.