Browse Source

merge patches, add comments and add optional ODBC support

Ralf S. Engelschall 19 years ago
parent
commit
677b23568f
3 changed files with 160 additions and 58 deletions
  1. 54 27
      sqlite/sqlite.patch
  2. 0 15
      sqlite/sqlite.patch.v2
  3. 106 16
      sqlite/sqlite.spec

+ 54 - 27
sqlite/sqlite.patch

@@ -1,30 +1,21 @@
-Index: configure
---- configure.orig	2005-12-19 18:30:55 +0100
-+++ configure	2006-01-11 11:50:03 +0100
-@@ -20255,6 +20255,10 @@
+Index: sqlite-2.8.17/configure
+--- sqlite-2.8.17/configure.orig	2005-04-24 00:43:23 +0200
++++ sqlite-2.8.17/configure	2006-12-18 09:51:03 +0100
+@@ -20450,7 +20450,10 @@
    TARGET_HAVE_READLINE=0
  fi
  
+-
 +if [ "$ac_cv_lib_readline_readline" = "no" ]
 +then
 +    TARGET_HAVE_READLINE=0
 +fi
  
- 
  #########
-Index: sqlite3.pc.in
---- sqlite3.pc.in.orig	2004-07-19 06:25:47 +0200
-+++ sqlite3.pc.in	2006-06-10 12:36:25 +0200
-@@ -8,5 +8,5 @@
- Name: SQLite
- Description: SQL database engine
- Version: @VERSION@
--Libs: -L${libdir} -lsqlite3
-+Libs: -L${libdir} -lsqlite3 @TARGET_LIBS@
- Cflags: -I${includedir}
-Index: Makefile.in
---- Makefile.in.orig	2006-10-03 14:40:42 +0200
-+++ Makefile.in	2006-12-18 09:11:09 +0100
+ # Figure out whether or not we have a "usleep()" function.
+Index: sqlite-3.3.8/Makefile.in
+--- sqlite-3.3.8/Makefile.in.orig	2006-10-03 14:40:42 +0200
++++ sqlite-3.3.8/Makefile.in	2006-12-18 09:51:03 +0100
 @@ -132,6 +132,12 @@
           vdbe.lo vdbeapi.lo vdbeaux.lo vdbefifo.lo vdbemem.lo \
           where.lo utf.lo legacy.lo vtab.lo
@@ -53,9 +44,23 @@ Index: Makefile.in
  
  fulltest:	testfixture$(TEXE) sqlite3$(TEXE)
  	./testfixture $(TOP)/test/all.test
-Index: ext/fts1/fts1.c
---- ext/fts1/fts1.c.orig	2006-10-08 13:16:32 +0200
-+++ ext/fts1/fts1.c	2006-12-18 09:04:08 +0100
+Index: sqlite-3.3.8/configure
+--- sqlite-3.3.8/configure.orig	2006-10-03 14:42:27 +0200
++++ sqlite-3.3.8/configure	2006-12-18 09:51:03 +0100
+@@ -20472,6 +20472,10 @@
+   TARGET_HAVE_READLINE=0
+ fi
+ 
++if [ "$ac_cv_lib_readline_readline" = "no" ]
++then
++    TARGET_HAVE_READLINE=0
++fi
+ 
+ 
+ #########
+Index: sqlite-3.3.8/ext/fts1/fts1.c
+--- sqlite-3.3.8/ext/fts1/fts1.c.orig	2006-10-08 13:16:32 +0200
++++ sqlite-3.3.8/ext/fts1/fts1.c	2006-12-18 09:51:03 +0100
 @@ -19,11 +19,7 @@
  #endif
  
@@ -68,9 +73,9 @@ Index: ext/fts1/fts1.c
  #include <stdio.h>
  #include <string.h>
  #include <ctype.h>
