aboutsummaryrefslogtreecommitdiffstats
path: root/libopkg
AgeCommit message (Collapse)Author
2015-05-17opkg_install: Fix error status during upgradeAlejandro del Castillo
During an upgrade, if A is upgraded, and A depends on B, B is upgraded automatically. Then the upgrade procedures moves to B, where it fails, as B was already updated (issue 154). Skip package if the version to be installed and the version on the system match AND it's an upgrade operation. Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-23libopkg/Makefile.am: Include xfuncs.h in opkg_headersPaul Barker
The omission of xfuncs.h from the headers list in libopkg/Makefile.am caused the file not to be included in the release archive. This meant that -rc1 was not buildable from the release archive. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-21opkg_install: Fix segfault with force_reinstall setPaul Barker
If a package is reinstalled with force_reinstall set, the 'new' version of the package used for the reinstall will be initialised by reading the package file itself. Therefore, this pkg object will not have a valid pkg->src. Calling pkg_src_verify(NULL) results in a segfault. This issue is solved by checking that the package has a valid pkg->src before trying to verify it. This should also ensure that the installation of packages directly from a local package file will succeed. For reinstallations this does not present a security risk as the original package feed and file will be verified during opkg_prepare_url_for_install before this file is used to construct the new pkg object. This fixes issue 153. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-21opkg_download_curl: Fix segfaultPaul Barker
When improving the logic in opkg_validate_cached_file in commit fdc453c508ed3e38393039fa51348ed252c2b481, a segfault was introduced. We should ensure that etag is non-NULL before calling create_file_stamp. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18pkg: Improve logic in pkg_get_installed_filesPaul Barker
We can now use str_starts_with instead of reimplementing the same functionality here. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18opkg_utils: Define str_starts_with oncePaul Barker
str_starts_with was defined as a static function in both opkg_download.c and opkg_download_curl.c. We now define this function once publically in opkg_utils.c and call this implementation where needed. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18opkg_install: Refactor stray if statementPaul Barker
One if statement slipped through the previous cleanups. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18pkg_depends: Improve logic in pkg_hash_fetch_unsatisfied_dependenciesPaul Barker
By moving a DEBUG message slightly earlier in the function we can simplify the logic. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18opkg_remove: Improve logic in opkg_remove_pkgPaul Barker
We don't need a separate variable in which to store pkg->parent. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18opkg_install: Improve logic in satisfy_dependencies_forPaul Barker
If opkg_config->force_depends is set, the old code would never set 'conflicts', therefore 'if (conflicts)' would be false and the bulk of the code in this function would not be executed. This meant that the code to set 'level' based on the value of opkg_config->force_depends was nonsensical. This situation is improved by simply returning 0 early of opkg_config->force_depends is set. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18opkg_download_curl: Improve logic in opkg_validate_cached_filePaul Barker
The existing logic repeatedly checked etag and has been slightly improved. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18opkg_download_curl: Improve logic in check_file_stampPaul Barker
We can use 'diff = x' instead of the equivalent of 'if (x) diff = 1; else diff = 0;'. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18file_util: Improve logic in file_copyPaul Barker
We can avoid an unnecessary comparison where the destination path does not exist. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-18opkg_download_curl: Check for error after freadPaul Barker
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15opkg_remove: Add comment on dependency filteringPaul Barker
Explain why we're discarding 'dependencies' which aren't DEPENDS, RECOMMENDS or PREDEPENDS. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Minor tidyupsPaul Barker
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15pkg_parse: Use regular format for if statementsPaul Barker
Even though this change results in a few long lines, it keeps the source code clear to read. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15pkg_depends: Drop unnecessary if statementsPaul Barker
We can just use 'return x' instead of 'if (x) return 1; else return 0;' where x is a boolean expression. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Use regular format for strcmp testsPaul Barker
The return value of strcmp or strncmp is always compared to zero using either '==', '!=', '<', '<=', '>' or '>='. Using a regular format like this should make the logic easy to understand at first glance. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Unconditionally call freePaul Barker
Passing a NULL pointer to free() is a no-op therefore there is no need to test whether a pointer is NULL or not before calling free(). Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Avoid assingment in if statementsPaul Barker
Assignment in if statements is just confusing. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Avoid functions with side effects in if statementsPaul Barker
Functions which have significant side effects are moved outside of if statements. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Reformat multi-line if statmentsPaul Barker
Use an intermediate variable to move multi-line expressions outside of if statements. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15opkg_download_curl: Refactor calls to curl_easy_setoptPaul Barker
Most calls to curl_easy_setopt in the initialisation function should be checked for success or failure and a debugging message should be printed if they fail. For these calls, a setopt macro is introduced which wraps curl_easy_setopt with error checking and printing of the debug message as needed. This macro is now used for all calls to curl_easy_setopt other than those which need to print an error message and cause the initialisation function to abort if they fail. This change adds error checking to all curl_easy_setopt calls in the initialisation function which were previously missing error checking. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Tidy up reformatted C filesPaul Barker
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15libopkg: Tidy up reformatted headersPaul Barker
During the tidy up, includes have been moved outside of the 'extern "C" {}' construct where necessary. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-12-15Initial reformat with 'indent'Paul Barker
For each file, the command executed was: indent -linux -i4 -nut -sc -bbo -nhnl $f This is the first step in improving the code formatting and further work is still required. 'indent' is confused by the 'extern "c" {}' wrapping in the header files and gets the indentation wrong. It also produces sub-optimal formatting for some long lines. Each file will be reviewed by hand after this commit. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-11-13Merge branch 'opkg-0.2.x'Paul Barker
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-11-13pkg_hash: Fix selection with multiple equal providersPaul Barker
In pkg_hash_fetch_best_installation_candidate, we should not error out if multiple providers of a given abstract package are present but there is nothing to differentiate between them (neither is held, preferred, matches the abstract package name or is already installed). Instead we should just select any valid provider and get on with the install. This fixes issue 152. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-11-10opkg: Add and implement '--add-exclude' argumentMark Hatle
Add a way to exclude specific packages from the install. When an excluded package is required by another package an error will be generated. If the excluded package is only recommended, no error will be generated. Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Jonathan Liu <net147@gmail.com> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-11-10opkg_conf: Add and implement 'no_install_recommends' optionMark Hatle
Add the ability to not install ANY recommended packages. This option is matched by the command line argument '--no-install-recommends'. Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28Merge branch 'opkg-0.2.x'Paul Barker
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28opkg_install: Set pkg state and give advice when install failsPaul Barker
The status line for a package for which installation had failed was the cryptic "install prefer,user not-installed". This is very unclear and doesn't represent the broken state of the package clearly. Instead we set flags so that we get "install reinst-required half-installed". This is better but still not perfect as 'install' could be misinterpreted. Further cleanup of the state formatting will improve this. We also give some advice on how to remove package debris or reattempt the install. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28opkg_upgrade: Do not upgrade orphan packagesGaël PORTAY
In the case of upgrading many packages (most likely common case is upgrade all installed packages), packages may become orphan. Those orphans should not be upgraded and must be removed. Use case: * A1 depends on B1 * A2 does not depend anymore on B * A1 and B1 are outdated * A2 and B2 are available. $ opkg-cl upgrade A Is fine: A1 is upgraded to A2 B1 is removed $ opkg-cl upgrade Will upgrade A2 and install B2 (remove orphan B1 and install B2). This patch will halt upgrade of B2 when opkg tries to upgrade a package marked as "replace". Signed-off-by: Gaël PORTAY <g.portay@overkiz.com> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28opkg_upgrade: Upgrade must not modify package flagsGaël PORTAY
Upgrade has to copy the flags of the old package. Signed-off-by: Gaël PORTAY <g.portay@overkiz.com> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28release: Verify correct file when not using gzipPaul Barker
If we're downloading a non-gzipped "Packages" file it is written straight to list_file_name and nothing is written to tmp_file_name. So it is list_file_name that should be verified not tmp_file_name. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28pkg_hash_fetch_conflicts: fix possible segfaultsAndreas Oberritter
Signed-off-by: Andreas Oberritter <obi@opendreambox.org> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28pkg_depends: Don't mark Conflicts as DependsAndreas Oberritter
parseDepends sets conflicts->type to DEPEND so we move the setting to CONFLICTS after the call to parseDepends so that it is not overwritten. - Fixes 'whatconflicts' sub-command. Signed-off-by: Andreas Oberritter <obi@opendreambox.org> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28pkg_depends: Prevent repeats in depended_upon_byPaul Barker
Duplicate entries in the depended_upon_by list may cause a package to not be considered an orphan when it should be, or cause removals to be attempted twice when removing all dependent packages. Now that depended_upon_by is a pkg_vec, it is easy to ensure that duplicates do not enter the list. This change should fix issue 140. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28opkg_install: Fix check for orphan dependentsPaul Barker
In pkg_remove_orphan_dependent(), we look for DEPENDS or RECOMMENDS which existed for old_pkg but don't exist for pkg. Previously this was done by comparing 'struct depend_t' addresses to see if the exact same dependency existed in both packages. However, each 'struct depend_t' addressed in the possibilites list is allocated separately during parseDepends(), so two parses of the exact same dependency string will result in different pointers. Thus we should not be directly comparing 'struct depend_t' addresses. Instead, we can compare the addresses of the abstract packages which each 'struct depend_t' references. These addresses are set via a call to ensure_abstract_pkg_by_name() which will return the same pointer if it sees the same pkg name several times as the abstract_pkg_t objects are stored in a hash table. This change also ensures that if the constraint within a dependency changes between old_pkg and pkg, it is not considered an orphan. The constraints of the dependencies of the new package will already have been checked prior to installing the new package so we know that such changes will have already been handled. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28opkg_install: Keep auto-installed packages when moved from 'Depends' to ↵Andreas Monzner
'Recommends' Signed-off-by: Andreas Monzner <andreas.monzner@dream-property.net> Signed-off-by: Andreas Oberritter <obi@opendreambox.org> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28abstract_pkg_t: Make depended_upon_by a pkg_vecPaul Barker
This change is required to simplify code paths and enable the next couple of changes. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28opkg_install: Remove orphan RECOMMENDS during upgradePaul Barker
If a package is upgraded from an old version to a new version and the old version RECOMMENDS a package which the new version does not, the recommended package should be removed if it was auto installed and nothing else requires it. This fixes issue 144. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-28opkg_conf, pkg_hash: Correct checks of pkg->state_flagPaul Barker
state_flag is set by or-ing together the flags which are set. Therefore, '==' and '!=' should not be used to check whether a particular flag is set or not. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-26str_list: Add str_list_contains functionPaul Barker
This helper function checks if a given string is present in a given string list. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-24opkg_install: Update prerm/postrm commentsPaul Barker
The comments regarding dpkg incompatibility with prerm and postrm scripts during package upgrades are tidied up. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-24opkg_install: Call prerm and postrm scripts on package upgradePeter Urbanec
When upgrading a package from v1 to v2, run "v1-prerm upgrade v2" and "v1-postrm upgrade v2", similarly to what dpkg does. This patch fixes issue 104. Signed-off-by: Peter Urbanec <openembedded-devel@urbanec.net> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-24opkg_remove_pkg: Remove from_upgrade argumentPaul Barker
The from_upgrade argument was never set to a non-zero value when opkg_remove_pkg was called. Additionally, the argument was called 'message' in the header instead of 'from_upgrade'. This confusing mess can just be removed, removal of an old package during an upgrade is handled by opkg_install_pkg without calling opkg_remove_pkg. Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-21Merge branch 'opkg-0.2.x'Paul Barker
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
2014-10-21opkg_remove: avoid remove pkg repeatly with option ↵Hongxu Jia
--force-removal-of-dependent-packages While remove pkg with '--force-removal-of-dependent-packages', pkg may be added to pkgs remove list multiple times, add status check to make sure pkg only be removed once. Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>