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
This commit is contained in:
Takuya ASADA 2020-05-11 18:17:51 +09:00 committed by Avi Kivity
parent 18f8acc60e
commit 52bd496006
7 changed files with 80 additions and 37 deletions

View File

@ -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

View File

@ -1,4 +1,4 @@
{{product}}-jmx ({{version}}-{{release}}-{{revision}}) {{codename}}; urgency=medium
%{product}-jmx (%{version}-%{release}-%{revision}) %{codename}; urgency=medium
* Initial release.

View File

@ -1,13 +1,13 @@
Source: {{product}}-jmx
Source: %{product}-jmx
Maintainer: Takuya ASADA <syuu@scylladb.com>
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,

View File

@ -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:

68
dist/debian/debian_files_gen.py vendored Executable file
View File

@ -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 <http://www.gnu.org/licenses/>.
#
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)

View File

@ -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

View File

@ -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')