pkg-lock(8): use single hyphen and use complete words
1. Use "-all" which man will render as "--all".
2. Use complete words (such as upgrade, downgrade etc.) for a good
grammatical view.
Signed-off-by: rilysh <nightquick at proton.me>
src/lock.c: print on stdout when no locked packages are found
Printing on stderr, raises test errors, and it seems only resonable
when an error occurs. As this isn't an error, it should be on stdout.
Signed-off-by: rilysh <nightquick at proton.me>
src/lock.c: add a message when there are no locked packages
Right now, even if there are no locked packages to list, it shows
a line, with message "Currently locked packages:" and nothing else.
From a user prospective, it's better to have a clear error/help
message if there are no locked packages to list.
Also, the return value is kind of odd here. If there are no locked
packages, "pkg lock -l" command doesn't return 1 or anything > 0.
"pkg lock -lq" also has the same behavior, except if we pass
--has-locked-packages and gotone is false, it returns 1 (EXIT_FAILURE).
I think it's also better to simply return 0 (if there are locked
packages) or 1 (if there's none locked packages).
Signed-off-by: rilysh <nightquick at proton.me>
libpkg: push siglen +/- 1 into the ossl signer
pack_sign() cannot know that it's safe to read past the bounds of the buffer
provided, so we have to stop that. We can't just stop writing the nul
terminator to avoid breaking compatibility with previous versions' signing
and verifying RSA signatures, so instead push the hack into the ossl signer.
This fixes an overflow when trying to read from the libder-encoded buffer.
plist: grow the notion of variable
Now %%var%% can be defined directly in the plist in the form
@var key value
The line read from the plist are first parsed and get its %%var%%
expanded prior any analysis
external: import libder changes to zero out payloads
libder doesn't know whether it's dealing with sensitive material or not, so
it now zeroes out every buffer it uses for DER data transport to be overly
cautious.
libpkg/pkg_solve.c: remove the err label
Remove the "err" jump label as it just being used to return NULL,
which can be directly returned (without a jump).
Signed-off-by: rilysh <nightquick at proton.me>
Revert "src/info.c: keep the length in a variable to avoid another call"
This reverts commit caa1d6b3e8b188412c6eea704572e0b1e82ff3a0.
This changes causes segfaults because strlen(pkgname) on a non
initialized pkgname
Take PKG_ATTR_{VITAL,LOCKED} into account when solving for pkg upgrade.
The package marked "vital" could not be removed. However, the plan generated
by the solver may still contain such decisions. Such plans will fail when
executed, but this change prevent them from being generated to begin with.
Sponsored by: Serenity Cybersecurity, LLC
src/info.c: keep the length in a variable to avoid another call
Keeping the string length (strlen()) value in a variable can avoid
re-calculating the length of the string (or another strlen() function
call). Although, most compilers might just "fix" this by keeping it
in the previous register, but it will only, if optimization is enabled.
To avoid this, it seems just better to do this manually.
Signed-off-by: rilysh <nightquick at proton.me>
src/add.c: check the getenv() before to avoid another getenv() call
Instead of calling getenv() in a ternary, call it before and keep the
value in a variable. This avoids calling getenv() for the second time,
and also makes the code a bit more clean.
Signed-off-by: rilysh <nightquick at proton.me>
libpkg/pkg_repo.c: multiple trivial changes
1. In pkg_repo_archive_extract_check_archive() function, don't set rc
value that needed to be returned whenever an error or okay happens.
Instead, just return the error to avoid a few more instructions to
set the rc variable and jumping to a different label.
2. pkg_repo_fetch_data_fd(): do the check, whether fd is -1 in the same
braces where the function was called. This avoids two multiple checks
for fd if the first one isn't -1.
e.g. if fd isn't -1
and below another check which will be always true if the previous one
succeed.
if fd isn't -1
...
3. Use the environment variable "TMPDIR" and not "TMMDIR". (It doesn't
exists) and so the branch will always going to be false.
[6 lines not shown]
libpkg/fetch_libcurl.c: use label name do_retry
Use the lable name do_retry, instead of, retry to distinguish between
variable (retry variable) and the jump label.
Signed-off-by: rilysh <nightquick at proton.me>
libpkg/pkg_status.c: keep the getenv() value in a variable
Same as commit: aa1ef79d9796494d0c3807dd7a7bf2af1803cd97
Signed-off-by: rilysh <nightquick at proton.me>
libpkg/utils.c: keep the length in a variable to avoid another call
1. Same as commit b8a10ba09c1874365ce88a6ff3c3f688a45da0bb
2. Move the struct (tempdir) at the toplevel of the function.
Signed-off-by: rilysh <nightquick at proton.me>