Commit Graph

1050 Commits (bc0ed3774aa78dcd8b9cd97edaffdab7f60ffb4d)

Author SHA1 Message Date
William Pitcock ba7b50c0f8 solver: don't clobber package swaps in cases where an installed package is being replaced by a provider 2017-04-27 23:23:47 +00:00
Timo Teräs 027df02dc2 print: handle mixing stdout and stderr printing
Fixes regression from commit 5ba27c90 which caused stdio
buffering issues now that output is split to stderr/stdout.

See also commit 51737872 for some of the history.

Fixes #7107
2017-04-26 09:34:32 +03:00
readerreader f3a4272a02 fetch: spell "its" properly in user visible message 2017-04-25 08:07:32 +03:00
William Pitcock 9fb2568aa7 fetch: open the installed database to allow fetching a dependency tree rooted by a virtual 2017-04-25 00:26:36 +00:00
William Pitcock e7f8d71d2b fetch: don't segfault when given an unknown package name 2017-04-25 00:00:19 +00:00
William Pitcock a841d6b259 print: don't shadow log() 2017-04-24 23:53:26 +00:00
Shiz 5ba27c9000 print: print warnings and errors to stderr 2017-04-24 22:42:29 +00:00
Avi Halachmi (:avih) 515f31eb52 progress: shorten bar to prevent newlines on some terminals
On some (probably buggy) terminals, printing up to the rightmost column
may end up with the terminal issueing a newline (probably due to putting
the cursor at the next char -> new line).

Some other progress bars avoid it by not reaching the rightmost column.

Shorten the bar width from term-width - 7 to -8 (the 7 are "xxx% []").
2017-03-29 08:14:39 +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
Natanael Copa 17ba5dc11c commit: include limits.h for PATH_MAX
this fixes build on ppc64le
2017-03-06 17:38:32 +01:00
Timo Teräs 697c50524a package: add more secure signature methods 2017-02-28 10:47:15 +02: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 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 704694bd1d commit: fix to work if commit_hook.d directory does not exist 2017-02-27 10:54:28 +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 faff904740 commit: log parameter passed to a hook script 2017-02-16 10:10:30 +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
Breno Leitao 28a9dcda56 Add ppc64le entry in apk defines.
Currently apk only knows about powerpc and ppc64. I am adding support for ppc64le.
ppc64le is the based on the ABI v2, which defines the endianess as little,
while ppc64 is based on the first 64-bits ABI.
2017-01-17 08:39:06 +02:00
Timo Teräs ca368916e0 tar: return correct error for short read of tar archive 2017-01-05 16:18:39 +02:00
Tuan M. Hoang ce72c8498e add s390x headers 2016-11-21 09:43:37 +02:00
Timo Teräs 0545fa0d35 pkg: reset umask for package scripts
It is unreasonable to assume that all package writers would except
to reset umask themselves. It's done currently in most packages,
but we had first issue of this kind recently, so better just reset
umask.
2016-08-23 14:21:16 +03: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 22434a5ff0 lua: remove unused reg_apk_db_meta_methods 2016-07-22 10:11:04 +03:00
Timo Teräs 06ae5fdfdc detect aarch64 architecture and assign default name for it 2016-07-08 11:10:32 +03:00
Timo Teräs 5723afded3 fix cross-compiling to pick right libfetch.a 2016-07-06 14:19:08 +03:00
Natanael Copa bb622dc9b0 info: add support for --license
print license with the --license option.
2016-06-13 10:02:08 +00:00
Natanael Copa 98a13624a1 build: allow override compiler/linker flags for external libs
Make it possible to individually override openssl, zlib and libfetch
cflags and linker flags. This makes it possible to build apk-tools
without having pkg-config installed.
2016-06-13 09:32:02 +00:00
Timo Teräs 5906aef695 fix info --who-owns to work with relative filenames
fixes #5656
2016-05-31 16:58:05 +03:00
Timo Teräs 6807de43da index: don't return error if --index does not exists
it's only used to speed up things, and having it non-existant
is not a fatal error - all included things in index will be
passed in command line anyway
2016-05-27 12:21:14 +03:00
Timo Teräs f9b4fb469b apk: don't exit with error code for -V and --print-arch 2016-04-19 08:55:58 +03:00
Timo Teräs 9039dbe06c blob: fix sign extension in test_bit 2016-04-03 16:06:57 +03:00
Timo Teräs a2a5cd9c69 fetch: allow enabling --simulate 2016-02-16 15:59:55 +02:00
Timo Teräs 445ea07220 implement fetch --purge
which will delete any .apk package on output directory that were
not downloaded by fetch

