project/opkg-lede.git
7 years agotests: fix build of opkg_extract_test
Jo-Philipp Wich [Fri, 17 Feb 2017 14:08:44 +0000 (15:08 +0100)]
tests: fix build of opkg_extract_test

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agobuild: add cmake build system
Jo-Philipp Wich [Fri, 17 Feb 2017 14:08:03 +0000 (15:08 +0100)]
build: add cmake build system

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agoopkg-cl: stop preloading package feeds on install
Jo-Philipp Wich [Thu, 16 Feb 2017 15:44:07 +0000 (16:44 +0100)]
opkg-cl: stop preloading package feeds on install

Instead of unconditionally loading all package feed lists entirely into
memory, let opkg_install_cmd() selectively parse the lists using the new
pkg_hash_load_package_details() helper.

This will result in a slightly longer runtime but dramatically reduces the
memory requirements. On an x86_64 test system, the peak heap memory
consumption during an "opkg install luci" dropped from 3.7 MB to about
360 KB, a decrease of roughly 90%.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: selectively load package feeds in opkg_info_status_cmd()
Jo-Philipp Wich [Thu, 16 Feb 2017 15:36:58 +0000 (16:36 +0100)]
libopkg: selectively load package feeds in opkg_info_status_cmd()

Use the new pkg_hash_load_package_details() helper to selectively load the
dependency subgraphs of the to be installed packages.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: immediately free packages not marked for detail parsing
Jo-Philipp Wich [Thu, 16 Feb 2017 15:33:57 +0000 (16:33 +0100)]
libopkg: immediately free packages not marked for detail parsing

Stop recording packages into the dependency graph which are not flagged
with SF_NEED_DETAILS.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: avoid aggregating multiple identical providers
Jo-Philipp Wich [Thu, 16 Feb 2017 14:56:14 +0000 (15:56 +0100)]
libopkg: avoid aggregating multiple identical providers

Since we might do multiple parsing runs over the feed list files in the
future, ensure that we do not insert the abstract provider package multiple
times into the provided_by vector.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: implement pkg_hash_load_package_details() helper
Jo-Philipp Wich [Thu, 16 Feb 2017 11:19:02 +0000 (12:19 +0100)]
libopkg: implement pkg_hash_load_package_details() helper

The purpose of this new function is to keep parsing feed lists until
all package detail requests are satisified.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: support passing default state flags in pkg_hash_load_feeds()
Jo-Philipp Wich [Thu, 16 Feb 2017 11:16:29 +0000 (12:16 +0100)]
libopkg: support passing default state flags in pkg_hash_load_feeds()

Add a new argument to pkg_hash_load_feeds() which allows specifying default
state flags that should be applied to all loaded packages.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: flag package with SF_NEED_DETAIL in pkg_init_from_file()
Jo-Philipp Wich [Thu, 16 Feb 2017 11:12:04 +0000 (12:12 +0100)]
libopkg: flag package with SF_NEED_DETAIL in pkg_init_from_file()

Flag the package loaded from file as SF_NEED_DETAIL to properly fetch and
resolve dependencies.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix printing provides in pkg_formatted_field()
Jo-Philipp Wich [Thu, 16 Feb 2017 11:10:16 +0000 (12:10 +0100)]
libopkg: fix printing provides in pkg_formatted_field()

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix pkg_deinit() to properly free the resources in the blob buffer
Jo-Philipp Wich [Thu, 16 Feb 2017 10:57:55 +0000 (11:57 +0100)]
libopkg: fix pkg_deinit() to properly free the resources in the blob buffer

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: free old provides list in pkg_merge()
Jo-Philipp Wich [Thu, 16 Feb 2017 10:50:02 +0000 (11:50 +0100)]
libopkg: free old provides list in pkg_merge()

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix merging PKG_CONFFILES in pkg_merge()
Jo-Philipp Wich [Thu, 16 Feb 2017 10:47:48 +0000 (11:47 +0100)]
libopkg: fix merging PKG_CONFFILES in pkg_merge()

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix pkg_set_ptr() to properly set NULL pointers
Jo-Philipp Wich [Thu, 16 Feb 2017 10:46:31 +0000 (11:46 +0100)]
libopkg: fix pkg_set_ptr() to properly set NULL pointers

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: allow passing common package state flags to pkg_hash_add_from_file()
Jo-Philipp Wich [Wed, 15 Feb 2017 23:24:29 +0000 (00:24 +0100)]
libopkg: allow passing common package state flags to pkg_hash_add_from_file()

