From 52bd4960066602a3c3d38d4dca9b637902eb93d7 Mon Sep 17 00:00:00 2001 From: Takuya ASADA Date: Mon, 11 May 2020 18:17:51 +0900 Subject: [PATCH] dist/debian: drop dependency on pystache Drop dependency on pystache since it nolong present in Fedora 32. To implement it, simplified debian package build process. It will be generate debian/ directory when building relocatable package, we just need to run debuild using the package. To generate debian/ directory this commit added debian_files_gen.py, it construct whole directory including control and changelog files from template files. Since we need to stop pystache, these template files swiched to string.Template class which is included python3 standard library. see: https://github.com/scylladb/scylla/pull/6313 --- dist/debian/build_deb.sh | 28 -------- ...{changelog.mustache => changelog.template} | 2 +- .../{control.mustache => control.template} | 6 +- dist/debian/{rules.mustache => debian/rules} | 11 +-- dist/debian/debian_files_gen.py | 68 +++++++++++++++++++ reloc/build_reloc.sh | 1 + scripts/create-relocatable-package.py | 1 + 7 files changed, 80 insertions(+), 37 deletions(-) rename dist/debian/{changelog.mustache => changelog.template} (52%) rename dist/debian/{control.mustache => control.template} (85%) rename dist/debian/{rules.mustache => debian/rules} (61%) create mode 100755 dist/debian/debian_files_gen.py diff --git a/dist/debian/build_deb.sh b/dist/debian/build_deb.sh index 0fec8f2..4c9f4a1 100755 --- a/dist/debian/build_deb.sh +++ b/dist/debian/build_deb.sh @@ -58,10 +58,6 @@ if [ ! -f "$RELOC_PKG" ]; then exit 1 fi -if [ -e debian ] || [ -e build/release ]; then - sudo rm -rf debian build - mkdir build -fi if is_debian_variant; then sudo apt-get -y update fi @@ -85,13 +81,6 @@ fi if [ ! -f /usr/bin/fakeroot ]; then pkg_install fakeroot fi -if [ ! -f /usr/bin/pystache ]; then - if is_redhat_variant; then - sudo yum install -y /usr/bin/pystache - elif is_debian_variant; then - sudo apt-get install -y python-pystache - fi -fi if [ "$ID" = "ubuntu" ] && [ ! -f /usr/share/keyrings/debian-archive-keyring.gpg ]; then sudo apt-get install -y debian-archive-keyring @@ -106,21 +95,4 @@ SCYLLA_VERSION=$(cat SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/') SCYLLA_RELEASE=$(cat SCYLLA-RELEASE-FILE) ln -fv $RELOC_PKG_FULLPATH ../$PRODUCT-jmx_$SCYLLA_VERSION-$SCYLLA_RELEASE.orig.tar.gz - -cp -al dist/debian/debian debian -if [ "$PRODUCT" != "scylla" ]; then - for i in debian/scylla-*;do - mv $i ${i/scylla-/$PRODUCT-} - done -fi - -REVISION="1" -MUSTACHE_DIST="\"debian\": true, \"$TARGET\": true, \"product\": \"$PRODUCT\", \"$PRODUCT\": true" -pystache dist/debian/changelog.mustache "{ $MUSTACHE_DIST, \"version\": \"$SCYLLA_VERSION\", \"release\": \"$SCYLLA_RELEASE\", \"revision\": \"$REVISION\", \"codename\": \"$TARGET\" }" > debian/changelog -pystache dist/debian/rules.mustache "{ $MUSTACHE_DIST }" > debian/rules -chmod a+rx debian/rules -pystache dist/debian/control.mustache "{ $MUSTACHE_DIST }" > debian/control - -cp dist/common/systemd/scylla-jmx.service debian/scylla-jmx.service - debuild -rfakeroot -us -uc diff --git a/dist/debian/changelog.mustache b/dist/debian/changelog.template similarity index 52% rename from dist/debian/changelog.mustache rename to dist/debian/changelog.template index 62e9596..a214785 100644 --- a/dist/debian/changelog.mustache +++ b/dist/debian/changelog.template @@ -1,4 +1,4 @@ -{{product}}-jmx ({{version}}-{{release}}-{{revision}}) {{codename}}; urgency=medium +%{product}-jmx (%{version}-%{release}-%{revision}) %{codename}; urgency=medium * Initial release. diff --git a/dist/debian/control.mustache b/dist/debian/control.template similarity index 85% rename from dist/debian/control.mustache rename to dist/debian/control.template index 887efd4..8b21ee2 100644 --- a/dist/debian/control.mustache +++ b/dist/debian/control.template @@ -1,13 +1,13 @@ -Source: {{product}}-jmx +Source: %{product}-jmx Maintainer: Takuya ASADA Homepage: http://scylladb.com Section: database Priority: optional Standards-Version: 3.9.5 -Package: {{product}}-jmx +Package: %{product}-jmx Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, openjdk-8-jre-headless | openjdk-8-jre | oracle-java8-set-default | adoptopenjdk-8-hotspot-jre, {{product}}-server +Depends: ${shlibs:Depends}, ${misc:Depends}, openjdk-8-jre-headless | openjdk-8-jre | oracle-java8-set-default | adoptopenjdk-8-hotspot-jre, %{product}-server Conflicts: openjdk-11-jre-headless, openjdk-11-jre, oracle-java11-set-default Description: Scylla JMX server binaries Scylla is a highly scalable, eventually consistent, distributed, diff --git a/dist/debian/rules.mustache b/dist/debian/debian/rules similarity index 61% rename from dist/debian/rules.mustache rename to dist/debian/debian/rules index a6030f6..cd0b5d1 100755 --- a/dist/debian/rules.mustache +++ b/dist/debian/debian/rules @@ -1,20 +1,21 @@ #!/usr/bin/make -f +include /usr/share/dpkg/pkg-info.mk + override_dh_auto_build: override_dh_auto_clean: override_dh_auto_install: dh_auto_install - ./install.sh --root "$(CURDIR)/debian/{{product}}-jmx" --sysconfdir /etc/default + ./install.sh --root "$(CURDIR)/debian/$(DEB_SOURCE)" --sysconfdir /etc/default override_dh_installinit: -{{#scylla}} +ifeq ($(DEB_SOURCE),scylla-jmx) dh_installinit --no-start -{{/scylla}} -{{^scylla}} +else dh_installinit --no-start --name scylla-jmx -{{/scylla}} +endif override_dh_strip_nondeterminism: diff --git a/dist/debian/debian_files_gen.py b/dist/debian/debian_files_gen.py new file mode 100755 index 0000000..9343b80 --- /dev/null +++ b/dist/debian/debian_files_gen.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (C) 2020 ScyllaDB +# + +# +# This file is part of Scylla. +# +# Scylla is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Scylla 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 Scylla. If not, see . +# + +import string +import os +import glob +import shutil + +class DebianFilesTemplate(string.Template): + delimiter = '%' + +scriptdir = os.path.dirname(__file__) + +with open(os.path.join(scriptdir, 'changelog.template')) as f: + changelog_template = f.read() + +with open(os.path.join(scriptdir, 'control.template')) as f: + control_template = f.read() + +with open('build/SCYLLA-PRODUCT-FILE') as f: + product = f.read().strip() + +with open('build/SCYLLA-VERSION-FILE') as f: + version = f.read().strip() + +with open('build/SCYLLA-RELEASE-FILE') as f: + release = f.read().strip() + +shutil.rmtree('build/debian/debian', ignore_errors=True) +shutil.copytree('dist/debian/debian', 'build/debian/debian') + +if product != 'scylla': + for p in glob.glob('build/debian/debian/scylla-*'): + shutil.move(p, p.replace('scylla-', '{}-'.format(product))) + +shutil.copy('dist/common/systemd/scylla-jmx.service', 'build/debian/debian/scylla-jmx.service') + +s = DebianFilesTemplate(changelog_template) +changelog_applied = s.substitute(product=product, version=version, release=release, revision='1', codename='stable') + +s = DebianFilesTemplate(control_template) +control_applied = s.substitute(product=product) + +with open('build/debian/debian/changelog', 'w') as f: + f.write(changelog_applied) + +with open('build/debian/debian/control', 'w') as f: + f.write(control_applied) diff --git a/reloc/build_reloc.sh b/reloc/build_reloc.sh index 8417e01..3d2b5df 100755 --- a/reloc/build_reloc.sh +++ b/reloc/build_reloc.sh @@ -54,4 +54,5 @@ fi mvn -B --file scylla-jmx-parent/pom.xml install ./SCYLLA-VERSION-GEN +./dist/debian/debian_files_gen.py scripts/create-relocatable-package.py build/scylla-jmx-package.tar.gz diff --git a/scripts/create-relocatable-package.py b/scripts/create-relocatable-package.py index 2a70acf..f4dd3d3 100755 --- a/scripts/create-relocatable-package.py +++ b/scripts/create-relocatable-package.py @@ -48,3 +48,4 @@ ar.add('target/scylla-jmx-1.0.jar', arcname='scylla-jmx-1.0.jar') ar.add('scripts/scylla-jmx', arcname='scylla-jmx') ar.add('README.md') ar.add('NOTICE') +ar.add('build/debian/debian', arcname='debian')