%define jdbcver 9.0
%define jdbcrel 801
%global gcj_support 0
Summary: JDBC driver for PostgreSQL
Summary(ja): PostgreSQL データベースにアクセスする Java プログラムのために必要なファイル群
Group: Applications/Databases
Name: postgresql-jdbc
Version: %{jdbcver}.%{jdbcrel}
Release: 1%{?_dist_release}
License: BSD and ASL 2.0
URL: http://www.postgresql.org/ 
Source0: http://jdbc.postgresql.org/download/%{name}-%{jdbcver}-%{jdbcrel}.src.tar.gz
Source1: postgresql-jdbc.pom
Buildrequires: perl build-essential
Buildrequires: ant >= 0:1.6.2

#%if ! %{gcj_support}
#BuildArch: noarch
#%endif

# ant (1.8.1-1vl6)
# ecj (3.6-1vl6)
# gcc-java (4.4.3-9vl6)
# java-1.5.0-gcj (1.5.0.0-36vl6)
# java-1.5.0-gcj-devel (1.5.0.0-36vl6)
# libgcj (4.4.3-9vl6)
# libgcj-devel (4.4.3-9vl6)
# libgcj-src (4.4.3-9vl6)
# xerces-j2 (2.9.0-5vl6)

%if %{gcj_support}
BuildRequires: java-1.5.0-gcj-devel
Requires(post): java-1.5.0-gcj
Requires(postun): java-1.5.0-gcj
%endif

Requires(post): jpackage-utils >= 0:1.7.2
Requires(postun): jpackage-utils >= 0:1.7.2
Buildroot: %{_tmppath}/%{name}-%{version}-root
Obsoletes: postgresql7-jdbc
Conflicts: postgresql8-jdbc
Conflicts: postgresql-jdbc < %{jdbcver}

%description
PostgreSQL is an advanced Object-Relational database management
system. The postgresql-jdbc package includes the .jar file needed for
Java programs to access a PostgreSQL database.