Add a new parameter to pkg_hash_add_from_file() for passing package state
flags that shall be applied to all pkg_t instances parsed from the given
file and use it to mark all packages loaded from local status files with
the SF_NEED_DETAIL flag.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: propagate SF_NEED_DETAIL from abstract to discrete package
Jo-Philipp Wich [Wed, 15 Feb 2017 23:21:05 +0000 (00:21 +0100)]
libopkg: propagate SF_NEED_DETAIL from abstract to discrete package

During parsing, propagate the state of the SF_NEED_DETAIL flag from the
related abstract package to the discrete pkg_t instance getting assembled.

This is required to ensure that subsequent parsing of pkg_t's dependency
lists considers the state of SF_NEED_DETAIL.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: do not clobber package flags during parsing
Jo-Philipp Wich [Wed, 15 Feb 2017 23:18:25 +0000 (00:18 +0100)]
libopkg: do not clobber package flags during parsing

When parsing "Status:" lines from package control or list files, do not
overwrite previously set flags in the package structure.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: propagate SF_NEED_DETAIL to related packages
Jo-Philipp Wich [Wed, 15 Feb 2017 23:15:05 +0000 (00:15 +0100)]
libopkg: propagate SF_NEED_DETAIL to related packages

When parsing Provides, Suggests, Conflicts, Replaces and Depends lists,
propagate the parent package SF_NEED_DETAIL flag to related abstract
packages in order to ensure that the entire related dependency graph
is processed.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: directly pass type to parseDepends()
Jo-Philipp Wich [Wed, 15 Feb 2017 23:09:05 +0000 (00:09 +0100)]
libopkg: directly pass type to parseDepends()

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: expose abstract_pkg_fetch_by_name()
Jo-Philipp Wich [Wed, 15 Feb 2017 23:01:58 +0000 (00:01 +0100)]
libopkg: expose abstract_pkg_fetch_by_name()

We need this function in other places later in order to be able to fetch
abstract packages without implicitely creating them.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: mark to-be-installed non-local, non-url packages for detail parsing
Jo-Philipp Wich [Wed, 15 Feb 2017 22:54:13 +0000 (23:54 +0100)]
libopkg: mark to-be-installed non-local, non-url packages for detail parsing

When just a package name is passed to opkg install, we need to retrieve
information about this package from the feeds list so stage an abstract
package with the given name and flag it with SF_NEED_DETAIL.

Packages specified as local file paths or direct download URLs do not
need this special treatment as the required details can be extracted
from their embedded control files.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: introduce SF_NEED_DETAIL flag
Jo-Philipp Wich [Wed, 15 Feb 2017 22:47:53 +0000 (23:47 +0100)]
libopkg: introduce SF_NEED_DETAIL flag

Introduce a new pkt_t state_flag value SF_NEED_DETAIL which will be used
to mark packages for which we require details.

When parsing the feed lists, we'll only keep information about packages
marked with SF_NEED_DETAIL and packages related to them through Provides,
Suggests, Conflicts, Depends etc.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: make checksum_bin2hex() and checksum_hex2bin() cope with NULL
Jo-Philipp Wich [Wed, 15 Feb 2017 22:42:58 +0000 (23:42 +0100)]
libopkg: make checksum_bin2hex() and checksum_hex2bin() cope with NULL

Those functions may be called with a NULL source pointer, especially during
pkg_merge(), so allow that to keep call sites simple.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix unsatisfied dependency reporting
Jo-Philipp Wich [Wed, 15 Feb 2017 22:39:47 +0000 (23:39 +0100)]
libopkg: fix unsatisfied dependency reporting

Previous refactoring of pkg_hash_fetch_unsatisfied_dependencies() caused the
outermost loop counter variable to not get incremented anymore, causing the
function to always report the first dependency as unsatisifed.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix hex encoding/decoding, add checksum getter/setter
Jo-Philipp Wich [Mon, 13 Feb 2017 17:07:04 +0000 (18:07 +0100)]
libopkg: fix hex encoding/decoding, add checksum getter/setter

Fix broken hex encoding/decoding due to the use of signed chars and introduce
new convenience getters and setters to simplify the checksum usage.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: store checksums in binary form, use integer index for architecture
Jo-Philipp Wich [Mon, 13 Feb 2017 17:07:04 +0000 (18:07 +0100)]
libopkg: store checksums in binary form, use integer index for architecture

