Pacman currently bails when trying to extract a file over a directory
when using --force. Instead of ignoring all conflict, perform the
check and skip any file-file conflicts. Conflicts between directories
and files are still flagged and cause the transation to abort.
As a bonus, we now know about files changing packages when using
--force, so we can skip removing them fixing upgrade046.
Signed-off-by: Allan McRae <allan@archlinux.org>
alpm_filelist_contains was being used to search for resolved paths, but
searching in the unresolved paths, causing it to miss matches. We
always search unresolved paths and search the resolved paths if
available because _alpm_filelist_resolve is not public and requires
a context handle, so it can't be called from alpm_filelist_contains.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
We were comparing files based on resolved paths but returning the
original file_t structures, which were not necessarily in the same
order. The extra file_t information was only being used to determine if
the file was a directory which can be accomplished by testing for
a trailing slash, so just return the resolved path.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
We were comparing files based on resolved paths but returning the
original file_t structures, which were not necessarily in the same
order. The additional file_t information was never used, so just return
the resolved path.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Installing filesystem entries first allows the filesystem to provide
a symlink to a directory. Packages will then be able to use the symlink
as if it were a directory instead of causing an error.
For example:
self.filesystem = ["dir/", "link -> dir/"]
pkg = pmpkg("pkg1")
pkg.files = ["link/file"]
self.addpkg2db("local", pkg)
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
We don't want test files to do any checks for fakechroot since we will
print a warning if it is not found.
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Teach pacsort to understand package filenames and optionally strip away
some of the context. alpm_pkg_vercmp() intentionally only understands
pure versions, so strings such as '18.0-2-x86_64' and '18.0.1-1-x86_64'
will be compared wrongly.
Partially addresses FS#33455.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
The FHS (2.3) says having ldconfig in /sbin is optional and it is usually
located in /usr/sbin. So /sbin/ldconfig should not be hard coded in
pacman. Instead, provide a configure option --with-ldconfig that defaults
to the current path.
Signed-off-by: Allan McRae <allan@archlinux.org>
The leading / makes the pactest suite look for the file in the users
filesystem. This meant the ldconfig tests always passed (even when
broken in pacman...).
Signed-off-by: Allan McRae <allan@archlinux.org>
pacman can be configured to use a different shell than /bin/sh for
scriplets. Pass the cnfigured value to the pactest suite and make the
necessary "copy" of the shell in the test root.
Also update all copyright years in the pactest suite.
Signed-off-by: Allan McRae <allan@archlinux.org>
This reverts commit 4a8c2852a8.
This reverts commit 993700bc6b.
This reverts commit bb4d2b72c1.
This reverts commit 60b192e383.
Signed-off-by: Allan McRae <allan@archlinux.org>
In order to support a variety of values for the --with-scriptlet-shell
configure flag, pmtest has to be aware of what kind of path was passed,
be it an absolute path or a fragment for a path lookup. For absolute
paths, leave the path alone. For fragments, search the PATH environment
var for the resolved path to the binary. In both cases, join the
resultant path to the root directory defined for the test, not a
pre-determined bin directory.
Fixes FS#31552.
With-contribution-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Teach pacman to save backup files with extension .pacsave.n, where n is a
positive integer. The current backup file shall be saved as <name>.pacsave,
while existing .pacsave.n files will be renamed to <name>.pacsave.n+1
Example:
1. You have subversion installed in your local repo. /etc/conf.d/svnserve
is a file to be backed up. It contains local modifications
2. You remove subversion from your repo. /etc/conf.d/svnserve is backed up as
/etc/conf.d/svnserve.pacsave
2. You install subversion again
3. You edit /etc/conf.d/svnserve
4. You remove subversion. The existing /etc/conf.d/svnserve.pacsave is renamed
to /etc/conf.d/svnserve.pacsave.1 and /etc/conf.d/svnserve is backed up as
/etc/conf.d/svnserve.pacsave
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Rebased from original email and adjusted for util-common usage.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
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>
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>
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>
When using the --valgrind flag with the pactest.py script, the path
to the suppression file relies on the script being called from the
source root directory. Construct the path from the scripts location
to allow it to be called from directory.
Dan: style cleanup.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
If a pacakge has a directory symlink (e.g. /lib -> usr/lib), do not
allow it to be removed if any other package is trying to install a
file into that path (e.g. /lib/foo). This is because the local
database can become invalidated if the symlink is removed after the
package with file /lib/foo is installed (sync702.py). If the symlink
is removed before the file is installed (sync701.py), the upgrade is
actually a success, but we can not guarantee the ordering so both
cases should fail.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
If we have a symlink to a directory (e.g. /lib -> usr/lib), then
we can not remove it if a local package thinks it has files in the
symlink directory (e.g. /lib/foo), because this will invalidate the
local file database.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Note failure to detect a conflict between files having the same
effective path across packages due to a directory symlink.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Note failure to detect a conflict between a directory in one package
and a file in the other when the directory is not currently on the
filesystem.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
The wrong test file was inadvertantly committed in 44e9fdd0. Add the
correct test and tidy up the test which was committed.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
When checking if a package owns a directory, it is important to check
not only that all the files in the directory are part of the package,
but also if the directory is part of a package. This catches empty
subdirectories during conflict checking for directory to file/symlink
replacements.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
When two packages own an empty directory, pacman finds no conflict when
one of those packages wants to replace the directory with a file or a
symlink. When it comes to actually extracting the new file/symlink,
pacman sees the directory is still there (we do not remove empty
directories if they are owned by a package) and refuses to extract.
Detect this potential conflict early and bail. Note that it is a
_potential_ conflict and not a guaranteed one as the other package owning
the directory could be updated or removed first which would remove
the conflict. However, pacman currently can not sort package installation
order to ensure this, so this conflict requires manual upgrade ordering.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This is a bash wrapper around an awk function that parses human readable
sizes and returns their representative values in bytes, as a string. A
small test harness is added to validate the functionality.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Check for an exact match when querying ownership of files in the root.
Previously, our test was too simple and would match the the basename of
package files against the query parameter, e.g.
$ pacman -Qo config
/config is owned by cower-git 20120614-1
Adds a new test to verify this behavior, query007.py.
Fixes FS#30388.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This will replace our current options parser used in pacman-key,
makepkg, and ideally elsewhere. It follows heuristics closer to that of
GNU getopt long (and thus pacman itself), with the exception that it
does not allow for options with optional arguments. Due to the way this
parser will be used, this sort of functionality will not be needed.
Instead of relying on eval+set, options are normalized into an array,
OPTRET, which callers should expect to be populated after returning from
parseopts. This avoids problems with quotes and spaces in arguments,
assuming that the user quotes properly when passing into the
application.
A new test harness for parseopts is added in test/scripts.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
This has outlived its usefulness and causes more problems than it
solves. It has historically only ever been used to install pacman first.
That should not be needed given we provide the vercmp utility (which has
no library dependencies) and so calling pacman in install scripts is a
sign of poor packaging.
Work-duplicated-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Python PEP-394 states that all python code should point at the
python2 or python3 symlinks at maintain cross-distro compatibility.
Note that this does not matter when calling these scripts using
"make check" as they are explictly called using the detected python
version. As this only affects manually calling these scripts, I
have not had configure/make replace the shebangs.
Signed-off-by: Allan McRae <allan@archlinux.org>
This reverts commit f3fa77bcf1 along with
making other necessary changes to fully back this (mis)feature out until
we can do it correctly.
The quick summary here is this was not implemented correctly; provides
are not fully taken into account in this logic, and making that happen
exposes a lot of other flaws in this code that are covered up later on
in the dependency resolving process by several other pieces of
convoluted and conditional logic.
Tests have been adjusted accordingly. Some test EXISTS conditions have
been removed as we already know the package is installed locally, and we
also are checking the VERSION condition anyway.
With these two related revert commits, we do have some changes in test
pass/fail results:
* upgrade078.py: does not pass, this is due to --recursive getting
removed for -U/-S operations after this commit.
* sync302.py: the version checks have been disabled, so this test
continues to pass but has been scaled back in scope.
* sync303.py: now passes, was failing before.
* sync304.py: still failing, was failing before.
* sync305.py: now passes, was failing before.
* sync306.py: still passes, was passing before.
Signed-off-by: Dan McGee <dan@archlinux.org>