Commit Graph

313 Commits (2da67940d50865d206f6a79165ce7b3de5a90de3)

Author SHA1 Message Date
Timo Teräs 039ff3bd46 split --force to several --force-[type] options
This unloads --force as several of the things are really not wanted
together. E.g. --force-refresh is a lot different from --force-broken-world
and doing --force to get the other might introduce unwanted behaviour.

--force is still kept for backwards compatibility and it enables
most things --force was used for.
2018-01-03 16:00:38 +02:00
Timo Teräs b0fcc56f22 db: fix triggers to report deleted directories
This change just changes to keep deleted directory items in
the hash with ref count zero and modified flag set. Those entries
are reused when needed. The side effect is that fire_triggers()
will now see those removed direcotries and reports them. Other
enumerators of the directories hash are protected to skip removed
directories when appropriate.
2018-01-03 09:31:10 +02:00
Timo Teräs 97e4d0531f db: handle default root correctly for /proc
dbopts->root may be null; use db->root instead

fixes #7162
2017-10-10 11:39:38 +03:00
A. Wilcox 13747fab83 database: include POSIX header for ST_* defines 2017-07-29 01:57:34 +00:00
Timo Teräs 51ec463e9d db: fix current directory instance caching in tar extraction
Depending how the directory entries are ordered, the cached dir
instance might not have been updated correctly. This has not been
a problem as the entries have been ordered, but is now triggered
on ppc.
2017-06-26 10:59:37 +03:00
A. Wilcox 17dd532e42 database: mark error on renameat failure 2017-06-26 10:32:38 +03:00
Timo Teräs 4d9c0c39b0 io: make io vtables const struct, and add accessors for them
This reduces function pointers in heap, and unifies how the
io functions are called.
2017-06-23 10:07:44 +03:00
Timo Teräs ede5165833 db: fix regression preventing remounting apk cache r/w
Introduced in commit c0f2d88f34.
fstatfs is needed to inspect the mount flags.
2017-05-25 18:06:27 +03:00
Kaarle Ritvanen 5c349335c7 db: separate init from open 2017-04-28 13:28:32 +03:00
Natanael Copa bcb4b06ff8 db: catch asprintf failure 2017-03-13 14:55:36 +01:00
Natanael Copa 93d6b2b529 db: prevent umount /proc when it was mounted by someone else
This fixes regression introduced by commit 72b878e655
2017-03-13 14:55:36 +01:00
Timo Teräs 6542d4ca2c db: allow overriding cache location 2017-02-27 11:14:33 +02:00
Timo Teräs c0f2d88f34 db: allow caching packages on tmpfs
fixes #5616

The original intention was not use unnecessary space on tmpfs
e.g. if the cache directory is a mount point, but accidentally
left unmounted. But there are valid cases when packages are
intentionally wanted to be cached on tmpfs. If caching is not
desired, the user can just remove the cache directory.
2017-02-27 11:05:01 +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
Natanael Copa c43bfed8de db: add support for --no-cache
Implement --no-cache. The index is read directly from network and not
cached. This is useful for docker, where you install a set of packages
and directly after purge the cache. (see
1fc9e59d16/builder/scripts/apk-install)

fixes #4905
2015-12-07 12:50:32 +00:00
Timo Teräs cce4cff553 io, database: preserve [am]time for cached and fetched files
preserve [am]time for all packages and indexes. this fixes the caching
error that 'apk update' is after new index is generated, but before
the used mirror is synchronized. this caused local apkindex timestamp
to be newer than file in mirror, when in fact it was outdated index.