Instead of storing a copy of the architecture string and architecture
priority value in each pkg_t instance, declare a 3 bit wide field which
allows referencing the architecture in the global config array by index.

The 3 bit field allows referencing up to 8 different architectures which
is more than enough for the systems we target with opkg. Another nice side
effect is that we can coalesce this field with other flag values in pkg_t,
saving 4 bytes for an int member.

Also convert the hexadecimal checksums to binary format before storing them in
pkg_t's blob buffer to save 50% of the space per checksum.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agopkg: move active_list structure out of pkg_t
Jo-Philipp Wich [Mon, 13 Feb 2017 13:31:24 +0000 (14:31 +0100)]
pkg: move active_list structure out of pkg_t

The active list head is only used by a tiny fraction of the allocated
package structures in memory so do not waste heap memory by allocating
space for it in all loaded packages.

Instead allocate active list heads dynamically where needed and point
them to the corresponding packages.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agopkg: convert most other struct members into dynamic blob buffer fields
Jo-Philipp Wich [Sun, 12 Feb 2017 20:43:11 +0000 (21:43 +0100)]
pkg: convert most other struct members into dynamic blob buffer fields

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agopkg: store size, installed size and installed time info in blob buffer
Jo-Philipp Wich [Fri, 10 Feb 2017 21:56:13 +0000 (22:56 +0100)]
pkg: store size, installed size and installed time info in blob buffer

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agopkg: use a blob buffer in pkg_t to store variable fields
Jo-Philipp Wich [Fri, 10 Feb 2017 16:14:53 +0000 (17:14 +0100)]
pkg: use a blob buffer in pkg_t to store variable fields

Adds infrastructure to use a blob buffer in pkg_t to store and retrieve
optional dynamic fields.

This reduces the size of the pkg_t structure itself and lays the
ground work for further optimization.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agopkg: coalesce soem flag members into a packed bit field
Jo-Philipp Wich [Fri, 10 Feb 2017 15:21:14 +0000 (16:21 +0100)]
pkg: coalesce soem flag members into a packed bit field

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agotreewrite: use Lindent to reformat to kernel coding style
Jo-Philipp Wich [Fri, 10 Feb 2017 10:20:23 +0000 (11:20 +0100)]
treewrite: use Lindent to reformat to kernel coding style

Use the kernels "Lindent" script to reformat files using kernel coding style.
This should make subsequent refactoring much easier.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: clarify messages and errors related to downloads
Jo-Philipp Wich [Fri, 10 Feb 2017 10:06:38 +0000 (11:06 +0100)]
libopkg: clarify messages and errors related to downloads

Clarify opkg's messages related to downloads:

 * more visible error message for package list download failure
 * separate error message for signature file download error
 * if wget returns 4, signal the network error more clearly
 * remove '.' from end of filenames and URLs

 * try signature check only if the package list was downloaded ok.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
7 years agolibopkg: run prerm scripts for the old version also on upgrade
Jo-Philipp Wich [Fri, 10 Feb 2017 10:05:44 +0000 (11:05 +0100)]
libopkg: run prerm scripts for the old version also on upgrade

To make sure we properly restart services on upgrade we need to
call the prerm script of the old package, in case the init script
changes (or vanishes).

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Acked-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix use-after-free with duplicate packages on the command line
Jo-Philipp Wich [Fri, 10 Feb 2017 10:04:10 +0000 (11:04 +0100)]
libopkg: fix use-after-free with duplicate packages on the command line

When the same package file is specified multiple times on the opkg install
command line, the name pointer on the argv array becomes stale after the
package structures have been merged, leading to invalid memory accesses
upon install.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: implement --size
Jo-Philipp Wich [Fri, 10 Feb 2017 09:57:45 +0000 (10:57 +0100)]
cli: implement --size

Implement a new switch "--size" which causes opkg to print the package size
in the listing output.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: implement --lists-dir
Jo-Philipp Wich [Fri, 10 Feb 2017 09:44:17 +0000 (10:44 +0100)]
cli: implement --lists-dir

Add a new flag --lists-dir which allows setting the package feed list
directory from command arguments.

This is required to be able to use opkg without any configuration file.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix --force-checksum to cover sha256sum cases as well
Jo-Philipp Wich [Fri, 10 Feb 2017 09:43:57 +0000 (10:43 +0100)]
libopkg: fix --force-checksum to cover sha256sum cases as well

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: make MD5 support optional
Jo-Philipp Wich [Fri, 10 Feb 2017 09:41:51 +0000 (10:41 +0100)]
libopkg: make MD5 support optional

