12.OpenWrt-OPKG包管理
创始人
2024-02-15 18:51:36
0

12.OpenWrt-OPKG包管理

Android系统手机都有应用商店,苹果手机也有app store,用来下载安装各种app.在OpenWrt系统中也有自己的 应用商店,OpenWrt是通过OPKG(Open/OpenWrt Package)来管理软件包,OPKG是一个轻量快速的软件包管理系统,用来管理软件包的下载、安装、升级、卸载和查询等,并处理软件包的依赖关系.OPKG不光可以安装应用程序也可以安装驱动程序等,安装的软件可以是编译出来的ipk安装包,也可以是从互联网下载的安装包.

12.1 OPKG 命令

OPKG 的功能主要分两类,一种是软件包的管理命令,另外一种是软件包的查询命令.另外还有很多可以修饰的选项.

12.1.1 软件包的管理

软件包的管理是OPKG最重要的功能,主要包含更新软件包列表、安装、卸载和升级等功能.

1. opkg update

该命令用于更新可以安装的软件包列表.该命令不需要参数,执行时从服务器地址下载软件包列表文件并存储在/var/opkg-lists/目录下.OPKG在安装或升级时需要读取这个文件,这个文件代表当前仓库中所有可用的软件包.也可以删除该文件来释放存储空间,在安装软件前需要重新获取这个文件.

2. opkg install

该命令用于安装软件包, 需要一个参数,传递一个软件包名称.如果软件包之间有依赖关系,会自动下载所有被依赖的软件包,并依次将所有被依赖的软件包安装上.

3. opkg remove

该命令用于卸载软件包,需要一个参数,传递一个软件包名称.需要注意的是,在安装时自动安装的软件包并不会删除,需要自己手动删除,或者在卸载软件包的同时增加(–autoremove)参数将不需要的安装包也删除.示例 3-2 所示代码用于删除 file 软件包及不再使用的依赖包.

4. opkg upgrade

该命令用于升级软件包.如果软件包没有安装,该命令执行之后和“opkg install”效果相同.如果升级多个软件包,以空格分隔列在命令之后即可.例如使用 opkg upgrade ip wget 来升级两个软件包.对大多数用户来说,不推荐升级软件包. OpenWrt 发布后再进行升级大多数情况下是不可能的,这是因为 OpenWrt 发布之后一般不再更新,除非主干的快照被编译机器人(buildbot)自动更新.如果内核升级了,可能带来升级风险,因为内核可能和原始安装的应用软件不兼容.因此一般只升级应用,即非内核软件包.

12.1.2 查询信息

OPKG 查询命令可以在软件仓库中查询,也可以在运行的系统中查询. OPKG 提供了软件包的双向查询功能:正向查询,即从软件包来查询所包含的文件列表;也可以反向查询,从系统中所安装的文件查询所属的软件包.

1. opkg list

该命令用于列出所有可使用的软件包,列出内容格式为:软件包名称 – 版本 – 描述.描述内容是可以有换行的.如果使用 grep 命令来查找软件包则需注意, grep 是单行匹配, 因此使用 grep 查找的结果并不准确.

2. opkg list-installed

该命令用于列出系统中已经安装的软件包.

3. opkg list-changed-conffiles

该命令用于列出用户修改过的配置文件.

4. opkg files

该命令用于列出属于这个软件包( )中的所有文件,这个软件包必须已经安装.

5. opkg search

该命令用于列出提供的软件包,注意:需要传递文件的绝对路径.

6. opkg find

该命令用于列出软件包名称和匹配的软件包. 是一个正则表达式,可以精确匹配,也可以使用星号来模糊匹配,例如使用“net*”或者“net”,均可以匹配 NetCat.

7. opkg info [pkg]

该命令用于显示已安装[pkg]软件包的信息,包含软件包名称、版本、所依赖的软件包名称、安装状态和安装时间等.如果没有指定参数则输出所有已安装软件包的信息.“opkgstatus”和这个命令功能完全相同.

8. opkg download

该命令用于将软件包下载到当前目录.

9. opkg print-architecture

该命令用于列出安装包的架构.

10. opkg whatdepends [-A] [pkg]

该命令用于针对已安装的软件包,输出依赖这个软件包的软件包.

12.2 使用举例

12.2.1 安装软件包

SSH是非常有用的调试工具,可以在同一局域网中连接到板子的Terminal,也可以通过SSH收发文件.有时候并不知道软件包的完整名称,这时候可以通过模糊查找,找到对应的软件包名称来进行安装.

更新软件包 :guilabel:opkg update.
模糊查找关键字 :guilabel:opkg list |grep ssh.
安装软件包 :guilabel:opkg install openssh-server.

 root@GTC-OpenWrt:/# opkg updateDownloading https://downloads.openwrt.org/snapshots/targets/ramips/mt76x8/packages/Packages.gzUpdated list of available packages in /var/opkg-lists/openwrt_coreDownloading https://downloads.openwrt.org/snapshots/targets/ramips/mt76x8/packages/Packages.sigSignature check passed.Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/base/Packages.gzUpdated list of available packages in /var/opkg-lists/openwrt_baseDownloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/base/Packages.sigSignature check passed.Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/luci/Packages.gzUpdated list of available packages in /var/opkg-lists/openwrt_luciDownloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/luci/Packages.sigSignature check passed.Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/Packages.gzUpdated list of available packages in /var/opkg-lists/openwrt_packagesDownloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/Packages.sigSignature check passed.Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/routing/Packages.gzUpdated list of available packages in /var/opkg-lists/openwrt_routingDownloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/routing/Packages.sigSignature check passed.Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/telephony/Packages.gzUpdated list of available packages in /var/opkg-lists/openwrt_telephonyDownloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/telephony/Packages.sigSignature check passed.root@GTC-OpenWrt:~# opkg list |grep sshannounce - 1.0.1-1 - Announce services on the network with Zeroconf/Bonjour. This announces services such as ssh, sftp, and http running on the local machine to the network.autossh - 1.4g-4 - Autossh clientavahi-daemon-service-ssh - 0.8-7 - Avahi is an mDNS/DNS-SD (aka RendezVous/Bonjour/ZeroConf) implementation (library). It facilitates service discovery on a local network -- this means that you can plug your laptop or computer into a network and instantly be able to view other people who you can chat with, find printers to print to or find files being shared. This kind of technology is already found in MacOS X (branded 'Rendezvous', 'Bonjour' and sometimes 'ZeroConf') and is very convenient. . This package contains the service definition for announcing SSH service.cryptsetup-ssh - 2.5.0-1 - Experimental SSH token support for cryptsetup.erlang-ssh - 4.13 - Erlang/OTP is a general-purpose programming language and runtime environment. Erlang has built-in support for concurrency, distribution and fault tolerance. . This Erlang/OTP package provides an implementation of the Secure Shell protocol, with SSH & SFTP support.gsocket - 1.4.37-1 - Global Socket allows two workstations on different private networks to communicate with each other. Through firewalls and through NAT - like there is no firewall.  The TCP connection is secured with AES-256 and using OpenSSL's SRP protocol (RFC 5054). It does not require a PKI and has forward secrecy and (optional) TOR support.  The gsocket tools derive temporary session keys and IDs and connect two TCP pipes through the Global Socket Relay Network (GSRN). This is  done regardless and independent of the local IP Address or geographical location.  The session keys (secrets) never leave the workstation. The GSRN sees only the encrypted traffic.  The workhorse is 'gs-netcat' which opens a ssh-like interactive PTY command shell to a remote workstation (which resides on a private and remote network and/or behind a firewall).libssh - 0.10.3-1 - libssh is a mulitplatform C library implementing the SSHv2 and SSHv1 protocol for client and server implementations.libssh2-1 - 1.10.0-1 - libssh2 is a client-side C library implementing the SSH2 protocol.luci-proto-pppossh - git-21.158.38888-88b9d84 - Support for ppposshopenssh-client - 9.0p1-1 - OpenSSH client.openssh-client-utils - 9.0p1-1 - OpenSSH client utilities.openssh-keygen - 9.0p1-1 - OpenSSH keygen.openssh-moduli - 9.0p1-1 - OpenSSH server moduli file.openssh-server - 9.0p1-1 - OpenSSH server.openssh-server-pam - 9.0p1-1 - OpenSSH server (with PAM support).openssh-sftp-avahi-service - 9.0p1-1 - This package contains the service definition for announcing SFTP support via mDNS/DNS-SD.openssh-sftp-client - 9.0p1-1 - OpenSSH SFTP client.openssh-sftp-server - 9.0p1-1 - OpenSSH SFTP server.pagekitec - 0.91.201110C-2 - PageKite is a system for running publicly visible servers (generally web servers) on machines without a direct connection to the Internet, such as mobile devices or computers behind restrictive firewalls. PageKite works around NAT, firewalls and IP-address limitations by using a combination of tunnels and reverse proxies.  This package provides an implementation of the PageKite Protocol in C, optimized for high-performance or embedded applications.   This package contains a basic backend useful for exposing http/ssh servers.  Basic UCI support for configuring this backend is also included.passh - 1.0.1-2 - Passh is an sshpass alternative.pppossh - 2 - This package adds protocol support for PPP over SSH.  The protocol name is 'pppossh' as in netifd interface config option 'proto'.rrsync - 3.2.7-1 - rrsync is a script which wraps around rsync to restrict its permission to a particular subdirectory via ~/.ssh/authorized_keys and/or to read-only or write-only modesshfs - 3.7.2-3 - Mount remote system over sftp.sshpass - 1.09-1 - Sshpass is a tool for non-interactively performing password authentication with SSH's so-called "interactive keyboard password authentication". Most user should use SSH's more secure public-key authentication instead.sshtunnel - 4-5 - Creates openssh ssh(1) Local and Remote tunnels configured in UCI file. Can be used to allow remote connections, possibly over NATed connections or without public IP/DNSstrongswan-mod-sshkey - 5.9.7-8.1 - StrongSwan SSH key decoding plugintmate-ssh-server - 511fd2bd852464e76824279609a34ee93fe148a4-2 - tmate-ssh-server is the server side part of tmate.io.root@GTC-OpenWrt:/# opkg install openssh-serverInstalling openssh-server (9.0p1-1) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/openssh-server_9.0p1-1_mipsel_24kc.ipkInstalling libopenssl1.1 (1.1.1s-1) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/base/libopenssl1.1_1.1.1s-1_mipsel_24kc.ipkInstalling zlib (1.2.12-4) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/base/zlib_1.2.12-4_mipsel_24kc.ipkInstalling openssh-keygen (9.0p1-1) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/openssh-keygen_9.0p1-1_mipsel_24kc.ipkInstalling libcbor0 (0.8.0-1) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/libcbor0_0.8.0-1_mipsel_24kc.ipkInstalling libevdev (1.13.0-1) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/libevdev_1.13.0-1_mipsel_24kc.ipkInstalling libudev-zero (1.0.1-1) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/libudev-zero_1.0.1-1_mipsel_24kc.ipkInstalling libfido2-1 (1.12.0-1) to root...Downloading https://downloads.openwrt.org/snapshots/packages/mipsel_24kc/packages/libfido2-1_1.12.0-1_mipsel_24kc.ipkConfiguring libevdev.Configuring libopenssl1.1.Configuring zlib.Configuring openssh-keygen.Configuring libcbor0.Configuring libudev-zero.Configuring libfido2-1.Configuring openssh-server.

相关内容

热门资讯

亚马逊将展示关税价格!白宫怒斥... 当地时间4月29日,在亚马逊宣布将开始标注特朗普关税政策带来的商品额外成本后,特朗普政府当日对亚马逊...
佰维存储:AI端侧应用核心标的... 4月29日晚间,佰维存储发布2024年年报,2024年公司实现营业总收入66.95亿元,同比增长86...
星宸科技:高阶机器人芯片有望于... 人民财讯4月30日电,星宸科技(301536)在业绩说明会上表示,公司机器人芯片已初步完成产品矩阵,...
山东高速股份有限公司 2025...   证券代码:600350                                     ...
首钢股份:技术领先、绿色低碳,... 投资者提问:尊敬的公司高层,在行业竞争日益激烈的当下,第一梯队钢企往往代表着卓越的业绩与高效的运营模...
面对救人辅警应“破格转正”呼声... 转自:上观新闻近日,新疆女辅警布帕太姆下井救童的事迹引发全网点赞,网友“破格转正”的呼声更是冲上热搜...
粤海控股集团探索“公益+”新模... 转自:广东省国资委长期以来,粤海控股集团充分发挥平台资源与产业优势,以“公益+教育+产业”的创新模式...
华西证券:债市当前处于等待收益... 格隆汇4月30日|华西证券指出,债市的低波状态大概率还会延续一个交易日,30日的制造业PMI数据以及...
东易日盛2024年年报解读:营... 东易日盛2024年年报显示,公司面临着严峻的经营挑战,营业收入同比下降55.84%,净利润同比下降4...
惠伦晶体:晶振产品应用于机器人... 投资者提问:在机器人,以及人形机器人方面,公司产品实际应用情况如何?董秘回答(惠伦晶体(维权)SZ3...
关于为“国君-2025平安租赁... 各相关单位:根据上海国泰君安证券资产管理有限公司申请,本所自2025年5月6日起采用协商成交、点击成...
甘肃省纪委监委通报6起违反中央... 省纪委监委通报6起违反中央八项规定精神典型问题  每日甘肃网兰州讯(新甘肃·甘肃日报记者马颖)“五一...
CBOT玉米下跌,因春播步伐加... 原标题:CBOT玉米下跌,因春播步伐加速 来源:南方小麦网周二,芝加哥期货交易所(CBOT)玉...
第八届数字中国建设峰会开幕 第八届数字中国建设峰会开幕24家企业福州亮相展辽宁之“智”  本报讯 特派记者孔爱群福州报道 “这款...
今天9点,苏州正式迎来…… 今天(4月30日)9至11时我们将迎来本年度首个“蛇年蛇月蛇日蛇时” 什么是蛇年蛇月蛇日蛇时?这是基...
康宁杰瑞制药-B(09966)... 康宁杰瑞制药-B(09966)发布公告,JSKN021及JSKN022临床前研究的最新成果已于202...
投资者提问:请问贵公司截止20... 投资者提问:请问贵公司截止2025年4月28日股东人数是多少?董秘回答(正丹股份(维权)SZ3006...
合纵科技2024年报解读:营收... 2025年4月,合纵科技股份有限公司发布2024年年度报告。报告期内,公司实现营业收入26.50亿元...
破解异地就医家庭“做饭难” 这... 文/图 羊城晚报全媒体记者 陈辉 实习生 易梦然在南方医科大学南方医院、广东三九脑科医院附近,居民区...
天能电池集团股份有限公司 20...   证券代码:688819                                     ...