this allows apk fetch to incrementally build repositories for
binary images
2016-02-16 15:19:52 +02:00
Timo Teräs 9c736d01d9 archive: fix long symlink target names
don't overwrite the link_target if it was found from pax header.
ref #5076
2016-02-09 16:55:06 +02:00
Timo Teräs 2a066169bd commit: self-conflict error and satisfies printing
- self-conflicts when the exact same version of a name is provided
  twice is now properly detected and diagnozed
- don't print redundant satisfies diagnostic
2015-12-10 14:30:57 +02:00
Timo Teräs 8a41fd98a4 solver: more debug output for package errors 2015-12-10 13:45:18 +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 31ed887a64 info: fix --installed test of conflicts 2015-11-12 13:11:55 +02:00
Timo Teräs 5a59c73ffd add armv7 target 2015-11-12 09:24:02 +02: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 7501f6012f search: match packages only once
fixes #4770

apk_name_foreach_matching() can matches each package via it's
main name and all it's provides. Print matched packages only once.
2015-11-09 10:06:57 +02:00
Natanael Copa 707b51e0c6 io: fix posix_fallocate failure handling
We need fall back to a splice buffer if posix_fallocate call fails due
to file being a device (eg tty) or a pipe. This fixes apk fetch --stdout.
2015-10-08 11:42:23 +03:00
Andrew Wilcox 1bc31bdf22 blob: Add missing header 2015-10-08 11:35:09 +03: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 9ffa38222b io: use posix_fallocate to allocate disk space
ftruncate does not allocate it, and subsequent access to mmaped
file will result in SIGBUS. this fixes to properly report disk
full errors.
2015-09-03 13:15:18 +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 5ecc97e724 add simple stats applet 2015-06-12 11:20:01 +03:00
Timo Teräs 3e8e2b5622 free atoms when VALGRIND is defined 2015-06-12 10:32:54 +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 6b140ec5c7 fix bstream_from_fd to use mmap when available 2015-06-12 09:57:52 +03:00
Timo Teräs f08fee9528 fix search --has-origin to not leak memory 2015-06-12 09:48:29 +03:00
Timo Teräs 36d730e95d optimize base64 decoding a bit
it's a hot path for decoding checksums in fdb
2015-06-12 09:08:31 +03:00
Timo Teräs ed94d8ffba use murmur3_32 hash
it is more efficient than the previously used djb hash
2015-06-11 16:54:13 +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
Bobby Bingham e01b29e2fa search: fix swapped needle and haystack 2015-06-10 08:08:56 +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
Alex Dowad 4c3712ecb4 detect failures in writing to file during final flush of buffers
In practice this should fix to e.g. not wipe out /etc/apk/world if
final flush to /etc/apk/world.new fails.

This was prompted by an incident the other day where I ran the root
partition of an Alpine box out of space using 'apk add', and apk
helpfully wiped the contents of /etc/apk/world at the same time.

It might be tricky to try to reproduce exactly the same failure,
but from an examination of the code, setting 'rc' before the final
call to fdo_flush rather than after is one possible cause of this
behavior. (If the entire contents of /etc/apk/world.new are buffered,
and all get written out in the final fdo_flush call, and that call
fails, fdo_close will still happily rename /etc/apk/world.new to
/etc/apk/world.)
2015-05-26 08:38:45 +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 c4960a1a7d allow virtual packages beginning with dot by default on tmpfs installs
the allows update-kernel script to work on tmpfs install before
cache is configured.
2015-04-24 09:33:09 +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
Alex Dowad 74dc8e232f print.c: provide more detailed error messages if retrieving a package fails
fetch_maperror() translates error codes returned by libfetch to our error
codes. Handle those in apk_error_str(), returning error messages which
advise the user of the most likely fix.

A custom error code, EAPKSTALEINDEX, has been added for cases where
retrieving a package fails due to a HTTP error 404 or similar.

