This allows compiling in both clang and gcc without running into
oddities regarding const vs. defined constant values.
Signed-off-by: Dan McGee <dan@archlinux.org>
If we are reversed, then we were correctly freeing both the list and the
contained data. However, we were leaking a list in the case of a
non-reversed traversal.
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Fun fact about bash: the below is valid and will only ever print 'a'!
fn() {
continue 2
}
for x in {1..5}; do
for y in {a..e}; do
echo "$y"
fn
done
done
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
A properly formatted mtree file may stick a leading "./" in front
of file names in the root directory. Strip this if present.
Signed-off-by: Allan McRae <allan@archlinux.org>
Bail early in file validation checks if the file type given in the
mtree file does not match that in the filesystem.
Signed-off-by: Allan McRae <allan@archlinux.org>
The "install" and "changelog" entries for a package in the local
database are now checked for changes with -Qkk.
Signed-off-by: Allan McRae <allan@archlinux.org>
The follow fields are checked:
Directory: uid, gid, mode
File: uid, gid, mode, size, time
Symbolic Link: uid, gid, mode, link, time
A skeleton is added for checking a files md5sum and sha256sum when
reading this information is supported by libarchive.
Signed-off-by: Allan McRae <allan@archlinux.org>
If a package has an mtree file, using pacman -Qkk will read that
file and use it to perform more in depth package checking.
Currently this only checks for file presence.
Signed-off-by: Allan McRae <allan@archlinux.org>
There is going to be a lot of overlap in the code for the quick
and full checks that can be abstracted into their own functions.
Also many other file checking functions will be needed for the
full check. Put all these in a separate source file.
Signed-off-by: Allan McRae <allan@archlinux.org>
Add an mtree file to the package with all file information. This
can be added to the local pacman database on install allowing full
package verification.
Signed-off-by: Allan McRae <allan@archlinux.org>
When a configured repo database is not already downloaded, a warning
message such as "warning: database file for 'testing' does not exist"
is printed. Disable this warning when the database is scheduled to
be downloaded in the transaction.
Signed-off-by: Allan McRae <allan@archlinux.org>
The warning given for a signature timstamp being in the future compared
to the system time stated the opposite.
Also, move this warning to debug output. It is useless in its current
form as the package or database that is giving the error is not
mentioned and so other debug output is needed to find the offending
signature.
Signed-off-by: Allan McRae <allan@archlinux.org>
The previous commit removed the Vim modelines which replaced tabs with
spaces. This commit replaces the space-based indents with tabs.
Tabs are generally more compatible with various user preferences
regarding indentation of code. Using space-based indents is not flexible
regarding user preferences at all.
Signed-off-by: Jason St. John <jstjohn@purdue.edu>
It makes little sense to "force" users to replace tabs with spaces, with
a width of 2. These settings should be configured by the user in their
own ~/.vimrc.
This is a resubmission based on Allan's feedback on the ML.
Signed-off-by: Jason St. John <jstjohn@purdue.edu>
Places logs in a pre-defined location. The logs are always neatly
labeled with package names and numbers, and this way can be more easily
sent to network shares as they are written or compressed/cleaned en
masse.
Signed-off-by: William Giokas <1007380@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Specifically, we shouldn't allow newlines in the pkgdesc field, as
pacman will ignore the continuation and end the description prematurely
as written to the local DB. Normalize ALL whitespace, replacing it with
single whitespace characters.
Fixes strange errors as seen by FS#32852.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Instead of blindly consuming data from the .PKGINFO file, parse it more
closely and only declare variables as needed.
Should help to avoid nonsensical errors and possibly dangerous command
execution as seen in FS#32852.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
When a packages (new) optdepends are printed in install (update),
add a note of their current installation status. Packages currently
installed are labelled with [installed] and packages to be installed
in this transaction are labelled [pending].
Signed-off-by: Allan McRae <allan@archlinux.org>
Much like packages that require a give package are displayed in the
"Required by" field of its information output, alos display packages
that optionally require the package.
Inspired-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
When a package is being removed, provide a notification (via a callback)
if any local package requires it as an optdepend.
Signed-off-by: Allan McRae <allan@archlinux.org>
This is a bug that has been around since at least 2007. On a package
upgrade (either by -S or -U) a new directory could overwrite any file.
This is caused by the filelist difference calculation ignoring all
directories and thus no new directories were checked for conflicting
files on the filesystem.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
[Allan: Remove expected failure from fixed pactests]
Signed-off-by: Allan McRae <allan@archlinux.org>
Provide a package for removing packages with unmet dependencies.
Currently pacman removes too many packages from the transaction
(FS#30649).
Signed-off-by: Allan McRae <allan@archlinux.org>
Return -1 if a path is too long to resolve or we run out of memory.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This applies to a case such as when /lib is a symlink to /usr/lib. If a
package is installed which contains /lib/libfoo.so, pacman will complain
if this package is then "fixed" to contain /usr/lib/libfoo.so. Since
these have the same effective path and it exists within the same
package, ignore the conflict.
Fixes FS#30681.
Signed-off-by: Allan McRae <allan@archlinux.org>
File paths are resolved if necessary during inter-package conflict
checks so that packages carrying the same effective file due to
directory symlinks on the filesystem are flagged as conflicting.
Signed-off-by: Allan McRae <allan@archlinux.org>
If a filename isn't resolved, the original can be used instead of strdup()ing
it.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
The _alpm_filelist_resolve function takes a filelist and creates
a list with any symlinks in directory paths resolved.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Add an array to hold the resolved paths of the files in alpm_filelist_t.
When the file name and its resolved file name are identical, the pointer
to the original file name is used to avoid duplicate memory allocation.
Signed-off-by: Allan McRae <allan@archlinux.org>
Detect a conflict between a file/symlink in one package and a directory
in another when both are being installed at once.
A side effect is the creation of conflicts between a directory symlink
and a real directory (e.g lib -> usr/lib in pkg1 and /lib in pkg2).
Given we can not guarantee pkg1 is installed before pkg2, this is a
genuine conflict.
Signed-off-by: Allan McRae <allan@archlinux.org>
It turns out when you set the filelist for a package to include
"usr/lib/foo" in the pactest suite, it thinks there is only the
file "usr/lib/foo" in there... No "usr/" or "usr/lib/" directory.
This makes life difficult when testing code that scrolls through
a filelist looking for directory entries.
Signed-off-by: Allan McRae <allan@archlinux.org>