-Index: ext/fts1/fts1_porter.c
---- ext/fts1/fts1_porter.c.orig	2006-10-01 20:01:13 +0200
-+++ ext/fts1/fts1_porter.c	2006-12-18 09:04:19 +0100
+Index: sqlite-3.3.8/ext/fts1/fts1_porter.c
+--- sqlite-3.3.8/ext/fts1/fts1_porter.c.orig	2006-10-01 20:01:13 +0200
++++ sqlite-3.3.8/ext/fts1/fts1_porter.c	2006-12-18 09:51:03 +0100
 @@ -26,11 +26,7 @@
  
  
@@ -83,9 +88,9 @@ Index: ext/fts1/fts1_porter.c
  #include <stdio.h>
  #include <string.h>
  #include <ctype.h>
-Index: ext/fts1/fts1_tokenizer1.c
---- ext/fts1/fts1_tokenizer1.c.orig	2006-09-30 15:57:33 +0200
-+++ ext/fts1/fts1_tokenizer1.c	2006-12-18 09:04:31 +0100
+Index: sqlite-3.3.8/ext/fts1/fts1_tokenizer1.c
+--- sqlite-3.3.8/ext/fts1/fts1_tokenizer1.c.orig	2006-09-30 15:57:33 +0200
++++ sqlite-3.3.8/ext/fts1/fts1_tokenizer1.c	2006-12-18 09:51:03 +0100
 @@ -18,11 +18,7 @@
  
  
@@ -98,3 +103,25 @@ Index: ext/fts1/fts1_tokenizer1.c
  #include <stdio.h>
  #include <string.h>
  #include <ctype.h>
+Index: sqlite-3.3.8/sqlite3.pc.in
+--- sqlite-3.3.8/sqlite3.pc.in.orig	2004-07-19 06:25:47 +0200
++++ sqlite-3.3.8/sqlite3.pc.in	2006-12-18 09:51:03 +0100
+@@ -8,5 +8,5 @@
+ Name: SQLite
+ Description: SQL database engine
+ Version: @VERSION@
+-Libs: -L${libdir} -lsqlite3
++Libs: -L${libdir} -lsqlite3 @TARGET_LIBS@
+ Cflags: -I${includedir}
+Index: sqliteodbc-0.69/Makefile.in
+--- sqliteodbc-0.69/Makefile.in.orig	2006-07-03 07:51:27 +0200
++++ sqliteodbc-0.69/Makefile.in	2006-12-18 09:51:12 +0100
+@@ -6,7 +6,7 @@
+ CC =		@CC@
+ INSTALL =	@INSTALL@
+ LIBTOOL =	./libtool
+-CFLAGS=		@CFLAGS@ -DDRIVER_VER_INFO=\"@VER_INFO@\"
++CFLAGS=		@CFLAGS@ @CPPFLAGS@ -DDRIVER_VER_INFO=\"@VER_INFO@\"
+ SQLITE_INC =	@SQLITE_INC@
+ SQLITE_LIB =	@SQLITE_LIB@
+ SQLITE_FLAGS =	-DHAVE_LIBVERSION=@SQLITE_LIBVERSION@ \

+ 0 - 15
sqlite/sqlite.patch.v2

@@ -1,15 +0,0 @@
-Index: configure
---- configure.orig	2004-06-03 13:36:27.000000000 +0200
-+++ configure	2004-06-03 13:39:37.000000000 +0200
-@@ -20447,7 +20447,10 @@
-   TARGET_HAVE_READLINE=0
- fi
- 
--
-+if [ "$ac_cv_lib_readline_readline" = "no" ]
-+then
-+    TARGET_HAVE_READLINE=0
-+fi
- 
- #########
- # Figure out whether or not we have a "usleep()" function.

+ 106 - 16
sqlite/sqlite.spec

@@ -23,8 +23,9 @@
 ##
 
 #   package version
-%define       V_v3  3.3.8
-%define       V_v2  2.8.17
+%define       V_v3   3.3.8
+%define       V_v2   2.8.17
+%define       V_odbc 0.69
 
 #   package information
 Name:         sqlite