[TimoT: add also EAPKBADURL, as well as organize a bit better where the
EAPKSTALEINDEX is generated]
2015-04-22 20:08:16 +03:00
Alex Dowad be31eb24d8 io: fix compiler error by including stdint.h
According to the C standards, uint32_t is defined in stdint.h.
Presumably apk is usually built against C libraries where
stdint.h is indirectly included through another header file,
but this isn't the case with the version of glibc which I am using.
2015-04-22 10:50:31 +03:00
Timo Teräs 1a5d6d06d6 fix issue introduced in previous xattr error handling changes 2015-04-17 10:34:49 +03:00
Timo Teräs 820098d6ad disable xattrs on symlinks for now
there's no nice syscall to manipulate xattrs with atfd and
or open the symlink without dereferencing it (and having fd
that we can do xattrs with)
2015-04-17 10:07:49 +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 4395532932 fix error mapping types
on arm char is by default unsigned, so this caused crashes
as the ERR_PTR mechanism did not work as expected with unsigned
types. extend the array type to be signed short explicitly.
2015-04-13 09:42:27 +03:00
Natanael Copa 2322ba0ad9 update: return errors also with --quiet
fixes #4040
2015-04-10 17:33:21 +00:00
Timo Teräs 60dd5798c9 use memmove for copying buffer leftovers, as the ranges may overlap
issue cought by fortify
2015-04-08 16:58:20 +03:00
Timo Teräs 9ed5a60dec unbreak audit after xattr support 2015-04-08 11:16:46 +03:00
Timo Teräs 23d0a2244a ignore .apk-new files for overlays 2015-04-08 11:08:16 +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
Timo Teräs 83ab022301 audit xattrs
ref #3027
2015-04-08 10:27:49 +03:00
Natanael Copa 944eae4b27 update: return failure if any mirror update failed
fixes #4040
2015-04-07 10:49:51 +02:00
Natanael Copa 7e3f4c3d79 commit: return failure if there are any errors
fixes #4019
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 be8e133c0b extract xattrs from packages
ref #3027
2015-03-10 14:38:06 +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 43182c02f4 remove spurious audit message from missing files with --system
fixes #3840
2015-01-30 16:12:45 +02:00
Timo Teräs cab03b6912 sort world dependencies alphabetically
this makes 'lbu diff' and aaudit diffs nice when a world
dependency is added or removed. sorting also makes the ordering
more deterministic as the world targets constraints are always
applied in the same order. test suite updated accordingly.
2015-01-30 15:53:11 +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 0276e22731 remove reverse dependencies first
when removing large sets of packets, the ordering of removal
was not quaranteed to honor dependencies. this fixes the removal
order to be in reverse dependency order as far as possible.
2015-01-30 14:30:15 +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
Timo Teräs 6697ed5e86 fix test mode 2014-12-08 08:30:35 +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 b80aba0b5a move --simulate to commit options group and alias -s for it 2014-11-01 20:29:38 +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 36d5b91495 support extended pax header in tar extractor 2014-11-01 19:17:06 +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 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 275dd16c42 url: fix double free from late libfetch changes 2014-10-08 15:29:04 +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 555363f056 url: use libfetch to retrieve http/https/ftp files 2014-10-08 10:10:45 +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 1bbca16333 io: fix few error path leaks 2014-10-07 17:04:38 +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 e0f9b0897b solver: enforce conflicts during upgrades and new pkg installs
This makes sure any conflicted packages will be removed first.
Useful if we know there are conflicting files, and want to avoid
adding potentially harmful replaces line. Add a test case for
this too.
2014-10-06 16:30:09 +03:00
Timo Teräs f2d9a14405 cache: delete more aggressively unneeded cached files
Also if --purge is specified delete all uninstalled packages.
Fixes #2889
2014-10-06 15:54:52 +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 6ea922cc87 info who-owns: print symlink target owner as a fallback
busybox trigger creates symlinks to itself. This helps user
to see where these come from.
2014-10-06 14:45:10 +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 7e64edfad6 test: improve loading of repositories, fix broken install-if test 2014-05-19 11:48:36 +03:00
Timo Teräs 2c4f6bb503 del: allow deletion of world dependency when it is not installed
this happens e.g. after tmpfs boot when not all packages where
available: the dependency is in world, but not installed.
2014-05-19 08:49:55 +03:00
Timo Teräs 1e36692a8a finally fix building PIE binaries
the dynamic applet registration never worked with PIE, and as
a temporary hack -nopie was added to default link flags in 2008.

