openwrt - opkg

 

 


opkg (Package Manager)

 

查看可用的 package:

http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages

設定檔:

/etc/opkg.conf

# 一此安裝 package 時會用到的系統路徑
dest  root  /
dest  ram  /tmp

# folder to store package lists
lists_dir   ext   /var/opkg-lists 

# Settings
option   overlay_root    /overlay
option   check_signature

# package優先次序
arch all 100

Package Repositories

# 從這裡下載 Packages.gz

/etc/opkg/distfeeds.conf

src/gz openwrt_core https://downloads.openwrt.org/releases/22.03.7/targets/x86/generic/packages
src/gz openwrt_base https://downloads.openwrt.org/releases/22.03.7/packages/i386_pentium4/base
src/gz openwrt_luci https://downloads.openwrt.org/releases/22.03.7/packages/i386_pentium4/luci
src/gz openwrt_packages https://downloads.openwrt.org/releases/22.03.7/packages/i386_pentium4/pa...
src/gz openwrt_routing https://downloads.openwrt.org/releases/22.03.7/packages/i386_pentium4/ro...
src/gz openwrt_telephony https://downloads.openwrt.org/releases/22.03.7/packages/i386_pentium4/telephony

設定使用另一個 Repo

MyRepo=https://Domain/Folder

cd /etc/opkg

cp distfeeds.conf distfeeds.conf.bak

sed -i "s%https://downloads.openwrt.org/releases%$MyRepo%g" distfeeds.conf

lock 檔

/usr/lib/opkg/lock

 


CLI Usage

 

opkg [options...] [arguments...]

update                            <-- 下載可用的 package 資料(/var/opkg-lists/snapshots)

install <pkgs>

remove <pkgs>

flag <flag> <pkgs>          <-- hold, noprune, user, ok, installed, unpacked

configure <pkgs>

upgrade <pkgs>              <-- (找出 pkgs opkg list-upgradable)  * 不建議在 SquashFS partition 上使用

download <pkg>             <-- 下載某 package (並沒有下載所要的依賴 package)

資訊 cli :

  • status [pkg|regexp]

  • info [pkg|regexp]

 

  • list [pkg|regexp]              # List available packages

  • list-installed                     # List installed packages 

 

  • files <pkg>                     # 這 <pkg> 有什麼 files

  • search <file|regexp>       # 這 file 是屬於什麼 package

 

Example

opkg info screen

Package: screen
Version: 4.3.1-1
Depends: libc, libncurses
Status: unknown ok not-installed
Section: utils
Architecture: ar71xx
Maintainer: Etienne CHAMPETIER <[email protected]>
MD5Sum: e49ce215d2ffaddb10a8d9974f56691e
Size: 154676
Filename: screen_4.3.1-1_ar71xx.ipk
Source: feeds/packages/utils/screen
Description: Screen is a full-screen window manager that multiplexes a physical
 terminal between several processes, typically interactive shells.

Destination for any package installation

Settings

#    Name Location
dest root /
dest ram /tmp
dest mnt /mnt

opkg install somepackage -d destination_name

e.g.

opkg install somepackage -d ram

有用 options

--cache <directory>

--nodeps

Install ipk

用 winscp 上載所需的 package 到 /tmp/package

cd /tmp/package
opkg install *

查看 package 間的依賴性

 

opkg depends muninlite

muninlite depends on:
        xinetd

opkg depends -A screen

screen depends on:
        libc
        libncurses

 

 


Upgrade Package

 

查看有什麼 Package 可供 upgrade

root@OpenWrt:~# opkg list-upgradable

luci-theme-bootstrap - git-23.093.42704-b47268a - git-23.338.81637-b07421e
luci-mod-status - git-23.292.78392-20daafc - git-23.340.83757-3cb6cf6
luci-base - git-23.292.78392-9f66674 - git-23.357.58072-4a451e3
luci-proto-ipv6 - git-21.148.48881-79947af - git-23.355.78888-e047387
luci-lib-nixio - git-20.234.06894-c4a4e43 - git-23.338.82617-581339c
luci-mod-network - git-23.170.81153-99d3815 - git-23.342.43369-35041cb

Upgrade All Package

opkg list-upgradable | cut -f 1 -d ' ' | xargs -r opkg upgrade

升級過程常見 Error

Collected errors:

 * resolve_conffiles: Existing conffile /etc/config/luci
  is different from the conffile in the new package.
  The new conffile will be placed at /etc/config/luci-opkg.

opkg install diffutils

diff luci luci-opkg

 


Troubleshoot

 

rm /usr/lib/opkg/lock

 

 

 

 

 

Creative Commons license icon Creative Commons license icon