dist: simplified build script templates
Currently we are using *.in files for templates, applying parameters by sed command one-by-one. This patch will replace them by Mustache, it's simple and easy syntax template language. Signed-off-by: Takuya ASADA <syuu@scylladb.com> Message-Id: <20180606183113.25275-1-syuu@scylladb.com>
This commit is contained in:
parent
b8394f677b
commit
2af17c1f53
@ -5,7 +5,12 @@ After=scylla-server.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=@@SYSCONFDIR@@/scylla-jmx
|
||||
{{#debian}}
|
||||
EnvironmentFile=/etc/default/scylla-jmx
|
||||
{{/debian}}
|
||||
{{#redhat}}
|
||||
EnvironmentFile=/etc/sysconfig/scylla-jmx
|
||||
{{/redhat}}
|
||||
User=scylla
|
||||
Group=scylla
|
||||
ExecStart=/usr/lib/scylla/jmx/scylla-jmx $SCYLLA_JMX_PORT $SCYLLA_API_PORT $SCYLLA_API_ADDR $SCYLLA_JMX_ADDR $SCYLLA_JMX_FILE $SCYLLA_JMX_LOCAL $SCYLLA_JMX_REMOTE $SCYLLA_JMX_DEBUG
|
34
dist/debian/build_deb.sh
vendored
34
dist/debian/build_deb.sh
vendored
@ -74,6 +74,13 @@ fi
|
||||
if [ ! -f /usr/bin/dh_testdir ]; then
|
||||
pkg_install debhelper
|
||||
fi
|
||||
if [ ! -f /usr/bin/pystache ]; then
|
||||
if is_redhat_variant; then
|
||||
sudo yum install -y python2-pystache || sudo yum install -y pystache
|
||||
elif is_debian_variant; then
|
||||
sudo apt-get install -y python-pystache
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$TARGET" ]; then
|
||||
@ -95,23 +102,22 @@ echo $VERSION > version
|
||||
./scripts/git-archive-all --extra version --force-submodules --prefix scylla-jmx ../scylla-jmx_$SCYLLA_VERSION-$SCYLLA_RELEASE.orig.tar.gz
|
||||
|
||||
cp -a dist/debian/debian debian
|
||||
cp dist/debian/changelog.in debian/changelog
|
||||
cp dist/debian/rules.in debian/rules
|
||||
sed -i -e "s/@@VERSION@@/$SCYLLA_VERSION/g" debian/changelog
|
||||
sed -i -e "s/@@RELEASE@@/$SCYLLA_RELEASE/g" debian/changelog
|
||||
sed -i -e "s/@@CODENAME@@/$TARGET/g" debian/changelog
|
||||
if [ "$TARGET" = "trusty" ] || [ "$TARGET" = "xenial" ] || [ "$TARGET" = "yakkety" ] || [ "$TARGET" = "zesty" ] || [ "$TARGET" = "artful" ] || [ "$TARGET" = "bionic" ]; then
|
||||
sed -i -e "s/@@REVISION@@/0ubuntu1~$TARGET/g" debian/changelog
|
||||
if [ "$TARGET" = "jessie" ] || [ "$TARGET" = "stretch" ]; then
|
||||
REVISION="1~$TARGET"
|
||||
elif [ "$TARGET" = "trusty" ] || [ "$TARGET" = "xenial" ] || [ "$TARGET" = "bionic" ]; then
|
||||
REVISION="0ubuntu1~$TARGET"
|
||||
else
|
||||
sed -i -e "s/@@REVISION@@/1~$TARGET/g" debian/changelog
|
||||
echo "Unknown distribution: $TARGET"
|
||||
fi
|
||||
if [ "$TARGET" = "trusty" ]; then
|
||||
sed -i -e "s/@@DH_INSTALLINIT@@/--upstart-only/g" debian/rules
|
||||
else
|
||||
sed -i -e "s/@@DH_INSTALLINIT@@//g" debian/rules
|
||||
|
||||
MUSTACHE_DIST="\"debian\": true, \"$TARGET\": true"
|
||||
pystache dist/debian/changelog.mustache "{ \"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
|
||||
|
||||
if [ "$TARGET" != "trusty" ]; then
|
||||
pystache dist/common/systemd/scylla-jmx.service.mustache "{ $MUSTACHE_DIST }" > debian/scylla-jmx.service
|
||||
fi
|
||||
cp dist/common/systemd/scylla-jmx.service.in debian/scylla-jmx.service
|
||||
sed -i -e "s#@@SYSCONFDIR@@#/etc/default#g" debian/scylla-jmx.service
|
||||
|
||||
cp ./dist/debian/pbuilderrc ~/.pbuilderrc
|
||||
sudo rm -fv /var/cache/pbuilder/scylla-jmx-$TARGET.tgz
|
||||
|
@ -1,4 +1,4 @@
|
||||
scylla-jmx (@@VERSION@@-@@RELEASE@@-@@REVISION@@) @@CODENAME@@; urgency=medium
|
||||
scylla-jmx ({{version}}-{{release}}-{{revision}}) {{codename}}; urgency=medium
|
||||
|
||||
* Initial release.
|
||||
|
@ -26,7 +26,12 @@ override_dh_auto_install:
|
||||
ln -sf /usr/bin/java $(DEST)/symlinks/scylla-jmx
|
||||
|
||||
override_dh_installinit:
|
||||
dh_installinit --no-start @@DH_INSTALLINIT@@
|
||||
{{#trusty}}
|
||||
dh_installinit --no-start --upstart-only
|
||||
{{/trusty}}
|
||||
{{^trusty}}
|
||||
dh_installinit --no-start
|
||||
{{/trusty}}
|
||||
|
||||
%:
|
||||
dh $@
|
11
dist/redhat/build_rpm.sh
vendored
11
dist/redhat/build_rpm.sh
vendored
@ -62,14 +62,19 @@ fi
|
||||
if [ ! -f /usr/bin/git ]; then
|
||||
pkg_install git
|
||||
fi
|
||||
if [ ! -f /usr/bin/pystache ]; then
|
||||
if is_redhat_variant; then
|
||||
sudo yum install -y python2-pystache || sudo yum install -y pystache
|
||||
elif is_debian_variant; then
|
||||
sudo apt-get install -y python-pystache
|
||||
fi
|
||||
fi
|
||||
|
||||
VERSION=$(./SCYLLA-VERSION-GEN)
|
||||
SCYLLA_VERSION=$(cat build/SCYLLA-VERSION-FILE)
|
||||
SCYLLA_RELEASE=$(cat build/SCYLLA-RELEASE-FILE)
|
||||
git archive --format=tar --prefix=scylla-jmx-$SCYLLA_VERSION/ HEAD -o build/scylla-jmx-$VERSION.tar
|
||||
cp dist/redhat/scylla-jmx.spec.in build/scylla-jmx.spec
|
||||
sed -i -e "s/@@VERSION@@/$SCYLLA_VERSION/g" build/scylla-jmx.spec
|
||||
sed -i -e "s/@@RELEASE@@/$SCYLLA_RELEASE/g" build/scylla-jmx.spec
|
||||
pystache dist/redhat/scylla-jmx.spec.mustache "{ \"version\": \"$SCYLLA_VERSION\", \"release\": \"$SCYLLA_RELEASE\" }" > build/scylla-jmx.spec
|
||||
|
||||
sudo mock --buildsrpm --root=$TARGET --resultdir=`pwd`/build/srpms --spec=build/scylla-jmx.spec --sources=build/scylla-jmx-$VERSION.tar
|
||||
sudo mock --rebuild --root=$TARGET --resultdir=`pwd`/build/rpms build/srpms/scylla-jmx-$VERSION*.src.rpm
|
||||
|
@ -1,15 +1,17 @@
|
||||
Name: scylla-jmx
|
||||
Version: @@VERSION@@
|
||||
Release: @@RELEASE@@%{?dist}
|
||||
Version: {{version}}
|
||||
Release: {{release}}%{?dist}
|
||||
Summary: Scylla JMX
|
||||
Group: Applications/Databases
|
||||
|
||||
License: AGPLv3
|
||||
URL: http://www.scylladb.com/
|
||||
Source0: %{name}-@@VERSION@@-@@RELEASE@@.tar
|
||||
Source0: %{name}-{{version}}-{{release}}.tar
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: maven systemd-units java-1.8.0-openjdk-devel
|
||||
%{?fedora:BuildRequires: python2-pystache}
|
||||
%{?rhel:BuildRequires: pystache python-setuptools}
|
||||
Requires: scylla-server java-1.8.0-openjdk-headless
|
||||
|
||||
%description
|
||||
@ -22,8 +24,8 @@ Requires: scylla-server java-1.8.0-openjdk-headless
|
||||
%build
|
||||
mvn -B install
|
||||
mkdir build
|
||||
cp dist/common/systemd/scylla-jmx.service.in build/scylla-jmx.service
|
||||
sed -i -e "s#@@SYSCONFDIR@@#/etc/sysconfig#g" build/scylla-jmx.service
|
||||
MUSTACHE_DIST="\"redhat\": true"
|
||||
pystache dist/common/systemd/scylla-jmx.service.mustache "{ $MUSTACHE_DIST }" > build/scylla-jmx.service
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
Loading…
Reference in New Issue
Block a user