OpenWrt的ipk包安装

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

在 make menuconfig 进行裁减 OpenWrt 时,为了让系统更精小一点,我们会把部分功能以“模块”的方式编译,即不编入内核,只是在后期用户可以进行安装与卸载。


包安装示例

如下关于Lua的配置项:

182445_iPLw_243525.png

其中 json4lua, lua-cjson, lua-copas, lua-coxpcall 是没有编入原生系统的。

在 make 完成之后。

在 bin/ar71xx/packages/ 路径下全是 ipk 安装包。其中上面对应的安装包就在 bin/ar71xx/packages/packages/ 目录下。


#--开发机--
$ ls lua*
lua-cjson_2.1.0-1_ar71xx.ipk      lua-rs232_1.0.3-1_ar71xx.ipk
lua-copas_2.0.0-1_ar71xx.ipk      luasocket_3.0-rc1-20130909-3_ar71xx.ipk
lua-coxpcall_1.15.0-1_ar71xx.ipk  luasql-mysql_2.3.0-1_ar71xx.ipk
luaposix_v33.2.1-4_ar71xx.ipk     luasql-sqlite3_2.3.0-1_ar71xx.ipk


怎么安装到 OpenWrt上呢?

首先,用 scp 将 ipk 包发送到 OpenWrt 系统上。本人的 OpenWrt 的 IP 为 192.168.1.2,以 luasql 为例


#--开发机--
$ scp luasql-mysql_2.3.0-1_ar71xx.ipk root@192.168.1.2:
root@192.168.1.2's password: <输入密码>
luasql-mysql_2.3.0-1_ar71xx.ipk                      100% 6441     6.3KB/s   00:00


SSH登入 OpenWrt,查看文件。luasql-mysql_2.3.0-1_ar71xx.ipk 已在 /root/ 目录下了。


#--OpenWrt---
$ opkg install luasql-mysql_2.3.0-1_ar71xx.ipk
Installing luasql-mysql (2.3.0-1) to root...
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for luasql-mysql:
 *     libmysqlclient * 
 * opkg_install_cmd: Cannot install package luasql-mysql.


Oops,出师不力(不用惊慌,这也是常常遇到的事儿)~缺 libmysqlclient 库。

那就看看 libmysqlclient 库的 ipk 包有没有。如果 bin/ar71xx/packages 路径下没有,则是 make menuconfig 时没有加进来。这时,修改配置,再make一下就会有了。

在 bin/ar71xx/packages/ 路径下 find 一下。


#--开发机---
$ find -name "libmysqlclient*"
./packages/libmysqlclient_5.1.73-1_ar71xx.ipk


有!那就不用再make一遍了。

同样,用 scp 将 libmysqlclient_5.1.73-1_ar71xx.ipk 文件传送到 OpenWrt。


#--开发机---
$ scp libmysqlclient_5.1.73-1_ar71xx.ipk root@192.168.1.2:


再在 OpenWrt 的 SSH 里安装刚发送过来的 ipk 包。


#--OpenWrt---
$ opkg install libmysqlclient_5.1.73-1_ar71xx.ipk 
Installing libmysqlclient (5.1.73-1) to root...
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for libmysqlclient:
 *     uclibcxx * 
 * opkg_install_cmd: Cannot install package libmysqlclient.


Oops~Again,libmysqlclient还依赖于uclibcxx库。安装 uclibcxx 库。


#--开发机---
$ scp base/uclibcxx_0.2.4-1_ar71xx.ipk root@192.168.1.2:



#--OpenWrt---
$ opkg install uclibcxx_0.2.4-1_ar71xx.ipk 
Installing uclibcxx (0.2.4-1) to root...
Configuring uclibcxx.


uclibcxx库OK了

再来安装 libmysqlclient 库


#--OpenWrt---
$ opkg install libmysqlclient_5.1.73-1_ar71xx.ipk 
Installing libmysqlclient (5.1.73-1) to root...
Configuring libmysqlclient.


libmysqlclient库OK了。

最后安装 luasql 库


#--OpenWrt---
$ opkg install luasql-mysql_2.3.0-1_ar71xx.ipk
Installing luasql-mysql (2.3.0-1) to root...
Configuring luasql-mysql.


就这样,luasql 库安装完成了。

在 OpenWrt 系统的 /usr/lib/lua/ 目录下多出一个 luasql 目录,在该目录下有一个 mysql.so 文件。

启动 Lua 试试看:


#--OpenWrt---
$ lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio (double int32)
> require 'luasql.mysql'


成功。


opkg 的使用

opkg 有点类似地 ubuntu 中的 dpkg 包管理工具。常见的用法是:安装、卸载软件包。


usage: opkg [options...] sub-command [arguments...]
where sub-command is one of:

