sqlite.spec 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.6.9
  25. %define V_odbc 0.79
  26. %define V_jdbc 20081006
  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: 20090115
  39. # package options
  40. %option with_debug no
  41. %option with_readline no
  42. %option with_threads no
  43. %option with_fts3 no
  44. %option with_rtree no
  45. %option with_odbc no
  46. %option with_jdbc no
  47. # list of sources
  48. Source0: http://www.sqlite.org/sqlite-%{V_sqlite}.tar.gz
  49. Source1: http://www.ch-werner.de/sqliteodbc/sqliteodbc-%{V_odbc}.tar.gz
  50. Source2: http://www.ch-werner.de/javasqlite/javasqlite-%{V_jdbc}.tar.gz
  51. Patch0: sqlite.patch
  52. Patch1: sqlite.patch.odbc
  53. # build information
  54. Prefix: %{l_prefix}
  55. BuildRoot: %{l_buildroot}
  56. BuildPreReq: OpenPKG, openpkg >= 20040130, make, gawk
  57. PreReq: OpenPKG, openpkg >= 20040130
  58. %if "%{with_readline}" == "yes"
  59. BuildPreReq: readline, pkgconfig
  60. PreReq: readline
  61. %endif
  62. %if "%{with_odbc}" == "yes"
  63. BuildPreReq: ODBC
  64. PreReq: ODBC
  65. %endif
  66. %if "%{with_jdbc}" == "yes"
  67. BuildPreReq: java, JAVA-JDK
  68. PreReq: java, JAVA-JDK
  69. %endif
  70. AutoReq: no
  71. AutoReqProv: no
  72. %description
  73. SQLite is a C library that implements an embeddable SQL database
  74. engine. Programs that link with the SQLite library can have SQL
  75. database access without running a separate RDBMS process. The
  76. distribution comes with a standalone command-line access program
  77. (sqlite) that can be used to administer an SQLite database and which
  78. serves as an example of how to use the SQLite library. SQLite is not
  79. a client library used to connect to a big database server. SQLite is
  80. the server. The SQLite library reads and writes directly to and from
  81. the database files on disk.
  82. %track
  83. prog sqlite = {
  84. version = %{V_sqlite}
  85. url = http://www.sqlite.org/download.html
  86. regex = sqlite-(\d+\.\d+\.\d+(?:\.\d+)?)\.tar\.gz
  87. }
  88. prog sqlite:odbc = {
  89. version = %{V_odbc}
  90. url = http://www.ch-werner.de/sqliteodbc/
  91. regex = sqliteodbc-(__VER__)\.tar\.gz
  92. }
  93. prog sqlite:jdbc = {
  94. version = %{V_jdbc}
  95. url = http://www.ch-werner.de/javasqlite/overview-summary.html
  96. regex = javasqlite-(\d+)\.tar\.gz
  97. }
  98. %prep
  99. %setup -q
  100. %patch -p0 -P 0
  101. %if "%{with_odbc}" == "yes"
  102. %setup -q -D -T -a 1
  103. %patch -p0 -d sqliteodbc-%{V_odbc} -P 1
  104. %endif
  105. %if "%{with_jdbc}" == "yes"
  106. %setup -q -D -T -a 2
  107. %endif
  108. # post-adjust sources
  109. %{l_shtool} subst \
  110. -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
  111. configure
  112. %build
  113. # configure and build SQLite
  114. CC="%{l_cc}"
  115. CFLAGS="%{l_cflags -O}"
  116. CPPFLAGS="-I. %{l_cppflags}"
  117. LDFLAGS="%{l_ldflags}"
  118. LIBS="-lm"
  119. export CC
  120. export CPPFLAGS
  121. export CFLAGS
  122. export LDFLAGS
  123. export LIBS
  124. GREP="grep" \
  125. ./configure \
  126. --prefix=%{l_prefix} \
  127. %if "%{with_threads}" == "yes"
  128. --enable-threadsafe \
  129. %else
  130. --disable-threadsafe \
  131. %endif
  132. %if "%{with_readline}" == "yes"
  133. --enable-readline \
  134. --with-readline-lib="`%{l_prefix}/bin/pkg-config --libs readline`" \
  135. --with-readline-inc="`%{l_prefix}/bin/pkg-config --cflags readline`" \
  136. %else
  137. --disable-readline \
  138. %endif
  139. %if "%{with_debug}" == "yes"
  140. --enable-debug \
  141. %else
  142. --disable-debug \
  143. %endif
  144. --disable-tcl \
  145. --disable-amalgamation \
  146. --disable-shared
  147. MFLAGS=""
  148. %if "%{with_fts3}" == "yes"
  149. MFLAGS="$MFLAGS FTS3=1"
  150. %endif
  151. %if "%{with_rtree}" == "yes"
  152. MFLAGS="$MFLAGS RTREE=1"
  153. %endif
  154. %{l_make} %{l_mflags -O} $MFLAGS
  155. # optionally build ODBC driver
  156. %if "%{with_odbc}" == "yes"
  157. ( cd sqliteodbc-%{V_odbc}
  158. export CC="%{l_cc}"
  159. export CFLAGS="%{l_cflags -O}"
  160. export CPPFLAGS=""
  161. export LDFLAGS=""
  162. CPPFLAGS="$CPPFLAGS -I.."
  163. LDFLAGS="$LDFLAGS -L../.libs"
  164. ./configure \
  165. --prefix=%{l_prefix} \
  166. --with-sqlite3=.. \
  167. --with-odbc=%{l_prefix} \
  168. --disable-static \
  169. --enable-shared
  170. %{l_make} %{l_mflags -O}
  171. ) || exit $?
  172. %endif
  173. # optionally build JDBC driver
  174. %if "%{with_jdbc}" == "yes"
  175. ( cd javasqlite-%{V_jdbc}
  176. export JAVA_PLATFORM="sun-jdk"
  177. eval `%{l_prefix}/bin/java-toolkit -e`
  178. export CC="%{l_cc}"
  179. export CFLAGS="%{l_cflags -O}"
  180. export CPPFLAGS=""
  181. export LDFLAGS=""
  182. CPPFLAGS="$CPPFLAGS -I.."
  183. LDFLAGS="$LDFLAGS -L../.libs"
  184. ./configure \
  185. --prefix=%{l_prefix} \
  186. --with-jardir=%{l_prefix}/lib \
  187. --with-jdk=$JAVA_HOME \
  188. --with-sqlite3=..
  189. %{l_make} %{l_mflags}
  190. ) || exit $?
  191. %endif
  192. %install
  193. # create installation hierarchy
  194. rm -rf $RPM_BUILD_ROOT
  195. %{l_shtool} mkdir -f -p -m 755 \
  196. $RPM_BUILD_ROOT%{l_prefix}/bin \
  197. $RPM_BUILD_ROOT%{l_prefix}/lib \
  198. $RPM_BUILD_ROOT%{l_prefix}/include \
  199. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  200. # install SQLite
  201. %{l_make} %{l_mflags} install \
  202. prefix=$RPM_BUILD_ROOT%{l_prefix}
  203. %{l_shtool} install -c -m 644 \
  204. sqlite3.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1
  205. # install SQLite ODBC driver (optional)
  206. %if "%{with_odbc}" == "yes"
  207. ( cd sqliteodbc-%{V_odbc}
  208. %{l_make} %{l_mflags} install \
  209. prefix=$RPM_BUILD_ROOT%{l_prefix}
  210. ) || exit $?
  211. %endif
  212. # install SQLite JDBC driver (optional)
  213. %if "%{with_jdbc}" == "yes"
  214. ( cd javasqlite-%{V_jdbc}
  215. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  216. ) || exit $?
  217. %endif
  218. # strip down installation files
  219. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  220. # provide convenient symlinks
  221. ln $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite3 \
  222. $RPM_BUILD_ROOT%{l_prefix}/bin/sqlite
  223. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite3.1 \
  224. $RPM_BUILD_ROOT%{l_prefix}/man/man1/sqlite.1
  225. # determine installation files
  226. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  227. %{l_files_std}
  228. %files -f files
  229. %clean
  230. rm -rf $RPM_BUILD_ROOT
  231. %post
  232. # optionally link into ODBC
  233. %if "%{with_odbc}" == "yes"
  234. if ! $RPM_INSTALL_PREFIX/bin/odbcinst -q -d -n "SQLite3" >/dev/null 2>&1; then
  235. ( echo "[SQLite3]"
  236. echo "Description = SQLite 3 ODBC Driver"
  237. echo "Driver = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  238. echo "Setup = $RPM_INSTALL_PREFIX/lib/libsqlite3odbc.so"
  239. echo "FileUsage = 1"
  240. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -n "SQLite3" -r >/dev/null 2>&1 || true
  241. fi
  242. %endif
  243. %preun
  244. if [ $1 -eq 1 ]; then : ;
  245. # optionally unlink from ODBC
  246. %if "%{with_odbc}" == "yes"
  247. $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "SQLite3 DataSource" >/dev/null 2>&1 || true
  248. %endif
  249. fi