This commit implements multiple performance improvements
to the transaction code:
- Don't process xbps_pkg_name() N times each time we access
its package dictionary (via pkgdb or rpool), just do it once
at xbps_pkgdb_init() time. At pkgdb init time, it just creates
a property in pkgdb, "pkgname". At rpool time, each time a
package is accessed, the "pkgname" string property is added.
- The package transaction dictionary contains the "transaction"
object to know what's the pkg type. This has been changed to an
uint8, this simplifies the logic and it's faster than checking
a string object. See xbps_trans_type_t and xbps_transaction_pkg_type().
- Fixed the issue that was marked with XXX in transaction shlibs
checking code. This has been fixed and improved and resources are
now just freed as expected.
- Simplified random code all over the place, avoiding unnecessary
allocations or operations.
- Rename some transaction files to have a better description.
This is my first rototill to the code in 2020.
The funcs xbps_pkg_name() and xbps_pkgpattern_name() were
using malloc(3) to return the result, until now.
They now have been changed to not allocate the result
via malloc, the caller is responsible to provide a buffer
at least of XBPS_NAME_SIZE (64).
If for whatever reason the pkgname can't be guessed,
returns false. This should avoid lots of small allocs
around libxbps.
New functions have the following prototype:
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
bool xbps_pkgpattern_name(char *dst, size_t len, const char *pkg)
as suggested by @duncaen.
Added support to download all dependencies even
if the euid does not have write perms to rootdir.
In this mode we only care if cachedir is writable,
rootdir access is not necessary.
This is really useful to download all binary packages
required by any number of packages as any regular
user to later perform off-line installations, i.e:
```
$ xbps-install -c $PWD/cachedir -yD xbps
...
$ tree cachedir
cachedir/
├── acl-2.2.53_1.x86_64-musl.xbps
├── acl-2.2.53_1.x86_64-musl.xbps.sig
├── attr-2.4.48_1.x86_64-musl.xbps
├── attr-2.4.48_1.x86_64-musl.xbps.sig
├── bzip2-1.0.8_1.x86_64-musl.xbps
├── bzip2-1.0.8_1.x86_64-musl.xbps.sig
├── ca-certificates-20190110_1.noarch.xbps
├── ca-certificates-20190110_1.noarch.xbps.sig
├── libarchive-3.4.1_1.x86_64-musl.xbps
├── libarchive-3.4.1_1.x86_64-musl.xbps.sig
├── libcrypto45-3.0.2_2.x86_64-musl.xbps
├── libcrypto45-3.0.2_2.x86_64-musl.xbps.sig
├── liblz4-1.9.2_1.x86_64-musl.xbps
├── liblz4-1.9.2_1.x86_64-musl.xbps.sig
├── liblzma-5.2.4_2.x86_64-musl.xbps
├── liblzma-5.2.4_2.x86_64-musl.xbps.sig
├── libressl-3.0.2_2.x86_64-musl.xbps
├── libressl-3.0.2_2.x86_64-musl.xbps.sig
├── libssl47-3.0.2_2.x86_64-musl.xbps
├── libssl47-3.0.2_2.x86_64-musl.xbps.sig
├── libtls19-3.0.2_2.x86_64-musl.xbps
├── libtls19-3.0.2_2.x86_64-musl.xbps.sig
├── libxbps-0.57.1_8.x86_64-musl.xbps
├── libxbps-0.57.1_8.x86_64-musl.xbps.sig
├── libzstd-1.4.4_1.x86_64-musl.xbps
├── libzstd-1.4.4_1.x86_64-musl.xbps.sig
├── musl-1.1.24_1.x86_64-musl.xbps
├── musl-1.1.24_1.x86_64-musl.xbps.sig
├── run-parts-4.9.1_1.x86_64-musl.xbps
├── run-parts-4.9.1_1.x86_64-musl.xbps.sig
├── xbps-0.57.1_8.x86_64-musl.xbps
├── xbps-0.57.1_8.x86_64-musl.xbps.sig
├── xbps-triggers-0.113_3.noarch.xbps
├── xbps-triggers-0.113_3.noarch.xbps.sig
├── zlib-1.2.11_3.x86_64-musl.xbps
└── zlib-1.2.11_3.x86_64-musl.xbps.sig
0 directories, 36 files
$
```
Inpired by #213Closes#213
When there's a new xbps update, xbps-install(1) will now return
EBUSY (16) and a message (if dry-run disabled) explaining
how to proceed.
If there's an update and transaction does not contain xbps, it will
error out unless the 'xbps' pkg is the only target pkg, i.e:
# xbps-install -Su
# echo $?
16
To update xbps, the only way to proceed is to explicitly declare
it as an update, i.e:
# xbps-install -u xbps
The dry-run mode will still show there's an xbps update.
Modified the existing test cases to satisfy the new behaviour.
Closes#166Closes#142
Added `-D, --download-only` flag to allow downloading
packages to the cache without attempting to install them.
Contributed by Toyam Cox via #9
Adapted to master by yours truly.
Close#9
If set it will continue with the transaction and will
just print what are the conflicting files without returning
EEXIST.
This is a temporary solution for void where there are still
some packages with conflicting files (qt5-host-tools vs qt5-tools-devel).
With input by @duncaen
Before this change xbps-install could return EEXIST
when the package is already installed, or already up-to-date.
Return 0 if such condition happens, and only return EEXIST
if there's a file conflict.
Close#51
See the manual page:
XBPS-DIGEST(1) General Commands Manual XBPS-DIGEST(1)
NAME
xbps-digest - XBPS utility to generate message digests
SYNOPSIS
xbps-digest [OPTIONS] [FILE] [FILE+N]
DESCRIPTION
The xbps-digest utility generates message digests for specified FILE or
stdin if unset.
OPTIONS
-m, --mode mode
Sets the message digest mode. Supported: sha256. If unset, defaults
to sha256.
-h, --help
Show the help message.
-V, --version
Show the version information.
SEE ALSO
xbps.d(5), xbps-checkvers(1), xbps-create(1), xbps-dgraph(1),
xbps-fbulk(1), xbps-install(1), xbps-pkgdb(1), xbps-query(1),
xbps-reconfigure(1), xbps-remove(1), xbps-rindex(1), xbps-uchroot(1),
xbps-uunshare(1)
AUTHORS
Juan Romero Pardines <xtraeme@gmail.com>
BUGS
Probably, but I try to make this not happen. Use it under your own
responsibility and enjoy your life.
Report bugs at https://github.com/void-linux/xbps/issues
June 12, 2019
Signed-off-by: Juan RP <xtraeme@gmail.com>
Original message:
```
fetch_cb.c:80:29: error: ‘h’ directive output may be truncated writing 1 byte into a region of size between 0 and 14 [-Werror=format-truncation=]
snprintf(str, sizeof str, "%02ldh%02ldm",
^~~~~~~~~~~~~~
fetch_cb.c:80:29: note: directive argument in the range [0, 59]
fetch_cb.c:80:3: note: ‘snprintf’ output between 7 and 21 bytes into a destination of size 16
snprintf(str, sizeof str, "%02ldh%02ldm",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eta / 3600, (eta % 3600) / 60);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fetch_cb.c:83:30: error: ‘%02ld’ directive output may be truncated writing between 2 and 19 bytes into a region of size 16 [-Werror=format-truncation=]
snprintf(str, sizeof str, "%02ldm%02lds",
^~~~~
fetch_cb.c:83:29: note: directive argument in the range [-153722867280912930, 60]
snprintf(str, sizeof str, "%02ldm%02lds",
^~~~~~~~~~~~~~
fetch_cb.c:83:29: note: directive argument in the range [-59, 59]
fetch_cb.c:83:3: note: ‘snprintf’ output between 7 and 25 bytes into a destination of size 16
snprintf(str, sizeof str, "%02ldm%02lds",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eta / 60, eta % 60);
~~~~~~~~~~~~~~~~~~~
fetch_cb.c:80:29: error: ‘h’ directive output may be truncated writing 1 byte into a region of size between 0 and 14 [-Werror=format-truncation=]
snprintf(str, sizeof str, "%02ldh%02ldm",
^~~~~~~~~~~~~~
fetch_cb.c:80:29: note: directive argument in the range [0, 59]
fetch_cb.c:80:3: note: ‘snprintf’ output between 7 and 21 bytes into a destination of size 16
snprintf(str, sizeof str, "%02ldh%02ldm",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eta / 3600, (eta % 3600) / 60);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fetch_cb.c:83:30: error: ‘%02ld’ directive output may be truncated writing between 2 and 19 bytes into a region of size 16 [-Werror=format-truncation=]
snprintf(str, sizeof str, "%02ldm%02lds",
^~~~~
fetch_cb.c:83:29: note: directive argument in the range [-153722867280912930, 60]
snprintf(str, sizeof str, "%02ldm%02lds",
^~~~~~~~~~~~~~
fetch_cb.c:83:29: note: directive argument in the range [-59, 59]
fetch_cb.c:83:3: note: ‘snprintf’ output between 7 and 25 bytes into a destination of size 16
snprintf(str, sizeof str, "%02ldm%02lds",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eta / 60, eta % 60);
~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```
`xbps-install` will report free space available on disk wording:
> Free space on disk: ...
'free' above is supposed to be an adjective.
But 'free' can also be a verb,
thus the above message can be interpreted as free some space on disk.
'Free' is now changed to 'Available' to avoid ambiguity.