Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:additional-software:opkg [2019/06/17 19:17] – [Opkg Package Manager] typo and word change ratedpg65docs:guide-user:additional-software:opkg [2023/04/03 07:37] – [Local repository] vgaetera
Line 1: Line 1:
-====== Opkg Package Manager ====== +====== Opkg package manager ====== 
-Like most Linux distributions (or mobile device operating systems like say Android or iOS), the functionality of the system can be upgraded rather significantly by downloading and installing pre-made packages from package repositories (local or on the Internet).\\  +Like most Linux distributions (or mobile device operating systems like say Android or iOS), the functionality of the system can be upgraded rather significantly by downloading and installing pre-made packages from package repositories (local or on the Internet).
-The ''opkg'' utility is the lightweight package manager used for this job. Opkg is a fork of ''ipkg'', the package manager used in NSLU2's [[http://www.nslu2-linux.org/wiki/Optware/|Optware]], which is designed to add software to stock firmware of embedded devices.\\  +
-Opkg is a full package manager for the root file system, including kernel modules and drivers, while ipkg is just a way to add software to a separate directory (e.g. ''/opt''). +
  
-Opkg is sometimes called //Entware//, as it is used also in the [[http://entware.wl500g.info|Entware repository]] for embedded devices (a fork of OpenWRT community packages repository).+The ''opkg'' utility is the lightweight package manager used for this job. 
 +Opkg is a fork of ''ipkg'', the package manager used in NSLU2's [[https://web.archive.org/web/20200919214711if_/http://www2.nslu2-linux.org/wiki/pmwiki.php?pagename=Optware/HomePage|Optware]]<sup>(archive link)</sup>, which is designed to add software to stock firmware of embedded devices. 
 + 
 +Opkg is a full package manager for the root file system, including kernel modules and drivers, while ipkg is just a way to add software to a separate directory (e.g. ''/opt''). 
 + 
 +Opkg is sometimes called //Entware//, as it is also the package manager used by the [[https://github.com/Entware/Entware/wiki|Entware repository]] for embedded devices (itself a fork of OpenWrt'community packages repository).
  
 The package manager ''opkg'' attempts to resolve dependencies with packages in the repositories - if this fails, it will report an error and abort the installation of that package. The package manager ''opkg'' attempts to resolve dependencies with packages in the repositories - if this fails, it will report an error and abort the installation of that package.
  
 Missing dependencies with third-party packages are probably available from the source of the package.\\ Missing dependencies with third-party packages are probably available from the source of the package.\\
-To ignore dependency errors, pass the ''<nowiki>--</nowiki>force-depends'' flag.+To ignore dependency errors, pass the ''%%--force-depends%%'' flag.
  
-:!: If you are using a snapshot / trunk  / bleeding edge version, installing packages may fail if the package in the repository is for a newer kernel version than the kernel version you have.\\ +:!: If you are using a snapshot / trunk / bleeding edge version, installing packages may fail if the package in the repository is for a newer kernel version than the kernel version you have.\\ 
 In this case, you will get the error message //"Cannot satisfy the following dependencies for…"//.\\  In this case, you will get the error message //"Cannot satisfy the following dependencies for…"//.\\ 
-For such usage of LEDE firmware, it's warmly recommended to use the [[docs:guide-user:additional-software:imagebuilder|Image Builder]] to make a flashable image containing all packages you need+For such usage of OpenWrt firmware, it's warmly recommended to use the [[docs:guide-user:additional-software:imagebuilder|Image Builder]] to make a flashable image containing all packages you need.
- +
- +
-:!: When on trunk/snapshot, kernel and kmod packages are flagged as //hold//, the ''opkg upgrade'' command won't attempt to update them+
  
 +:!: When on trunk/snapshot, kernel and kmod packages are flagged as //hold//, the ''opkg upgrade'' command won't attempt to update them.
  
 ===== Invocation ===== ===== Invocation =====
-<code>+<code bash> 
 +# opkg
 opkg must have one sub-command argument: opkg must have one sub-command argument:
 usage: opkg [options...] sub-command [arguments...] usage: opkg [options...] sub-command [arguments...]
Line 28: Line 30:
 You can use [[wp>Glob_(programming)|glob patterns]]. You can use [[wp>Glob_(programming)|glob patterns]].
  
