sqlite.spec 9.3 KB

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