[#223] Debian packaging
Debian package includes: - user creation; - directories and permissions; - unit file for systemd Signed-off-by: Dmitriy Zabolotskiy <d.zabolotskiy@yadro.com>
This commit is contained in:
parent
f4fbd936bc
commit
f88fe1092d
17 changed files with 318 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -16,3 +16,6 @@ testfile
|
||||||
|
|
||||||
coverage.txt
|
coverage.txt
|
||||||
coverage.html
|
coverage.html
|
||||||
|
|
||||||
|
# debhelpers
|
||||||
|
**/.debhelper
|
||||||
|
|
19
Makefile
19
Makefile
|
@ -16,6 +16,13 @@ BINS = $(BINDIR)/neofs-http-gw
|
||||||
|
|
||||||
.PHONY: all $(BINS) $(DIRS) dep docker/ test cover fmt image image-push dirty-image lint docker/lint version clean
|
.PHONY: all $(BINS) $(DIRS) dep docker/ test cover fmt image image-push dirty-image lint docker/lint version clean
|
||||||
|
|
||||||
|
# .deb package versioning
|
||||||
|
OS_RELEASE = $(shell lsb_release -cs)
|
||||||
|
PKG_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: debpackage debclean
|
||||||
|
|
||||||
# Make all binaries
|
# Make all binaries
|
||||||
all: $(BINS)
|
all: $(BINS)
|
||||||
|
|
||||||
|
@ -111,4 +118,16 @@ clean:
|
||||||
rm -rf vendor
|
rm -rf vendor
|
||||||
rm -rf $(BINDIR)
|
rm -rf $(BINDIR)
|
||||||
|
|
||||||
|
# Package for Debian
|
||||||
|
debpackage:
|
||||||
|
dch --package neofs-http-gw \
|
||||||
|
--controlmaint \
|
||||||
|
--newversion $(PKG_VERSION) \
|
||||||
|
--distribution $(OS_RELEASE) \
|
||||||
|
"Please see CHANGELOG.md for code changes for $(VERSION)"
|
||||||
|
dpkg-buildpackage --no-sign -b
|
||||||
|
|
||||||
|
debclean:
|
||||||
|
dh clean
|
||||||
|
|
||||||
include help.mk
|
include help.mk
|
||||||
|
|
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
neofs-http-gw (0.0.0) stable; urgency=medium
|
||||||
|
|
||||||
|
* Please see CHANGELOG.md
|
||||||
|
|
||||||
|
-- NeoSPCC <tech@nspcc.ru> Wed, 24 Aug 2022 18:29:49 +0300
|
15
debian/control
vendored
Normal file
15
debian/control
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
Source: neofs-http-gw
|
||||||
|
Section: neofs
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: NeoSPCC <tech@nspcc.ru>
|
||||||
|
Build-Depends: debhelper-compat (= 13), dh-sysuser, git, devscripts
|
||||||
|
Standards-Version: 4.5.1
|
||||||
|
Homepage: https://fs.neo.org/
|
||||||
|
Vcs-Git: https://github.com/nspcc-dev/neofs-http-gw.git
|
||||||
|
Vcs-Browser: https://github.com/nspcc-dev/neofs-http-gw
|
||||||
|
|
||||||
|
Package: neofs-http-gw
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${misc:Depends}
|
||||||
|
Description: NeoFS HTTP Gateway bridges NeoFS internal protocol and HTTP standard.
|
||||||
|
|
23
debian/copyright
vendored
Normal file
23
debian/copyright
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: neofs-http-gw
|
||||||
|
Upstream-Contact: tech@nspcc.ru
|
||||||
|
Source: https://github.com/nspcc-dev/neofs-http-gw
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2018-2022 NeoSPCC (@nspcc-dev), contributors of neofs-http-gw project
|
||||||
|
(https://github.com/nspcc-dev/neofs-http-gw/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 or at /usr/share/common-licenses/GPL-3.
|
||||||
|
If not, see <http://www.gnu.org/licenses/>.
|
2
debian/neofs-http-gw.dirs
vendored
Normal file
2
debian/neofs-http-gw.dirs
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
etc/neofs
|
||||||
|
srv/neofs_cache
|
4
debian/neofs-http-gw.docs
vendored
Normal file
4
debian/neofs-http-gw.docs
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
docs/gate-configuration.md
|
||||||
|
README.md
|
||||||
|
CREDITS.md
|
||||||
|
CONTRIBUTING.md
|
1
debian/neofs-http-gw.examples
vendored
Normal file
1
debian/neofs-http-gw.examples
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config/*
|
2
debian/neofs-http-gw.install
vendored
Normal file
2
debian/neofs-http-gw.install
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bin/neofs-http-gw usr/bin
|
||||||
|
config/config.yaml etc/neofs/http
|
51
debian/neofs-http-gw.postinst
vendored
Normal file
51
debian/neofs-http-gw.postinst
vendored
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# postinst script for neofs-http-gw
|
||||||
|
#
|
||||||
|
# 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=http
|
||||||
|
id -u neofs-$USERNAME >/dev/null 2>&1 || useradd -s /usr/sbin/nologin -d /srv/neofs_cache --system -M -U -c "NeoFS HTTP gateway" neofs-$USERNAME
|
||||||
|
if ! dpkg-statoverride --list /etc/neofs/$USERNAME >/dev/null; then
|
||||||
|
chown -f root:neofs-$USERNAME /etc/neofs/$USERNAME
|
||||||
|
chown -f root:neofs-$USERNAME /etc/neofs/$USERNAME/config.yaml || true
|
||||||
|
chmod -f 0750 /etc/neofs/$USERNAME
|
||||||
|
chmod -f 0640 /etc/neofs/$USERNAME/config.yaml || true
|
||||||
|
fi
|
||||||
|
USERDIR=$(getent passwd "neofs-$USERNAME" | cut -d: -f6)
|
||||||
|
if ! dpkg-statoverride --list neofs-$USERDIR >/dev/null; then
|
||||||
|
chown -f 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
|
41
debian/neofs-http-gw.postrm
vendored
Normal file
41
debian/neofs-http-gw.postrm
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# postrm script for neofs-http-gw
|
||||||
|
#
|
||||||
|
# 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_cache
|
||||||
|
;;
|
||||||
|
|
||||||
|
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
|
35
debian/neofs-http-gw.preinst
vendored
Normal file
35
debian/neofs-http-gw.preinst
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# preinst script for neofs-http-gw
|
||||||
|
#
|
||||||
|
# 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
|
38
debian/neofs-http-gw.prerm
vendored
Normal file
38
debian/neofs-http-gw.prerm
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# prerm script for neofs-http-gw
|
||||||
|
#
|
||||||
|
# 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
|
16
debian/neofs-http-gw.service
vendored
Normal file
16
debian/neofs-http-gw.service
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[Unit]
|
||||||
|
Description=NeoFS HTTP Gateway
|
||||||
|
Requires=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/neofs-http-gw --config /etc/neofs/http/config.yaml
|
||||||
|
User=neofs-http
|
||||||
|
Group=neofs-http
|
||||||
|
WorkingDirectory=/srv/neofs_cache
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
PrivateTmp=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
16
debian/rules
vendored
Executable file
16
debian/rules
vendored
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
# Do not try to strip Go binaries and do not run test
|
||||||
|
export DEB_BUILD_OPTIONS := nostrip nocheck
|
||||||
|
SERVICE = neofs-http-gw
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
override_dh_installsystemd:
|
||||||
|
dh_installsystemd --no-enable --no-start $(SERVICE).service
|
||||||
|
|
||||||
|
override_dh_installchangelogs:
|
||||||
|
dh_installchangelogs -k CHANGELOG.md
|
||||||
|
|
||||||
|
|
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
3.0 (quilt)
|
46
docs/building-deb-package.md
Normal file
46
docs/building-deb-package.md
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# Building Debian package on host
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
For now, we're assuming building for Debian 11 (stable) x86_64.
|
||||||
|
|
||||||
|
Go version 18.4 or later should already be installed, i.e. this runs
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
# 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 `PKG_VERSION` variable before
|
||||||
|
build, Debian package versioning rules should be respected.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ PKG_VERSION=0.32.0 make debpackge
|
||||||
|
```
|
Loading…
Reference in a new issue