this commit reworks the applet registration mechanism to something
that is compatible with PIE, and removes the hack. finally!
2014-05-12 19:45:36 +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 80e64f4c5d package: do not report duplicate reverse dependencies
most notable in error report from 'del' applet
2014-04-10 11:31:13 +00:00
Timo Teräs 9ee8c7ca00 url: double-fallback to static busybox 2014-04-10 12:57:58 +03:00
Timo Teräs c35086dc92 solver: purge install_if packages deleted from repositories on upgrade -a 2014-04-10 11:10:40 +03:00
Timo Teräs 9fa64ca1db solver: fix cleaning of packages that got replaced by provides 2014-04-10 09:52:40 +03:00
Timo Teräs 06071700c5 solver: fix inherited flags/pinning for install_if packages
noticeable fixes upgrading of packages which get pulled in only
by install_if rule. this also simplifies the inheritance calculation
for packages, as well as the place where it is done for install_if
triggered packages.
2014-04-04 13:05:52 +03:00
Timo Teräs ec1a3d57ab solver: do not consider packages in cache as 'available'
'available' really means 'available in one or more configured
repository'. Cache is not a repository we track, so those are
only available for installation, but not available as preferred
to be installed from repository. fixes #2831.
2014-04-04 10:56:13 +03:00
Timo Teräs c39dacf21b audit: report missing files in system mode
fixes #2113
2014-03-12 14:59:49 +02:00
Timo Teräs 065715a377 solver: additional improvements to install_if handling 2014-03-12 13:10:19 +02: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 5fdc391c10 solver: fixes to install_if handling 2014-03-11 18:38:39 +02:00
Timo Teräs f19566f6a8 info: fix printing of 'replaces' field 2014-03-07 10:22:03 +02:00
Natanael Copa f8b1c3ef83 fetch: disable all progress/log output with --stdout 2014-02-03 12:09:41 +00:00
Timo Teräs 354ba70dc5 fetch: disable progress when outputting pkg to stdout 2014-02-03 13:08:34 +02:00
Natanael Copa 5ccaa6796f Revert "fetch: run quiet when --stdout"
This reverts commit a99bedba6f.
2014-01-06 15:17:23 +01:00
Natanael Copa b06a43a465 apk: new option --print-arch
Simply print the default arch and exit.
This is so scripts don't need to parse the output of -V.
2014-01-06 14:52:05 +01:00
Natanael Copa a99bedba6f fetch: run quiet when --stdout
Prevent the progressbar and status messages to mess up stdout.
2013-12-10 15:47:56 +01:00
Natanael Copa 1f8b793471 print: flush on apk_log
Makes it more useful whith pipes.
2013-12-05 10:58:23 +01:00
Timo Teräs 5173787218 print: use stdout instead of stderr for logging and progress
stdout is the proper place for it. this also fixes the progress
bar in musl, which seems to not support using line buffering for
stderr.
2013-10-11 14:52:34 +03:00
Timo Teräs a6c4103df5 db: allow using cached packages with --no-network 2013-10-02 16:06:10 +03:00
Timo Teräs 74c4c95976 db, url: fix exec sentinels
http://ewontfix.com/11/
2013-10-01 16:22:29 +03:00
Timo Teräs 2721772488 db: minor improvements to an error and a verbose log messages 2013-09-20 21:54:33 +03:00
Timo Teräs 73820e4a3e archive: fix handling of name lengths of exactly 100 bytes 2013-09-20 21:51:57 +03:00
Timo Teräs cecb810746 db: fix error message 2013-09-20 21:31:29 +03:00
Timo Teräs 1c4223124d apk: new option --no-scripts
to not run any per-package scripts. useful for managing buildroot
when cross-compiling.
2013-09-10 13:51:30 +03:00
Timo Teräs 462bb3b8d3 solver: if pinning is specified, it overrides preferred repos
add also a test case for this
2013-09-06 14:21:59 +03:00
Timo Teräs 0fe8507f9d arch: use armhf for arm hardfloat eabi
at least debian and musl do this, so let's go along with that.
2013-09-05 11:52:12 +03:00
Natanael Copa 1fb5f71154 apk: minor fix in help text and a whitespace fix 2013-08-28 14:23:49 +00:00
Natanael Copa f69f047f25 search: implement --has-origin
This option lets us search for all package with given origin.
2013-08-28 14:17:45 +00:00
Natanael Copa 0a4ff4f534 commit: fix segfault
apk would try run the trigger even if package failed to install.
2013-08-05 10:57:00 +02:00
Timo Teräs 065427f417 commit: don't ask questions if simulating 2013-08-03 17:31:49 +03:00
Natanael Copa ed06091189 solver: do not disqualify already disqualified packages
We should not disqualify non-selectable packages as it would mark it as
dirty, forcing it to reconsider the name again, which could end up in
an endless loop.

