Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cos integration for KSQL. #663

Merged
merged 7 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions debian/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Dependencies you'll probably need to install to compile this: make, curl, git,
# zip, unzip, patch, java8-jdk | openjdk-8-jdk, maven.

SHELL=/bin/bash

ifndef VERSION
# Note that this is sensitive to this package's version being the first
# <version> tag in the pom.xml
VERSION=$(shell grep version pom.xml | head -n 1 | awk -F'>|<' '{ print $$3 }')
endif

export PACKAGE_TITLE=ksql
export FULL_PACKAGE_TITLE=confluent-ksql
export PACKAGE_NAME=$(FULL_PACKAGE_TITLE)-$(VERSION)

# Defaults that are likely to vary by platform. These are cleanly separated so
# it should be easy to maintain altered values on platform-specific branches
# when the values aren't overridden by the script invoking the Makefile

# Whether we should apply patches. This only makes sense for alternate packaging
# systems that know how to apply patches themselves, e.g. Debian.
APPLY_PATCHES?=yes

# DESTDIR may be overriden by e.g. debian packaging
ifeq ($(DESTDIR),)
DESTDIR=$(CURDIR)/BUILD/
endif

ifeq ($(PACKAGE_TYPE),archive)
PREFIX=$(PACKAGE_NAME)
SYSCONFDIR=$(PREFIX)/etc/$(PACKAGE_TITLE)
SYSTEMDDIR=$(PREFIX)/lib/systemd/system
else
PREFIX=/usr
SYSCONFDIR=/etc/$(PACKAGE_TITLE)
SYSTEMDDIR=/lib/systemd/system
endif

# Whether we should run tests during the build.
SKIP_TESTS?=yes

all: install


archive: install
rm -f $(CURDIR)/$(PACKAGE_NAME).tar.gz && cd $(DESTDIR) && tar -czf $(CURDIR)/$(PACKAGE_NAME).tar.gz $(PREFIX)
rm -f $(CURDIR)/$(PACKAGE_NAME).zip && cd $(DESTDIR) && zip -r $(CURDIR)/$(PACKAGE_NAME).zip $(PREFIX)

