1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-05 09:05:03 -05:00
Commit Graph

122 Commits

Author SHA1 Message Date
Dan McGee
49dff4c80b Add a random pactest
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 17:00:21 -05:00
Dave Reisner
e01dbcc068 include ldconfig.stub in EXTRA_DIST
Since c51b9ca, ldconfig.stub is required by pactest so we need to
include it as part of the dist tarball.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14 17:18:44 -05:00
Dan McGee
c51b9ca0ad pactest: remove PACMAN_OUTPUT from ldconfig tests
This removes the last usages of this rule that aren't explicitly looking
at real output from pacman. Notably, these tests depended on one
particular debug logger not ever being changed, which is too fragile,
not to mention doesn't work at all with --nolog.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-01 14:36:44 -05:00
Dan McGee
13072ef86c Add pactest for overflowing date (year 2038 problem)
This will work fine on x86_64 (or any platform that has a 64 bit long),
but currently fails on i686. This test also stresses the recent changes
to accommodate package size values greater than a 32 bit UINT_MAX.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-01 12:18:48 -05:00
Dan McGee
7480df68ce Rework scriptlet tests to not depend on pacman output
This actually does something in a scriptlet we can check with our normal
set of rules, rather than relying on pacman debug output.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-29 07:48:59 -05:00
Dan McGee
30d978a966 vercmp: ensure 2.0a and 2.0.a do not compare equal
We had this interesting set of facts conundrum, according to vercmp
return values:
    2.0a <  2.0
    2.0  <  2.0.a
    2.0a == 2.0.a

This introduces a code change that ensures '2.0a < 2.0.a' as would be
expected by the first two comparisons. Unfortunately this stays us a bit
further from upstream RPM code, but those are the breaks (in RPM, the
versions involving 'a' do in fact compare the same, but they are both
greater than the bare '2.0').

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-23 01:49:29 -05:00
Dan McGee
3752edbff4 Fix replacement of provider issue
When we switched to using alpm_depcmp() in resolving replacments, we had
some interesting behavior with regard to providers and packages not
found in repositories. Teach the replacement resolving code to not look
at provisions at all to be slightly more sane.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-18 10:47:41 -05:00
Dan McGee
3ceef97799 Fix trailing whitespace in whole codebase
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-17 17:03:19 -05:00
Dave Reisner
82ffe2cbfd build-sys: always use $(RM) instead of rm -f
These are equivalent. Use the autoconf macro for consistency.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 13:05:27 -05:00
Dave Reisner
8d5018e780 add pactest for replacing a shared provider
This is currently expected to fail.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 06:30:25 -05:00
Dave Reisner
ce8f91a71b pactest/sync200: check for curl instead of fetch
We can't just check for LIBS as curl won't be listed. Instead, look at
the length of the LIBCURL var from the Makefile.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 06:29:09 -05:00
Pang Yan Han
450bcb5d7b pactest: -U --recursive
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 12:52:18 -05:00
Dave Reisner
a58dc9283c pactest: add sync302 to test recursive syncfirst
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 11:36:58 -05:00
Dan McGee
5c1b83d9b1 Parse replaces strings as dep strings with version specs
This is done extremely crudely and is not very efficient, but it does
push us down the path of being closer to right, as one additional test
now passes.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09 16:13:25 -05:00
Dan McGee
5a6ebec7b2 Add a slightly simpler versioned replace test
It turns out we have a few problems here which are best tackled
independently. The first is simply parsing replacements as dep strings;
the second will be dealing with replaces when the original package name
still exists in the repository.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09 15:46:11 -05:00
Dan McGee
9d3d647f00 pactest: improve speed of local DB dependent rules
We were doing some really silly stuff before and abusing the os.walk()
call, having to walk the entire local database for every single PKG
rule. We really only need top level directories, and we can cache any
generated package since calls to db_read() are well-defined and only
happen in one place.

This speeds up the running of tests that may want to add 100 PKG_VERSION
rules at once, where before we had to limit how many we used in order to
not put a serious cramp in the speed of the test suite run.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09 15:36:05 -05:00
Dan McGee
d9f9b87d3f Add a test harness for new pacsort command
Note that this is meant to exercise pacsort more than the underlying
version comparsion; that is better left to the standalone vercmptest.sh
test script.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 16:55:01 -05:00
Dan McGee
fab66f157d Bash-ify test/util/vercmptest.sh
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 16:49:19 -05:00
Dan McGee
b03b06cfd3 Implement parsing of the new SigLevel directive
Add code to conf.c that parses the new SigLevel directive. An
overwhelming number of options are presented, but most users will still
be fine with the Never/Optional/Required trio. More advanced users can
combine these or any of the other options on a 'SigLevel = ' line, which
is parsed in a left-to-right fashion and flags turned on and off
accordingly. For example, all three of these will net the same config:

    SigLevel = Required PackageOptional
    SigLevel = Optional DatabaseRequired
    SigLevel = DatabaseRequired PackageOptional