Package Manipulation:
    update            Update list of available packages
    upgrade <pkgs>        Upgrade packages
    install <pkgs>        Install package(s)
    configure <pkgs>    Configure unpacked package(s)
    remove <pkgs|regexp>    Remove package(s)
    flag <flag> <pkgs>    Flag package(s)
     <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)

Informational Commands:
    list            List available packages
    list-installed        List installed packages
    list-upgradable        List installed and upgradable packages
    list-changed-conffiles    List user modified configuration files
    files <pkg>        List files belonging to <pkg>
    search <file|regexp>    List package providing <file>
    find <regexp>        List packages whose name or description matches <regexp>
    info [pkg|regexp]    Display all info for <pkg>
    status [pkg|regexp]    Display all status for <pkg>
    download <pkg>        Download <pkg> to current directory
    compare-versions <v1> <op> <v2>
                        compare versions using <= < > >= = << >>
    print-architecture    List installable package architectures
    depends [-A] [pkgname|pat]+
    whatdepends [-A] [pkgname|pat]+
    whatdependsrec [-A] [pkgname|pat]+
    whatrecommends[-A] [pkgname|pat]+
    whatsuggests[-A] [pkgname|pat]+
    whatprovides [-A] [pkgname|pat]+
    whatconflicts [-A] [pkgname|pat]+
    whatreplaces [-A] [pkgname|pat]+

Options:
    -A            Query all packages not just those installed
    -V[<level>]        Set verbosity level to <level>.
    --verbosity[=<level>]    Verbosity levels:
                    0 errors only
                    1 normal messages (default)
                    2 informative messages
                    3 debug
                    4 debug level 2
    -f <conf_file>        Use <conf_file> as the opkg configuration file
    --conf <conf_file>
    --cache <directory>    Use a package cache
    -d <dest_name>        Use <dest_name> as the the root directory for
    --dest <dest_name>    package installation, removal, upgrading.
                <dest_name> should be a defined dest name from
                the configuration file, (but can also be a
                directory name in a pinch).
    -o <dir>        Use <dir> as the root directory for
    --offline-root <dir>    offline installation of packages.
    --add-arch <arch>:<prio>    Register architecture with given priority
    --add-dest <name>:<path>    Register destination with given path

Force Options:
    --force-depends        Install/remove despite failed dependencies
    --force-maintainer    Overwrite preexisting config files
    --force-reinstall    Reinstall package(s)
    --force-overwrite    Overwrite files from other package(s)
    --force-downgrade    Allow opkg to downgrade packages
    --force-space        Disable free space checks
    --force-postinstall    Run postinstall scripts even in offline mode
    --force-remove    Remove package even if prerm script fails
    --force-checksum    Don't fail on checksum mismatches
    --noaction        No action -- test only
    --download-only    No action -- download only
    --nodeps        Do not follow dependencies
    --nocase        Perform case insensitive pattern matching
    --force-removal-of-dependent-packages
                Remove package and all dependencies
    --autoremove        Remove packages that were installed
                automatically to satisfy dependencies
    -t            Specify tmp-dir.
    --tmp-dir        Specify tmp-dir.

 regexp could be something like 'pkgname*' '*file*' or similar
 e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'



相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
4月前
|
开发工具 git iOS开发
Mac 安装软件包管理工具Homebrew
Mac 安装软件包管理工具Homebrew
|
IDE 开发工具
R问题|如何本地安装 R 包
R问题|如何本地安装 R 包
451 0
R问题|如何本地安装 R 包
|
监控 安全 网络协议
OpenWRT好用的插件
OpenWRT好用的插件:
3866 0
OpenWRT好用的插件
|
Python
内网机上使用pip离线安装whl包的方法
内网机上使用pip离线安装whl包的方法
2053 0
内网机上使用pip离线安装whl包的方法
|
应用服务中间件 Linux nginx
使用yumdownloader命令离线安装rpm服务包
使用yumdownloader命令离线安装rpm服务包
446 0
|
IDE 开发工具
R问题|如何本地安装R包
平常在各种R语言群里,总会遇到关于安装R包的问题,例如:搭载在github上的R包,由于网速(外网)原因而无法下载该怎么办? 这里小编分享下平常逼不得已才使用的“下三滥”方法——直接下载包,通过本地安装。
1204 0
R问题|如何本地安装R包
|
Linux 编译器 应用服务中间件
7.13 Linux源码包安装和卸载
由于 Linux 操作系统开放源代码,因此在其上安装的软件大部分也都是开源软件,例如 Apache、Tomcat 和 PHP 等。开源软件基本都提供源码下载,可采用源码安装的方式安装软件。
272 0
7.13 Linux源码包安装和卸载
|
域名解析 Ubuntu Linux
安装软件包
本文以阿里云软件源中的Apache服务器为例,为大家讲解如何在不同Linux发行版上安装软件包。
1356 0
安装软件包
|
Ubuntu 前端开发 数据库