sqlite.spec 8.5 KB

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