Additionally, database-specific lines assume you wish to start with any
global default that has been set. For example, if any of the above lines
were in the [options] section, something such as:

    SigLevel = PackageRequired PackageAllowMarginal

Would continue to enforce required database signatures.

Inspiration-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-02 08:25:09 -04:00
Dan McGee
cbaff216b3 Don't trim whitespace when reading database entries
We don't write with extra or unknown whitespace, so there is little
reason for us to trim it when reading either. This also fixes the
hopefully never encountered "paths that start or end with spaces" issue,
for which two pactests have been added. The tests also contain other
evil characters that we have encountered before and handle just fine,
but it doesn't hurt to ensure we don't break such support in the future.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-02 08:20:34 -04:00
Dan McGee
573260556d pactest: use subprocess module instead of os.system
This is more in line with standard Python practice, and makes keyboard
interrupts behave a lot more sanely. It also prevents the useless
spawning of a shell as well as simplifies the command building and
working directory stuff.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-02 08:20:27 -04:00
Dan McGee
0b92d9ed9c Add a new epoch pactest
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-18 10:34:39 -05:00
Dan McGee
1c39e4fbad Handle removal of empty directories properly
This addresses FS#25141. We shouldn't remove every empty directory we
come across during the removal process unless it is truly not known to
any other package. This will prevent removal of essential directories
such as '/var/lock/'.

This is accomplished by first checking the empty/non-empty status of a
directory, which was previously done implicitly by calling rmdir() and
ignoring errors. We do this to avoid the next (new) check in most cases,
which is to look at all local packages to see if the to-be-removed
directory is present in another packages' filelist. If we do not find it
anywhere, then we remove it, else we keep the file around.

The pactest has been updated to test more cases, as well as finding a
flaw in the original expected to fail case- we need separate DIR and
FILE based EXIST rules.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-18 10:34:05 -05:00
Dan McGee
af357d6ab0 Allow fileconflict if unowned file moving into backup array
The bulk of this commit is adding new tests to ensure the new behavior
works without disrupting old behavior. This is a relatively sane maneuver
when a package adds a conf file (e.g. '/etc/mercurial/hgrc') that was
not previously in the package, but it is placed in the backup array. In
essence, we can treat the existing file as having always been a part of
the package and do our normal compare/install as pacnew logic checks.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-14 15:34:04 -05:00
Dan McGee
a2995f586e pactest: add a few more checks to fileconflict checks
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 13:44:45 -05:00
Dan McGee
35ffe6af2d pactest: remove no longer necessary newline hacks
libalpm can now cope with this as of commit 719e0d3ddb.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 12:02:33 -05:00
Dan McGee
0ed848a9ea pactest: create packages in memory
This is similar to what was just done for the sync databases. Move a few
pieces around so we never need to actually write out the filesystem to
create a package, and simply stream the tarfile out from the data we've
collected.

Once again, a few newline addition hacks and other things have to be
left in place in order not to break everything; this time however most
of the assumptions are in pactest and not libalpm.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 11:55:00 -05:00
Dan McGee
77a09c92c6 Merge branch 'maint'
Conflicts:
	lib/libalpm/conflict.c
2011-06-27 09:33:27 -05:00
Dan McGee
e378170c25 Ensure a file can be replaced by a directory
This addresses FS#24904. In a normal upgrade case, this replacement
seems to work just fine. However, when doing a sync "replace" type
upgrade, we weren't properly handling this edge case due to path
comparison not ignoring trailing slashes. Fix this by pruning any
trailing slashes past a certain point of file conflict resolution where
we no longer need them, which allows us to safely detect cases such as
now tested in the new pactest.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-27 09:15:31 -05:00
Dan McGee
79e98316ea Add a 'valid' flag to the database object
Start by converting all of our flags to a 'status' bitmask (pkgcache
status, grpcache status). Add a new 'valid' flag as well. This will let
us keep track if the database itself has been marked valid in whatever
fashion.

For local databases at the moment we ensure there are no depends files;
for sync databases we ensure the PGP signature is valid if
required/requested. The loading of the pkgcache is prohibited if the
database is invalid.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 03:46:12 -05:00
Dan McGee
db3b86e7f3 Do database signature checking at load time
This is the ideal place to do it as all clients should be checking the
return value and ensuring there are no errors. This is similar to
pkg_load().

