OPKG软件包管理
opkg(an ipkg fork)是一个可以从本地软件仓库或互联网软件仓库上下载并安装OpenWrt包的轻量型实用工具。
GNU/Linux用户可能会对apt-get,aptitude,pacman,yum等比较熟悉,也会看出其相似之处。
opkg试图在软件包仓库内来解决依赖关系。如果失败了,它将会报告一个错误并退出停止安装该软件包。
如果丢失第三方包的依赖关系,源码包依然可用的话,为了忽略依赖关系的错误可以使用 –force-depends选项。
请注意:
Invocation
opkg必须有一个子命令参数: 用法:opkg [选项…] 子命令 [参数]
软件包管理
update
- 更新可用软件包列表
upgrade
<pkgs> - 升级软件包
要升级一组软件包,运行opkg upgrade 软件包名1 软件包名2即可
获得一个可升级列表可以使用opkg list-upgradable命令
通常我们是不推荐普通用户去升级软件包,因为一个典型的Openwrt系统是存储在只读的SquashFS文件系统中,同时当升级工作做完后,使用了远超出在SquashFS文件系统或JFFS2文件系统默认安装基本软件包的容量。
因此,推荐用刷一个更新的Openwrt固件来代替使用升级软件包。
install
install <pkgs> 安装软件包
configure
configure <pkgs> - 配置一个或多个未安装的包
remove
remove <pkgs|regexp> 移除一个或多个软件包
flag
命令信息
list - 有效软件包列表 Package name - Version - Description
选项
选项:
- A 查询除已安装包外的其他所有软件包
- V[<level>] 设置显示信息的详细程度等级
- -verbosity[=<level>] 详细等级:
0 只有出错
1 正常信息(默认)
2 informative messages
3 调试
4 调试 等级2
-f <conf_file> Use <conf_file> as the opkg configuration file
--conf <conf_file>
--cache <directory> 使用一个缓存的软件包
-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
- -noaction No action – test only
- -download-only No action – download only
- -nodeps Do not follow dependencies
- -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*'
举例
搜索 To search • opkg列表仅仅显示软件包名称-版本-描述 • opkg将会限时所有有效的信息
你可以用正则表达式同时也可以写一下小shell脚本去获取信息。使用管道、grepawk、sed去过滤输出: • opkg list | grep pattern
• opkg list | awk '/pattern/ {print $0} • opkg info kmod-ipt-* | awk '/length/ {print $0}' • opkg list-installed | awk '{print $1}' | sed ':M;N;$!bM;s#\n# #g • var="packagename1 packagename2 packagename2"; for i in $variable; do opkg info $i; done; • opkg depends dropbear doesn't work either.
配置
修改配置文件
唯一的配置文件是/etc/opkg.conf,它可能看起来会像是这样: src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages dest root / dest ram /tmp lists_dir ext /var/opkg-lists option overlay_root /overlay
修改处理器架构
代理支持
要使用代理,在/etc/opkg.conf中添加:
option http_proxy http://proxy.example.org:8080/ option ftp_proxy ftp://proxy.example.org:2121/
使用以下设置来进行代理服务器的认证:
option proxy_username xxxx option proxy_password xxxx
The authentication may fail due to the limitations of busybox wget. Try passing the username and password as part of the url in this case.
option http_proxy http://username:password@proxy.example.org:8080/ option ftp_proxy http://username:password@proxy.example.org:2121/
zh-cn/doc/techref/opkg.txt · Last modified: 2011/04/25 10:47 by mli
