Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Debian packaging #223

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ testfile

coverage.txt
coverage.html

# debhelpers
**/.debhelper
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

# .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
all: $(BINS)

Expand Down Expand Up @@ -111,4 +118,16 @@ clean:
rm -rf vendor
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
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
neofs-http-gw (0.0.0) stable; urgency=medium
alexvanin marked this conversation as resolved.
Show resolved Hide resolved

* Please see CHANGELOG.md

-- NeoSPCC <[email protected]> Wed, 24 Aug 2022 18:29:49 +0300
15 changes: 15 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Source: neofs-http-gw
Section: neofs
Priority: optional
Maintainer: NeoSPCC <[email protected]>
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 changes: 23 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: neofs-http-gw
Upstream-Contact: [email protected]
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 changes: 2 additions & 0 deletions debian/neofs-http-gw.dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
etc/neofs
srv/neofs_cache
4 changes: 4 additions & 0 deletions debian/neofs-http-gw.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docs/gate-configuration.md
README.md
CREDITS.md
CONTRIBUTING.md
1 change: 1 addition & 0 deletions debian/neofs-http-gw.examples
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config/*
2 changes: 2 additions & 0 deletions debian/neofs-http-gw.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/neofs-http-gw usr/bin
config/config.yaml etc/neofs/http
51 changes: 51 additions & 0 deletions debian/neofs-http-gw.postinst
Original file line number Diff line number Diff line change
@@ -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 changes: 41 additions & 0 deletions debian/neofs-http-gw.postrm
Original file line number Diff line number Diff line change
@@ -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 changes: 35 additions & 0 deletions debian/neofs-http-gw.preinst
Original file line number Diff line number Diff line change
@@ -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 changes: 38 additions & 0 deletions debian/neofs-http-gw.prerm
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions debian/neofs-http-gw.service
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
46 changes: 46 additions & 0 deletions docs/building-deb-package.md
Original file line number Diff line number Diff line change
@@ -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
```