fixes #2135
2013-07-17 08:31:40 +03:00
Natanael Copa 21d4e9243a db: fix segfault when --root points to invalid dir
fixes #2134
2013-07-17 08:30:53 +03:00
Timo Teräs 3f8c817b6e del: don't print own name as reverse dependency 2013-07-08 15:18:10 +03:00
Timo Teräs 70e45998ad apk: give more space for applet descriptions on generic help 2013-07-08 15:12:35 +03:00
Timo Teräs 26558bd126 io: use fget{pw,gr}ent_r only on uclibc and glibc
musl does not have those.
2013-07-04 10:36:47 +03:00
Timo Teräs 4fad6d9c15 solver: use ffs (posix) instead of ffsl (gnu extension)
for musl compatibility
2013-07-04 09:00:23 +03:00
Timo Teräs 608ae57ef7 upgrade: prefer not to upgrade dependencies during self-upgrade 2013-07-02 11:05:03 +03:00
Timo Teräs e184571feb defines: detect endianess on arm, for armel 2013-07-02 11:01:05 +03:00
Dubiousjim 927456fd97 Allow "apk search -x" for -e 2013-06-30 11:17:21 +03:00
Dubiousjim d035ef60d2 apk: infrastructure for short-option-only synonyms 2013-06-30 11:16:52 +03:00
Dubiousjim bfa39f6bf6 fix: improve usage
Acked-by: Natanael Copa <ncopa@alpinelinux.org>
2013-06-28 13:49:39 +03:00
Dubiousjim fbc4d912ab version: clarify usage
Acked-by: Natanael Copa <ncopa@alpinelinux.org>
2013-06-28 13:48:58 +03:00
Dubiousjim f45aefd961 add, del: main dependencies -> 'world'
Acked-by: Natanael Copa <ncopa@alpinelinux.org>
2013-06-28 13:47:14 +03:00
Dubiousjim ac7616b0a9 various: applet help text and comment fixes
Acked-by: Natanael Copa <ncopa@alpinelinux.org>
2013-06-28 13:45:41 +03:00
Natanael Copa fcb540ab69 build: lua module build fixes
- do not link with -llua. We should not link apk or lua module with it.
- default to lua 5.2
- allow override the lua version with LUA_VERSION
- allow override the lua pkg-config package with LUA_PC
- only add the pkg-config lua --cflags to the lua module
2013-06-26 16:42:10 +02:00
Timo Teräs a2fa544ac6 db: write ipkg flags in proper place 2013-06-21 11:48:15 +03:00
Timo Teräs 654ddbf05f db: reset broken pkg state on reinstall 2013-06-21 11:45:03 +03:00
Timo Teräs f28e77b64d commit: fix another re-installing misspelling to reinstalling 2013-06-21 11:32:23 +03:00
Timo Teräs e1068ce649 commit: fix ssize_t printing 2013-06-20 15:56:04 +03:00
Timo Teräs 3f27da2ade solver: fix pinning+cache to work
Mistakenly allowed masked out package to be installed if it was
in cache.
2013-06-20 14:08:16 +03:00
Timo Teräs 7e18398781 commit, db: make file conflicts and script errors non-fatal
fixes #1482
2013-06-20 13:12:44 +03:00
Timo Teräs 17145f82ae solver: fix package deletion to consier provides properly 2013-06-19 21:39:01 +03:00
Timo Teräs 6da083fc24 all: few behavioural regression fixes
Wildcard matching with no names should match all packages only for
info and search applet. "apk del" would otherwise try to delete
everything, etc.

Fix also interactive mode to ask questions only if we are actually
changing something.
2013-06-19 20:56:18 +03:00
Timo Teräs e4c65886dd solver: properly order deletion of unneeded packages 2013-06-19 20:46:53 +03:00
Timo Teräs 81152df214 applets: unify help message by removing final dots 2013-06-19 16:49:14 +03:00
Timo Teräs 9c54ef726c fetch, del: perform wildcard matching
ref #511
2013-06-19 14:49:44 +03:00
Timo Teräs a984fd3679 solver: add logic: transitive provides exclusion
If name N is required, and all providers of A also provide B, it
means that only instances of B can be selected that provide N. This
is strong help with cases when so:libfoo.so.1 is updated to
so:libfoo.so.2 and not everything is recompiled.
2013-06-19 13:15:53 +03:00
Natanael Copa 956bd5f032 apk: set automatic flags before parsing the opts
Otherwise we cannot override with --no-progress
2013-06-19 10:00:31 +00:00
Natanael Copa adc5b0b161 print: move progress bar update logic to apk_print_progress
- let the apk_print functions deal with the forced print itself. We
  avoid that the callbacks need to deal with the force flag. We can
  also get rid of the APK_PRINT_PROGRESS_* defines.

