Skip to content

Commit

Permalink
Add RPM spec file and Makefile logic
Browse files Browse the repository at this point in the history
Task: BABEL-4412
Signed-off-by: Rishabh Tanwar <[email protected]>
  • Loading branch information
ritanwar committed Sep 19, 2023
1 parent d060983 commit d6cc858
Show file tree
Hide file tree
Showing 2 changed files with 256 additions and 0 deletions.
219 changes: 219 additions & 0 deletions BabelfishDump.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# This spec file and ancillary files are licensed in accordance with

# The PostgreSQL license.


# In this file you can find the default build package list macros.

# These can be overridden by defining on the rpm command line:

# rpm --define 'packagename 1' .... to force the package to build.

# rpm --define 'packagename 0' .... to force the package NOT to build.


%{!?external_libpq:%global external_libpq 0}


%{!?ssl:%global ssl 1}

%{!?icu:%global icu 1}

%{!?kerberos:%global kerberos 1}


%{!?uuid:%global uuid 1}

%{!?xml:%global xml 1}

# https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_of_Additional_RPM_Macros

%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)

%undefine _missing_build_ids_terminate_build

Summary: Postgresql dump utilities modified for Babelfish

Name: BabelfishDump

%global majorversion 15

Version: %{majorversion}.3

Release: 2%{?dist}

License: PostgreSQL

Url: https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish

BuildArch: noarch


BuildRequires: make

BuildRequires: gcc

#BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk

BuildRequires: readline-devel zlib-devel

%if %external_libpq

BuildRequires: libpq-devel >= %version

%endif

# postgresql-setup build requires

BuildRequires: m4


%if %ssl

BuildRequires: openssl-devel

%endif


%if %kerberos

BuildRequires: krb5-devel

%endif


%if %uuid

BuildRequires: uuid-devel

%endif


%if %xml

BuildRequires: libxml2-devel

%endif

%if %icu

BuildRequires: libicu-devel

%endif


Source: %{name}.tar.gz

# https://bugzilla.redhat.com/1464368

# and do not provide pkgconfig RPM provides (RHBZ#1980992) and #2121696

%global __provides_exclude_from %{_libdir}/(pgsql|pkgconfig)


%description

This package provides utilities to dump a Babelfish database.


Requires(post): glibc

Requires(postun): glibc


%prep

%setup -q -n %{name}

# Update binary versions
sed -i "s/pg_dump (PostgreSQL)/bbf_dump (pg_dump compatible with Babelfish for PostgreSQL)/g" src/bin/pg_dump/pg_dump.c
sed -i "s/pg_dumpall (PostgreSQL)/bbf_dumpall (pg_dumpall compatible with Babelfish for PostgreSQL)/g" src/bin/pg_dump/pg_dumpall.c

%build

# Building BabelfishDump

# Fiddling with CFLAGS.


CFLAGS="${CFLAGS:-%optflags}"

# Strip out -ffast-math from CFLAGS....

CFLAGS=`echo $CFLAGS|xargs -n 1|grep -v ffast-math|xargs -n 100`

export CFLAGS


common_configure_options='

--disable-rpath

--enable-debug

--enable-cassert

%if %ssl

--with-openssl

--with-ssl=libssl3

%endif

--with-zlib

--with-libxml

--with-readline

%if %kerberos

--with-gssapi

%endif

%if %uuid

--with-ossp-uuid

%endif

%if %icu

--with-icu

%endif
'

export LIBS="-lz -lc -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lk5crypto -ldl -lkrb5support -lssl3"

%configure $common_configure_options

make -C src/backend generated-headers
make -C src/bin/pg_dump -j4 pg_dump pg_dumpall


%install

make -C src/bin/pg_dump install DESTDIR=$RPM_BUILD_ROOT

# We don't need pg_restore
rm -f $RPM_BUILD_ROOT/usr/bin/pg_restore

# Rename binaries to bbf_* equivalent
mv $RPM_BUILD_ROOT/usr/bin/pg_dump $RPM_BUILD_ROOT/usr/bin/bbf_dump
mv $RPM_BUILD_ROOT/usr/bin/pg_dumpall $RPM_BUILD_ROOT/usr/bin/bbf_dumpall

%check
$RPM_BUILD_ROOT/usr/bin/bbf_dumpall -V
$RPM_BUILD_ROOT/usr/bin/bbf_dump -V

# FILES sections.
%files

%{_bindir}/bbf_dump

%{_bindir}/bbf_dumpall

%changelog
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,40 @@ all check install installdirs installcheck installcheck-parallel uninstall clean
echo "You must use GNU make to build PostgreSQL." ; \
false; \
fi

PACKAGE_NAME = BabelfishDump
SOURCE_TARBALL = $(PACKAGE_NAME).tar.gz
SPECFILE = $(PACKAGE_NAME).spec
BUILD_DIR = build/rpmbuild

.PHONY: rpm-clean
rpm-clean:
rm -rf $(BUILD_DIR)
rm -rf $(PACKAGE_NAME)
rm -f $(SOURCE_TARBALL)

.PHONY: tarball
tarball: rpm-clean
mkdir -p $(PACKAGE_NAME)

cp -p aclocal.m4 $(PACKAGE_NAME)
cp -p configure* $(PACKAGE_NAME)
cp -p GNUmakefile* $(PACKAGE_NAME)
cp -p Makefile $(PACKAGE_NAME)
cp -rp config src $(PACKAGE_NAME)

tar -czf $(SOURCE_TARBALL) $(PACKAGE_NAME)/*

.PHONY: sources
sources: tarball

.PHONY: rpm-only
rpm-only:
mkdir -p $(BUILD_DIR)/{SPECS,COORD_SOURCES,DATA_SOURCES,BUILD,RPMS,SOURCES,SRPMS}
cp $(SPECFILE) $(BUILD_DIR)/SPECS
cp $(SOURCE_TARBALL) $(BUILD_DIR)/SOURCES
rpmbuild -ba --define "_topdir `pwd`/$(BUILD_DIR)" $(BUILD_DIR)/SPECS/$(SPECFILE)
cp $(BUILD_DIR)/RPMS/*/*rpm build

.PHONY: rpm
rpm: sources rpm-only

0 comments on commit d6cc858

Please sign in to comment.