Disable md5 support code by default and introduce a new configure flag
"--enable-md5" which allows reenabling the code.

This shrinks the opkg executable by a few KB.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: drop support for Release files
Jo-Philipp Wich [Fri, 10 Feb 2017 09:40:04 +0000 (10:40 +0100)]
libopkg: drop support for Release files

Remove support for Release files as this facility is unused in LEDE/OpenWrt.
Removing this allows us to shrink the opkg executable a little bit.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: implement --force-signature
Jo-Philipp Wich [Fri, 10 Feb 2017 09:37:02 +0000 (10:37 +0100)]
cli: implement --force-signature

Implement a new "--force-signature" flag which causes opkg to ignore signature
verification errors.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: add support for signature checking through usign
Jo-Philipp Wich [Fri, 10 Feb 2017 09:34:21 +0000 (10:34 +0100)]
libopkg: add support for signature checking through usign

Adds a new configure switch "--enable-usign" which enables code to perform
package feed signature checking using an external "/usr/sbin/opkg-key" helper
program.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: pass PKG_UPGRADE variable to package scripts
Jo-Philipp Wich [Fri, 10 Feb 2017 09:31:55 +0000 (10:31 +0100)]
libopkg: pass PKG_UPGRADE variable to package scripts

When installing or upgrading packages, pass an PKG_UPGRADE environment
variable to maintainer scripts to allow the to perform different actions
depending on whether a package is freshly installed or upgraded.

During installs the PKG_UPGRADE variable will be set to 0 and during
upgrades to 1.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: implement --force-checksum
Jo-Philipp Wich [Fri, 10 Feb 2017 09:30:33 +0000 (10:30 +0100)]
cli: implement --force-checksum

Introduce a new --force-checksum flag which allows installing packages even if
the checksum does not match. This is useful for development and debugging.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: suppress empty provides
Jo-Philipp Wich [Fri, 10 Feb 2017 09:29:44 +0000 (10:29 +0100)]
libopkg: suppress empty provides

When writing out status information, suppress the Provides field if there
are no providers.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: discard empty control file fields
Jo-Philipp Wich [Fri, 10 Feb 2017 09:28:09 +0000 (10:28 +0100)]
libopkg: discard empty control file fields

If the resulting string is empty after whitespace trimming, free it and
store NULL instead of an empty string buffer.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: store compressed package lists
Jo-Philipp Wich [Fri, 10 Feb 2017 09:24:58 +0000 (10:24 +0100)]
libopkg: store compressed package lists

To save storage space, store the package lists in compressed form and
decompress them on-the-fly during parsing.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibbb: use external gzip command as I/O layer
Jo-Philipp Wich [Fri, 10 Feb 2017 09:19:14 +0000 (10:19 +0100)]
libbb: use external gzip command as I/O layer

Remove the builtin inflate code and rely on the external gzip command instead
to inflate data streams.

This change is needed to properly support vfork(). We cannot use the builtin
code because it uses a single global state which will get clobbered when
recursively inflating nested archives.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: implement find command
Jo-Philipp Wich [Fri, 10 Feb 2017 09:18:18 +0000 (10:18 +0100)]
cli: implement find command

Introduce a new opkg "find" command which matches both the name and the
description of packages.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: implement --nocase flag
Jo-Philipp Wich [Fri, 10 Feb 2017 09:16:33 +0000 (10:16 +0100)]
cli: implement --nocase flag

Introduce a new --nocase flag which causes all opkg pattern matching
operations to ignore the case.

This is useful to find packages with uppercase letters in their name.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: line-wrap descriptions only on interactive terminals
Jo-Philipp Wich [Fri, 10 Feb 2017 09:14:02 +0000 (10:14 +0100)]
libopkg: line-wrap descriptions only on interactive terminals

Various programs call opkg and extract information from its list and info
commands. To simplify parsing the output, do not line-wrap long description
lines if opkg is not talking to a tty.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: fix double-free crash on recursive package removal
Jo-Philipp Wich [Fri, 10 Feb 2017 09:04:57 +0000 (10:04 +0100)]
libopkg: fix double-free crash on recursive package removal

The opkg_remove_dependent_pkgs() function will trigger a pkg_vec_free() and
break the loop when an error is returned by opkg_remove_pkg().

Since the vector is freed anyway after the loop, a double free occurs,
leading to a segmentation fault.

This situation commonly happens when recursively deleting packages in
conjunction with --autoremove where dependent packages might already have
been removed by previous iterations.

Simply break the loop without prematurely freeing the vector to fix this.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: do not rely on getline()
Jo-Philipp Wich [Fri, 10 Feb 2017 09:03:19 +0000 (10:03 +0100)]
libopkg: do not rely on getline()

OpenWrt/LEDE uses opkg on both the target systems and the build hosts and not
every supported host system provides a getline() implementation.

Rewrite affected code to not require the getline() function.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: print error messages to stderr
Jo-Philipp Wich [Fri, 10 Feb 2017 09:02:42 +0000 (10:02 +0100)]
libopkg: print error messages to stderr

Print the collected error list to stderr isntead of stdout. This is useful
for wrapping programs that treat stdout and stderr differently.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agolibopkg: strip trailing white space in conffile specification
Jo-Philipp Wich [Fri, 10 Feb 2017 08:59:59 +0000 (09:59 +0100)]
libopkg: strip trailing white space in conffile specification

The conffile entries in package control lines may have trailing white space,
causing opkg to fail looking up the file paths.

Trim white space to avoid this error.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: default to /etc/opkg.conf
Jo-Philipp Wich [Fri, 10 Feb 2017 08:58:20 +0000 (09:58 +0100)]
cli: default to /etc/opkg.conf

If neither --conf-file nor --offline-root are specified, default to the
traditional /etc/opkg.conf location to retain compatibility with OpenWrt/LEDE.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agocli: enforce argument to upgrade command
Jo-Philipp Wich [Fri, 10 Feb 2017 08:57:18 +0000 (09:57 +0100)]
cli: enforce argument to upgrade command

Blindly upgrading all upgradable packages usually brick the system, so disable
support for argument-less upgrade commands for now.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agobuild: statically link libopkg
Jo-Philipp Wich [Fri, 10 Feb 2017 08:54:34 +0000 (09:54 +0100)]
build: statically link libopkg

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agobuild: allow overriding host cpu with make variable
Jo-Philipp Wich [Fri, 10 Feb 2017 08:53:40 +0000 (09:53 +0100)]
build: allow overriding host cpu with make variable

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agobuild: remove output shaving support
Jo-Philipp Wich [Fri, 10 Feb 2017 08:51:44 +0000 (09:51 +0100)]
build: remove output shaving support

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years agobuild: missing pkg.m4
Jo-Philipp Wich [Fri, 10 Feb 2017 08:50:20 +0000 (09:50 +0100)]
build: missing pkg.m4

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
13 years agoFix compilation after r617
google@wwsnet.net [Fri, 8 Apr 2011 13:33:11 +0000 (13:33 +0000)]
Fix compilation after r617

git-svn-id: http://opkg.googlecode.com/svn/trunk@618 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoDon't include the source URI in the cached filename.
graham.gower@gmail.com [Fri, 8 Apr 2011 04:30:10 +0000 (04:30 +0000)]
Don't include the source URI in the cached filename.

This avoids multiple downloads in the case where a repository is simply a
mirror of another. The old, uri mangled, filename is still checked to ensure
backwards compatibility with existing caches.

Patch from robert.melchers@gmail.com.

git-svn-id: http://opkg.googlecode.com/svn/trunk@617 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoRead the contents of lists files coming from 'dist' entries
javiplx@gmail.com [Thu, 7 Apr 2011 16:11:55 +0000 (16:11 +0000)]
Read the contents of lists files coming from 'dist' entries

git-svn-id: http://opkg.googlecode.com/svn/trunk@616 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoDownload all the valid Packages files for dist entries
javiplx@gmail.com [Thu, 7 Apr 2011 16:07:25 +0000 (16:07 +0000)]
Download all the valid Packages files for dist entries

git-svn-id: http://opkg.googlecode.com/svn/trunk@615 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoIntroduce a new pkg_src list in global configuration to store the contents of 'dists...
javiplx@gmail.com [Thu, 7 Apr 2011 15:53:24 +0000 (15:53 +0000)]
Introduce a new pkg_src list in global configuration to store the contents of 'dists' entries for apt-alike repositories

git-svn-id: http://opkg.googlecode.com/svn/trunk@614 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFix mistype in define clause
javiplx@gmail.com [Thu, 7 Apr 2011 15:51:52 +0000 (15:51 +0000)]
Fix mistype in define clause

git-svn-id: http://opkg.googlecode.com/svn/trunk@613 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoCode to handle the apt-alike configuration entries
javiplx@gmail.com [Thu, 7 Apr 2011 15:35:24 +0000 (15:35 +0000)]
Code to handle the apt-alike configuration entries

git-svn-id: http://opkg.googlecode.com/svn/trunk@612 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoCreate parse_util with some of the non-public functions from pkg_parse.c
javiplx@gmail.com [Thu, 7 Apr 2011 15:17:27 +0000 (15:17 +0000)]
Create parse_util with some of the non-public functions from pkg_parse.c

git-svn-id: http://opkg.googlecode.com/svn/trunk@611 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoAdd flag in opkg_download calls to reduce the severity of the 'failed download' message
javiplx@gmail.com [Thu, 7 Apr 2011 15:03:54 +0000 (15:03 +0000)]
Add flag in opkg_download calls to reduce the severity of the 'failed download' message

git-svn-id: http://opkg.googlecode.com/svn/trunk@610 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFix opkg_re_read_config_files().
graham.gower@gmail.com [Tue, 22 Feb 2011 03:39:04 +0000 (03:39 +0000)]
Fix opkg_re_read_config_files().

This fixes segfaults when opkg_update_package_lists() is called multiple times.

git-svn-id: http://opkg.googlecode.com/svn/trunk@609 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFix memory leak when !defined(HAVE_GPGME) and !defined(HAVE_OPENSSL).
graham.gower@gmail.com [Tue, 22 Feb 2011 03:38:50 +0000 (03:38 +0000)]
Fix memory leak when !defined(HAVE_GPGME) and !defined(HAVE_OPENSSL).

git-svn-id: http://opkg.googlecode.com/svn/trunk@608 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoAdd regress test for the bug from r605.
graham.gower@gmail.com [Mon, 21 Feb 2011 04:45:33 +0000 (04:45 +0000)]
Add regress test for the bug from r605.

git-svn-id: http://opkg.googlecode.com/svn/trunk@607 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoList some sub-commands that were missing from the --help output.
graham.gower@gmail.com [Mon, 21 Feb 2011 04:24:55 +0000 (04:24 +0000)]
List some sub-commands that were missing from the --help output.

git-svn-id: http://opkg.googlecode.com/svn/trunk@606 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoGet the owner of the file_name after the offline root has been stripped.
graham.gower@gmail.com [Mon, 21 Feb 2011 04:24:42 +0000 (04:24 +0000)]
Get the owner of the file_name after the offline root has been stripped.

Fixes a problem where the old package maintains that it owns a file even
though the new pkg has been installed with --force-overwrite.

git-svn-id: http://opkg.googlecode.com/svn/trunk@605 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoAllow vfork()ing an external gunzip binary instead of using fork().
graham.gower@gmail.com [Fri, 18 Feb 2011 00:02:14 +0000 (00:02 +0000)]
Allow vfork()ing an external gunzip binary instead of using fork().

Patch from Mike Westerhof, with minor modifications to allow the use of both
GNU gunzip and busybox gunzip. His original patch header follows.

This patch allows a user to set an environment variable to cause opkg to
select either the built-in gunzip code or an external gunzip utility, in
order to dodge the OOM Killer.

The built-in code is, of course, is the most desirable way to use opkg,
since it is far more efficient.  However, the built-in code can trigger
the OOM (out of memory) killer on small-memory machines, like the 32MB
NSLU2.  This occurs because a standard fork will duplicate the entire
address space of the parent.  Since opkg reads the entire feed database
into memory, this problem is compounded by large feeds.

This patch introduces a means for the user to cause opkg to use vfork()
instead -- vfork() does not behave in the same manner as fork(), and
does not trigger the OOM killer.  However, the semantics of vfork() are
such that it cannot run the built-in gunzip code.  Instead, it must
exec() an external utility to perform the gunzip operation.  It seems
counter-intuitive, but the vfork()/exec() approach is the only good way
to avoid triggering the dreaded OOM killer.

In order to use this, the user must manually set the OPKG_USE_VFORK
environment variable to any value.  For example:

$ OPKG_USE_VFORK=1 opkg install samba

The external utility used to do the gunzip operation is "busybox gunzip".
It would have been nice to be able to just invoke "gunzip", but the
full gunzip executable behaves slightly differently than does busybox,
generating annoying warning messages.

This is an update of the original patch by Mike Westerhof, Dec 2008.

Mike Westerhof, Feb 2011

git-svn-id: http://opkg.googlecode.com/svn/trunk@604 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoDelete package sources that fail the signature check.
graham.gower@gmail.com [Mon, 14 Feb 2011 02:47:09 +0000 (02:47 +0000)]
Delete package sources that fail the signature check.

From Bernhard Guillon.

git-svn-id: http://opkg.googlecode.com/svn/trunk@603 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoCall gpgme_check_version() before using other gpgpe functions.
graham.gower@gmail.com [Mon, 14 Feb 2011 02:46:33 +0000 (02:46 +0000)]
Call gpgme_check_version() before using other gpgpe functions.

The function initializes some sub-systems, and for this reason alone
it must be invoked early in your program, before you make use of the
other functions in GPGME.
see http://pyme.sourceforge.net/doc/gpgme/Library-Version-Check.html

Patch from Bernhard Guillon.

git-svn-id: http://opkg.googlecode.com/svn/trunk@602 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoAdd overlay_root config option. Opkg checks this location for available space.
graham.gower@gmail.com [Mon, 14 Feb 2011 02:46:01 +0000 (02:46 +0000)]
Add overlay_root config option. Opkg checks this location for available space.

This option is useful in the case where root is mounted ro, and another rw
filesystem is overlaid on top with e.g. mini_fo.

From Nicolas Thill via OpenWrt.

git-svn-id: http://opkg.googlecode.com/svn/trunk@601 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoAdd missing space.
graham.gower@gmail.com [Mon, 14 Feb 2011 02:45:32 +0000 (02:45 +0000)]
Add missing space.

git-svn-id: http://opkg.googlecode.com/svn/trunk@600 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFix depmod intercept. Patch from Andreas Oberritter.
graham.gower@gmail.com [Wed, 2 Feb 2011 00:53:46 +0000 (00:53 +0000)]
Fix depmod intercept. Patch from Andreas Oberritter.

* If depmod -a ${KERNEL_VERSION} is called, the version should be retained.
* The script calls depmod -A, which does nothing if the installed module's
  timestamp is older than modules.dep's timestamp. As modules generally
  inherit the timestamp of the build, this would result in depmod doing nothing.

git-svn-id: http://opkg.googlecode.com/svn/trunk@599 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFixed a bug causing segfaults when an upgraded package has less dependencies than...
pixdamix [Tue, 1 Feb 2011 14:36:50 +0000 (14:36 +0000)]
Fixed a bug causing segfaults when an upgraded package has less dependencies than the old package.

git-svn-id: http://opkg.googlecode.com/svn/trunk@598 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoCreate the regress offline_root from scratch.
graham.gower@gmail.com [Thu, 23 Dec 2010 01:38:57 +0000 (01:38 +0000)]
Create the regress offline_root from scratch.

git-svn-id: http://opkg.googlecode.com/svn/trunk@596 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFix potential undefined references to FILE, for libopkg users.
graham.gower@gmail.com [Thu, 23 Dec 2010 01:38:40 +0000 (01:38 +0000)]
Fix potential undefined references to FILE, for libopkg users.

Patch from Richard Purdie.

git-svn-id: http://opkg.googlecode.com/svn/trunk@595 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoDon't truncate long symlink paths.
graham.gower@gmail.com [Thu, 23 Dec 2010 01:38:25 +0000 (01:38 +0000)]
Don't truncate long symlink paths.

Patch from Richard Purdie. Tracked as Issue #72. Original patch header follows.

If a tarball contains a long symlink (over 100 chars) in a longpath (over 100
chars) then the resulting link or path can be truncated to 100 chars.

This is due to a bug where if both 'L' and 'K' entries are found in the tarball,
only the first one takes affect due to get_header_tar recursively calling itself.
To fix this, process longname and linkname at the end of the function rather
than the start after any subcalls have taken place.

Richard Purdie
22/12/2010

git-svn-id: http://opkg.googlecode.com/svn/trunk@594 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoAdd regress test for issue72.
graham.gower@gmail.com [Thu, 23 Dec 2010 01:37:58 +0000 (01:37 +0000)]
Add regress test for issue72.

git-svn-id: http://opkg.googlecode.com/svn/trunk@593 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoDon't gitignore the regress Makefile.
graham.gower@gmail.com [Thu, 23 Dec 2010 01:37:42 +0000 (01:37 +0000)]
Don't gitignore the regress Makefile.

git-svn-id: http://opkg.googlecode.com/svn/trunk@592 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoDon't print the function name when just outputting a \n.
graham.gower@gmail.com [Thu, 23 Dec 2010 01:37:18 +0000 (01:37 +0000)]
Don't print the function name when just outputting a \n.

git-svn-id: http://opkg.googlecode.com/svn/trunk@591 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoRemove stray exit() in the regress test.
graham.gower@gmail.com [Mon, 13 Dec 2010 04:39:47 +0000 (04:39 +0000)]
Remove stray exit() in the regress test.

git-svn-id: http://opkg.googlecode.com/svn/trunk@590 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFix missing declarations, found by Clang.
graham.gower@gmail.com [Mon, 13 Dec 2010 04:39:29 +0000 (04:39 +0000)]
Fix missing declarations, found by Clang.

git-svn-id: http://opkg.googlecode.com/svn/trunk@589 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

13 years agoFix if statement with empty body due to stray semicolon.
graham.gower@gmail.com [Mon, 13 Dec 2010 04:39:11 +0000 (04:39 +0000)]
Fix if statement with empty body due to stray semicolon.

Found with Clang.

git-svn-id: http://opkg.googlecode.com/svn/trunk@588 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoAbort package removal if the prerm script of a package returns non zero.
graham.gower@gmail.com [Wed, 24 Nov 2010 00:01:35 +0000 (00:01 +0000)]
Abort package removal if the prerm script of a package returns non zero.

This can be overridden with --force-remove.
Also, improve propagation of errors up the call stack for related errors.

From Sergey 'Jin' Bostandzhyan.

git-svn-id: http://opkg.googlecode.com/svn/trunk@587 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoPrint the package name corresponding to a failed script.
graham.gower@gmail.com [Mon, 22 Nov 2010 23:48:31 +0000 (23:48 +0000)]
Print the package name corresponding to a failed script.

From Sergey 'Jin' Bostandzhyan.

git-svn-id: http://opkg.googlecode.com/svn/trunk@586 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoFix formatting issues found with the last commit.
graham.gower@gmail.com [Fri, 19 Nov 2010 06:19:25 +0000 (06:19 +0000)]
Fix formatting issues found with the last commit.

git-svn-id: http://opkg.googlecode.com/svn/trunk@585 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoUse printf format specifier attribute for opkg_message().
graham.gower@gmail.com [Fri, 19 Nov 2010 06:19:11 +0000 (06:19 +0000)]
Use printf format specifier attribute for opkg_message().

git-svn-id: http://opkg.googlecode.com/svn/trunk@584 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoRemove an unnecessary allocation.
graham.gower@gmail.com [Fri, 19 Nov 2010 04:30:47 +0000 (04:30 +0000)]
Remove an unnecessary allocation.

According to SUS3:
If the value of n is zero on a call to snprintf(), nothing shall be written, the number of bytes that would have been written had n been sufficiently large excluding the terminating null shall be returned, and s may be a null pointer.

git-svn-id: http://opkg.googlecode.com/svn/trunk@583 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoCheck return codes from vsnprintf and vfprintf.
graham.gower@gmail.com [Fri, 19 Nov 2010 03:56:06 +0000 (03:56 +0000)]
Check return codes from vsnprintf and vfprintf.

git-svn-id: http://opkg.googlecode.com/svn/trunk@582 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoRewrite sprintf_alloc.
graham.gower@gmail.com [Fri, 19 Nov 2010 03:55:52 +0000 (03:55 +0000)]
Rewrite sprintf_alloc.

The example in printf(3) that this was taken from should not be used as
it ignores negative return codes from vsnprintf, instead allocating more
memory. Given an error from vsnprintf, this would loop until the process'
virtual memory is exhausted.

So we just exit in the event of a problem instead.

git-svn-id: http://opkg.googlecode.com/svn/trunk@581 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoFix indentation.
graham.gower@gmail.com [Fri, 19 Nov 2010 03:55:38 +0000 (03:55 +0000)]
Fix indentation.

git-svn-id: http://opkg.googlecode.com/svn/trunk@580 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

14 years agoopkg_find_package() should not return garbage if it cannot find the package.
graham.gower@gmail.com [Mon, 15 Nov 2010 22:47:28 +0000 (22:47 +0000)]
opkg_find_package() should not return garbage if it cannot find the package.

From juliosao via Issue #69.

git-svn-id: http://opkg.googlecode.com/svn/trunk@579 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358