- let the reader of --progress-fd decide how often things are updated
  rather than having a fixed granularity off 1/100 (percent)

- avoid detect screen size and percent/bar calculations in case the
  --no-progress was given

- track satistics for both the ascii bar and percent info and update bar
  only if either percent or bar changes. This makes the bar go smoother
  when width is wider than 100 chars and it makes the percent counter
  go smooth when screen width is less thann 100 chars. It also
  simplifies the callbacks as they no longer need to deal with update
  granularity.
2013-06-19 10:00:31 +00:00
Timo Teräs 0c1a26f25c del: fix a segfault when trying to delete uninstalled packages 2013-06-19 11:01:08 +03:00
Natanael Copa 0e9d67aea8 print: percent arg for process_fd is integer
With commit 0a13141889 the percent
variable became an integer instead of size_t. We fix the format
modifier accordingly.
2013-06-19 08:07:37 +02:00
Timo Teräs 8c425a1e33 dot: new option: --installed
to consider only installed packages
2013-06-19 08:48:24 +03:00
Timo Teräs d315c9019c upgrade: new option: --latest (-l)
Select latest version of package (if it is not pinned), and print
error if it cannot be installed due to other dependencies.

Together with --available, it selects the latest package which is
present at least in some repository.

This also fixes few solver issues with ordering of package selection
that got quite apparent with this flag. Namely, we cannot "lock"
a package until it's reverse dependencies are locked or not all of
the solver flags are propagated properly.
2013-06-19 08:33:51 +03:00
Timo Teräs f91b01fea8 errors: fix a test case, and misanalysis of certain names
the pinning11 changed when @repo got the leading @ on error messages.
analyze_dep() now properly ignores conflict dependencies, as those
names are usually intentionally left unassigned.
2013-06-18 16:23:14 +03: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
Natanael Copa c51d82f8f6 url: fix fetching from local repositories 2013-06-18 08:53:35 +00:00
Timo Teräs 01ec60f718 errors: improve analysis for virtual packages
if all packages named N provide the virtual package, list only the
name N instead of all packages providing it.
2013-06-18 08:03:40 +03:00
Timo Teräs 54509e7a1a all: various conversions to foreach_array_item, and simplifications of code 2013-06-18 08:03:40 +03:00
Timo Teräs 72139b82d3 fetch: implement progress (fixes #1170) 2013-06-17 17:51:41 +03:00
Timo Teräs 656190b0a0 io: get rid of APK_PROGRESS_SCALE
no need to muldiv all the time, just pass the current amount of bytes
done, and let callbacks use that directly.
2013-06-17 17:28:03 +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 557d360c7f url: remove unused apk_url_download 2013-06-17 14:40:50 +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 dbb642206d io: fix splice for copying unknown lengths 2013-06-17 14:23:14 +03:00
Timo Teräs f79e3946a4 pkg: apk_pkg_foreach_* add matching generation
So same package it is possible to not match same package multiple
times. Use generation count, so this is handled cleanly during
recursion, like in the use case of search applet.
2013-06-15 22:25:23 +03:00
Timo Teräs 5b02400b26 lua: use apk_dep_analyze
and remove the now unused apk_dep_is_materialized_or_provided
which was superceded by apk_dep_analyze.
2013-06-15 19:48:30 +03:00
Timo Teräs ac0c7457c2 errors: detect self-conflicts properly
and add the provided version information to the conflicts.
fixes the final test case that was broken. hooray.
2013-06-14 21:37:38 +03:00
Timo Teräs 56b623b9e2 solver: use array_foreach_item and clean ups 2013-06-14 21:24:33 +03:00
Timo Teräs edf03b155b audit, index, search, upgrade: use foreach_array_item 2013-06-14 20:26:48 +03:00
Timo Teräs 59d15ab259 solver, errors: fix few additional test cases and clean ups 2013-06-13 21:59:08 +03:00
Timo Teräs 2ff59b7c23 search: speed up searching exact package names 2013-06-13 21:19:30 +03:00
Timo Teräs f4ce2bf4c4 search: fix reverse dependency searching (fixes #2084)
use the new apk_pkg_foreach_reverse_dependency helper to find
the reverse dependencies properly.
2013-06-13 21:12:40 +03:00
Timo Teräs bcda66bf08 pkg: add global reverse dependency iterator helpers and use them
... in the error printing and the package deletion.
2013-06-13 20:48:38 +03:00
Timo Teräs e51232e710 errors: rewrite the logic how errors are reported
Instead of the dependency oriented logic, switch to print them
for each package or name needed. Might give a bit more readable
errors now. There's still few corner cases that proper error is
not output, which are cought by the test cases.
2013-06-13 18:22:00 +03:00
Timo Teräs 25ff68a87e solver: prune broken world dependencies with --force
mostly useful for reboot, when all packages are not available.
2013-06-13 18:22:00 +03:00
Timo Teräs 59678309ea solver: corner case fixes
- try harder to not change anything during self-upgrade
- also honor locking to packages that where earlier used in
  merging common dependencies
- clarify upgrade applet help messages
2013-06-13 18:22:00 +03:00
Timo Teräs e7fd4d03bf solver: rewrite as deductive solver -- pinning support
Fix also pinning test cases to be more sane.
2013-06-13 18:22:00 +03:00
Timo Teräs 426a12686e solver: rewrite as deductive solver -- per name flags
Handle properly per-name preference flags, and add test cases
for testing those via fix applet.
2013-06-13 18:22:00 +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
Natanael Copa f292a85867 lua: support for lua 5.2 2013-06-13 14:21:01 +00:00
William Pitcock 860aa642f0 Revert "Revert "solver: increase score fields to 32-bits (from 16-bits)""
This reverts commit a2d873a77c.
2013-06-12 10:47:11 -05:00
William Pitcock 78ee4267cd libapk, apk(8): fix header inclusion issues with musl's headers 2013-06-12 10:47:11 -05:00
root a2d873a77c Revert "solver: increase score fields to 32-bits (from 16-bits)"
This reverts commit 84bfef1a6b.
2013-06-11 10:30:31 -05:00
Timo Teräs 447b194b26 index: add sensible error message if metadata is too long
fixes #1476

Instead of:
ERROR: Index generation failed: Success

The following is now printed:
ERROR: Metadata for package timo-1.0-r0 is too long.
ERROR: Index generation failed: No buffer space available
2013-05-30 10:22:35 +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 6a761c72e2 db: make dev/null a character device with --initdb
fixes #1714
2013-05-29 13:44:42 +03:00
Timo Teräs 84bfef1a6b solver: increase score fields to 32-bits (from 16-bits)
We are having so many packages that they might overflow otherwise.
"ERROR: Preference overflow" was already reported.
2013-04-29 14:14:57 +03:00
Timo Teräs 4c08eca3bb upgrade: handle solver failure gracefully
It is internal bug, but don't segfault on it. Fixes #1576.
2013-04-29 14:14:57 +03:00
Pierre Carrier 4d95266e4d apk_hash.h: include stddef.h
Needed for ptrdiff_t in some libcs.
2013-04-18 06:19:45 +00:00
Pierre Carrier 61b4c443c9 *.c: malloc.h->stdlib.h 2013-04-18 06:19:33 +00:00
Timo Teräs 72cd34cf81 solver: remove backjumping by name
It is incorrect optimization causing valid solutions to be skipped.
Any performance it might've gained, should be fixed by reintroduction
of the minimum penalty logic added in previous commit.
2013-01-28 15:34:09 +02:00
Timo Teräs cb98b55b7e solver: reintroduce minimum penalty logic
Basic per-name per-package specific scoring added.
2013-01-28 15:31:34 +02:00
Timo Teräs 528156a9fa solver: do not backtrack over "exclude none"
Otherwise we can return no solution at all instead of partially
satisfied solution (and give proper error message).
2013-01-22 16:23:16 +02:00
Timo Teräs 93bd305713 solver: simplify strength evaluation in constraint handling 2013-01-21 15:37:23 +02:00
Timo Teräs 2a194f3e7b solver: check if solution is not found at all
This is an internal error.
2013-01-21 09:12:44 +02:00
Timo Teräs b960759daa solver: fix reset of last_touched to zero 2013-01-18 16:21:38 +02:00
Timo Teräs cb15b31b79 solver: some code clean ups 2013-01-18 16:20:55 +02:00
Natanael Copa 3c40070752 solver: build fix for debug print on x86_64
use %zu for size_t
2013-01-18 14:46:25 +01:00
Timo Teräs 86a7338575 solver: fix name assignment logic to not mess up internal state
Should get rid of error messages like:
ERROR: Saved_score {4/0/0,74} != score {6/0/0,74}
2013-01-18 11:38:31 +02:00
Timo Teräs e50da7e4a5 ver: fix help message of --limit 2012-11-05 13:59:10 +02:00
Timo Teräs 832dfed637 solver: fix package prefence calculation a bit 2012-11-04 12:13:19 +02:00
Timo Teräs 60f9a03174 del: consider also reverse dependencies for provided names
So we get better error report if package is not deleted due to
reverse dependency.
2012-10-09 13:09:56 +03:00
Timo Teräs 16b70566bf solver: additional backjumping scheme
Enabled when all attempts to satisfy a name failed, we know that we
can ignore all decisions until we find a decision affecting the name
we wanted to satisfy.
2012-10-08 15:22:06 +03:00
Timo Teräs 01d0e4c408 solver: optimize backjumping
to be functional when backtracking
2012-10-08 12:25:43 +03:00
Timo Teräs 831bce5cf9 solver: properly calculate decision "strength" with provides 2012-10-08 11:50:52 +03:00
Timo Teräs dec409c6d4 solver: fix back jumping once more 2012-10-05 17:26:53 +03:00
Timo Teräs bc7e8f5da8 solver: record dependency apk_name in apk_decision
We can't just use the primary name, as that would mess up
backtracking. We need to record the name which caused the name
to get considered - that way the right last_touched_decision is
used on backtracking.
2012-10-05 15:48:12 +03:00
Timo Teräs 4dd8c58df9 solver: various fixes
* push_decision expects to always get the package primary 'name'
   as apk_name. ASSERT that and fix problem cases.
   (though - this might need to be reverted, and store the non
    primary name in apk_decision instead to accomodate for better
    backtracking optimizations)
 * fix error reporting of virtual package names
 * make 'assign_name' errors soft. the incorrect packages just are
   no longer consider instead of aborting whole calculation.
 * fix backtracking of virtual packages that are not depended
   directly
2012-10-03 15:07:31 +03:00
Natanael Copa 081155c438 solver: improve assert error messages
Print name of package and void double "ERROR"
2012-10-03 09:16:28 +02:00
Natanael Copa 00958d9207 solver: fix compile with -Werror on 64bit 2012-10-03 09:04:35 +02:00
Natanael Copa 4b7b5d4668 info: --provides alias -p is reserved for --root, use -P
fixes #1396
2012-09-28 10:25:30 +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 8a4371ccd7 db: remove AT_SYMLINK_NOFOLLOW for directory permissions
fchmodat does not support this flag - symlinks do not have permissions.

Sysadmin probably does not expect us to not follow symlinks either:
if /var -> /mnt/foo/var, we should be making sure the permissions
and ownership is correct on the target directory, not on the symlink.

Since fchmodat never returned ENOENT with AT_SYMLINK_NOFOLLOW, this
also fixes directory re-creation if it does not exist. fixes #1348.
2012-09-04 10:38:13 +03:00
Timo Teräs 0999ec9533 audit: report new directories in recurse mode too
Add new 'd' flag for it.
2012-07-16 16:34:35 +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 5aa6998459 audit: get right protection mask for base directories in the lists
Use the paths' protection mask where available instead of the parent
paths'. ref #1241
2012-07-09 14:59:40 +03:00
Natanael Copa dde96976d3 search: improve output format for --rdepends
- makes -v option useful
- makes --origin --quiet --exact useful for piping and scripting
- makes the default output more readable
2012-06-06 15:32:13 +02:00
Natanael Copa a6b28beef0 ver: show all packages with -v
ref #1122
2012-05-07 10:53:45 +02:00
Natanael Copa 08595072ae ver: make --quiet output suitable for scripting/piping
Do not print version numbers or compare result char when in quiet
mode. This makes the output suitable for be used in scripts or pipes.

For example:

  # Upgrade all packages that matches a given regexp
  apk version --limit '<' --quiet | grep $regexp | apk fix --reinstall

  # Delete all packages that are removed from repository
  apk version --limit '?' --quiet | xargs apk del
2012-05-07 08:58:16 +02:00
Natanael Copa 9154b8b5e4 ver: print '?' when package is not available in any repo
This makes it possible to differ between downgradable packages (-l '<')
and unavailable in repos (-l '?').
2012-05-07 08:51:02 +02:00