@@ -45,12 +46,13 @@ Release:      20061218
 %option       with_assert          no
 %option       with_readline        no
 %option       with_fts1            no
+%option       with_odbc            no
 
 #   list of sources
 Source0:      http://www.sqlite.org/sqlite-%{V_v3}.tar.gz
 Source1:      http://www.sqlite.org/sqlite-%{V_v2}.tar.gz
+Source2:      http://www.ch-werner.de/sqliteodbc/sqliteodbc-%{V_odbc}.tar.gz
 Patch0:       sqlite.patch
-Patch1:       sqlite.patch.v2
 
 #   build information
 Prefix:       %{l_prefix}
@@ -61,6 +63,10 @@ PreReq:       OpenPKG, openpkg >= 20040130
 BuildPreReq:  readline, pkgconfig
 PreReq:       readline
 %endif
+%if "%{with_odbc}" == "yes"
+BuildPreReq:  ODBC
+PreReq:       ODBC
+%endif
 AutoReq:      no
 AutoReqProv:  no
 
@@ -78,6 +84,7 @@ AutoReqProv:  no
     This package contains both SQLite 3 (%{V_v3}) and optionally the old
     SQLite 2 (%{V_v2}). Notice that the two are API and database format
     incompatible but can be used in parallel (on different databases).
+    Additionally, this package optionally provides the SQLite ODBC driver.
 
 %track
     prog sqlite = {
@@ -92,26 +99,26 @@ AutoReqProv:  no
         url       = http://www.sqlite.org/download.html
         regex     = sqlite-(2\.\d+\.\d+)\.tar\.gz
     }
+    prog sqlite:odbc = {
+        version   = %{V_odbc}
+        url       = http://www.ch-werner.de/sqliteodbc/
+        regex     = sqliteodbc-(__VER__)\.tar\.gz
+    }
 
 %prep
     %setup -q -c
     %setup -q -D -T -a 1
-    %patch -p0 -d sqlite-%{V_v3} -P 0
-%if "%{with_v2}" == "yes"
-    %patch -p0 -d sqlite-%{V_v2} -P 1
-%endif
+    %setup -q -D -T -a 2
+    %patch -p0
+
+    #   post-adjust sources
     chmod a+x sqlite-%{V_v2}/install-sh
-    for v in %{V_v3} \
-%if "%{with_v2}" == "yes"
-        %{V_v2} \
-%endif
-    ; do
-        %{l_shtool} subst \
-            -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
-            sqlite-$v/configure
-    done
+    %{l_shtool} subst \
+        -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
+        sqlite-%{V_v3}/configure sqlite-%{V_v2}/configure
 
 %build
+    #   configure and build SQLite 3 and optionally SQLite 2
     for v in %{V_v3} \
 %if "%{with_v2}" == "yes"
         %{V_v2} \
@@ -158,19 +165,50 @@ AutoReqProv:  no
         ) || exit $?
     done
 
+    #   optionally build ODBC driver
+%if "%{with_odbc}" == "yes"
+    ( cd sqliteodbc-%{V_odbc}
+      export CC="%{l_cc}"
+      export CFLAGS="%{l_cflags -O}"
+      export CPPFLAGS=""
+      export LDFLAGS=""
+      CPPFLAGS="$CPPFLAGS -I../sqlite-%{V_v3}"
+      LDFLAGS="$LDFLAGS -L../sqlite-%{V_v3}/.libs"
+%if "%{with_v2}" == "yes"
+      CPPFLAGS="$CPPFLAGS -I../sqlite-%{V_v2}"
+      LDFLAGS="$LDFLAGS -L../sqlite-%{V_v2}/.libs"
+%endif
+      ./configure \
+          --prefix=%{l_prefix} \
+          --with-sqlite3=../sqlite-%{V_v3} \
+%if "%{with_v2}" == "yes"
+          --with-sqlite=../sqlite-%{V_v2} \
+%endif
+          --with-odbc=%{l_prefix} \
+          --disable-static \
+          --enable-shared
+          %{l_make} %{l_mflags -O}
+    ) || exit $?
+%endif
+
 %install