-===== Package Manipulation ===== +===== Package manipulation ===== 
-| ''**update**''  | Update list of available packages\\ This simply retrieves a file like this one: [[https://downloads.lede-project.org/snapshots/packages/aarch64_armv8-a/base/Packages|example]], for your installation and stores it on your [[wp>tmpfs|RAM partition]] under ''/tmp/opkg-lists''. As of LEDE 17.01, after the opkg upgrade, this folder occupies about 450 KiB of space. OPKG needs the content of this folder in order to install or upgrade packages or to print info about them. You can safely delete the contents of this folder anytime to free up some RAM (its content is also lost on reboot), don't forget to run ''opkg update'' again before you install a new package.  +| ''**update**'' | Update list of available packages\\ This simply retrieves a file like this one: [[https://downloads.lede-project.org/snapshots/packages/aarch64_armv8-a/base/Packages|example]], for your installation and stores it on your [[wp>tmpfs|RAM partition]] under ''/tmp/opkg-lists''. As of LEDE 17.01, after the opkg upgrade, this folder occupies about 450 KiB of space. OPKG needs the content of this folder in order to install or upgrade packages or to print info about them. You can safely delete the contents of this folder anytime to free up some RAM (its content is also lost on reboot), don't forget to run ''opkg update'' again before you install a new package. | 
-| ''**upgrade** <pkgs>''  | [[upgrade_packages|Upgrade packages]]\\ To upgrade a group of packages, run ''opkg upgrade //packagename1// //packagename2//''.\\ A list of upgradeable packages can be obtained with the ''opkg list-upgradable'' command.\\ ------------\\ :!: Since LEDE firmware stores the base system in a compressed read-only partition, any update to base system packages will be written in the read-write partition and therefore use more space than it would if it was just overwriting the older version in the compressed base system partition. It's recommended to check the available space in internal flash memory and the space requirements for updates of base system packages.\\ Upgrading packages you installed should not have this issue as they are already in the read-write partition so the new one will overwrite the older one, although checking before upgrading never hurts.\\ As a general rule of thumb, devices that have 8 MiB or more total flash size and no user-installed packages should not have space issues when updating base packages, and of course devices set up for [[docs:guide-user:additional-software:extroot_configuration|Extroot]] won't have any space issue.\\ To check for free space, write ''df -h /'' from SSH or go in Software page in Luci webinterface (System submenu --> Software) to see how much space is left in the internal storage.\\ Check the size of packages you want to update by writing ''opkg info package-name'' in SSH or by checking the package size listed in the table in Software page, or you can check the [[packages:start|Table of  Packages]] here in the wiki. While the "size" in opkg is the size of package in a compressed archive, the jffs2 or ubifs read-write partition will use the same compression algorithm on the installed files, so it should have similar size when installed.\\ :!: The package repositories in the development snapshots are updated by the build bots to new versions very often, so it's very likely you won't be able to upgrade some packages due to broken dependencies with kernel or kernel-related packages. In that case, it's recommended to use the [[docs:guide-user:additional-software:imagebuilder|Image Builder]] and make a new firmware image with all packages you need and flash that instead of upgrading through opkg. +| ''**upgrade** <pkgs>'' | Upgrade packages\\ To upgrade a group of packages, run ''opkg upgrade //packagename1// //packagename2//''.\\ A list of upgradeable packages can be obtained with the ''opkg list-upgradable'' command.\\ ------------\\ :!: Since OpenWrt firmware stores the base system in a compressed read-only partition, any update to base system packages will be written in the read-write partition and therefore use more space than it would if it was just overwriting the older version in the compressed base system partition. It's recommended to check the available space in internal flash memory and the space requirements for updates of base system packages.\\ Upgrading packages you installed should not have this issue as they are already in the read-write partition so the new one will overwrite the older one, although checking before upgrading never hurts.\\ As a general rule of thumb, devices that have 8 MiB or more total flash size and no user-installed packages should not have space issues when updating base packages, and of course devices set up for [[docs:guide-user:additional-software:extroot_configuration|Extroot]] won't have any space issue.\\ To check for free space, write ''df -h /'' from SSH or go in Software page in Luci webinterface (System submenu --> Software) to see how much space is left in the internal storage.\\ Check the size of packages you want to update by writing ''opkg info package-name'' in SSH or by checking the package size listed in the table in Software page, or you can check the [[packages:start|Table of Packages]] here in the wiki. While the "size" in opkg is the size of package in a compressed archive, the jffs2 or ubifs read-write partition will use the same compression algorithm on the installed files, so it should have similar size when installed.\\ :!: The package repositories in the development snapshots are updated by the build bots to new versions very often, so it's very likely you won't be able to upgrade some packages due to broken dependencies with kernel or kernel-related packages. In that case, it's recommended to use the [[docs:guide-user:additional-software:imagebuilder|Image Builder]] and make a new firmware image with all packages you need and flash that instead of upgrading through opkg. | 
-| ''**opkg list-upgradable <nowiki>|</nowiki> cut -f 1 -d ' ' <nowiki>|</nowiki> xargs opkg upgrade**'' | [[upgrade_packages|Upgrades all installed packages]] that are currently upgradable \\ :!: Read the file system notes of the previous section first before upgrading all packages +| ''**install** <pkgs|url>'' | Install package(s)\\ Examples: <code bash>opkg install hiawatha 
-| ''**install** <pkgs|FQDN>'' | Install package(s)\\ Examples: <code>opkg install hiawatha</code> <code>opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/hiawatha_7.7-2_ar71xx.ipk</code> <code>opkg install /tmp/hiawatha_7.7-2_ar71xx.ipk</code>  +opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/hiawatha_7.7-2_ar71xx.ipk 
-| ''**configure** <pkgs>'' | Configure unpacked package(s)  +opkg install /tmp/hiawatha_7.7-2_ar71xx.ipk</code>
-| ''**remove** <pkgs|globp>'' | Remove package(s)  +| ''**configure** <pkgs>'' | Configure unpacked package(s) | 
-| ''**flag** <flag> <pkgs>'' | Flag one or multiple package(s). Only one flag per invocation is allowed. Available flags:\\ hold • noprune • user • ok • installed • unpacked  |+| ''**remove** <pkgs|globp>'' | Remove package(s) | 
 +| ''**flag** <flag> <pkgs>'' | Flag one or multiple package(s). Only one flag per invocation is allowed. Available flags:\\ hold • noprune • user • ok • installed • unpacked |
  
-===== Informational Commands ===== +===== Informational commands ===== 
-| ''**list** [pkg|globp]''      | List available packages\\ <code>Package name - Version - Description</code> The Description can contain line breaks, so using merely grep is inapt since grep is line-based.  +| ''**list** [pkg|globp]'' | List available packages\\ <code bash>Package name - Version - Description</code> The Description can contain line breaks, so using merely grep is inapt since grep is line-based. | 
-| ''**list-installed**''         | List installed packages  +| ''**list-installed**'' | List installed packages | 
-| ''**list-upgradable**''        | List installed and upgradable packages  +| ''**list-upgradable**'' | List installed and upgradable packages | 
-| ''**list-changed-conffiles**'' | List user modified configuration files  +| ''**list-changed-conffiles**'' | List user modified configuration files | 
-| ''**files** <pkg>''            | List files belonging to <pkg>. The package has to be already installed for this to work. Example:<code>+| ''**files** <pkg>'' | List files belonging to <pkg>. The package has to be already installed for this to work. Example:<code bash>
 opkg files asterisk18 opkg files asterisk18
 Package asterisk18 (1.8.4.4-1) is installed on root and has the following files: Package asterisk18 (1.8.4.4-1) is installed on root and has the following files:
Line 76: Line 79:
 /usr/lib/asterisk/modules/pbx_config.so /usr/lib/asterisk/modules/pbx_config.so
 /usr/lib/asterisk/modules/func_logic.so /usr/lib/asterisk/modules/func_logic.so
-</code>  +</code>
-| ''**search** <file|globp>''   | List package providing <file>  +| ''**search** <file|globp>'' | List package providing <file>
-| ''**info** [pkg|globp]''      | Display all info for <pkg>\\ <code>+| ''**info** [pkg|globp]'' | Display all info for <pkg>\\ <code bash>
 Package: horst Package: horst
 Version: 2.0-rc1-2 Version: 2.0-rc1-2
Line 92: Line 95:
 Source: feeds/packages/net/horst Source: feeds/packages/net/horst
 Description: [horst] is a scanning and analysis tool for 802.11 wireless networks and Description: [horst] is a scanning and analysis tool for 802.11 wireless networks and
- especially IBSS (ad-hoc) mode and mesh networks (OLSR).</code> **''Note1:''** The <color red>size</color> is the size of the gzip compressed tar archive. At installation package gets un-tared and decompressed, but then again JFFS2 uses compression itself.\\ **''Note2:''** Since the compression of JFFS2 is transparent, commands like ''ls'' will always report the size of the uncompressed file. | + especially IBSS (ad-hoc) mode and mesh networks (OLSR).</code> **Note 1:** The //Size// is the size of the gzip compressed tar archive. At installation package gets un-tared and decompressed, but then again JFFS2 uses compression itself.\\ **Note 2:** Since the compression of JFFS2 is transparent, commands like ''ls'' will always report the size of the uncompressed file. | 
-| ''**status** [pkg|globp]''  | Display all status for <pkg>  +| ''**status** [pkg|globp]'' | Display all status for <pkg> | 
-| ''**download** <pkg>''       | Download <pkg> to current directory  +| ''**download** <pkg>'' | Download <pkg> to current directory | 
-| ''**compare-versions** <v1> <op> <v2>''  | Compare versions ''v1'' and ''v2'' using the operators ''%%<=%%'', ''<'', ''>'', ''>='', ''='', ''%%<<%%'' or ''%%>>%%''  +| ''**compare-versions** <v1> <op> <v2>'' | Compare versions ''v1'' and ''v2'' using the operators ''%%<=%%'', ''<'', ''>'', ''>='', ''='', ''%%<<%%'' or ''%%>>%%''
-| ''**print-architecture**''   | List installable package architectures  +| ''**print-architecture**'' | List installable package architectures | 
-| ''**whatdepends** [-A] [pkgname|pat]+'' | This only works for installed packages. So if you would like to know, how much storage a package and all of it's dependencies would need, at the moment, you will have to piece this information together with the ''info''-option.  +| ''**whatdepends** [-A] [pkgname|pat]+'' | This only works for installed packages. So if you would like to know, how much storage a package and all of it's dependencies would need, at the moment, you will have to piece this information together with the ''info''-option. | 
-| ''**whatdependsrec** [-A] [pkgname|pat]+''  | This only works for installed packages. So if you would like to know, how much storage a package and all of it's dependencies would need, at the moment, you will have to piece this information together with the ''info''-option.  +| ''**whatdependsrec** [-A] [pkgname|pat]+'' | This only works for installed packages. So if you would like to know, how much storage a package and all of it's dependencies would need, at the moment, you will have to piece this information together with the ''info''-option. | 
-| ''**whatprovides** [-A] [pkgname|pat]+''    +| ''**whatprovides** [-A] [pkgname|pat]+'' | | 
-| ''**whatconflicts** [-A] [pkgname|pat]+''   +| ''**whatconflicts** [-A] [pkgname|pat]+'' | | 
-| ''**whatreplaces** [-A] [pkgname|pat]+''    |+| ''**whatreplaces** [-A] [pkgname|pat]+'' | |
  
 ===== Options ===== ===== Options =====
-^ Option ^ Long ^ Description  +^ Option ^ Long ^ Description ^ 
-| ''-A''                                    | Query all packages not just those installed  +| ''-A'' | | Query all packages not just those installed | 
-| ''-V[<level>]''    | ''%%--%%verbosity[=<level>]''  | Set verbosity level to <level> Available verbosity levels:\\ 0 errors only\\ 1 normal messages (default)\\ 2 informative messages\\ 3 debug\\ 4 debug level 2  +| ''-V[<level>]'' | ''%%--%%verbosity[=<level>]'' | Set verbosity level to <level>. Available verbosity levels:\\ 0 errors only\\ 1 normal messages (default)\\ 2 informative messages\\ 3 debug\\ 4 debug level 2 | 
-| ''-f <conf_file>''     | ''%%--%%conf <conf_file>''  | Use <conf_file> as the opkg configuration file. Default is ''/etc/opkg.conf''  +| ''-f <conf_file>'' | ''%%--%%conf <conf_file>'' | Use <conf_file> as the opkg configuration file. Default is ''/etc/opkg.conf''
-  | ''%%--cache <directory>%%''  | Use a package cache  +| | ''%%--cache <directory>%%'' | Use a package cache | 
-| ''-d <dest_name>''     | ''%%--%%dest <dest_name>''  | Use <dest_name> as the the root directory for 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).  +| ''-d <dest_name>'' | ''%%--%%dest <dest_name>'' | Use <dest_name> as the the root directory for 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>''           | ''%%--%%offline-root <dir>''  | Use <dir> as the root directory for offline installation of packages.  +| ''-o <dir>'' | ''%%--%%offline-root <dir>'' | Use <dir> as the root directory for offline installation of packages. | 
-| | ''%%--%%add-arch <arch>:<prio>''  | Register architecture with given priority  +| | ''%%--%%add-arch <arch>:<prio>'' | Register architecture with given priority | 
-| | ''%%--%%add-dest <name>:<path>''  | Register destination with given path  |+| | ''%%--%%add-dest <name>:<path>'' | Register destination with given path |
 ^ Force Options ^^^ ^ Force Options ^^^
-| | ''%%--force-depends%%''      | Install/remove despite failed dependencies  +| | ''%%--force-depends%%'' | Install/remove despite failed dependencies | 
-| | ''%%--force-maintainer%%''   | Overwrite preexisting config files  +| | ''%%--force-maintainer%%'' | Overwrite preexisting config files | 
-| | ''%%--force-reinstall%%''    | Reinstall package(s)  +| | ''%%--force-reinstall%%'' | Reinstall package(s) | 
-| | ''%%--force-overwrite%%''    | Overwrite files from other package(s)  +| | ''%%--force-overwrite%%'' | Overwrite files from other package(s) | 
-| | ''%%--force-downgrade%%''    | Allow opkg to downgrade packages  +| | ''%%--force-downgrade%%'' | Allow opkg to downgrade packages | 
-| | ''%%--force-space%%''        | Disable free space checks  +| | ''%%--force-space%%'' | Disable free space checks | 
-| | ''%%--force-checksum%%''     | Ignore checksum mismatches  +| | ''%%--force-checksum%%'' | Ignore checksum mismatches | 
-| | ''%%--force-postinstall%%''  | Run postinstall scripts even in offline mode  +| | ''%%--force-postinstall%%'' | Run postinstall scripts even in offline mode | 
-| | ''%%--noaction%%''           | No action -- test only  +| | ''%%--noaction%%'' | No action -- test only | 
-| | ''%%--download-only%%''      | No action -- download only  +| | ''%%--download-only%%'' | No action -- download only | 
-| | ''%%--nodeps%%''             | Do not follow dependencies  +| | ''%%--nodeps%%'' | Do not follow dependencies | 
-| | ''%%--force-removal-of-dependent-packages%%''  | Remove package and all dependencies  +| | ''%%--force-removal-of-dependent-packages%%'' | Remove package and all dependencies | 
-| | ''%%--autoremove%%''         | Remove packages that were installed automatically to satisfy dependencies  +| | ''%%--autoremove%%'' | Remove packages that were installed automatically to satisfy dependencies | 
-| ''-t''  | ''%%--tmp-dir%%''    | Specify tmp-dir.  | +| ''-t'' | ''%%--tmp-dir%%'' | Specify tmp-dir. |
- +
  
 ===== Examples ===== ===== Examples =====
-To install a package run the following commands. List of available packages is lost upon reboot, so make sure to update the list before trying to install a package +==== Basics ==== 
- +<code bash> 
-<code>+# Install a package
 opkg update opkg update
 opkg install <package> opkg install <package>
 +
 +# List packages
 +opkg list
 +
 +# Display package information
 +opkg info <package>
 </code> </code>
  
-To search  +==== Extras ==== 
-  * ''opkg list'' will display only ''Package name — Version — Description'' +You can make use of [[wp>Glob_(programming)|glob patterns]] directly and also write a little [[wp>Shell script|shell script]] to use [[wp>Regular expression|regular expressions]] and otherwise further process information. 
-  * ''opkg info'' will display all available information.+Use a [[wp>Pipeline_(Unix)|pipeline]] and [[man>grep(1)|grep]], or [[man>awk(1)|awk]], or [[man>sed(1)|sed]] to filter that output:
  
-You can make use of [[wp>Glob_(programming)|glob pattern]]s directly and also write a little  [[wp>Shell script|shell script]] to use [[wp>Regular expression]]s and otherwise further process information. Use a pipe (''|'') and ''grep'' or ''awk'' or ''sed'' to filter that output:+<code bash> 
 +opkg list grep -e <pattern1> -e <pattern2> 
 +opkg list awk -e '/<pattern>/{print $0}' 
 +opkg info kmod-nf-\* awk -e '/length/{print $0}' 
 +opkg list-installed | awk -e '{print $1}| tr '\n' ' ' 
 +for pkg in <package1> <package2> <package3>; do opkg info ${pkg}; done 
 +opkg depends dropbear 
 +</code>
  
-  * ''opkg list | grep pattern''  +==== Upgrading packages ==== 
-  * ''opkg list | awk '/pattern/ {print $0}'' +<WRAP important> 
-  * ''opkg info kmod-ipt-* awk '/length/ {print $0}''' +Mass upgrade of all packages is [[meta:infobox:upgrade_packages_warning|strongly discouraged]]. 
-  * ''opkg list-installed | awk '{print $1}' | sed ':M;N;$!bM;s#\n# #g''' +The chance of soft-bricking your device is significant, so be fully prepared to perform a [[docs:guide-user:troubleshooting:failsafe_and_factory_reset|recovery and factory reset in failsafe mode]]. 
-  * ''var="packagename1 packagename2 packagename2"; for i in $var; do opkg info $i; done;'' +Proceed at your own risk. 
-  * ''opkg depends dropbear'' doesn't work either.+</WRAP>
  
 +<code bash>
 +# Upgrade all installed packages
 +opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade
 +</code>
  
 ===== Configuration ===== ===== Configuration =====
-The main configuration file is ''/etc/opkg.conf''. It could look like this: +The main configuration file is ''/etc/opkg.conf''. 
-<code>+It could look like this: 
 + 
 +<code bash>
 dest root / dest root /
 dest ram /tmp dest ram /tmp
Line 161: Line 181:
 option overlay_root /overlay option overlay_root /overlay
 </code> </code>
-As you can see, it sets default folders.\\  + 
-default root directory (default / ),\\  +As you can see, it sets default folders: 
-default ram disk (default /tmp ) +  default root directory (default ''/'' 
-default folder to store package lists (default /var/opkg-lists, still a ram disk) +  default ram disk (default ''/tmp'' 
-what is the overlay directory (default /overlay)+  default folder to store package lists (default ''/var/opkg-lists'', still a ram disk) 
 +  what is the overlay directory (default ''/overlay'')
  
 Most of these options must be left to default, or have no real reason to be changed. Most of these options must be left to default, or have no real reason to be changed.
Line 171: Line 192:
 You might want to change the ''lists_dir ext /var/opkg-lists'' to ''lists_dir ext /path/on/disk'' if your device has 32 MiB or less of RAM and [[docs:guide-user:additional-software:extroot_configuration|you expanded your firmware's storage space in an external drive]], so you can use opkg without causing Out Of Memory errors. You might want to change the ''lists_dir ext /var/opkg-lists'' to ''lists_dir ext /path/on/disk'' if your device has 32 MiB or less of RAM and [[docs:guide-user:additional-software:extroot_configuration|you expanded your firmware's storage space in an external drive]], so you can use opkg without causing Out Of Memory errors.
  
-This file is accessible and can be modified from Luci Web interface too, Click on **Services** then on **Software**. Click on **Configuration** tab.+This file is accessible and can be modified from Luci Web interface too, Click on **Services** then on **Software**. 
 +Click on **Configuration** tab.
  
-==== Adjust Repositories ==== +==== Adjust repositories ==== 
-Feeds are set in ''/etc/opkg/distfeeds.conf'' +Feeds are set in ''/etc/opkg/distfeeds.conf''
-<code>+ 
 +<code bash>
 src/gz reboot_core http://downloads.lede-project.org/snapshots/targets/ramips/mt7620/packages src/gz reboot_core http://downloads.lede-project.org/snapshots/targets/ramips/mt7620/packages
 src/gz reboot_base http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/base src/gz reboot_base http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/base
Line 183: Line 206:
 src/gz reboot_luci http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/luci src/gz reboot_luci http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/luci
 </code> </code>
-there is also another file for custom feeds called ''/etc/opkg/customfeeds.conf'' + 
-<code>+There is also another file for custom feeds called ''/etc/opkg/customfeeds.conf''
 + 
 +<code bash>
 # add your custom package feeds here # add your custom package feeds here
 # #
Line 190: Line 215:
 </code> </code>
  
-Both files are accessible and can be modified from Luci Web interface too, Click on **Services** then on **Software**. Click on **Configuration** tab, then scroll down.+Both files are accessible and can be modified from Luci Web interface too, Click on **Services** then on **Software**. 
 +Click on **Configuration** tab, then scroll down.
  
-=== Local Repositories ===+=== Local repositories ===
 You can configure opkg to fetch the packages locally: You can configure opkg to fetch the packages locally:
-<code>+ 
 +<code bash>
 src/gz local file:///path/to/packagesDirectory src/gz local file:///path/to/packagesDirectory
 </code> </code>
  
-LEDE uses multiple repositories, where every repository requires a unique identifier. It is logical to use their original names, e.g.:+OpenWrt uses multiple repositories, where every repository requires a unique identifier. 
 +It is logical to use their original names, e.g.:
  
-<code>+<code bash>
 ... ...
 src/gz base file:///path/to/packages/directory/packages/base src/gz base file:///path/to/packages/directory/packages/base
Line 209: Line 237:
 </code> </code>
  
-==== Change Architectures ==== +==== Change architectures ==== 
-<WRAP center round todo 90%+<WRAP todo> 
-LEDE is using package architectures, many devices pull packages from the same pool.\\ +OpenWrt is using package architectures
-The following paragraph requires proofreading and likely some modification to be adapted for the current LEDE status.+Many devices pull packages from the same pool. 
 + 
 +The following paragraph requires proofreading and likely some modification to be adapted for the current OpenWrt status.
 </WRAP> </WRAP>
  
-By default, opkg only allows packages with the architecture ''all'' (= architecture independent) and the architecture of the installed target.\\  +By default, opkg only allows packages with the architecture ''all'' (= architecture independent) and the architecture of the installed target. 
-In order to download and install packages for a foreign target architecture, the list of allowed architectures can be overridden in ''/etc/opkg.conf'' +In order to download and install packages for a foreign target architecture, the list of allowed architectures can be overridden in ''/etc/opkg.conf'' with the use of ''arch'' options:
- with the use of ''arch'' options:+
  
-<code>arch all 100+<code bash> 
 +arch all 100
 arch brcm4716 200 arch brcm4716 200
 arch brcm47xx 300 arch brcm47xx 300
 </code> </code>
  
-This example would allow installing ''brcm47xx'' packages (compiled to run on ''brcm47xx'' family of SoC/devices) on the ''brcm4716'' (a specific SoC) target.\\ +This example would allow installing ''brcm47xx'' packages (compiled to run on ''brcm47xx'' family of SoC/devices) on the ''brcm4716'' (a specific SoC) target.
 The number specifies a priority index which is used by ''opkg'' to determine which package to prefer in case it is available in multiple architectures. The number specifies a priority index which is used by ''opkg'' to determine which package to prefer in case it is available in multiple architectures.
  
 ==== Proxy support ==== ==== Proxy support ====
 +OpenWrt 21.02:
 +
 +<code bash>
 +# Configure profile
 +mkdir -p /etc/profile.d
 +cat << "EOF" > /etc/profile.d/custom.sh
 +export https_proxy=http://proxy.example.org:8080/
 +EOF
 +. /etc/profile
 +
 +# Workaround
 +sed -i -e "s/https/http/" /etc/opkg/distfeeds.conf
 +</code>
 +
 To use ''opkg'' through a proxy, add the following to ''/etc/opkg.conf'': To use ''opkg'' through a proxy, add the following to ''/etc/opkg.conf'':
  
-<code>+<code bash>
 option http_proxy http://proxy.example.org:8080/ option http_proxy http://proxy.example.org:8080/
 option ftp_proxy ftp://proxy.example.org:2121/ option ftp_proxy ftp://proxy.example.org:2121/
Line 237: Line 281:
 Use the options below to authenticate against the proxy server: Use the options below to authenticate against the proxy server:
  
-<code>+<code bash>
 option proxy_user xxxx option proxy_user xxxx
 option proxy_passwd xxxx option proxy_passwd xxxx
Line 244: Line 288:
 Alternatively, a username and password may be provided as part of the URL if busybox wget is installed: Alternatively, a username and password may be provided as part of the URL if busybox wget is installed:
  
-<code>+<code bash>
 option http_proxy http://username:password@proxy.example.org:8080/ option http_proxy http://username:password@proxy.example.org:8080/
 option ftp_proxy http://username:password@proxy.example.org:2121/ option ftp_proxy http://username:password@proxy.example.org:2121/
Line 251: Line 295:
 :!: Authentication currently fails when using uclient-fetch as wget due to ''Proxy-Authorization'' not yet being implemented. :!: Authentication currently fails when using uclient-fetch as wget due to ''Proxy-Authorization'' not yet being implemented.
  
 +If you are running apt-cacher-ng and want to use that for OpenWRT, you may experience problems downloading .sig files through apt-cacher-ng.
 +In that case put the following line in your ''acng.conf'' file:
 +
 +<code bash>
 +VfilePatternEx: |\.sig$
 +</code>
  
 ===== Troubleshooting ===== ===== Troubleshooting =====
 +==== Verbose opkg update ====
 +<code bash>
 +# Save the script
 +cat << "EOF" > opkg-update.sh
 +#!/bin/sh
 +rm -f -R /tmp/opkg-lists
 +mkdir -p /tmp/opkg-lists
 +while read TYPE REPO URL
 +do
 +wget -O /tmp/opkg-lists/"${REPO}".gz "${URL}"/Packages.gz
 +wget -O /tmp/opkg-lists/"${REPO}".sig "${URL}"/Packages.sig
 +gunzip -k /tmp/opkg-lists/"${REPO}".gz
 +usign -V -P /etc/opkg/keys -m /tmp/opkg-lists/"${REPO}" 2>&1 \
 +| grep -e "^OK$" \
 +&& mv -f /tmp/opkg-lists/"${REPO}".gz /tmp/opkg-lists/"${REPO}"
 +done < /etc/opkg/distfeeds.conf
 +EOF
 +chmod +x opkg-update.sh
 +
 +# Run the script
 +./opkg-update.sh
 +</code>
 +
 ==== Out of space ==== ==== Out of space ====
-If //opkg// runs out of space, it usually fails to recover cleanly leaving dangling lock files in place resulting in ''//Could not obtain administrative lock//'' error. The lock file can be deleted by issuing the ''rm /usr/lib/opkg/lock'' command.+Remove partly installed packages and their dependencies if //opkg// runs out of space during transaction.
  
-Additionally, //opkg// may not remove the files it was installing.\\ +<code bash> 
-One way to do this is get a list of the files it was installing, then delete them.+# Save the script 
 +cat << "EOF" > opkg-rm-pkg-deps.sh 
 +#!/bin/sh 
 +opkg update 
 +URL="$(opkg --force-space --noaction install "${@}"
 +| sed -n -e "/^Downloading\s*/s///p")" 
 +rm -f /usr/lib/opkg/lock 
 +for URL in ${URL} 
 +do FILE="$(wget -q -O - "${URL}"
 +| tar -O -x -z ./data.tar.gz \ 
 +| tar -t -z 
 +| sort -r \ 
 +| sed -e "s|^\.|/overlay/upper|")" 
 +for FILE in ${FILE} 
 +do if [ -f "${FILE}"
 +then rm -f "${FILE}" 
 +elif [ -d "${FILE}"
 +then rmdir "${FILE}" 
 +fi 
 +done 
 +done 
 +EOF 
 +chmod +x opkg-rm-pkg-deps.sh 
 +</code>
  
-Replace the url with the appropriate package.+<code bash>
  
-<code> +# Run the script 
-(cd /; \ +./opkg-rm-pkg-deps.sh package_name 
- wget -qOhttp://download.link.to.package | \ + 
- tar -Oxz ./data.tar.gz | tar -tz | xargs rm)+# Reboot to make the free space visible 
 +reboot
 </code> </code>
  
-However, the above line does not delete the dependencies that were installed along with the package responsibleAlsoit leaves empty directories around. The script below intends to fix those.+==== Local repository ==== 
 +There may be use cases where having a package repository on the device itself is advantageous: 
 +  * Unreliable WANswhere the connectivity upstream of the device to a remote repository goes down for an unacceptable period of time. 
 +  * Bandwidth Caps, where the connectivity upstream of the device to a remote repository has a limited amount of data that can be fetched before the connectivity is throttled or goes down until the next period where the cap resets. 
 +  * A repository with customization; built from sourcewhich isn't available from remote repositories. 
 +  * The device acts as a reference device for other systems, to ensure that the package versions across the devices local to the network remain consistent.
  
-<code> +Set up a local repository for your target. 
-#!/bin/sh +Assuming about 2-3 GB of free space is available.
-#takes one argument/parameter: the name of the package which didn't install correctly and should be removed along with its dependencies +
-#example: ./opkgremovepartlyinstalledpackage.sh pulseaudio-daemon+
  
-#get list of all packages that would be installed along with package x +<code bash> 
-PACKAGES=`opkg --force-space --noaction install $1 | grep "http:" | cut -f 2 -d ' ' | sed 's/\.$//'`+Install packages
 opkg update opkg update
 +opkg install rsync
  
-for i in $PACKAGES +# Save the script 
-do +cat << "EOF" > opkg-sync-local-repo.sh 
-        LIST=`wget -qO$i | tar -Oxz ./data.tar.gz | tar -tz | sort -r | sed 's/^./\/overlay\/upper/'` +#!/bin/sh 
-        for f in $LIST +/etc/os-release 
-        do +REPO_LOCAL="file://${1:-/${ID}}/
-                if [ -f $f ] +REPO_URL="https://downloads.${HOME_URL#*//}" 
-                then +case "${VERSION_ID}" in 
-                        echo "Removing file $f+(snapshot) REPO_DIR="downloads/snapshots" ;; 
-                        rm -f $f +(*) REPO_DIR="downloads/releases/${VERSION_ID}" ;; 
-                fi +esac 
-                if [ -$f ] +REPO_CORE="${REPO_DIR}/targets/${OPENWRT_BOARD}
-                then +REPO_PKGS="${REPO_DIR}/packages/${OPENWRT_ARCH}" 
-                        echo "Try to remove directory $f (will only work on empty directories)+for REPO_DIR in "${REPO_CORE}" "${REPO_PKGS}" 
-                        rmdir $+do mkdir -p "${REPO_LOCAL#*//}${REPO_DIR#*/}" 
-                fi +rsync --bwlimit="8M" --del -r -t -v \ 
-        done+"${REPO_URL/https/rsync}${REPO_DIR}/\ 
 +"${REPO_LOCAL#*//}${REPO_DIR#*/}/"
 done done
-echo "You may need to reboot for the free space to become visible" +EOF 
-</code> +chmod +x opkg-sync-local-repo.sh
-Save it as ''opkgremovepartlyinstalledpackage.sh'' somewhere, set it as an executable with ''chmod +x ./opkgremovepartlyinstalledpackage.sh'' and you can execute it by doing ''./opkgremovepartlyinstalledpackage.sh <package-name> '' .+
  
-==== Local Repository ====+# Run the script 
 +./opkg-sync-local-repo.sh /openwrt
  
-FIXME Convert this into LEDE and explain what it is actually doing.\\ +# Configure Opkg to use local repo 
-Live example: +/etc/os-release 
-<code> +REPO_LOCAL="file:///${ID}/" 
-r=44685 +REPO_URL="https://downloads.${HOME_URL#*//}
-search="http://downloads.openwrt.org/snapshots/trunk/ar71xx/generic+sed -i -e "s|${REPO_URL}|${REPO_LOCAL}|" /etc/opkg/distfeeds.conf
-replace="file:///mnt/sdcard/shared/users/www/r$r+
-sed -i -e "s!$search!$replace!" /etc/opkg.conf +
-</code>+
  
-Share for a second router: +Share the repository on the LAN 
-<code> +ln -f -s ${REPO_LOCAL#*///www/${ID}
-ln -s /mnt/sdcard/shared/users/www /www/pendrive +
-</code>+
  
-In the second router: +# Configure Opkg on the clients 
-<code> +. /etc/os-release 
-r=44685 +REPO_LOCAL="http://192.168.1.1/${ID}/
-search="downloads.openwrt.org/snapshots/trunk/ar71xx/generic" +REPO_URL="https://downloads.${HOME_URL#*//}
-replace="192.168.1.1/pendrive/r$r+sed -i -e "s|${REPO_URL}|${REPO_LOCAL}|" /etc/opkg/distfeeds.conf
-sed -i -e "s!$search!$replace!" /etc/opkg.conf+
 </code> </code>
  
 +See also: [[:downloads#how_to_mirror|How to mirror]]
  
-===== Non-standard Installation Destinations =====+===== Non-standard installation destinations =====
 Due to its history (fork of ipkg), opkg can specify a destination different than root for package installation, but since most packages don't support this natively, it's more a curiosity than actually useful. Due to its history (fork of ipkg), opkg can specify a destination different than root for package installation, but since most packages don't support this natively, it's more a curiosity than actually useful.
  
-<WRAP center round info 90%>+<WRAP info>
 The recommended way to have more space to install your packages is [[docs:guide-user:additional-software:extroot_configuration|Extroot]] The recommended way to have more space to install your packages is [[docs:guide-user:additional-software:extroot_configuration|Extroot]]
 </WRAP> </WRAP>
  
-<WRAP center round important 90%+<WRAP important> 
-**WARNING:** this solution will NOT work out-of-the-box in most cases, LEDE packages are designed to be installed in root filesystem and may need additional symlinks or modifications to work at all under the changed path!+This solution will NOT work out-of-the-box in most cases, OpenWrt packages are designed to be installed in root filesystem and may need additional symlinks or modifications to work at all under the changed path!
 </WRAP> </WRAP>
  
-The default opkg.conf actually contains three destinations:+The default ''/etc/opkg.conf'' actually contains three destinations:
  
-<code>+<code bash>
 dest root / dest root /
 dest ram /tmp dest ram /tmp
Line 343: Line 440:
 </code> </code>
  
-The format of destination lines is simply the keyword dest, followed by a name for this destination (this can be anything), followed by a filesystem location.  Any destination that has been thus configured can then be specified on the opkg command line like this:+The format of destination lines is simply the keyword dest, followed by a name for this destination (this can be anything), followed by a filesystem location. 
 +Any destination that has been thus configured can then be specified on the opkg command line like this:
  
-<code>+<code bash>
 opkg -d destination_name install somepackage opkg -d destination_name install somepackage
 </code> </code>
  • Last modified: 2024/04/12 10:08
  • by virtualguy