sqlcipher for openwrt

嵌入式软件 专栏收录该内容
82 篇文章 0 订阅

默认openwrt并没有sqlcipher的package包,网上介绍的都是单独编译很麻烦,这里给出openwrt环境下的快速编译方案,关于sqlcipher的介绍参考官方仓库地址

  • 先创建openwrt/package/libs/sqlcipher目录,同时在.config新增CONFIG_PACKAGE_sqlcipher=y选项
  • 再创建对应Makefile,内容如下
#
# Copyright (C) 2006-2020 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=sqlcipher
PKG_VERSION:=4.4.3
PKG_RELEASE:=1
PKG_INSTALL:=1

PKG_SOURCE:=v$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/sqlcipher/sqlcipher/archive/refs/tags
PKG_MD5SUM:=47a2a4c0fbbf4c46891b1678e893c4a3

include $(INCLUDE_DIR)/package.mk

define Package/sqlcipher
  SUBMENU:=database
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=SQLCipher extends the SQLite database library
  URL:=https://github.com/sqlcipher/sqlcipher
  DEPENDS:=+libopenssl
endef

EXTRA_CFLAGS+= \
    -DSQLITE_HAS_CODEC

EXTRA_LDFLAGS+= \
    -lcrypto

CONFIGURE_ARGS += \
            --enable-tempstore=yes \
            
CONFIGURE_ARGS+= \
    --build=$(GNU_HOST_NAME) \
    --host=$(GNU_TARGET_NAME) \
    --target=$(GNU_TARGET_NAME) \

define Package/sqlcipher/description
SQLCipher extends the SQLite database library to add security enhancements
endef

define Build/Prepare
    $(call Build/Prepare/Default)
endef

define Build/InstallDev
    $(INSTALL_DIR) $(1)/usr/include
    $(CP) $(PKG_INSTALL_DIR)/usr/include/sqlcipher $(1)/usr/include/
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsqlcipher.{a,so*} $(1)/usr/lib/
    $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/sqlcipher.pc $(1)/usr/lib/pkgconfig/
endef

define Package/sqlcipher/install
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsqlcipher.so $(1)/usr/lib/
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsqlcipher.so.* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,sqlcipher))
  • 修改默认PBKDF2_ITER宏加速数据库打开速度,由于默认的246000次iterator,导致在arm linux平台首次打开速度非常慢,
    和Makefile同一目录,创建patches目录,并在里面添加001-reduce-iterator-faster-con.patch文件,内容如下
Index: sqlcipher-4.4.3/src/crypto.h
===================================================================
--- sqlcipher-4.4.3.orig/src/crypto.h
+++ sqlcipher-4.4.3/src/crypto.h
@@ -72,6 +72,7 @@ void sqlite3pager_reset(Pager *pPager);
#define CIPHER_READ_CTX 0
#define CIPHER_WRITE_CTX 1
#define CIPHER_READWRITE_CTX 2
+#define PBKDF2_ITER 1000
#ifndef PBKDF2_ITER
#define PBKDF2_ITER 256000
  • 之后可以单独编译sqlcipher包:
make package/libs/sqlcipher/compile V=s
  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值