%prep
#%setup -q -n postgresql-jdbc-%{jdbcver}-%{jdbcrel}.src
%setup -c -q
mv -f %{name}-%{jdbcver}-%{jdbcrel}.src/* .
rm -f %{name}-%{jdbcver}-%{jdbcrel}.src/.cvsignore
rmdir %{name}-%{jdbcver}-%{jdbcrel}.src


%build
export OPT_JAR_LIST="ant/ant-junit junit"
export CLASSPATH=

# Ideally we would run "sh update-translations.sh" here, but that results
# in inserting the build timestamp into the generated messages_*.class
# files, which makes rpmdiff complain about multilib conflicts if the
# different platforms don't build in the same minute.  For now, rely on
# upstream to have updated the translations files before packaging.

ant


%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_javadir}
# Per jpp conventions, jars have version-numbered names and we add
# versionless symlinks.
install -m 644 jars/postgresql.jar $RPM_BUILD_ROOT%{_javadir}/%{name}-%{version}.jar

pushd $RPM_BUILD_ROOT%{_javadir}
ln -s %{name}-%{version}.jar %{name}.jar
# Also, for backwards compatibility with our old postgresql-jdbc packages,
# add these symlinks.  (Probably only the jdbc3 symlink really makes sense?)
ln -s postgresql-jdbc.jar postgresql-jdbc2.jar
ln -s postgresql-jdbc.jar postgresql-jdbc2ee.jar
ln -s postgresql-jdbc.jar postgresql-jdbc3.jar
popd

%if %{gcj_support}
%{_bindir}/aot-compile-rpm
%endif

# Install the pom after inserting the correct version number
sed 's/UPSTREAM_VERSION/%{upstreamver}/g' %{SOURCE1} >JPP-postgresql-jdbc.pom
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/maven2/poms/
install -m 644 JPP-postgresql-jdbc.pom $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP-postgresql-jdbc.pom
%add_to_maven_depmap postgresql postgresql %{version} JPP postgresql-jdbc


### Java/JDBC
### The user will have to set a CLASSPATH to find it here, but not sure where else to put it...
### JDBC jars 
##install -m 755 %{SOURCE10} $RPM_BUILD_ROOT%{_datadir}/pgsql
##install -m 755 %{SOURCE11} $RPM_BUILD_ROOT%{_datadir}/pgsql
##install -m 755 %{SOURCE12} $RPM_BUILD_ROOT%{_datadir}/pgsql
##install -m 755 %{SOURCE13} $RPM_BUILD_ROOT%{_datadir}/pgsql

%{_bindir}/aot-compile-rpm

%post
%update_maven_depmap
%if %{gcj_support}
  if [ -x %{_bindir}/rebuild-gcj-db ]
  then
    %{_bindir}/rebuild-gcj-db
  fi
%endif

%postun
%update_maven_depmap
%if %{gcj_support}
  if [ -x %{_bindir}/rebuild-gcj-db ]
  then
    %{_bindir}/rebuild-gcj-db
  fi
%endif


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%{_sysconfdir}/maven/fragments/postgresql-jdbc
%{_libdir}/gcj/postgresql-jdbc/postgresql-jdbc-9.0.801.jar.db
%{_libdir}/gcj/postgresql-jdbc/postgresql-jdbc-9.0.801.jar.so
%{_datadir}/java/postgresql-jdbc-9.0.801.jar
%{_datadir}/java/postgresql-jdbc.jar
%{_datadir}/java/postgresql-jdbc2.jar
%{_datadir}/java/postgresql-jdbc2ee.jar
%{_datadir}/java/postgresql-jdbc3.jar
%{_datadir}/maven2/poms/JPP-postgresql-jdbc.pom

%changelog
* Mon Apr 11 2011 Shu KONNO <owa@bg.wakwak.com> 9.0-801-1vl6
- initial build for VineSeed

* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 9.0.801-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Wed Dec 29 2010 Tom Lane <tgl@redhat.com> 9.0.801-1
- Update to build 9.0-801

* Mon May 31 2010 Tom Lane <tgl@redhat.com> 8.4.701-4
- Update gcj_support sections to meet Packaging/GCJGuidelines;
  fixes FTBFS in F-14 rawhide

* Tue Nov 24 2009 Tom Lane <tgl@redhat.com> 8.4.701-3
- Seems the .pom file *must* have a package version number in it, sigh
Resolves: #538487

* Mon Nov 23 2009 Tom Lane <tgl@redhat.com> 8.4.701-2
- Add a .pom file to ease use by maven-based packages (courtesy Deepak Bhole)
Resolves: #538487

* Tue Aug 18 2009 Tom Lane <tgl@redhat.com> 8.4.701-1
- Update to build 8.4-701

* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0:8.3.603-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Tue Apr 21 2009 Tom Lane <tgl@redhat.com> 8.3.603-3
- Avoid multilib conflict caused by overeager attempt to rebuild translations

* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0:8.3.603-2.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Wed Jul  9 2008 Tom "spot" Callaway <tcallawa@redhat.com> 8.3.603-1.1
- drop repotag

* Tue Feb 12 2008 Tom Lane <tgl@redhat.com> 8.3.603-1jpp
- Update to build 8.3-603

* Sun Aug 12 2007 Tom Lane <tgl@redhat.com> 8.2.506-1jpp
- Update to build 8.2-506

* Tue Apr 24 2007 Tom Lane <tgl@redhat.com> 8.2.505-1jpp
- Update to build 8.2-505
- Work around 1.4 vs 1.5 versioning inconsistency

* Fri Dec 15 2006 Tom Lane <tgl@redhat.com> 8.2.504-1jpp
- Update to build 8.2-504

* Wed Aug 16 2006 Tom Lane <tgl@redhat.com> 8.1.407-1jpp.4
- Fix Requires: for rebuild-gcj-db (bz #202544)

* Wed Aug 16 2006 Fernando Nasser <fnasser@redhat.com> 8.1.407-1jpp.3
- Merge with upstream

* Sat Jul 22 2006 Jakub Jelinek <jakub@redhat.com> 8.1.407-1jpp.2
- Rebuilt

* Wed Jul 12 2006 Jesse Keating <jkeating@redhat.com> - 0:8.1.407-1jpp.1
- rebuild

* Wed Jun 14 2006 Tom Lane <tgl@redhat.com> 8.1.407-1jpp
- Update to build 8.1-407

* Mon Mar 27 2006 Tom Lane <tgl@redhat.com> 8.1.405-2jpp
- Back-patch upstream fix to support unspecified-type strings.

* Thu Feb 16 2006 Tom Lane <tgl@redhat.com> 8.1.405-1jpp
- Split postgresql-jdbc into its own SRPM (at last).
- Build it from source.  Add support for gcj compilation.