We also add an additional step of validation after we download a new
database; a subsequent '-y' operation can potentially invalidate the
original check at registration time.

Note that this implementation is still a bit naive; if a signature is
invalid it is currently impossible to refresh and re-download the file
without manually deleting it first. Similarly, if one downloads a
database and the check fails, the database object is still there and can
be used. These shortcomings will be addressed in a future commit.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 02:34:50 -05:00
Dan McGee
624a878701 pactest: generate sync DB's in memory
Sync database are no longer exploded on the filesystem. Rework the logic
used to generate our test databases so we can create them completely in
memory without having to write the individual files to disk at all. The
local database is unaffected.

Note that several shortcomings in libalpm parsing were discovered by
this change, which have since been temporarily patched around in this
test suite:

* archive_fgets() did not properly handle a file that ended in a
  non-newline, and would silently drop the data in this line.
* sync database with only the file entries and not the directories would
  fail to parse properly, and even cause segfaults in some cases.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:48 -05:00
Dan McGee
63335859d1 pactest: refactor install file creation
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:48 -05:00
Dan McGee
f15cce1d41 pactest: move filelist/backup generation into package object
These are definite methods that operate on a package, so move them there
which cleans up util a bit more.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:48 -05:00
Dan McGee
3ace8ceb23 pactest: make pmfile a bit more pythonic
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:48 -05:00
Dan McGee
11d8418737 pactest: small cleanups and chmod -x most files
Remove empty docstrings, small and easy pylint fixes, etc.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:48 -05:00
Dan McGee
763d638ca1 pactest: clean up database section writing
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:48 -05:00
Dan McGee
a8c3202836 pactest: add isize attribute, fix url attribute
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:47 -05:00
Kerrick Staley
3d4bf3b3fd Fixed outdated documentation in test/pacman/README
test/pacman/README mentioned the -A flag, which no longer exists.

Signed-off-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-22 11:13:52 -05:00
Dan McGee
81e6071e0f pactest: add retcode=0 to several tests
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20 00:36:01 -05:00
Dan McGee
beffab02c4 pactest: only create install file if necessary
We were testing whether there were any values in the array, rather than
looking if the values contained anything.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-08 02:48:52 -05:00
Dan McGee
cc25576f8b Use standard errno codes in return from _alpm_archive_fgets
This allows us to not require the context (e.g. handle) when calling
this function. Also beef up the checks in the two callers of this
function to bail if the last return code is not ARCHIVE_EOF, which is
the expected value.

This requires a change to one of the pactest return codes and the
overall result of the test, but results in a much safer operating
condition whereby invalid database entries will stop the operation.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03 14:37:51 -05:00
Dan McGee
142c2132cf Add two currently failing test cases from bug reports
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-02 17:20:45 -05:00
Dan McGee
11fb9c7674 Merge branch 'maint'
Conflicts:
	lib/libalpm/trans.c
	src/pacman/query.c
2011-05-19 17:17:32 -05:00
Dan McGee
aec60e3782 Fix segfault when uninstalling broken backed-up symlink
Issue FS#24230. If a symlink is broken and included in the removal
process of a package, we blew up and segfaulted due to
alpm_compute_md5sum() returning NULL and then performing a strcmp()
operation.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-16 11:50:13 -05:00
Dan McGee
93f02f5793 Add test for FS#24230, dead backup symlink removal
This currently causes a segfault, which is bad news.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-16 11:32:33 -05:00
Dan McGee
3000b6b473 pactest: treat symlinks with more respect
Don't call os.stat() when we should be using os.lstat(); this allows us
to actually test dead symlinks that don't have a corresponding file. Add
a new LINK_EXIST rule that complements FILE_EXIST for a similar purpose.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-16 11:31:26 -05:00
Dan McGee
d360153bc6 pactest: run with root in /tmp and clean up automatically
This moves the generated root/ directory into /tmp, or at least a path
returned by tempfile.mkdtemp(), by default. This can make test runs
significantly faster if done when /tmp is a tmpfs.

If you are debugging a failed test, use the new --keep-root option to
not clean up and pactest will print the location of the generated root/
test directory.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-05 11:12:26 -05:00
Dan McGee
791928dc48 Header inclusion cleanup
This does touch a lot of things, and hopefully doesn't break things on
other platforms, but allows us to also clean up a bunch of crud that no
longer needs to be there.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 20:09:13 -05:00
Dan McGee
c5addd94e3 Merge branch 'maint'
Conflicts:
	lib/libalpm/be_sync.c
	lib/libalpm/db.c
	src/pacman/util.c
2011-04-05 00:49:30 -05:00