apply-patches: $(wildcard patches/*)
ifeq ($(APPLY_PATCHES),yes)
git reset --hard HEAD
cat patches/series | xargs -iPATCH bash -c 'patch -p1 < patches/PATCH'
endif

build: apply-patches
ifeq ($(SKIP_TESTS),yes)
mvn -DskipTests=true install
else
mvn install
endif

BINPATH=$(PREFIX)/bin
LIBPATH=$(PREFIX)/share/java/$(PACKAGE_TITLE)
DOCPATH=$(PREFIX)/share/doc/$(PACKAGE_TITLE)

INSTALL=install -D -m 644
INSTALL_X=install -D -m 755

install: build
# Safety precatuion to avoid removing of root dir when DESTDIR or PREFIX is not set, for wathever reason
if [[ $(DESTDIR)$(PREFIX) != /tmp/confluent/* ]]; then echo "DESTDIR=$(DESTDIR) or PREFIX=$(PREFIX) is weird" ; exit 1 ; fi
rm -rf $(DESTDIR)$(PREFIX)
mkdir -p $(DESTDIR)$(PREFIX)
mkdir -p $(DESTDIR)$(BINPATH)
mkdir -p $(DESTDIR)$(LIBPATH)
mkdir -p $(DESTDIR)$(SYSCONFDIR)
for svc in debian/*.service ; do \
$(INSTALL) -o root -g root -D $$svc $(DESTDIR)$(SYSTEMDDIR)/$$(basename $$svc) ; \
done
pushd "ksql/target/ksql-$(VERSION)-package" ; \
find bin/ -type f | grep -v README[.]rpm | xargs -I XXX $(INSTALL_X) -o root -g root XXX $(DESTDIR)$(PREFIX)/XXX ;\
find share/ -type f | grep -v README[.]rpm | xargs -I XXX $(INSTALL) -o root -g root XXX $(DESTDIR)$(PREFIX)/XXX ; \
pushd etc/ksql/ ; \
find . -type f | grep -v README[.]rpm | xargs -I XXX $(INSTALL) -o root -g root XXX $(DESTDIR)$(SYSCONFDIR)/XXX
Copy link
Contributor

@edenhill edenhill Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hint:
To (manually) verify final package contents, do:

for archive:
tar tvzf output/..ksql..tar.gz

rpm:
rpm -qpl output/..ksql..rpm

deb:
dpkg -c output/..ksql..all.deb



clean:
rm -rf $(CURDIR)/$(PACKAGE_NAME)*
rm -rf $(FULL_PACKAGE_TITLE)-$(RPM_VERSION)*rpm
rm -rf RPM_BUILDING

distclean: clean
git reset --hard HEAD
git status --ignored --porcelain | cut -d ' ' -f 2 | xargs rm -rf

test:

.PHONY: clean install



RPM_VERSION=$(shell echo $(VERSION) | sed -e 's/-alpha[0-9]*//' -e 's/-beta[0-9]*//' -e 's/-rc[0-9]*//' -e 's/-SNAPSHOT//')
# Get any -alpha, -beta, -rc piece that we need to put into the Release part of
# the version since RPM versions don't support non-numeric
# characters. Ultimately, for something like 0.8.2-beta, we want to end up with
# Version=0.8.2 Release=0.X.beta
# where X is the RPM release # of 0.8.2-beta (the prefix 0. forces this to be
# considered earlier than any 0.8.2 final releases since those will start with
# Version=0.8.2 Release=1)
RPM_RELEASE_POSTFIX=$(subst -,,$(subst $(RPM_VERSION),,$(VERSION)))
ifneq ($(RPM_RELEASE_POSTFIX),)
RPM_RELEASE_POSTFIX_UNDERSCORE=_$(RPM_RELEASE_POSTFIX)
RPM_RELEASE_ID=0.$(REVISION).$(RPM_RELEASE_POSTFIX)
else
RPM_RELEASE_ID=$(REVISION)
endif



rpm: RPM_BUILDING/SOURCES/$(FULL_PACKAGE_TITLE)-$(RPM_VERSION).tar.gz
echo "Building the rpm"
rpmbuild --define="_topdir `pwd`/RPM_BUILDING" -tb $<
find RPM_BUILDING/{,S}RPMS/ -type f | xargs -n1 -iXXX mv XXX .
echo
echo "================================================="
echo "The rpms have been created and can be found here:"
@ls -laF $(FULL_PACKAGE_TITLE)*rpm
echo "================================================="

# Unfortunately, because of version naming issues and the way rpmbuild expects
# the paths in the tar file to be named, we need to rearchive the package. So
# instead of depending on archive, this target just uses the unarchived,
# installed version to generate a new archive. Note that we always regenerate
# the symlink because the RPM_VERSION doesn't include all the version info -- it
# can leave of things like -beta, -rc1, etc.
RPM_BUILDING/SOURCES/$(FULL_PACKAGE_TITLE)-$(RPM_VERSION).tar.gz: rpm-build-area install debian/$(FULL_PACKAGE_TITLE).spec.in RELEASE_$(RPM_VERSION)$(RPM_RELEASE_POSTFIX_UNDERSCORE)
rm -rf $(FULL_PACKAGE_TITLE)-$(RPM_VERSION)
mkdir $(FULL_PACKAGE_TITLE)-$(RPM_VERSION)
cp -R $(DESTDIR)/* $(FULL_PACKAGE_TITLE)-$(RPM_VERSION)
sed "s@##RPMVERSION##@$(RPM_VERSION)@g; s@##RPMRELEASE##@$(RPM_RELEASE_ID)@g" < debian/$(FULL_PACKAGE_TITLE).spec.in > $(FULL_PACKAGE_TITLE)-$(RPM_VERSION)/$(FULL_PACKAGE_TITLE).spec
rm -f $@ && tar -czf $@ $(FULL_PACKAGE_TITLE)-$(RPM_VERSION)
rm -rf $(FULL_PACKAGE_TITLE)-$(RPM_VERSION)

rpm-build-area: RPM_BUILDING/BUILD RPM_BUILDING/RPMS RPM_BUILDING/SOURCES RPM_BUILDING/SPECS RPM_BUILDING/SRPMS

RPM_BUILDING/%:
mkdir -p $@

RELEASE_%:
echo 0 > $@

check:
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
confluent-ksql (0.1~SNAPSHOT-1) unstable; urgency=low

* Initial release.

-- Confluent Packaging <[email protected]> Fri, 02 Dec 2015 22:09:36 +0000
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
13 changes: 13 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: confluent-ksql
Section: misc
Priority: optional
Maintainer: Confluent Packaging <[email protected]>
Build-Depends: debhelper (>= 9), dh-systemd, java8-jdk, javahelper (>= 0.40),
make, maven
Standards-Version: 3.9.3
Homepage: http://confluent.io

Package: confluent-ksql
Architecture: all
Depends: ${misc:Depends}, confluent-rest-utils, adduser
Description: Streaming SQL engine for Apache Kafka.
27 changes: 27 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ksql
Source: https://github.com/confluentinc/ksql

Files: *
Copyright: 2014 Confluent, Inc.
License: Apache-2

Files: debian/*
Copyright: 2014 Confluent, Inc.
License: Apache-2

License: Apache-2
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
.
http://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language overning permissions and limitations under
the License.
.
On Debian systems, the Apache 2.0 license can be found in
/usr/share/common-licenses/Apache-2.0.
5 changes: 5 additions & 0 deletions debian/gbp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[DEFAULT]
upstream-tree=tag
upstream-tag=%(version)s
debian-tag=debian-%(version)s
debian-branch=debian-%(version)s
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
standard_build_layout.patch
14 changes: 14 additions & 0 deletions debian/patches/standard_build_layout.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3f83b80
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
+clean:
+
+distclean:
+
+%:
+ cp debian/Makefile Makefile.debian
+ $(MAKE) -f Makefile.debian $@
+ rm -f Makefile.debian
10 changes: 10 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/make -f

%:
dh $@ --with javahelper,systemd

override_dh_systemd_enable:
dh_systemd_enable --no-enable

override_dh_systemd_start:
dh_systemd_start --no-start
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)