+    #   create installation hierarchy
     rm -rf $RPM_BUILD_ROOT
     %{l_shtool} mkdir -f -p -m 755 \
         $RPM_BUILD_ROOT%{l_prefix}/bin \
         $RPM_BUILD_ROOT%{l_prefix}/lib \
         $RPM_BUILD_ROOT%{l_prefix}/include \
         $RPM_BUILD_ROOT%{l_prefix}/man/man1
+
+    #   install SQLite 3
     ( cd sqlite-%{V_v3}
       %{l_make} %{l_mflags} install \
           prefix=$RPM_BUILD_ROOT%{l_prefix}
       %{l_shtool} install -c -m 644 \
           sqlite3.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1
     ) || exit $?
+
+    #   install SQLite 2 (optional)
 %if "%{with_v2}" == "yes"
     ( cd sqlite-%{V_v2}
       %{l_make} %{l_mflags} install \
@@ -179,7 +217,19 @@ AutoReqProv:  no
           sqlite.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite.1
     ) || exit $?
 %endif
+
+    #   install SQLite ODBC driver (optional)
+%if "%{with_odbc}" == "yes"
+    ( cd sqliteodbc-%{V_odbc}
+      %{l_make} %{l_mflags} install \
+          prefix=$RPM_BUILD_ROOT%{l_prefix}
+    ) || exit $?
+%endif
+
+    #   strip down installation files
     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
+
+    #   determine installation files
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
         %{l_files_std} \
         '%not %dir %{l_prefix}/lib/pkgconfig'
@@ -189,3 +239,43 @@ AutoReqProv:  no
 %clean
     rm -rf $RPM_BUILD_ROOT
 
+%post
+    if [ $1 -eq 1 ]; then
+        #   optionally link into ODBC
+%if "%{with_odbc}" == "yes"
+        ( echo "[SQLite3]"
+          echo "Description     = SQLite 3 ODBC Driver"
+          echo "Driver          = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
+          echo "Setup           = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
+          echo "FileUsage       = 1"
+        ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -n "SQLite3" -r >/dev/null 2>&1 || true
+        ( echo "[SQLite3 DataSource]"
+          echo "Driver          = SQLite3"
+        ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "SQLite3 DataSource" -r >/dev/null 2>&1 || true
+%if "%{with_v2}" == "yes"
+        ( echo "[SQLite]"
+          echo "Description     = SQLite 2 ODBC Driver"
+          echo "Driver          = $RPM_INSTALL_PREFIX/lib/libsqliteodbc.so"
+          echo "Setup           = $RPM_INSTALL_PREFIX/lib/libsqliteodbc.so"
+          echo "FileUsage       = 1"
+        ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -n "SQLite" -r >/dev/null 2>&1 || true
+        ( echo "[SQLite DataSource]"
+          echo "Driver          = SQLite"
+        ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "SQLite DataSource" -r >/dev/null 2>&1 || true
+%endif
+%endif
+    fi
+
+%preun
+    if [ $1 -eq 0 ]; then
+        #   optionally unlink from ODBC
+%if "%{with_odbc}" == "yes"
+        $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "SQLite3 DataSource" >/dev/null 2>&1 || true
+        $RPM_INSTALL_PREFIX/bin/odbcinst -u -d    -n "SQLite3"            >/dev/null 2>&1 || true
+%if "%{with_v2}" == "yes"
+        $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "SQLite DataSource"  >/dev/null 2>&1 || true
+        $RPM_INSTALL_PREFIX/bin/odbcinst -u -d    -n "SQLite"             >/dev/null 2>&1 || true
+%endif
+%endif
+    fi
+