From 0ba830f48fb1047f1e578ec0a04158c22324e977 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 | 23 ++++++++++++++++++++++ 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, 266 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 0b93b2e..b5ef81d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ config.json /vendor/ .idea /bin/ + +# debhelpers +**/.debhelper diff --git a/Makefile b/Makefile index 6e9c4b3..47720b4 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,16 @@ export GOBIN ?= $(shell pwd)/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 @@ -58,3 +66,15 @@ archive: build @tar --transform "s|^./|frostfs-contract-$(VERSION)/|" \ -czf frostfs-contract-$(VERSION).tar.gz \ $(shell find . -name '*.nef' -o -name 'config.json') + +# Package for Debian +debpackage: + dch --package frostfs-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 f1cb808..6ba44c8 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..6c5954c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +frostfs-contract (0.0.0) stable; urgency=medium + + * Initial release + + -- TrueCloudLab Wed, 24 Aug 2022 18:29:49 +0300 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..1aa4fa2 --- /dev/null +++ b/debian/control @@ -0,0 +1,34 @@ +Source: frostfs-contract +Section: misc +Priority: optional +Maintainer: FrostFS +Build-Depends: debhelper-compat (= 13), git, devscripts, neo-go +Standards-Version: 4.5.1 +Homepage: https://fs.neo.org/ +Vcs-Git: https://github.com/TrueCloudLab/frostfs-contract.git +Vcs-Browser: https://github.com/TrueCloudLab/frostfs-contract + +Package: frostfs-contract +Architecture: all +Depends: ${misc:Depends} +Description: FrostFS-Contract contains all FrostFS related contracts. + Contracts are written for neo-go compiler. + These contracts are deployed both in the mainchain and the sidechain. + . + Mainchain contracts: + . + - frostfs + - processing + . + Sidechain contracts: + . + - alphabet + - audit + - balance + - container + - frostfsid + - netmap + - nns + - proxy + - reputation + - subnet diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..e27165e --- /dev/null +++ b/debian/copyright @@ -0,0 +1,23 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: frostfs-contract +Upstream-Contact: tech@frostfs.info +Source: https://github.com/TrueCloudLab/frostfs-contract + +Files: * +Copyright: 2022 TrueCloudLab (@TrueCloudLab) +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..e00b345 --- /dev/null +++ b/debian/postinst.ex @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for frostfs-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..a8aa1c1 --- /dev/null +++ b/debian/postrm.ex @@ -0,0 +1,37 @@ +#!/bin/sh +# postrm script for frostfs-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..41fd95d --- /dev/null +++ b/debian/preinst.ex @@ -0,0 +1,35 @@ +#!/bin/sh +# preinst script for frostfs-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..bf49395 --- /dev/null +++ b/debian/prerm.ex @@ -0,0 +1,38 @@ +#!/bin/sh +# prerm script for frostfs-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..8c5a550 --- /dev/null +++ b/debian/rules @@ -0,0 +1,20 @@ +#!/usr/bin/make -f + +SERVICE = frostfs-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/frostfs/contract + find . -maxdepth 2 \( -name '*.nef' -o -name 'config.json' \) -exec cp --parents \{\} debian/$(SERVICE)/var/lib/frostfs/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)