Commit Graph

122 Commits (d0edeec8fb8fa5abee8b3065cea5e4882d0c51c4)

Author SHA1 Message Date
Timo Teräs d0edeec8fb make the atom functions not use global state
This greatly helps with memory management on applications that
may want to daemonize and open/close database several times.

Also the lifetime and "owner" of memory for all data is now
explicitly bound to owning struct apk_database, which might
be helpful when writing language bindings. As side effect, the
interned "atoms" are unique only within what apk_database, so
comparing packages from different apk_database may not work
as expected.

Fixes #10697
2020-05-19 12:02:56 +03:00
TBK 5d796b5678 use SPDX-License-Identifier in source files 2020-05-07 10:45:42 +03:00
Fredrik Gustafsson d61c009f7a apk: do not manage file ownership as non-root or when asked so
If apk is run as a non-root user, it's not possible to chown files.

Maintainers note: minor wording changes on commit log and man page.

Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com>
2020-04-28 14:48:49 +03:00
Timo Teräs 6da3e8eb15 istream, archive, db: convert db and tar function to use istream 2020-01-11 11:20:45 +02:00
Timo Teräs 47570f80e9 prefer selecting packages by their primary name 2018-11-12 14:16:36 +02:00
Timo Teräs e1a05c74cb prevent automatic repository index update for 'apk del'
ref #9063
2018-07-18 13:29:13 +03:00
Timo Teräs 5f7dcadc69 auto-update index only when database is opened for writing 2018-01-08 11:56:48 +02:00
Timo Teräs 8a28c6d0d4 enable automatic update of indexes controlled by --cache-max-age
This modifies apk cache for indexes to be automatically refreshed
periodically without explicit 'update' or '--update-cache' usage.

The default is to do if-modified-since request if the local copy
is older than 4 hours. This age can be changed with --cache-max-age.
Using --update-cache will change this age to 60 seconds to make
sure the cached copy is relatively new. The small age is in order
to try to avoid downloading indexes second time when apk-tools is
upgraded and apk re-execs after self-upgrade.

Accordingly using explicitly 'apk update' will now enforce
--force-refresh and request the very latest index by requesting
any potential http proxy to do refresh too.
2018-01-04 10:56:09 +02:00
Kaarle Ritvanen 5c349335c7 db: separate init from open 2017-04-28 13:28:32 +03:00
Timo Teräs 0fe3f3964b fetch: fix --recursive mode to work with pure virtual packages
The virtual package provider still needs to be explicitly
given on command line.
2017-02-27 14:56:57 +02:00
Timo Teräs 6542d4ca2c db: allow overriding cache location 2017-02-27 11:14:33 +02:00
Timo Teräs 72b878e655 db: mount /proc for --root if it's not mounted, use mount syscall
musl c-library does not work properly without /proc, and potentially
running the scripts need this.
2017-02-27 10:52:16 +02:00
Henrik Riomar 349c61c961 add support for pre and post commit hooks
This allows for instance integration of etckeeper

[TT: Reorganized code a bit, and modified to use single
directory commit_hooks.d with argument for script of stage.]
2017-02-15 13:44:04 +02:00
Timo Teräs ac0a9659d1 upgrade: improve self upgrade functionality a bit
trigger it only if apk-tools can be upgrade, add test cases
2016-07-22 11:13:33 +03:00
Timo Teräs 4fab9290b6 speed improvements for database opening
resolve reverse dependencies after all packages have been loaded,
and avoid traversing the reverse name lists. now that we use
automatic virtual packages (soname, pkg-config, etc.) the reverse
dependency chains can become considerable longer than what it was
when the rdependency construction code was originally written.
2015-06-11 16:21:53 +03:00
Natanael Copa 944eae4b27 update: return failure if any mirror update failed
fixes #4040
2015-04-07 10:49:51 +02:00
Timo Teräs 8d1ec4c5bc calculate and store checksum of xattrs
ref #3027
2015-03-11 16:10:33 +02:00
Timo Teräs cd6786bc30 always save 'world' with line feeds
using space was for backwards compatibility with apk-tools 2.2.2
and earlier (from January 2012)
2015-01-30 14:40:00 +02:00
Timo Teräs 4f823f2a50 make 'mode, uid, gid' triplet separate atomized struct
there are only few combinations for that triplet, and they
occur multiple times reducing the struct sizes a bit. make
sane defaults and prepare to not write defaults to disk
to reduce on-disk installed db size.
2014-11-01 20:18:57 +02:00
Timo Teräs 38e3f54638 rework option parsing to have a group structure
Add also a new 'commit' group that is the common options
for all applets that can commit package changes.
2014-10-08 15:29:27 +03:00
Timo Teräs 09e48d8f06 db: rework directory permission handling
Apk used to reset directory permissions always, but this is undesirable
if user has modified the permissions - especially during tmpfs boot.
Though, it is desirable to update the permissions when packaging has
changed permissions, or a new package is installed and the merged
permission mask / owner changes.

Thus the new code updates the permissions only if:
 1) We are booting and directory is not in apkovl
 2) The directory is modified by a package install/remove/upgrade
 3) The filesystem directory permission matched database

Additionally "apk fix --directory-permissions" can be used to reset
all directory permissions to the database defaults.

Fixes #2966
2014-10-07 14:11:29 +03:00
Timo Teräs f911f7043b index: fix warning about package names without provider
It's real only if there's a package with actual dependency
(conflicts and install_if dependencies do not count).
2014-10-06 14:09:50 +03:00
Timo Teräs d99e82c633 audit: include all files in etc/apk in overlay
This implements a new protected path flag '!' to include always
matching entries in the backup mode (overlay). This is also turned
on for etc/apk to include everything there in overlay, because
the full list of repositories and signing keys need to be in
overlay - just getting them from a package is not enough during
bootstrap.
2014-03-12 09:08:26 +02:00
Timo Teräs 5725f656b0 policy: new applet
to show different versions of package and the repositories from
which it is available from.
2013-06-18 14:54:18 +03:00
Timo Teräs 98c6b46de6 db: store repository tag names including leading @ 2013-06-18 14:30:44 +03:00
Timo Teräs af2b008bab fix, info, ver: perform wildcard matching
ref #511
2013-06-18 13:34:01 +03:00
Timo Teräs fe41ae07b9 apk: use string array in applet mains, separate apk_name_foreach_matching 2013-06-18 13:02:27 +03:00
Timo Teräs ade8d0b4e9 cache: implement progress bar (ref #1170) 2013-06-17 17:13:14 +03:00
Timo Teräs 0a13141889 print: move progress printing to common functions 2013-06-17 16:47:49 +03:00
Timo Teräs 92764088a2 db, cache: do not use cache/tmp for downloads
instead use prefix for temporary files.
2013-06-17 16:33:59 +03:00
Timo Teräs 9d10037807 db: refactor repository file construction
Fixes also 'fetch' applet to prefer copying/linking to files from
cache if possible.
2013-06-17 14:38:27 +03:00
Timo Teräs b8c44536ca solver: rewrite as deductive solver -- core features
Implementing basic dependency handling, install_if and awareness
of pinning.
2013-06-13 18:22:00 +03:00
Timo Teräs aec93ee730 db: unify handling of special packages
make cache a special kind of repository, and automatically cache
special packages (virtual packages, or ones installed from command
line). add test cases for handling virtual packages. fixes #1617.
2013-05-30 08:48:32 +03:00
Timo Teräs 035da87036 db, info: allow packages to install files/symlinks to root
fixes #1578
2013-05-29 14:37:42 +03:00
Timo Teräs 43850a126b apk: implement --progress-fd to write progress to a specified fd 2012-09-20 15:12:15 +03:00
Timo Teräs ea5b08d1d5 audit: fix protection mask of non-db directories
If a directory has protection mask, but does not exist in db, we
do not handle it right unless we calculate the protection mask by
hand, or create temporary db dir entry for it. For simplicity create
always the db dir entry -- depending on audit type we likely need
to create it anyway. This commit also caches the db dir entry in the
audit tree context to avoid duplicate lookups. ref #1241.
2012-07-16 14:44:15 +03:00
Timo Teräs 2f66295fc7 solver: merge apk_name_state to apk_name
apk_name_state is now quite small; and we avoid overhead of two
pointers (+ malloc overhead) when we just make it part of apk_name.
It also fixes some problems (that got introduced) where apk_name_state
was not allocated.
2012-02-29 11:26:12 +02:00
Timo Teräs 12bdec38a3 solver, dot: elementary provides fixes
implementation is still not near finished, but now at least it
can handle it to a minimum degree. many cases are not done right
yet, though. ref #574.
2012-02-24 18:29:30 +02:00
Timo Teräs 99145e2c0d all: introduce apk_provides and use it in apk_name
in preparation for provides support. implements also some
dependency satisfaction helper routines.

ref #574.
2012-02-24 16:31:40 +02:00
Timo Teräs ba3ee3f863 audit, db: add etc/apk/protected_files.d and new audit features
fixes #607.

audit is now mostly rewritten for the new functionality. And
has new features like --check-permissions, --recursive and
--packages.

$ROOT/etc/apk/protected_files.d/*.list can now contain additional
protected paths, one path per line:

+etc
@etc/init.d
-tmp

+ will include the directory as protected configuration directory.
@ considers the directory protected, but will backup only symlinks.
- removes any protection

lbu should be modified to put include and exclude paths in
etc/apk/protected_files.d/lbu.list. Additionally, some packages
might provide their own listings.

E.g. ssh might want to provide ssh.list with something like:
+root/.ssh
+home/*/.ssh
2012-02-23 15:05:06 +02:00
Timo Teräs 77e203bf32 db, io: load repositories also from etc/apk/repositories.d/*.list
Load additional repositories from $ROOT/etc/apk/repositories.d/*.list
unless --repositories-file is given as parameter.
2012-02-22 13:57:05 +02:00
Timo Teräs bf82e2e5fd db, solver, io: scan cache items at startup
It is faster to just scan the cache directory for existing packages
at startup than trying to faccessat() them on demand. It also makes
quite a few parts of the code more readable and simpler.
2012-02-22 08:45:40 +02:00
Timo Teräs 41fb3a4f9e solver, db: repository pinning improvements
* solver internally calculates now using tags; not repository masks
* installeddb now contains the tag name where the package came from
  -> we can now handle upgrades properly
* the pinning is still a preference, and not strictly enforced;
  versioned dependencies may overrule preference
2012-02-15 13:57:36 +02:00
Timo Teräs 97bd260bfd db: record file uid/gid/mode in installed db 2012-02-14 15:51:26 +02:00
Timo Teräs 29ebf435d7 db: smarter handling of directory owner, group and mode 2012-02-10 15:21:41 +02:00
Timo Teräs 304dc4a692 pkg, db: fix signature checking for files without control part
Also clean up handling of signature failures for index files.
2012-01-31 15:49:04 +02:00
Timo Teräs b3df78ed03 solver, upgrade: properly detect missing repository tags
* upgrade needs explicit check so we don't try self-upgrade
   (which would print additional messages on screen)
 * add can fix problems, so check against the new world
 * merge the code in few places
2012-01-17 14:48:22 +02:00
Timo Teräs 1f9a36de68 db: support line feed as 'world' dependency separator
* default writing the world with spaces if a space is found
   (for backwards compatibility) for now
2012-01-12 14:33:29 +02:00
Timo Teräs 30965aa867 solver: print repository tag when committing package changes 2012-01-12 11:33:04 +02:00
Timo Teräs f1de353b81 db, solver: refuse committing changes if there is missing tags 2012-01-12 10:42:27 +02:00