From a7b2518828327317647eff5a03cd7290bf66a30a Mon Sep 17 00:00:00 2001 From: Oleg Aldekein Date: Mon, 16 Jun 2014 13:38:24 +0300 Subject: [PATCH 01/18] Update config.m4 for PHP 5.5 on AWS --- config.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.m4 b/config.m4 index 74af51d..8f0d50a 100644 --- a/config.m4 +++ b/config.m4 @@ -20,6 +20,8 @@ if test "$PHP_PDO_SQLCIPHER" != "no"; then pdo_inc_path=$prefix/include/php/ext elif test -f $prefix/include/php5/ext/pdo/php_pdo_driver.h; then pdo_inc_path=$prefix/include/php5/ext + elif test -f $prefix/include/php/5.5/php/ext/pdo/php_pdo_driver.h; then + pdo_inc_path=$prefix/include/php/5.5/php/ext else AC_MSG_ERROR([Cannot find php_pdo_driver.h.]) fi From a53b3d7249c2e8bfbf1a27898e1008541d87fff3 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 11 May 2015 07:12:49 +0200 Subject: [PATCH 02/18] create control.in --- package/DEBIAN/control.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 package/DEBIAN/control.in diff --git a/package/DEBIAN/control.in b/package/DEBIAN/control.in new file mode 100644 index 0000000..8f008ab --- /dev/null +++ b/package/DEBIAN/control.in @@ -0,0 +1,12 @@ +Package: php5-sqlcipher +Version: 5.4.4-14 +Architecture: amd64 +Maintainer: Anton Batenev +Installed-Size: 350 +Depends: libc6 (>= 2.13-38), libssl1.0.0 (>=1.0.1e-2), libicu48 (>=4.8.1.1-12), phpapi-20100525, php5-common (= 5.4.4-14) +Section: php +Priority: optional +Homepage: https://github.com/abbat/pdo_sqlcipher +Description: sqlcipher module for PHP 5 + SQLCipher is an SQLite extension that provides transparent + 256-bit AES encryption of database files. From 8e86d65b5876f2153a109ceadcfa95dfa74edbb8 Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 08:17:24 +0200 Subject: [PATCH 03/18] do replace in-file with sed --- package/DEBIAN/control | 4 ++-- package/DEBIAN/control.in | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 package/DEBIAN/control.in diff --git a/package/DEBIAN/control b/package/DEBIAN/control index 8f008ab..90f69c0 100644 --- a/package/DEBIAN/control +++ b/package/DEBIAN/control @@ -1,9 +1,9 @@ Package: php5-sqlcipher -Version: 5.4.4-14 +Version: _PHP_VER Architecture: amd64 Maintainer: Anton Batenev Installed-Size: 350 -Depends: libc6 (>= 2.13-38), libssl1.0.0 (>=1.0.1e-2), libicu48 (>=4.8.1.1-12), phpapi-20100525, php5-common (= 5.4.4-14) +Depends: libc6 (>= 2.13-38), libssl1.0.0 (>=1.0.1e-2), _LIBICU (>=_LIBICU_VER), phpapi-_PHP_API, php5-common (= _PHP_VER) Section: php Priority: optional Homepage: https://github.com/abbat/pdo_sqlcipher diff --git a/package/DEBIAN/control.in b/package/DEBIAN/control.in deleted file mode 100644 index 8f008ab..0000000 --- a/package/DEBIAN/control.in +++ /dev/null @@ -1,12 +0,0 @@ -Package: php5-sqlcipher -Version: 5.4.4-14 -Architecture: amd64 -Maintainer: Anton Batenev -Installed-Size: 350 -Depends: libc6 (>= 2.13-38), libssl1.0.0 (>=1.0.1e-2), libicu48 (>=4.8.1.1-12), phpapi-20100525, php5-common (= 5.4.4-14) -Section: php -Priority: optional -Homepage: https://github.com/abbat/pdo_sqlcipher -Description: sqlcipher module for PHP 5 - SQLCipher is an SQLite extension that provides transparent - 256-bit AES encryption of database files. From ae66aced1f419d407db608a99839e7ce36c39c52 Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 08:20:37 +0200 Subject: [PATCH 04/18] add the all-in-one-go script for a debian package --- build-debian.sh | 310 ++++++++++++++++++++++++++++++++++++++++++++++++ debian.sh | 53 --------- 2 files changed, 310 insertions(+), 53 deletions(-) create mode 100755 build-debian.sh delete mode 100755 debian.sh diff --git a/build-debian.sh b/build-debian.sh new file mode 100755 index 0000000..be79806 --- /dev/null +++ b/build-debian.sh @@ -0,0 +1,310 @@ +#!/bin/sh + +# +# SQLite3 compile options +# + +CFLAGS=" \ + -DSQLITE_HAS_CODEC \ + -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ + -DSQLITE_ENABLE_COLUMN_METADATA \ + -DSQLITE_ENABLE_STAT3 \ + -DSQLITE_ENABLE_RTREE \ + -DSQLITE_ENABLE_FTS3 \ + -DSQLITE_ENABLE_FTS3_PARENTHESIS \ + -DSQLITE_ENABLE_FTS4 \ + -DSQLITE_SECURE_DELETE \ + -DSQLITE_ENABLE_ICU \ + -DSQLITE_SOUNDEX \ + -DSQLITE_DEFAULT_FOREIGN_KEYS=1 \ + -I. -I/usr/local/include" + +LDFLAGS="-lcrypto -licuuc -licui18n -L/usr/local/lib" + + +PHP_CONFIG=$(which php-config) + +if [ "x${PHP_CONFIG}" = "x" ]; then + echo "Error: php-config not found" + exit 1 +fi + +PHP_VER=$(${PHP_CONFIG} --version ) +PHP_API=$(${PHP_CONFIG} --phpapi ) + +if [ "x${PHP_VER}" = "x" ]; then + echo "Error: unknown php version" + exit 1 +fi + +PHP_SRC="$(dpkg-query -W -f='${Version}' php5)" + +if [ ! -f "${PHP_SRC}" ]; then + apt-get source php5 + if [ $? -ne 0 ]; then + # sources.list not defined source packages + echo "Cannot get the php source package, please add a 'source' line to /etc/apt/sources.list" + exit $? + fi +fi + + +# +# Get SQLCipher source code and make SQLite Amalgamation +# + +SQLCIPHER_SRC="sqlcipher.git" + +if [ ! -d "${SQLCIPHER_SRC}" ]; then + git clone "git://github.com/sqlcipher/sqlcipher.git" "${SQLCIPHER_SRC}" + if [ $? -ne 0 ]; then + exit $? + fi +fi + +if [ ! -f "${SQLCIPHER_SRC}/sqlite3.c" ]; then + cd "${SQLCIPHER_SRC}" + + make distclean + + # subject to change (see http://www.sqlite.org/compile.html) + ./configure \ + --disable-shared \ + --enable-tempstore=yes \ + CFLAGS="${CFLAGS}" \ + LDFLAGS="${LDFLAGS}" + if [ $? -ne 0 ]; then + exit $? + fi + + make + if [ $? -ne 0 ]; then + exit $? + fi + + cd .. +fi + +# +# Clone pdo_sqlite sources for pdo_sqlcipher +# + +BUILD_DIR="build" + +if [ -d "${BUILD_DIR}" ]; then + rm -rf "${BUILD_DIR}" + if [ $? -ne 0 ]; then + exit $? + fi +fi + +mkdir -p "${BUILD_DIR}" +if [ $? -ne 0 ]; then + exit $? +fi + +PDO_SQLITE="${PHP_SRC}/ext/pdo_sqlite" + +cp "${PDO_SQLITE}/"*.c "${PDO_SQLITE}"/*.h "${BUILD_DIR}/" +if [ $? -ne 0 ]; then + exit $? +fi + +# magic :) +for FILE in "${BUILD_DIR}"/* +do + cat "${FILE}" | \ + sed -e 's/sqlite/sqlcipher/g' | \ + sed -e 's/SQLite/SQLCipher/g' | \ + sed -e 's/PDO_SQLITE/PDO_SQLCIPHER/g' > \ + "${FILE}.tmp" + if [ $? -ne 0 ]; then + exit $? + fi + + NEW_FILE=$(echo ${FILE} | sed 's/sqlite/sqlcipher/') + + mv "${FILE}.tmp" "${NEW_FILE}" + if [ $? -ne 0 ]; then + exit $? + fi + + if [ "${NEW_FILE}" != "${FILE}" ]; then + rm -f "${FILE}" + if [ $? -ne 0 ]; then + exit $? + fi + fi +done + +# magic for sqlite3 api sources +cp "${SQLCIPHER_SRC}/sqlite3.c" "${BUILD_DIR}/sqlcipher3.c" +if [ $? -ne 0 ]; then + exit $? +fi + +cp "${SQLCIPHER_SRC}/sqlite3.h" "${BUILD_DIR}/sqlcipher3.h" +if [ $? -ne 0 ]; then + exit $? +fi + +for FILE in "${BUILD_DIR}"/sqlcipher3.* +do + sed -ie 's/sqlite3/sqlcipher3/g' "${FILE}" + if [ $? -ne 0 ]; then + exit $? + fi + + sed -rie 's/(".*)sqlcipher3(.*")/\1sqlite3\2/g' "${FILE}" + if [ $? -ne 0 ]; then + exit $? + fi +done + +# +# Build pdo_sqlcipher +# + +cp "config.m4" "${BUILD_DIR}/config.m4" +if [ $? -ne 0 ]; then + exit $? +fi + +cd "${BUILD_DIR}" + +phpize --clean +if [ $? -ne 0 ]; then + exit $? +fi + +phpize +if [ $? -ne 0 ]; then + exit $? +fi + +./configure \ + CFLAGS="${CFLAGS}" \ + LDFLAGS="${LDFLAGS}" +if [ $? -ne 0 ]; then + exit $? +fi + +make +if [ $? -ne 0 ]; then + exit $? +fi + +cd .. + +# +# Copy binaries +# + +RELEASE_DIR="release" + +if [ -d "${RELEASE_DIR}" ]; then + rm -rf "${RELEASE_DIR}" + if [ $? -ne 0 ]; then + exit $? + fi +fi + +mkdir -p "${RELEASE_DIR}" +if [ $? -ne 0 ]; then + exit $? +fi + +# pdo_sqlite.so +cp "${BUILD_DIR}/modules/pdo_sqlcipher.so" "${RELEASE_DIR}/pdo_sqlcipher.so" +if [ $? -ne 0 ]; then + exit $? +fi + +strip "${RELEASE_DIR}/pdo_sqlcipher.so" +if [ $? -ne 0 ]; then + exit $? +fi + +chmod 0644 "${RELEASE_DIR}/pdo_sqlcipher.so" +if [ $? -ne 0 ]; then + exit $? +fi + +# sqlcipher static binary +cp "${SQLCIPHER_SRC}/sqlcipher" "${RELEASE_DIR}/sqlcipher" +if [ $? -ne 0 ]; then + exit $? +fi + +strip "${RELEASE_DIR}/sqlcipher" +if [ $? -ne 0 ]; then + exit $? +fi + +# +# Clean +# + +#rm -rf ${PHP_SRC} +#rm -rf ${SQLCIPHER_SRC} +#rm -rf ${BUILD_DIR} +#rm -f ${PHP_TGZ} + + +## Create the .deb package + +LIBICU="$(dpkg-query -W -f='${Package}\n' libicu* | grep -v '\-') +LIBICU_VER="$(dpkg-query -W -f='${Version}' $LIBICU)" + +sed -i "s/_PHP_VER/$PHP_VER/g;s/_PHP_API/$PHP_API/g;s/_LIBICU/$LIBICU/g;s/_LIBICU_VER/$LIBICU_VER/g" package/DEBIAN/control + +mkdir -p package/usr/bin +if [ $? -ne 0 ]; then + exit $? +fi + +mkdir -p package/usr/lib/php5/${PHP_API} +if [ $? -ne 0 ]; then + exit $? +fi + +cp "${RELEASE_DIR}/pdo_sqlcipher.so" package/usr/lib/php5/${PHP_API}/ +if [ $? -ne 0 ]; then + exit $? +fi + +cp "${RELEASE_DIR}/sqlcipher" package/usr/bin/ +if [ $? -ne 0 ]; then + exit $? +fi + +cd package + +md5deep -rl etc usr > DEBIAN/md5sums +if [ $? -ne 0 ]; then + exit $? +fi + +cd .. + +fakeroot dpkg-deb -z9 -b package +if [ $? -ne 0 ]; then + exit $? +fi + +mv package.deb php5-sqlcipher.deb +if [ $? -ne 0 ]; then + exit $? +fi + +# http://lintian.debian.org/tags.html +lintian php5-sqlcipher.deb +if [ $? -ne 0 ]; then + exit $? +fi + +# clean +rm -rf package/usr/bin +rm -rf package/usr/lib +rm -f package/DEBIAN/md5sums + diff --git a/debian.sh b/debian.sh deleted file mode 100755 index 0d0be00..0000000 --- a/debian.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -RELEASE_DIR="release" - -mkdir -p package/usr/bin -if [ $? -ne 0 ]; then - exit $? -fi - -mkdir -p package/usr/lib/php5/20100525 -if [ $? -ne 0 ]; then - exit $? -fi - -cp "${RELEASE_DIR}/pdo_sqlcipher.so" package/usr/lib/php5/20100525/ -if [ $? -ne 0 ]; then - exit $? -fi - -cp "${RELEASE_DIR}/sqlcipher" package/usr/bin/ -if [ $? -ne 0 ]; then - exit $? -fi - -cd package - -md5deep -rl etc usr > DEBIAN/md5sums -if [ $? -ne 0 ]; then - exit $? -fi - -cd .. - -fakeroot dpkg-deb -z9 -b package -if [ $? -ne 0 ]; then - exit $? -fi - -mv package.deb php5-sqlcipher.deb -if [ $? -ne 0 ]; then - exit $? -fi - -# http://lintian.debian.org/tags.html -lintian php5-sqlcipher.deb -if [ $? -ne 0 ]; then - exit $? -fi - -# clean -rm -rf package/usr/bin -rm -rf package/usr/lib -rm -f package/DEBIAN/md5sums From c8fb55c87ff3ee59302f8d739bd01a5b936b600b Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 08:48:27 +0200 Subject: [PATCH 05/18] strip source line from version --- build-debian.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-debian.sh b/build-debian.sh index be79806..116011e 100755 --- a/build-debian.sh +++ b/build-debian.sh @@ -37,7 +37,8 @@ if [ "x${PHP_VER}" = "x" ]; then exit 1 fi -PHP_SRC="$(dpkg-query -W -f='${Version}' php5)" +PHP_SRC1="$(dpkg-query -W -f='${Version}' php5)" +PHP_SRC=${PHP_SRC1%*-*} if [ ! -f "${PHP_SRC}" ]; then apt-get source php5 From 925d306a67b91566a1605e6ab57f31056f1b77f5 Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 09:25:43 +0200 Subject: [PATCH 06/18] touchup control --- package/DEBIAN/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/DEBIAN/control b/package/DEBIAN/control index 90f69c0..d1f9cb6 100644 --- a/package/DEBIAN/control +++ b/package/DEBIAN/control @@ -3,7 +3,7 @@ Version: _PHP_VER Architecture: amd64 Maintainer: Anton Batenev Installed-Size: 350 -Depends: libc6 (>= 2.13-38), libssl1.0.0 (>=1.0.1e-2), _LIBICU (>=_LIBICU_VER), phpapi-_PHP_API, php5-common (= _PHP_VER) +Depends: libc6 (>= 2.13-38), libssl1.0.0 (>= 1.0.1e-2), _LIBICU (>= _LIBICU_VER), phpapi-_PHP_API, php5-common (= _PHP_VER) Section: php Priority: optional Homepage: https://github.com/abbat/pdo_sqlcipher From 238613b4c6534397d16cad8800058e6eb1005b29 Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 09:27:53 +0200 Subject: [PATCH 07/18] add qoute and proper replace order --- build-debian.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-debian.sh b/build-debian.sh index 116011e..09467f9 100755 --- a/build-debian.sh +++ b/build-debian.sh @@ -254,10 +254,10 @@ fi ## Create the .deb package -LIBICU="$(dpkg-query -W -f='${Package}\n' libicu* | grep -v '\-') +LIBICU="$(dpkg-query -W -f='${Package}\n' libicu* | grep -v '\-')" LIBICU_VER="$(dpkg-query -W -f='${Version}' $LIBICU)" -sed -i "s/_PHP_VER/$PHP_VER/g;s/_PHP_API/$PHP_API/g;s/_LIBICU/$LIBICU/g;s/_LIBICU_VER/$LIBICU_VER/g" package/DEBIAN/control +sed -i "s/_PHP_VER/$PHP_VER/g;s/_PHP_API/$PHP_API/g;s/_LIBICU_VER/$LIBICU_VER/g;s/_LIBICU/$LIBICU/g" package/DEBIAN/control mkdir -p package/usr/bin if [ $? -ne 0 ]; then From db089965b3972001907637d4dc19ba8ad953045a Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 09:30:38 +0200 Subject: [PATCH 08/18] Make the source line proper --- build-debian.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-debian.sh b/build-debian.sh index 09467f9..08ec76e 100755 --- a/build-debian.sh +++ b/build-debian.sh @@ -37,8 +37,9 @@ if [ "x${PHP_VER}" = "x" ]; then exit 1 fi +# There is prolly a better way to do this (getting the proper source pkg name): PHP_SRC1="$(dpkg-query -W -f='${Version}' php5)" -PHP_SRC=${PHP_SRC1%*-*} +PHP_SRC=php5-${PHP_SRC1%*-*} if [ ! -f "${PHP_SRC}" ]; then apt-get source php5 From 57375aee9c3f9987e81d48f8d632bcb58a903bf7 Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 09:40:09 +0200 Subject: [PATCH 09/18] set proper version for deb --- build-debian.sh | 9 ++++----- package/DEBIAN/control | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build-debian.sh b/build-debian.sh index 08ec76e..323e521 100755 --- a/build-debian.sh +++ b/build-debian.sh @@ -31,16 +31,15 @@ fi PHP_VER=$(${PHP_CONFIG} --version ) PHP_API=$(${PHP_CONFIG} --phpapi ) +# There is prolly a better way to do this (getting the proper source pkg name): +PHP_DEB_VER="$(dpkg-query -W -f='${Version}' php5)" +PHP_SRC=php5-${PHP_DEB_VER%*-*} if [ "x${PHP_VER}" = "x" ]; then echo "Error: unknown php version" exit 1 fi -# There is prolly a better way to do this (getting the proper source pkg name): -PHP_SRC1="$(dpkg-query -W -f='${Version}' php5)" -PHP_SRC=php5-${PHP_SRC1%*-*} - if [ ! -f "${PHP_SRC}" ]; then apt-get source php5 if [ $? -ne 0 ]; then @@ -258,7 +257,7 @@ fi LIBICU="$(dpkg-query -W -f='${Package}\n' libicu* | grep -v '\-')" LIBICU_VER="$(dpkg-query -W -f='${Version}' $LIBICU)" -sed -i "s/_PHP_VER/$PHP_VER/g;s/_PHP_API/$PHP_API/g;s/_LIBICU_VER/$LIBICU_VER/g;s/_LIBICU/$LIBICU/g" package/DEBIAN/control +sed -i "s/_PHP_DEB_VER/$PHP_DEB_VER/g;s/_PHP_VER/$PHP_VER;s/_PHP_API/$PHP_API/g;s/_LIBICU_VER/$LIBICU_VER/g;s/_LIBICU/$LIBICU/g" package/DEBIAN/control mkdir -p package/usr/bin if [ $? -ne 0 ]; then diff --git a/package/DEBIAN/control b/package/DEBIAN/control index d1f9cb6..601d193 100644 --- a/package/DEBIAN/control +++ b/package/DEBIAN/control @@ -3,7 +3,7 @@ Version: _PHP_VER Architecture: amd64 Maintainer: Anton Batenev Installed-Size: 350 -Depends: libc6 (>= 2.13-38), libssl1.0.0 (>= 1.0.1e-2), _LIBICU (>= _LIBICU_VER), phpapi-_PHP_API, php5-common (= _PHP_VER) +Depends: libc6 (>= 2.13-38), libssl1.0.0 (>= 1.0.1e-2), _LIBICU (>= _LIBICU_VER), phpapi-_PHP_API, php5-common (= _PHP_DEB_VER) Section: php Priority: optional Homepage: https://github.com/abbat/pdo_sqlcipher From d06aabf1790ff899366754970dfc5d7fa27d8c5b Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 09:41:51 +0200 Subject: [PATCH 10/18] fix up sed line --- build-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-debian.sh b/build-debian.sh index 323e521..7186780 100755 --- a/build-debian.sh +++ b/build-debian.sh @@ -257,7 +257,7 @@ fi LIBICU="$(dpkg-query -W -f='${Package}\n' libicu* | grep -v '\-')" LIBICU_VER="$(dpkg-query -W -f='${Version}' $LIBICU)" -sed -i "s/_PHP_DEB_VER/$PHP_DEB_VER/g;s/_PHP_VER/$PHP_VER;s/_PHP_API/$PHP_API/g;s/_LIBICU_VER/$LIBICU_VER/g;s/_LIBICU/$LIBICU/g" package/DEBIAN/control +sed -i "s/_PHP_DEB_VER/$PHP_DEB_VER/g;s/_PHP_VER/$PHP_VER/g;s/_PHP_API/$PHP_API/g;s/_LIBICU_VER/$LIBICU_VER/g;s/_LIBICU/$LIBICU/g" package/DEBIAN/control mkdir -p package/usr/bin if [ $? -ne 0 ]; then From d98007d3171e8f95aa1089f5cee462dbaa56972a Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 09:45:08 +0200 Subject: [PATCH 11/18] Add instructions for install --- build-debian.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build-debian.sh b/build-debian.sh index 7186780..98594b3 100755 --- a/build-debian.sh +++ b/build-debian.sh @@ -309,3 +309,10 @@ rm -rf package/usr/bin rm -rf package/usr/lib rm -f package/DEBIAN/md5sums +echo "=============== All Done =====================" +echo "Now run 'dpkg -i php5-sqlcipher.deb' to install" +echo "" + +exit + +#EOF From 37b0e09c94a024dbc5f3a788f8a26346be855a14 Mon Sep 17 00:00:00 2001 From: Vincent Kersten Date: Mon, 11 May 2015 09:45:08 +0200 Subject: [PATCH 12/18] Add instructions for install --- build-debian.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build-debian.sh b/build-debian.sh index 7186780..98594b3 100755 --- a/build-debian.sh +++ b/build-debian.sh @@ -309,3 +309,10 @@ rm -rf package/usr/bin rm -rf package/usr/lib rm -f package/DEBIAN/md5sums +echo "=============== All Done =====================" +echo "Now run 'dpkg -i php5-sqlcipher.deb' to install" +echo "" + +exit + +#EOF From 964db221c5bb4b0d6be88ea84716ea4a8351b392 Mon Sep 17 00:00:00 2001 From: sergeypayu Date: Wed, 1 Mar 2017 12:52:43 +0200 Subject: [PATCH 13/18] Hardcoded change VFS type --- build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.sh b/build.sh index 2156f3a..b4e608c 100755 --- a/build.sh +++ b/build.sh @@ -128,6 +128,9 @@ if [ $? -ne 0 ]; then exit $? fi +# change VFS type in +sed -ie 's/i = sqlite3_open(filename, &H->db);/sqlite3_vfs_register(sqlite3_vfs_find("unix-excl"), 1); i = sqlite3_open(filename, &H->db);/g' "${BUILD_DIR}/sqlite_driver.c" + # magic :) for FILE in "${BUILD_DIR}"/* do From 3960a233c4fd086e0bcf26e1ed0671da92407a9d Mon Sep 17 00:00:00 2001 From: sergeypayu Date: Wed, 1 Mar 2017 13:05:26 +0200 Subject: [PATCH 14/18] Updated sed command to change VFS --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index b4e608c..30f230d 100755 --- a/build.sh +++ b/build.sh @@ -129,7 +129,7 @@ if [ $? -ne 0 ]; then fi # change VFS type in -sed -ie 's/i = sqlite3_open(filename, &H->db);/sqlite3_vfs_register(sqlite3_vfs_find("unix-excl"), 1); i = sqlite3_open(filename, &H->db);/g' "${BUILD_DIR}/sqlite_driver.c" +sed -i 's/i = sqlite3_open(filename, &H->db);/sqlite3_vfs_register(sqlite3_vfs_find("unix-excl"), 1);\n&/' "${BUILD_DIR}/sqlite_driver.c" # magic :) for FILE in "${BUILD_DIR}"/* From c9b5f62ec38b058f58c2c2b6996614ff1f01d86d Mon Sep 17 00:00:00 2001 From: Miles Fink Date: Wed, 19 Jul 2017 09:34:57 -0400 Subject: [PATCH 15/18] Update config.m4 for PHP 5.6 --- config.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.m4 b/config.m4 index 8f0d50a..292c2fe 100644 --- a/config.m4 +++ b/config.m4 @@ -22,6 +22,8 @@ if test "$PHP_PDO_SQLCIPHER" != "no"; then pdo_inc_path=$prefix/include/php5/ext elif test -f $prefix/include/php/5.5/php/ext/pdo/php_pdo_driver.h; then pdo_inc_path=$prefix/include/php/5.5/php/ext + elif test -f $prefix/include/php/5.6/php/ext/pdo/php_pdo_driver.h; then + pdo_inc_path=$prefix/include/php/5.6/php/ext else AC_MSG_ERROR([Cannot find php_pdo_driver.h.]) fi From bcec9ca73f8dca87da8e4348f4b29bd252182ee7 Mon Sep 17 00:00:00 2001 From: Sergey Payu Date: Fri, 8 Dec 2017 09:20:44 +0000 Subject: [PATCH 16/18] Added PHP7 compilation support --- build.sh | 4 ++-- config.m4 | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 30f230d..1e6a44f 100755 --- a/build.sh +++ b/build.sh @@ -38,8 +38,8 @@ if [ "x${PHP_CONFIG}" = "x" ]; then exit 1 fi -# 5.3.3-7+squeeze13 PHP_VER=$(${PHP_CONFIG} --version | cut -d '-' -f 1) +PHP_MAJOR_VER=${PHP_VER:0:1} if [ "x${PHP_VER}" = "x" ]; then echo "Error: unknown php version" @@ -50,7 +50,7 @@ PHP_SRC="php-${PHP_VER}" PHP_TGZ="${PHP_SRC}.tar.gz" if [ ! -f "${PHP_TGZ}" ]; then - wget "http://museum.php.net/php5/${PHP_TGZ}" + wget "http://museum.php.net/php${PHP_MAJOR_VER}/${PHP_TGZ}" if [ $? -ne 0 ]; then # newest version? wget -O "${PHP_TGZ}" "http://ru2.php.net/get/${PHP_TGZ}/from/this/mirror" diff --git a/config.m4 b/config.m4 index 292c2fe..62370cd 100644 --- a/config.m4 +++ b/config.m4 @@ -16,6 +16,8 @@ if test "$PHP_PDO_SQLCIPHER" != "no"; then pdo_inc_path=$abs_srcdir/ext elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then pdo_inc_path=$abs_srcdir/ext + elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then + pdo_inc_path=$phpincludedir/ext elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then pdo_inc_path=$prefix/include/php/ext elif test -f $prefix/include/php5/ext/pdo/php_pdo_driver.h; then From f880a67457485fa14be580281e21483d90a9eb96 Mon Sep 17 00:00:00 2001 From: Sergey Payu Date: Fri, 8 Dec 2017 09:24:08 +0000 Subject: [PATCH 17/18] Removed excplicit using of VFS --- build.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.sh b/build.sh index 1e6a44f..e7a55bc 100755 --- a/build.sh +++ b/build.sh @@ -128,9 +128,6 @@ if [ $? -ne 0 ]; then exit $? fi -# change VFS type in -sed -i 's/i = sqlite3_open(filename, &H->db);/sqlite3_vfs_register(sqlite3_vfs_find("unix-excl"), 1);\n&/' "${BUILD_DIR}/sqlite_driver.c" - # magic :) for FILE in "${BUILD_DIR}"/* do From 89fe5665730d056ebbe115c95602c74cb9c62ecf Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Mon, 13 Oct 2025 10:45:01 +1100 Subject: [PATCH 18/18] Update for PHP 8.4 and my needs (packaging happens elsewhere) --- README.en.md | 54 --- README.md | 34 +- build-debian.sh | 318 ------------------ build.sh | 269 --------------- config.m4 | 19 +- example.php | 95 ------ package/DEBIAN/conffiles | 1 - package/DEBIAN/control | 12 - package/etc/php5/conf.d/pdo_sqlcipher.ini | 1 - .../usr/share/doc/php5-sqlcipher/copyright | 4 - .../share/lintian/overrides/php5-sqlcipher | 7 - 11 files changed, 27 insertions(+), 787 deletions(-) delete mode 100644 README.en.md delete mode 100755 build-debian.sh delete mode 100755 build.sh delete mode 100644 example.php delete mode 100644 package/DEBIAN/conffiles delete mode 100644 package/DEBIAN/control delete mode 100644 package/etc/php5/conf.d/pdo_sqlcipher.ini delete mode 100644 package/usr/share/doc/php5-sqlcipher/copyright delete mode 100644 package/usr/share/lintian/overrides/php5-sqlcipher diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 2c39e95..0000000 --- a/README.en.md +++ /dev/null @@ -1,54 +0,0 @@ -# PDO SQLCipher - -A driver for implementing [PDO](http://php.net/manual/en/book.pdo.php) (PHP Data Objects) interface for [SQLCipher](http://sqlcipher.net) without replacing genuine PDO SQLite or the system version of [SQLite](http://www.sqlite.org/). It's based on PDO SQLite source code and created by simply replacing names and inserting SQLCipher code (instead of dynamic linking with SQLite libraries). - -A detachment of this kind allows granting access to encrypted databases only to applications that obviously need it, without fear of data loss or slowing down other applications. - -## Assembling - -To assemble this extension, run `build.sh` script. After successful assembly, all the necessary files will be placed in the directory named `release`: - -* `sqlcipher` - console client (equivalent of `sqlite3` client) -* `pdo_sqlcipher.so` - php extension (equivalent of `pdo_sqlite.so` extension) - -If assembling is performed under Debain, the following dev packages may be required (in addition to standard): - -* `libicu-dev` -* `libreadline-dev` -* `libssl-dev` -* `php5-dev` -* `tcl-dev` - -If assembling is performed under RHEL, the following dev packages may be required (in addition to standard): - -* `libicu-devel` -* `readline-devel` -* `openssl-devel` -* `php-devel` -* `tcl-devel` - -If assembling is performed under FreeBSD, `lang/tcl-wrapper` port installation may be required (to support `tclsh`). - -Assembling script was tested under Debian Wheezy (PHP 5.4.4-14) and FreeBSD 9.1 (PHP 5.4.13) - -## Installation - -Install this extension by copying files from the `release` directory: - -* `sqlcipher` to the `/usr/local/bin/` directory -* `pdo_sqlcipher.so` to the directory of php modules (depends on specific distro): - * Debian: `/usr/lib/php5/20100525/` - * RHEL: `/usr/lib64/php/modules/` - * FreeBSD: `/usr/local/lib/php/20100525/` - -And enable the php extension: - -``` -extension=pdo_sqlcipher.so -``` - -* Debian: `/etc/php5/conf.d/pdo_sqlcipher.ini` -* RHEL: `/etc/php.d/pdo_sqlcipher.ini` -* FreeBSD: `/usr/local/etc/php/extensions.ini` - -You can find an example of extension usage in `example.php` file within the repository. diff --git a/README.md b/README.md index 0e11c8c..2c39e95 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,17 @@ # PDO SQLCipher -[English version](https://github.com/abbat/pdo_sqlcipher/blob/master/README.en.md) +A driver for implementing [PDO](http://php.net/manual/en/book.pdo.php) (PHP Data Objects) interface for [SQLCipher](http://sqlcipher.net) without replacing genuine PDO SQLite or the system version of [SQLite](http://www.sqlite.org/). It's based on PDO SQLite source code and created by simply replacing names and inserting SQLCipher code (instead of dynamic linking with SQLite libraries). -Драйвер, реализующий интерфейс [PDO](http://php.net/manual/en/book.pdo.php) (PHP Data Objects) для [SQLCipher](http://sqlcipher.net) без замещения оригинальной версии PDO SQLite или системной версии [SQLite](http://www.sqlite.org/). Основан на оригинальном коде PDO SQLite путем простого замещения имен и встраиванием кода SQLCipher (вместо динамической линковки с библиотеками SQLite). +A detachment of this kind allows granting access to encrypted databases only to applications that obviously need it, without fear of data loss or slowing down other applications. -Подобное разделение позволяет работать с шифрованными базами только тем приложениям, которые в этом явно нуждаются не опасаясь потери данных или замедления работы остальных приложений. +## Assembling -## Сборка +To assemble this extension, run `build.sh` script. After successful assembly, all the necessary files will be placed in the directory named `release`: -Для сборки расширения запустите скрипт `build.sh`. После успешной сборки необходимые файлы будут помещены в директорию `release`: +* `sqlcipher` - console client (equivalent of `sqlite3` client) +* `pdo_sqlcipher.so` - php extension (equivalent of `pdo_sqlite.so` extension) -* `sqlcipher` - консольный клиент (аналогичный клиенту `sqlite3`) -* `pdo_sqlcipher.so` - расширение php (аналогичное расширению `pdo_sqlite.so`) - -Для сборки под Debain могут потребоваться (помимо стандартных) следующие dev пакеты: +If assembling is performed under Debain, the following dev packages may be required (in addition to standard): * `libicu-dev` * `libreadline-dev` @@ -21,7 +19,7 @@ * `php5-dev` * `tcl-dev` -Для сборки под RHEL могут потребоваться (помимо стандартных) следующие dev пакеты: +If assembling is performed under RHEL, the following dev packages may be required (in addition to standard): * `libicu-devel` * `readline-devel` @@ -29,21 +27,21 @@ * `php-devel` * `tcl-devel` -Для сборки под FreeBSD может потребоваться установка порта `lang/tcl-wrapper` (для поддержки `tclsh`). +If assembling is performed under FreeBSD, `lang/tcl-wrapper` port installation may be required (to support `tclsh`). -Скрипт сборки протестирован на Debian Wheezy (PHP 5.4.4-14) и FreeBSD 9.1 (PHP 5.4.13) +Assembling script was tested under Debian Wheezy (PHP 5.4.4-14) and FreeBSD 9.1 (PHP 5.4.13) -## Установка +## Installation -Для установки расширения скопируйте файлы из директории `release`: +Install this extension by copying files from the `release` directory: -* `sqlcipher` в директорию `/usr/local/bin/` -* `pdo_sqlcipher.so` в директорию модулей php (зависит от дистрибутива): +* `sqlcipher` to the `/usr/local/bin/` directory +* `pdo_sqlcipher.so` to the directory of php modules (depends on specific distro): * Debian: `/usr/lib/php5/20100525/` * RHEL: `/usr/lib64/php/modules/` * FreeBSD: `/usr/local/lib/php/20100525/` -И подключите расширение php: +And enable the php extension: ``` extension=pdo_sqlcipher.so @@ -53,4 +51,4 @@ extension=pdo_sqlcipher.so * RHEL: `/etc/php.d/pdo_sqlcipher.ini` * FreeBSD: `/usr/local/etc/php/extensions.ini` -Пример использования расширения можно найти в файле `example.php` репозитория. +You can find an example of extension usage in `example.php` file within the repository. diff --git a/build-debian.sh b/build-debian.sh deleted file mode 100755 index 98594b3..0000000 --- a/build-debian.sh +++ /dev/null @@ -1,318 +0,0 @@ -#!/bin/sh - -# -# SQLite3 compile options -# - -CFLAGS=" \ - -DSQLITE_HAS_CODEC \ - -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ - -DSQLITE_ENABLE_COLUMN_METADATA \ - -DSQLITE_ENABLE_STAT3 \ - -DSQLITE_ENABLE_RTREE \ - -DSQLITE_ENABLE_FTS3 \ - -DSQLITE_ENABLE_FTS3_PARENTHESIS \ - -DSQLITE_ENABLE_FTS4 \ - -DSQLITE_SECURE_DELETE \ - -DSQLITE_ENABLE_ICU \ - -DSQLITE_SOUNDEX \ - -DSQLITE_DEFAULT_FOREIGN_KEYS=1 \ - -I. -I/usr/local/include" - -LDFLAGS="-lcrypto -licuuc -licui18n -L/usr/local/lib" - - -PHP_CONFIG=$(which php-config) - -if [ "x${PHP_CONFIG}" = "x" ]; then - echo "Error: php-config not found" - exit 1 -fi - -PHP_VER=$(${PHP_CONFIG} --version ) -PHP_API=$(${PHP_CONFIG} --phpapi ) -# There is prolly a better way to do this (getting the proper source pkg name): -PHP_DEB_VER="$(dpkg-query -W -f='${Version}' php5)" -PHP_SRC=php5-${PHP_DEB_VER%*-*} - -if [ "x${PHP_VER}" = "x" ]; then - echo "Error: unknown php version" - exit 1 -fi - -if [ ! -f "${PHP_SRC}" ]; then - apt-get source php5 - if [ $? -ne 0 ]; then - # sources.list not defined source packages - echo "Cannot get the php source package, please add a 'source' line to /etc/apt/sources.list" - exit $? - fi -fi - - -# -# Get SQLCipher source code and make SQLite Amalgamation -# - -SQLCIPHER_SRC="sqlcipher.git" - -if [ ! -d "${SQLCIPHER_SRC}" ]; then - git clone "git://github.com/sqlcipher/sqlcipher.git" "${SQLCIPHER_SRC}" - if [ $? -ne 0 ]; then - exit $? - fi -fi - -if [ ! -f "${SQLCIPHER_SRC}/sqlite3.c" ]; then - cd "${SQLCIPHER_SRC}" - - make distclean - - # subject to change (see http://www.sqlite.org/compile.html) - ./configure \ - --disable-shared \ - --enable-tempstore=yes \ - CFLAGS="${CFLAGS}" \ - LDFLAGS="${LDFLAGS}" - if [ $? -ne 0 ]; then - exit $? - fi - - make - if [ $? -ne 0 ]; then - exit $? - fi - - cd .. -fi - -# -# Clone pdo_sqlite sources for pdo_sqlcipher -# - -BUILD_DIR="build" - -if [ -d "${BUILD_DIR}" ]; then - rm -rf "${BUILD_DIR}" - if [ $? -ne 0 ]; then - exit $? - fi -fi - -mkdir -p "${BUILD_DIR}" -if [ $? -ne 0 ]; then - exit $? -fi - -PDO_SQLITE="${PHP_SRC}/ext/pdo_sqlite" - -cp "${PDO_SQLITE}/"*.c "${PDO_SQLITE}"/*.h "${BUILD_DIR}/" -if [ $? -ne 0 ]; then - exit $? -fi - -# magic :) -for FILE in "${BUILD_DIR}"/* -do - cat "${FILE}" | \ - sed -e 's/sqlite/sqlcipher/g' | \ - sed -e 's/SQLite/SQLCipher/g' | \ - sed -e 's/PDO_SQLITE/PDO_SQLCIPHER/g' > \ - "${FILE}.tmp" - if [ $? -ne 0 ]; then - exit $? - fi - - NEW_FILE=$(echo ${FILE} | sed 's/sqlite/sqlcipher/') - - mv "${FILE}.tmp" "${NEW_FILE}" - if [ $? -ne 0 ]; then - exit $? - fi - - if [ "${NEW_FILE}" != "${FILE}" ]; then - rm -f "${FILE}" - if [ $? -ne 0 ]; then - exit $? - fi - fi -done - -# magic for sqlite3 api sources -cp "${SQLCIPHER_SRC}/sqlite3.c" "${BUILD_DIR}/sqlcipher3.c" -if [ $? -ne 0 ]; then - exit $? -fi - -cp "${SQLCIPHER_SRC}/sqlite3.h" "${BUILD_DIR}/sqlcipher3.h" -if [ $? -ne 0 ]; then - exit $? -fi - -for FILE in "${BUILD_DIR}"/sqlcipher3.* -do - sed -ie 's/sqlite3/sqlcipher3/g' "${FILE}" - if [ $? -ne 0 ]; then - exit $? - fi - - sed -rie 's/(".*)sqlcipher3(.*")/\1sqlite3\2/g' "${FILE}" - if [ $? -ne 0 ]; then - exit $? - fi -done - -# -# Build pdo_sqlcipher -# - -cp "config.m4" "${BUILD_DIR}/config.m4" -if [ $? -ne 0 ]; then - exit $? -fi - -cd "${BUILD_DIR}" - -phpize --clean -if [ $? -ne 0 ]; then - exit $? -fi - -phpize -if [ $? -ne 0 ]; then - exit $? -fi - -./configure \ - CFLAGS="${CFLAGS}" \ - LDFLAGS="${LDFLAGS}" -if [ $? -ne 0 ]; then - exit $? -fi - -make -if [ $? -ne 0 ]; then - exit $? -fi - -cd .. - -# -# Copy binaries -# - -RELEASE_DIR="release" - -if [ -d "${RELEASE_DIR}" ]; then - rm -rf "${RELEASE_DIR}" - if [ $? -ne 0 ]; then - exit $? - fi -fi - -mkdir -p "${RELEASE_DIR}" -if [ $? -ne 0 ]; then - exit $? -fi - -# pdo_sqlite.so -cp "${BUILD_DIR}/modules/pdo_sqlcipher.so" "${RELEASE_DIR}/pdo_sqlcipher.so" -if [ $? -ne 0 ]; then - exit $? -fi - -strip "${RELEASE_DIR}/pdo_sqlcipher.so" -if [ $? -ne 0 ]; then - exit $? -fi - -chmod 0644 "${RELEASE_DIR}/pdo_sqlcipher.so" -if [ $? -ne 0 ]; then - exit $? -fi - -# sqlcipher static binary -cp "${SQLCIPHER_SRC}/sqlcipher" "${RELEASE_DIR}/sqlcipher" -if [ $? -ne 0 ]; then - exit $? -fi - -strip "${RELEASE_DIR}/sqlcipher" -if [ $? -ne 0 ]; then - exit $? -fi - -# -# Clean -# - -#rm -rf ${PHP_SRC} -#rm -rf ${SQLCIPHER_SRC} -#rm -rf ${BUILD_DIR} -#rm -f ${PHP_TGZ} - - -## Create the .deb package - -LIBICU="$(dpkg-query -W -f='${Package}\n' libicu* | grep -v '\-')" -LIBICU_VER="$(dpkg-query -W -f='${Version}' $LIBICU)" - -sed -i "s/_PHP_DEB_VER/$PHP_DEB_VER/g;s/_PHP_VER/$PHP_VER/g;s/_PHP_API/$PHP_API/g;s/_LIBICU_VER/$LIBICU_VER/g;s/_LIBICU/$LIBICU/g" package/DEBIAN/control - -mkdir -p package/usr/bin -if [ $? -ne 0 ]; then - exit $? -fi - -mkdir -p package/usr/lib/php5/${PHP_API} -if [ $? -ne 0 ]; then - exit $? -fi - -cp "${RELEASE_DIR}/pdo_sqlcipher.so" package/usr/lib/php5/${PHP_API}/ -if [ $? -ne 0 ]; then - exit $? -fi - -cp "${RELEASE_DIR}/sqlcipher" package/usr/bin/ -if [ $? -ne 0 ]; then - exit $? -fi - -cd package - -md5deep -rl etc usr > DEBIAN/md5sums -if [ $? -ne 0 ]; then - exit $? -fi - -cd .. - -fakeroot dpkg-deb -z9 -b package -if [ $? -ne 0 ]; then - exit $? -fi - -mv package.deb php5-sqlcipher.deb -if [ $? -ne 0 ]; then - exit $? -fi - -# http://lintian.debian.org/tags.html -lintian php5-sqlcipher.deb -if [ $? -ne 0 ]; then - exit $? -fi - -# clean -rm -rf package/usr/bin -rm -rf package/usr/lib -rm -f package/DEBIAN/md5sums - -echo "=============== All Done =====================" -echo "Now run 'dpkg -i php5-sqlcipher.deb' to install" -echo "" - -exit - -#EOF diff --git a/build.sh b/build.sh deleted file mode 100755 index e7a55bc..0000000 --- a/build.sh +++ /dev/null @@ -1,269 +0,0 @@ -#!/bin/sh - -# -# SQLite3 compile options -# - -CFLAGS=" \ - -DSQLITE_HAS_CODEC \ - -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \ - -DSQLITE_ENABLE_COLUMN_METADATA \ - -DSQLITE_ENABLE_STAT3 \ - -DSQLITE_ENABLE_RTREE \ - -DSQLITE_ENABLE_FTS3 \ - -DSQLITE_ENABLE_FTS3_PARENTHESIS \ - -DSQLITE_ENABLE_FTS4 \ - -DSQLITE_SECURE_DELETE \ - -DSQLITE_ENABLE_ICU \ - -DSQLITE_SOUNDEX \ - -DSQLITE_DEFAULT_FOREIGN_KEYS=1 \ - -I. -I/usr/local/include" - -LDFLAGS="-lcrypto -licuuc -licui18n -L/usr/local/lib" - -# fix FreeBSD include -UNAME=$(uname) -if [ "x${UNAME}" = "xFreeBSD" ]; then - CFLAGS="${CFLAGS} -include /usr/include/sys/stat.h" -fi - -# -# Get PHP source code (installed version) -# - -PHP_CONFIG=$(which php-config) - -if [ "x${PHP_CONFIG}" = "x" ]; then - echo "Error: php-config not found" - exit 1 -fi - -PHP_VER=$(${PHP_CONFIG} --version | cut -d '-' -f 1) -PHP_MAJOR_VER=${PHP_VER:0:1} - -if [ "x${PHP_VER}" = "x" ]; then - echo "Error: unknown php version" - exit 1 -fi - -PHP_SRC="php-${PHP_VER}" -PHP_TGZ="${PHP_SRC}.tar.gz" - -if [ ! -f "${PHP_TGZ}" ]; then - wget "http://museum.php.net/php${PHP_MAJOR_VER}/${PHP_TGZ}" - if [ $? -ne 0 ]; then - # newest version? - wget -O "${PHP_TGZ}" "http://ru2.php.net/get/${PHP_TGZ}/from/this/mirror" - if [ $? -ne 0 ]; then - exit $? - fi - fi -fi - -if [ ! -d "${PHP_SRC}" ]; then - tar -xf "${PHP_TGZ}" -C ./ - if [ $? -ne 0 ]; then - exit $? - fi -fi - -# -# Get SQLCipher source code and make SQLite Amalgamation -# - -SQLCIPHER_SRC="sqlcipher.git" - -if [ ! -d "${SQLCIPHER_SRC}" ]; then - git clone "git://github.com/sqlcipher/sqlcipher.git" "${SQLCIPHER_SRC}" - if [ $? -ne 0 ]; then - exit $? - fi -fi - -if [ ! -f "${SQLCIPHER_SRC}/sqlite3.c" ]; then - cd "${SQLCIPHER_SRC}" - - make distclean - - # subject to change (see http://www.sqlite.org/compile.html) - ./configure \ - --disable-shared \ - --enable-tempstore=yes \ - CFLAGS="${CFLAGS}" \ - LDFLAGS="${LDFLAGS}" - if [ $? -ne 0 ]; then - exit $? - fi - - make - if [ $? -ne 0 ]; then - exit $? - fi - - cd .. -fi - -# -# Clone pdo_sqlite sources for pdo_sqlcipher -# - -BUILD_DIR="build" - -if [ -d "${BUILD_DIR}" ]; then - rm -rf "${BUILD_DIR}" - if [ $? -ne 0 ]; then - exit $? - fi -fi - -mkdir -p "${BUILD_DIR}" -if [ $? -ne 0 ]; then - exit $? -fi - -PDO_SQLITE="${PHP_SRC}/ext/pdo_sqlite" - -cp "${PDO_SQLITE}/"*.c "${PDO_SQLITE}"/*.h "${BUILD_DIR}/" -if [ $? -ne 0 ]; then - exit $? -fi - -# magic :) -for FILE in "${BUILD_DIR}"/* -do - cat "${FILE}" | \ - sed -e 's/sqlite/sqlcipher/g' | \ - sed -e 's/SQLite/SQLCipher/g' | \ - sed -e 's/PDO_SQLITE/PDO_SQLCIPHER/g' > \ - "${FILE}.tmp" - if [ $? -ne 0 ]; then - exit $? - fi - - NEW_FILE=$(echo ${FILE} | sed 's/sqlite/sqlcipher/') - - mv "${FILE}.tmp" "${NEW_FILE}" - if [ $? -ne 0 ]; then - exit $? - fi - - if [ "${NEW_FILE}" != "${FILE}" ]; then - rm -f "${FILE}" - if [ $? -ne 0 ]; then - exit $? - fi - fi -done - -# magic for sqlite3 api sources -cp "${SQLCIPHER_SRC}/sqlite3.c" "${BUILD_DIR}/sqlcipher3.c" -if [ $? -ne 0 ]; then - exit $? -fi - -cp "${SQLCIPHER_SRC}/sqlite3.h" "${BUILD_DIR}/sqlcipher3.h" -if [ $? -ne 0 ]; then - exit $? -fi - -for FILE in "${BUILD_DIR}"/sqlcipher3.* -do - sed -ie 's/sqlite3/sqlcipher3/g' "${FILE}" - if [ $? -ne 0 ]; then - exit $? - fi - - sed -rie 's/(".*)sqlcipher3(.*")/\1sqlite3\2/g' "${FILE}" - if [ $? -ne 0 ]; then - exit $? - fi -done - -# -# Build pdo_sqlcipher -# - -cp "config.m4" "${BUILD_DIR}/config.m4" -if [ $? -ne 0 ]; then - exit $? -fi - -cd "${BUILD_DIR}" - -phpize --clean -if [ $? -ne 0 ]; then - exit $? -fi - -phpize -if [ $? -ne 0 ]; then - exit $? -fi - -./configure \ - CFLAGS="${CFLAGS}" \ - LDFLAGS="${LDFLAGS}" -if [ $? -ne 0 ]; then - exit $? -fi - -make -if [ $? -ne 0 ]; then - exit $? -fi - -cd .. - -# -# Copy binaries -# - -RELEASE_DIR="release" - -if [ -d "${RELEASE_DIR}" ]; then - rm -rf "${RELEASE_DIR}" - if [ $? -ne 0 ]; then - exit $? - fi -fi - -mkdir -p "${RELEASE_DIR}" -if [ $? -ne 0 ]; then - exit $? -fi - -# pdo_sqlite.so -cp "${BUILD_DIR}/modules/pdo_sqlcipher.so" "${RELEASE_DIR}/pdo_sqlcipher.so" -if [ $? -ne 0 ]; then - exit $? -fi - -strip "${RELEASE_DIR}/pdo_sqlcipher.so" -if [ $? -ne 0 ]; then - exit $? -fi - -chmod 0644 "${RELEASE_DIR}/pdo_sqlcipher.so" -if [ $? -ne 0 ]; then - exit $? -fi - -# sqlcipher static binary -cp "${SQLCIPHER_SRC}/sqlcipher" "${RELEASE_DIR}/sqlcipher" -if [ $? -ne 0 ]; then - exit $? -fi - -strip "${RELEASE_DIR}/sqlcipher" -if [ $? -ne 0 ]; then - exit $? -fi - -# -# Clean -# - -rm -rf ${PHP_SRC} -rm -rf ${SQLCIPHER_SRC} -rm -rf ${BUILD_DIR} -rm -f ${PHP_TGZ} diff --git a/config.m4 b/config.m4 index 62370cd..83dd3fe 100644 --- a/config.m4 +++ b/config.m4 @@ -1,16 +1,12 @@ dnl $Id$ dnl config.m4 for extension pdo_sqlcipher dnl vim:et:sw=2:ts=2: - PHP_ARG_ENABLE(pdo_sqlcipher, whether to enable pdo_sqlcipher support, [ --enable-pdo_sqlcipher Enable pdo_sqlcipher support]) - if test "$PHP_PDO_SQLCIPHER" != "no"; then - if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.]) fi - AC_MSG_CHECKING([for PDO includes]) if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then pdo_inc_path=$abs_srcdir/ext @@ -30,13 +26,20 @@ if test "$PHP_PDO_SQLCIPHER" != "no"; then AC_MSG_ERROR([Cannot find php_pdo_driver.h.]) fi AC_MSG_RESULT($pdo_inc_path) + php_pdo_sqlcipher_sources_core="pdo_sqlite.c sqlite_driver.c sqlite_statement.c sqlite3.c" + dnl Detect PHP 8.4’s DSN parser unit and compile it if present + AC_MSG_CHECKING([for sqlite_sql_parser.c (PHP 8.4 DSN parser)]) + if test -f "$abs_srcdir/sqlite_sql_parser.c"; then + AC_MSG_RESULT([yes]) + php_pdo_sqlcipher_sources_core="$php_pdo_sqlcipher_sources_core sqlite_sql_parser.c" + else + AC_MSG_RESULT([no]) + fi - php_pdo_sqlcipher_sources_core="pdo_sqlcipher.c sqlcipher_driver.c sqlcipher_statement.c sqlcipher3.c" - - PHP_NEW_EXTENSION(pdo_sqlcipher, $php_pdo_sqlcipher_sources_core, $ext_shared,,-I$pdo_inc_path) + PHP_NEW_EXTENSION(pdo_sqlite, $php_pdo_sqlcipher_sources_core, $ext_shared,,-I$pdo_inc_path) ifdef([PHP_ADD_EXTENSION_DEP], [ - PHP_ADD_EXTENSION_DEP(pdo_sqlcipher, pdo) + PHP_ADD_EXTENSION_DEP(pdo_sqlite, pdo) ]) fi diff --git a/example.php b/example.php deleted file mode 100644 index fe67899..0000000 --- a/example.php +++ /dev/null @@ -1,95 +0,0 @@ -getMessage() . PHP_EOL); - } - - return $pdo; -} - -// -// Create new example database with one table -// (it can be done through sqlcipher command line client) -// - -$sql = "PRAGMA key = '$password'; -PRAGMA encoding = \"UTF-8\"; -PRAGMA auto_vacuum = 2; -PRAGMA incremental_vacuum(10); - -CREATE TABLE `test` ( - `id` INTEGER NOT NULL PRIMARY KEY, - `value` TEXT NOT NULL -);"; - -$pdo = getPDO($database); - -if ($pdo->exec($sql) === false) { - $error = $pdo->errorInfo(); - die($error[0] . ": " . $error[2] . PHP_EOL); -} - -// -// Use example database -// - -// set encryption key before any sql command -$sql = "PRAGMA key = '$password'"; -$pdo = getPDO($database); - -if ($pdo->exec($sql) === false) { - $error = $pdo->errorInfo(); - die($error[0] . ": " . $error[2] . PHP_EOL); -} - -// insert rows -$sql = "INSERT INTO `test` VALUES (1, 'value1'); -INSERT INTO `test` VALUES (2, 'value2'); -INSERT INTO `test` VALUES (3, 'value3');"; - -if ($pdo->exec($sql) === false) { - $error = $pdo->errorInfo(); - die($error[0] . ": " . $error[2] . PHP_EOL); -} - -// select rows -$result = $pdo->query("SELECT * FROM `test`"); - -if ($result === false) { - $error = $pdo->errorInfo(); - die($error[0] . ": " . $error[2] . PHP_EOL); -} - -foreach ($result as $row) { - print_r($row); -} - -// alter table -$sql = "ALTER TABLE `test` RENAME TO `test2`"; - -if ($pdo->exec($sql) === false) { - $error = $pdo->errorInfo(); - die($error[0] . ": " . $error[2] . PHP_EOL); -} - -// select rows -$result = $pdo->query("SELECT * FROM `test2`"); - -if ($result === false) { - $error = $pdo->errorInfo(); - die($error[0] . ": " . $error[2] . PHP_EOL); -} - -foreach ($result as $row) { - print_r($row); -} diff --git a/package/DEBIAN/conffiles b/package/DEBIAN/conffiles deleted file mode 100644 index ee67535..0000000 --- a/package/DEBIAN/conffiles +++ /dev/null @@ -1 +0,0 @@ -/etc/php5/conf.d/pdo_sqlcipher.ini diff --git a/package/DEBIAN/control b/package/DEBIAN/control deleted file mode 100644 index 601d193..0000000 --- a/package/DEBIAN/control +++ /dev/null @@ -1,12 +0,0 @@ -Package: php5-sqlcipher -Version: _PHP_VER -Architecture: amd64 -Maintainer: Anton Batenev -Installed-Size: 350 -Depends: libc6 (>= 2.13-38), libssl1.0.0 (>= 1.0.1e-2), _LIBICU (>= _LIBICU_VER), phpapi-_PHP_API, php5-common (= _PHP_DEB_VER) -Section: php -Priority: optional -Homepage: https://github.com/abbat/pdo_sqlcipher -Description: sqlcipher module for PHP 5 - SQLCipher is an SQLite extension that provides transparent - 256-bit AES encryption of database files. diff --git a/package/etc/php5/conf.d/pdo_sqlcipher.ini b/package/etc/php5/conf.d/pdo_sqlcipher.ini deleted file mode 100644 index 324bfa4..0000000 --- a/package/etc/php5/conf.d/pdo_sqlcipher.ini +++ /dev/null @@ -1 +0,0 @@ -extension=pdo_sqlcipher.so diff --git a/package/usr/share/doc/php5-sqlcipher/copyright b/package/usr/share/doc/php5-sqlcipher/copyright deleted file mode 100644 index 600762d..0000000 --- a/package/usr/share/doc/php5-sqlcipher/copyright +++ /dev/null @@ -1,4 +0,0 @@ -This package was debianized by Anton Batenev - -pdo_sqlite under PHP License (http://www.php.net/license/3_0.txt) -sqlcipher under BSD-style open source license (http://sqlcipher.net/license) diff --git a/package/usr/share/lintian/overrides/php5-sqlcipher b/package/usr/share/lintian/overrides/php5-sqlcipher deleted file mode 100644 index bac25c2..0000000 --- a/package/usr/share/lintian/overrides/php5-sqlcipher +++ /dev/null @@ -1,7 +0,0 @@ -php5-sqlcipher: debian-changelog-file-missing -php5-sqlcipher: hardening-no-relro -php5-sqlcipher: copyright-without-copyright-notice -php5-sqlcipher: binary-or-shlib-defines-rpath -php5-sqlcipher: embedded-library -php5-sqlcipher: hardening-no-fortify-functions -php5-sqlcipher: binary-without-manpage