this also fixes fetched files to have build timestamp so that files
going to .iso or custom images have proper timestamps (rsync with
appropriate --modify-window now works)
2015-11-09 12:51:01 +02:00
Timo Teräs d99214ea55 db: stop extract more files if disk is full 2015-09-03 13:20:59 +03:00
Timo Teräs 57de8d0c5d relocate lock file to /lib/apk/db
the problem is that var/lock is on root installs symlink to /run/lock
(on tmpfs) and does not exist if doing chroot() to that root. fixes
apk to work when chrooted to existing rootfs install.
2015-07-02 09:56:50 +03:00
Timo Teräs 68453b99e6 remove db dir entry properly, so it can be recreated properly if needed
fixes #4261
2015-06-26 16:28:22 +03:00
Timo Teräs c4295e9cf8 for completeness free all arrays before exit
so valgrind does not report any leaks
2015-06-12 10:18:06 +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
Timo Teräs 37b65f1c01 fix directory permissions loading
commit 941fc1b1 uncovered a bug that directory permissions are
not updated properly at db load time if it's the default acl.
2015-06-01 11:22:58 +03:00
Timo Teräs 997aa99e3d do not extract files with malicious name
the security implications are not as high as compared to regular
tar/unzip archiver. this is because you are anyway trusting
the package to install files anywhere in the filesystem.

this serves rather as a sanity to check against errors in created
package.
2015-04-24 09:54:54 +03:00
Timo Teräs fd98e9c718 modifications for the previous commit in error message handling
forgot to --amend my changes
2015-04-24 09:32:22 +03:00
Timo Teräs 90e760339e make file install errors non-fatal, and xattr errors hidden
user xattrs on tmpfs are not supported no non-grsec kernels,
and many times root fs is mounted without user_xattr. Thus
to allow things to go smoothly on non-grsec kernels xattr
unsupported errors are now hidden.

xattrs can be fixed still now with "apk fix --xattrs"
2015-04-17 10:05:10 +03:00
Timo Teräs 3490ff789a fix tee io error handling
use ERR_PTR mechanism, and handle it at all places.
2015-04-13 09:42:27 +03:00
Timo Teräs 941fc1b10c make default dir/file acl implicit
apk in alpine 3.1 already supports this optimization, but kept
the database format. now is time to start using this feature.
2015-04-08 10:58:00 +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 da6e455f70 rename file info related functions for consistency 2015-03-10 15:47:13 +02:00
Timo Teräs 255fd81d79 rework error handling for write streams 2015-03-10 13:15:58 +02:00
Timo Teräs 2a6896b2b4 rework error handling for read streams 2015-03-10 13:15:31 +02:00
Timo Teräs 4c1cdf5b9c remove old compat. field entry from installed db handling
Package pinning was first implemented with 'p' tag. However, it
was before any release renamed to 's', and 'p' was reserved for
package provides support for which is used now.
2015-02-04 11:54:08 +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 c553970061 remove support for old database location in /var
the location changed in apk-tools 2.1.0 (March 2011) which was
used in Alpine Linux 2.2.
2015-01-30 14:35:02 +02:00
Timo Teräs 02cd5a9c76 make del, fetch, fix and info return errors
In case all applet arguments are packages names (that is are not
including wildcards), return error if they do not match to some
package.
2014-12-08 08:31:41 +02:00
Kaarle Ritvanen f726e672c0 db: assign write permission to lock file
Allows running apk as an unprivileged user, e.g. with fakeroot.
Opening the lock file fails without the write permission.
2014-11-03 14:56:07 +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 bb1ac2557d db: improve and unify fdb error messages 2014-10-13 13:33:19 +03:00
Timo Teräs 82713dc389 db: unconditionally refresh index with --force 2014-10-09 19:32:48 +03:00
Timo Teräs 32627939f5 io,url,db: support for if-modified-since 2014-10-08 11:13:21 +03:00
Timo Teräs 5496560a4f db: fix crash if unable to download cache item
fixes #3371
2014-10-07 17:05:06 +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 f5674b9582 db: use per-pkg architecture (if available) to form download url
Allows one arch index files to refer to other arch packages. Mostly
useful with noarch packages, but could be used e.g. to ship build
with some of packages optimized for specific cpu generation and
share most packages with the standard build.
2014-10-06 14:54:54 +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 1dc70477b5 solver: fix installation of non-repository packages during tmpfs boot
allow packages in the cache's installed to be selected for installation
by the solver. add test case for the issue.
2014-05-19 11:50:10 +03:00
Timo Teräs 73a03c2e40 db: allow replacing files of origin package is same
basically this makes packager's life simpler as there is no need
to list the subpkg names in replaces. this was also very error
prone and tedious job to do properly.
2014-04-25 22:17:49 +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 a6c4103df5 db: allow using cached packages with --no-network 2013-10-02 16:06:10 +03:00