From 0f86c9dc1bcd47a2a3c2d209e0815a9a216a7699 Mon Sep 17 00:00:00 2001 From: Dmitriy Zabolotskiy Date: Mon, 31 Oct 2022 18:48:26 +0300 Subject: [PATCH] [#291] Debian packaging Debian package contains compiled contracts and manifests with corresponding directories, which will be placed into /var/lib/neofs/contract for further usage. Depends on neo-go package to build. Signed-off-by: Dmitriy Zabolotskiy --- .gitignore | 3 +++ Makefile | 20 +++++++++++++++++++ README.md | 10 ++++++++++ debian/changelog | 5 +++++ debian/control | 34 +++++++++++++++++++++++++++++++++ debian/copyright | 22 +++++++++++++++++++++ debian/neofs-contract.docs | 1 + debian/postinst.ex | 39 ++++++++++++++++++++++++++++++++++++++ debian/postrm.ex | 37 ++++++++++++++++++++++++++++++++++++ debian/preinst.ex | 35 ++++++++++++++++++++++++++++++++++ debian/prerm.ex | 38 +++++++++++++++++++++++++++++++++++++ debian/rules | 20 +++++++++++++++++++ debian/source/format | 1 + 13 files changed, 265 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/neofs-contract.docs create mode 100644 debian/postinst.ex create mode 100644 debian/postrm.ex create mode 100644 debian/preinst.ex create mode 100644 debian/prerm.ex create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/.gitignore b/.gitignore index 127abf6..c9a2797 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ config.json /vendor/ .idea + +# debhelpers +**/.debhelper diff --git a/Makefile b/Makefile index b934ca7..3546a6a 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,16 @@ GOBIN ?= $(shell go env GOPATH)/bin NEOGO ?= $(GOBIN)/cli VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop") + +# .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: all build clean test neo-go .PHONY: alphabet mainnet morph nns sidechain +.PHONY: debpackage debclean build: neo-go all all: sidechain mainnet sidechain: alphabet morph nns @@ -55,3 +63,15 @@ archive: build @tar --transform "s|^./|neofs-contract-$(VERSION)/|" \ -czf neofs-contract-$(VERSION).tar.gz \ $(shell find . -name '*.nef' -o -name 'config.json') + +# Package for Debian +debpackage: + dch --package neofs-contract \ + --controlmaint \ + --newversion $(PKG_VERSION) \ + --distribution $(OS_RELEASE) \ + "Please see CHANGELOG.md for code changes for $(VERSION)" + dpkg-buildpackage --no-sign -b + +debclean: + dh clean diff --git a/README.md b/README.md index a79e269..a8a89b7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,16 @@ $ NEOGO=/home/user/neo-go/bin/neo-go make all Remove compiled files with `make clean` or `make mr_proper` command. +## Building Debian package + +To build Debian package containing compiled contracts, run `make debpackage` +command. Package will install compiled contracts `*_contract.nef` and manifest +`config.json` with corresponding directories to `/var/lib/neofs/contract` for +further usage. +It will download and build neo-go, if needed. + +To clean package-related files, use `make debclean`. + # Testing Smartcontract tests reside in `tests/` directory. To execute test suite after applying changes, simply run `make test`. diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..ee8b0cc --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +neofs-contract (0.0.0) stable; urgency=medium + + * Initial release + + -- NeoSPCC Wed, 24 Aug 2022 18:29:49 +0300 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..4efdc9e --- /dev/null +++ b/debian/control @@ -0,0 +1,34 @@ +Source: neofs-contract +Section: misc +Priority: optional +Maintainer: NeoSPCC +Build-Depends: debhelper-compat (= 13), git, devscripts, neo-go +Standards-Version: 4.5.1 +Homepage: https://fs.neo.org/ +Vcs-Git: https://github.com/nspcc-dev/neofs-contract.git +Vcs-Browser: https://github.com/nspcc-dev/neofs-contract + +Package: neofs-contract +Architecture: all +Depends: ${misc:Depends} +Description: NeoFS-Contract contains all NeoFS related contracts. + Contracts are written for neo-go compiler. + These contracts are deployed both in the mainchain and the sidechain. + . + Mainchain contracts: + . + - neofs + - processing + . + Sidechain contracts: + . + - alphabet + - audit + - balance + - container + - neofsid + - netmap + - nns + - proxy + - reputation + - subnet diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..a0fc66d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,22 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: neofs-contract +Upstream-Contact: tech@nspcc.ru +Source: https://github.com/nspcc-dev/neofs-contract + +Files: * +Copyright: 2018-2022 NeoSPCC (@nspcc-dev) + +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; either version 3 of the License, or + (at your option) any later version. + + 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 . diff --git a/debian/neofs-contract.docs b/debian/neofs-contract.docs new file mode 100644 index 0000000..ab1a32b --- /dev/null +++ b/debian/neofs-contract.docs @@ -0,0 +1 @@ +README* diff --git a/debian/postinst.ex b/debian/postinst.ex new file mode 100644 index 0000000..47eefa4 --- /dev/null +++ b/debian/postinst.ex @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for neofs-contract +# +# 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) + ;; + + 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/postrm.ex b/debian/postrm.ex new file mode 100644 index 0000000..e2bc910 --- /dev/null +++ b/debian/postrm.ex @@ -0,0 +1,37 @@ +#!/bin/sh +# postrm script for neofs-contract +# +# 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|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/preinst.ex b/debian/preinst.ex new file mode 100644 index 0000000..af5a071 --- /dev/null +++ b/debian/preinst.ex @@ -0,0 +1,35 @@ +#!/bin/sh +# preinst script for neofs-contract +# +# 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/prerm.ex b/debian/prerm.ex new file mode 100644 index 0000000..60e41bd --- /dev/null +++ b/debian/prerm.ex @@ -0,0 +1,38 @@ +#!/bin/sh +# prerm script for neofs-contract +# +# 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 0000000..0e3ddd1 --- /dev/null +++ b/debian/rules @@ -0,0 +1,20 @@ +#!/usr/bin/make -f + +SERVICE = neofs-contract +export NEOGO ?= $(shell command -v neo-go) + +%: + dh $@ + +override_dh_auto_build: + + make all + +override_dh_auto_install: + install -D -m 0750 -d debian/$(SERVICE)/var/lib/neofs/contract + find . -maxdepth 2 \( -name '*.nef' -o -name 'config.json' \) -exec cp --parents \{\} debian/$(SERVICE)/var/lib/neofs/contract \; + +override_dh_installchangelogs: + dh_installchangelogs -k CHANGELOG.md + + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt)