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.

相关内容

热门资讯

Python|位运算|数组|动... 目录 1、只出现一次的数字(位运算,数组) 示例 选项代...
张岱的人物生平 张岱的人物生平张岱(414年-484年),字景山,吴郡吴县(今江苏苏州)人。南朝齐大臣。祖父张敞,东...
西游西后传演员女人物 西游西后传演员女人物西游西后传演员女人物 孙悟空 六小龄童 唐僧 徐少华 ...
名人故事中贾岛作诗内容简介 名人故事中贾岛作诗内容简介有一次,贾岛骑驴闯了官道.他正琢磨着一句诗,名叫《题李凝幽居》全诗如下:闲...
和男朋友一起优秀的文案? 和男朋友一起优秀的文案?1.希望是惟一所有的人都共同享有的好处;一无所有的人,仍拥有希望。2.生活,...
戴玉手镯的好处 戴玉手镯好还是... 戴玉手镯的好处 戴玉手镯好还是碧玺好 女人戴玉?戴玉好还是碧玺好点佩戴手镯,以和田玉手镯为佳!相嫌滑...
依然什么意思? 依然什么意思?依然(汉语词语)依然,汉语词汇。拼音:yī    rán基本解释:副词,指照往常、依旧...
高尔基的散文诗 高尔基的散文诗《海燕》、《大学》、《母亲》、《童年》这些都是比较出名的一些代表作。
心在飞扬作者简介 心在飞扬作者简介心在飞扬作者简介如下。根据相关公开资料查询,心在飞扬是一位优秀的小说作者,他的小说作...
卡什坦卡的故事赏析? 卡什坦卡的故事赏析?讲了一只小狗的故事, 我也是近来才读到这篇小说. 作家对动物的拟人描写真是惟妙...
林绍涛为简艾拿绿豆糕是哪一集 林绍涛为简艾拿绿豆糕是哪一集第三十二集。 贾宽认为是阎帅间接导致刘映霞住了院,第二天上班,他按捺不...
小爱同学是女生吗小安同学什么意... 小爱同学是女生吗小安同学什么意思 小爱同学,小安同学说你是女生。小安是男的。
内分泌失调导致脸上长斑,怎么调... 内分泌失调导致脸上长斑,怎么调理内分泌失调导致脸上长斑,怎么调理先调理内分泌,去看中医吧,另外用好的...
《魔幻仙境》刺客,骑士人物属性... 《魔幻仙境》刺客,骑士人物属性加点魔幻仙境骑士2功1体质
很喜欢她,该怎么办? 很喜欢她,该怎么办?太冷静了!! 太理智了!爱情是需要冲劲的~不要考虑着考虑那~否则缘...
言情小说作家 言情小说作家我比较喜欢匪我思存的,很虐,很悲,还有梅子黄时雨,笙离,叶萱,还有安宁的《温暖的玄》 小...
两个以名人的名字命名的风景名胜... 两个以名人的名字命名的风景名胜?快太白楼,李白。尚志公园,赵尚志。
幼儿教育的代表人物及其著作 幼儿教育的代表人物及其著作卡尔威特的《卡尔威特的教育》,小卡尔威特,他儿子成了天才后写的《小卡尔威特...
海贼王中为什么说路飞打凯多靠霸... 海贼王中为什么说路飞打凯多靠霸气升级?凯多是靠霸气升级吗?因为之前刚到时确实打不过人家因为路飞的实力...
运气不好拜财神有用吗运气不好拜... 运气不好拜财神有用吗运气不好拜财神有没有用1、运气不好拜财神有用。2、拜财神上香前先点蜡烛,照亮人神...