sqlite.spec 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. ##
  2. ## sqlite.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package version
  24. %define V_sqlite 3.5.4
  25. %define V_odbc 0.77
  26. %define V_jdbc 20080130
  27. # package information
  28. Name: sqlite
  29. Summary: SQL Lite
  30. URL: http://www.sqlite.org/
  31. Vendor: D. Richard Hipp
  32. Packager: OpenPKG Foundation e.V.
  33. Distribution: OpenPKG Community
  34. Class: BASE
  35. Group: Database
  36. License: PD
  37. Version: %{V_sqlite}
  38. Release: 20080130
  39. # package options
  40. %option with_assert no
  41. %option with_readline no
  42. %option with_threads no
  43. %option with_fts1 no
  44. %option with_fts2 no
  45. %option with_fts3 no
  46. %option with_odbc no
  47. %option with_jdbc no
  48. # list of sources
  49. Source0: http://www.sqlite.org/sqlite-%{V_sqlite}.tar.gz
  50. Source1: http://www.ch-werner.de/sqliteodbc/sqliteodbc-%{V_odbc}.tar.gz
  51. Source2: http://www.ch-werner.de/javasqlite/javasqlite-%{V_jdbc}.tar.gz
  52. Patch0: sqlite.patch
  53. Patch1: sqlite.patch.odbc
  54. # build information
  55. Prefix: %{l_prefix}
  56. BuildRoot: %{l_buildroot}
  57. BuildPreReq: OpenPKG, openpkg >= 20040130, make, gawk
  58. PreReq: OpenPKG, openpkg >= 20040130
  59. %if "%{with_readline}" == "yes"
  60. BuildPreReq: readline, pkgconfig
  61. PreReq: readline
  62. %endif
  63. %if "%{with_odbc}" == "yes"
  64. BuildPreReq: ODBC
  65. PreReq: ODBC
  66. %endif
  67. %if "%{with_jdbc}" == "yes"
  68. BuildPreReq: java, JAVA-JDK
  69. PreReq: java, JAVA-JDK
  70. %endif
  71. AutoReq: no
  72. AutoReqProv: no
  73. %description
  74. SQLite is a C library that implements an embeddable SQL database
  75. engine. Programs that link with the SQLite library can have SQL
  76. database access without running a separate RDBMS process. The
  77. distribution comes with a standalone command-line access program
  78. (sqlite) that can be used to administer an SQLite database and which
  79. serves as an example of how to use the SQLite library. SQLite is not
  80. a client library used to connect to a big database server. SQLite is
  81. the server. The SQLite library reads and writes directly to and from
  82. the database files on disk.
  83. %track
  84. prog sqlite = {
  85. version = %{V_sqlite}
  86. url = http://www.sqlite.org/download.html
  87. regex = sqlite-(\d+\.\d+\.\d+)\.tar\.gz
  88. }
  89. prog sqlite:odbc = {
  90. version = %{V_odbc}
  91. url = http://www.ch-werner.de/sqliteodbc/
  92. regex = sqliteodbc-(__VER__)\.tar\.gz
  93. }
  94. prog sqlite:jdbc = {
  95. version = %{V_jdbc}
  96. url = http://www.ch-werner.de/javasqlite/overview-summary.html
  97. regex = javasqlite-(\d+)\.tar\.gz
  98. }
  99. %prep
  100. %setup -q
  101. %patch -p0 -P 0
  102. %if "%{with_odbc}" == "yes"
  103. %setup -q -D -T -a 1
  104. %patch -p0 -d sqliteodbc-%{V_odbc} -P 1
  105. %endif
  106. %if "%{with_jdbc}" == "yes"
  107. %setup -q -D -T -a 2
  108. %endif
  109. # post-adjust sources
  110. %{l_shtool} subst \
  111. -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
  112. configure
  113. %build
  114. # configure and build SQLite
  115. CC="%{l_cc}"
  116. CFLAGS="%{l_cflags -O}"
  117. %if "%{with_assert}" == "no"
  118. CFLAGS="$CFLAGS -DNDEBUG=1"
  119. %endif
  120. CPPFLAGS="%{l_cppflags}"
  121. LDFLAGS="%{l_ldflags}"
  122. LIBS="-lm"
  123. export CC
  124. export CPPFLAGS
  125. export CFLAGS
  126. export LDFLAGS
  127. export LIBS
  128. GREP="grep" \
  129. ./configure \
  130. --prefix=%{l_prefix} \
  131. %if "%{with_threads}" == "yes"
  132. --enable-threadsafe \
  133. %else
  134. --disable-threadsafe \
  135. %endif
  136. %if "%{with_readline}" == "yes"
  137. --enable-readline \
  138. --with-readline-lib="`%{l_prefix}/bin/pkg-config --libs readline`" \
  139. --with-readline-inc="`%{l_prefix}/bin/pkg-config --cflags readline`" \
  140. %else
  141. --disable-readline \
  142. %endif
  143. --disable-shared
  144. %if "%{with_assert}" == "yes"
  145. %{l_shtool} subst \
  146. -e 's;-DNDEBUG;;' \
  147. Makefile
  148. %endif
  149. MFLAGS=""
  150. %if "%{with_fts1}" == "yes"
  151. MFLAGS="$MFLAGS FTS1=1"
  152. %endif
  153. %if "%{with_fts2}" == "yes"
  154. MFLAGS="$MFLAGS FTS2=1"
  155. %endif
  156. %{l_make} %{l_mflags -O} $MFLAGS
  157. # optionally build ODBC driver
  158. %if "%{with_odbc}" == "yes"
  159. ( cd sqliteodbc-%{V_odbc}
  160. export CC="%{l_cc}"
  161. export CFLAGS="%{l_cflags -O}"
  162. export CPPFLAGS=""
  163. export LDFLAGS=""
  164. CPPFLAGS="$CPPFLAGS -I.."
  165. LDFLAGS="$LDFLAGS -L../.libs"
  166. ./configure \
  167. --prefix=%{l_prefix} \
  168. --with-sqlite3=.. \
  169. --with-odbc=%{l_prefix} \
  170. --disable-static \
  171. --enable-shared
  172. %{l_make} %{l_mflags -O}
  173. ) || exit $?
  174. %endif
  175. # optionally build JDBC driver
  176. %if "%{with_jdbc}" == "yes"
  177. ( cd javasqlite-%{V_jdbc}
  178. export JAVA_PLATFORM="sun-jdk"
  179. eval `%{l_prefix}/bin/java-toolkit -e`
  180. export CC="%{l_cc}"
  181. export CFLAGS="%{l_cflags -O}"
  182. export CPPFLAGS=""
  183. export LDFLAGS=""
  184. CPPFLAGS="$CPPFLAGS -I.."
  185. LDFLAGS="$LDFLAGS -L../.libs"
  186. ./configure \
  187. --prefix=%{l_prefix} \
  188. --with-jardir=%{l_prefix}/lib \
  189. --with-jdk=$JAVA_HOME \
  190. --with-sqlite3=..
  191. %{l_make} %{l_mflags}
  192. ) || exit $?
  193. %endif
  194. %install
  195. # create installation hierarchy
  196. rm -rf $RPM_BUILD_ROOT
  197. %{l_shtool} mkdir -f -p -m 755 \
  198. $RPM_BUILD_ROOT%{l_prefix}/bin \
  199. $RPM_BUILD_ROOT%{l_prefix}/lib \
  200. $RPM_BUILD_ROOT%{l_prefix}/include \
  201. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  202. # install SQLite
  203. %{l_make} %{l_mflags} install \
  204. prefix=$RPM_BUILD_ROOT%{l_prefix}
  205. %{l_shtool} install -c -m 644 \
  206. sqlite3.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1
  207. # install SQLite ODBC driver (optional)
  208. %if "%{with_odbc}" == "yes"
  209. ( cd sqliteodbc-%{V_odbc}
  210. %{l_make} %{l_mflags} install \
  211. prefix=$RPM_BUILD_ROOT%{l_prefix}
  212. ) || exit $?
  213. %endif
  214. # install SQLite JDBC driver (optional)
  215. %if "%{with_jdbc}" == "yes"
  216. ( cd javasqlite-%{V_jdbc}
  217. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  218. ) || exit $?
  219. %endif
  220. # strip down installation files
  221. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  222. # provide convenient symlinks
  223. ln $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite3 \
  224. $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite
  225. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1 \
  226. $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite.1
  227. # determine installation files
  228. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  229. %{l_files_std}
  230. %files -f files
  231. %clean
  232. rm -rf $RPM_BUILD_ROOT
  233. %post
  234. if [ $1 -eq 1 ]; then : ;
  235. # optionally link into ODBC
  236. %if "%{with_odbc}" == "yes"
  237. ( echo "[SQLite3]"
  238. echo "Description = SQLite 3 ODBC Driver"
  239. echo "Driver = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  240. echo "Setup = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  241. echo "FileUsage = 1"
  242. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -n "SQLite3" -r >/dev/null 2>&1 || true
  243. ( echo "[SQLite3 DataSource]"
  244. echo "Driver = SQLite3"
  245. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "SQLite3 DataSource" -r >/dev/null 2>&1 || true
  246. %endif
  247. fi
  248. %preun
  249. if [ $1 -eq 1 ]; then : ;
  250. # optionally unlink from ODBC
  251. %if "%{with_odbc}" == "yes"
  252. $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "SQLite3 DataSource" >/dev/null 2>&1 || true
  253. $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "SQLite3" >/dev/null 2>&1 || true
  254. %endif
  255. fi