1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 14:56:14 +01:00
Commit Graph

95 Commits

Author SHA1 Message Date
Marcus Huewe
c534d7e990 Fix logic error in DebQuery.vercmp
res is never None, because DebQuery.rpmvercmp always returns -1, 0,
or 1.
2019-01-27 19:43:38 +01:00
Marcus Huewe
cd5f46984d Port debquery module to python3
No functional changes. Note that we cannot simply decode the control's
fields as ascii/utf-8 because a field is not necessarily a valid
ascii/utf-8 encoding (it is possible to register _arbitrary_ custom
fields via a 'register-custom-fields' hook when building a deb
package).

Note: DebQuery.debvercmp really deserves a cleanup:/
2019-01-27 19:31:47 +01:00
Marcus Huewe
bb9f9a7fde Refactor DebQuery.__parse_control a bit
No functional changes. This just simplifies the upcoming python3
port a bit.
2019-01-27 17:35:47 +01:00
Marcus Huewe
f63a0957af Remove superfluous try-except block in the archquery module
ArchQuery.query never raises an ArchError exception.
2019-01-27 16:51:58 +01:00
Marcus Huewe
2074a1c01d Make ArchQuery.canonname more robust against None values
Use ArchQuery.filename to construct the filename and raise an
ArchError exception if we are unable to construct a filename.
2019-01-27 16:46:52 +01:00
Marcus Huewe
8c1cb190bd Port the missing pieces of the archquery module to python3
This is a follow-up commit for commit
21eca9e3f1 ("[python3] switch
ArchQuery to bytestrings").
2019-01-27 16:27:30 +01:00
Marcus Huewe
2d0c974296 Add cmp function to packagequery module
cmp(a, b) returns
-1 if a < b
 0 if a == 0
 1 if a > b

This is needed since python3 has no cmp function anymore.

All credits for this go to Marco Strigl <mstrigl@suse.com> (see
PR#483 [1]).

[1] https://github.com/openSUSE/osc/pull/483
2019-01-27 16:12:57 +01:00
Marcus Huewe
a3720c5286 Fix ArchQuery.rpmvercmp if one of its arguments is None
The None argument is always <= than the other argument. We need this
in case of a broken/pathological package where version() or release()
return None (see vercmp (which calls rpmvercmp)).
2019-01-27 15:50:35 +01:00
Marcus Huewe
5c639db805 ArchQuery.epoch should never return None
Returning None breaks ArchQuery.vercmp. Returning b'0' is ok because
an epoch, if present, is always supposed to be an integer (at least
in a "valid" arch package (see scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
in the pacman sources)). Hence, if we compare the epoch of a package,
which has no explicit epoch set, with the epoch of a package, which
has an explicit epoch set, we always have a <= relation.
2019-01-27 15:39:07 +01:00
Marcus Huewe
deee8ef6cb Fix logic error in ArchQuery.vercmp
res is never None, because ArchQuery.rpmvercmp always returns -1, 0,
or 1.
2019-01-27 15:00:36 +01:00
Marcus Huewe
562374f045 Simplify ArchQuery.read a bit
No functional changes - just to improve readability.
2019-01-27 14:57:47 +01:00
Marcus Huewe
e580769757 Merge branch 'python3_archquery_module' of https://github.com/lethliel/osc
Initial port of the archquery module to python3 (ArchQuery.__init__,
ArchQuery.read, and ArchQuery.canonname are ported - the rest is missing).
2019-01-27 14:55:01 +01:00
lethliel
21eca9e3f1 [python3] switch ArchQuery to bytestrings
decode explicit (ascii)
2019-01-23 22:59:55 +01:00
Marco Strigl
f233066448
Merge pull request #482 from lethliel/python3_packagequery_module
[python3] magic is now a bytestring in python3
2019-01-18 14:34:43 +01:00
Marcus Huewe
e60af6f120 Use with statement in CpioRead._copyin_file
This makes sure that the file is closed in case of an exception.
2019-01-15 20:49:26 +01:00
Marcus Huewe
5387744d36 Port CpioWrite to python3
Now, CpioWrite provides a bytes-only API. It would be also possible
that the API accepts bytes and str (we would need to explicitly
encode the latter) but this would be a bit inconsistent wrt.
cpio.CpioRead (which is bytes-only).
Also, by using a bytesarray instead of a [] we avoid several
intermediate ''.join(...)s.
2019-01-15 20:48:42 +01:00
Marcus Huewe
3e326b1bb4 Port CpioRead and CpioHdr to python3
This is a bytes only API because a filename in a cpio archive can
contain, for instance, illegal utf-8 sequences. A user can decode
the filename/content as she wishes.
2019-01-15 20:05:47 +01:00
Marcus Huewe
54ac438eb0 Do not mmap a cpio archive
There is simply no need for a mmap.
2019-01-15 19:47:27 +01:00
Marcus Huewe
1c4385a579 Run a small demo when the cpio module is invoked as a script
It just reads in a cpio archive and print the headers.
2019-01-15 19:46:00 +01:00
Marcus Huewe
5c19425c9b Use with statement in ArFile.saveTo
This makes sure that the file is closed in case of an exception.
2019-01-15 17:18:50 +01:00
Marcus Huewe
b26a4a967d Raise a ValueError if neither fn nor fh is passed to Ar.__init__
A ValueError is more appropriate because there is no issue with the
ar archive itself. Also, the old codepath never worked because the
fn parameter was missing.
2019-01-15 17:18:50 +01:00
Marcus Huewe
6fdce86fc9 Port the ar module to python3
Since an ar archive can contain arbitary filenames (that is a
filename can be an invalid utf-8 encoding (for instance,
"foo\xff\xffbar")), the ar module provides a bytes only API. A
user can decode filenames as she wishes.
Note: if a "fn" parameter is passed to Ar.__init__ it should be a
bytes (a str is also ok, but then be aware that an ArError's file
attribute might be a str or a bytes).
2019-01-15 17:18:37 +01:00
Marcus Huewe
68cf974c78 Do not mmap the ar archive
There is really no need for a mmap here. Also, the comment in the
docstr does not apply/is nonsense (there is no performance gain).
2019-01-15 17:18:19 +01:00
Marcus Huewe
e12181b11d An ext fn header in an ar file has no mode
Use a dummy mode of 0 in this case (internally, the mode is never
used).
2019-01-15 17:18:19 +01:00
Marcus Huewe
2e45edbe16 Remove superfluous StopIteration exception from the ar module
There is no need to raise a StopIteration exception.
2019-01-15 17:18:19 +01:00
Marcus Huewe
470b187374 Run a small demo when the ar module is invoked as a script
It just prints the ar headers.
2019-01-15 17:18:10 +01:00
Marcus Huewe
28eeff8683 Simplify rpmquery.unpack_string
There is no need to unpack a single byte because it is not
affected by (byte) endianness (and that's what struct.unpack is
about). Moreover, rpmquery.unpack_string now supports an optional
encoding parameter, which could be used by the python3 port to
decode a string. Note: in general we cannot assume that all strings
in a rpm are utf-8 encoded (it is possible to build a rpm that
contains illegal utf-8 sequences).
2019-01-14 16:40:09 +01:00
lethliel
2d5a3aeb3b [python3] magic is now a bytestring in python3 2018-12-13 13:23:26 +01:00
Fridrich Štrba
89cef1f8c1 Do not choke on operators < and > in spec files 2018-11-28 10:55:17 +01:00
lethliel
9ffe9b9288 improve error message if file is not a valid rpm
The current error message is quite confusing and nobody knows what
"invalid lead magic" means.
2018-10-09 10:16:27 +02:00
lethliel
779b66f3c3 fixed indentation of return[].
It works in python2, but will break in python3
2018-07-06 09:54:59 +02:00
Marcus Huewe
caaefb0bf5 Fix and simplify util.safewriter.SafeWriter
Storing the error encoding in an "encoding" attribute "breaks" the
python3 "input" function: In essence, builtin_input_impl does a
getattr(sys.stdout, 'encoding'), which returns our error encoding
instead of the "real" stdout encoding. In order to avoid this, we
store the error encoding in an "_encoding" attribute.

Making SafeWriter a new-style class simplifies the code a lot.
2018-03-09 16:55:56 +01:00
Marcus Huewe
ebb2f2ee0d Add support for querying weak dependencies
The following abstract methods are added to the PackageQueryResult
class: recommends(), suggests(), supplements(), and enhances().
Note that not all package/metadata formats have a notion of these
weak dependencies.

              rpm   rpmmd   deb   arch
recommends     x      x      x
suggests       x      x      x     x
supplements    x      x
enhances       x      x      x

(where "x" represents "supported"). In case of an unsupported weak
dependency, the implementation returns an empty list.

We need the weak dependency support in order to fix #363 ("osc build
-p ../rpms/tw doesnt send recommends to the server which makes client
side build behave differently to server side build").
2017-12-26 23:14:47 +01:00
Riku Voipio
9166a7f075 debquery: support control.tar.xz
Similar to recent fixes in libsolv and obs-build. Since tarfile
on python2 doesn't do lzma, decompress the file into memory and
feed it as a fake file via StringIO to tarfile
2017-10-30 14:10:54 +02:00
9f00759e02 Support arm packages in pkg-prefer 2016-08-08 10:35:14 +02:00
Marcus Huewe
fa4f24f06b - RpmQuery.rpmvercmp: support tilde ('~') 2015-07-03 14:22:00 +02:00
Daniel Gollub
64838ffd51 Support native Debian packages in pkg-prefer
fixes #158
2015-07-02 15:08:39 +02:00
Marcus Huewe
a80b286ac9 - fixed #147
Introduced new PackageQueryResult class and adapted existing
modules accordingly.
2015-06-23 17:52:37 +02:00
Michael Schroeder
7acaba2d8a add obsoletes, conflicts, evr query methods 2014-12-09 13:04:55 +01:00
Michael Schroeder
f47c39521d Verify hdrmd5 of packages if specified in the buildinfo
Needed for buildenv builds that want specific packages.
2014-11-17 12:40:54 +01:00
Christian Berendt
1751bdc47f Resolve PEP8 issue E231
* E231 missing whitespace after ':'
2014-08-13 17:30:12 +02:00
Dinar Valeev
ee15c4cb11 Add ppc64le to Debian arch map
Signed-off-by: Dinar Valeev <dvaleev@suse.com>
2014-06-25 15:05:17 +02:00
Michael Schroeder
42c357336e take epoch into account when calculating the filename
ArchLinux has the epoch in the canonname, Debian discusses doing
this as well.
2014-05-13 13:29:41 +02:00
Marcus Huewe
d6e6c0538e - get "osc build --prefer-pkgs ..." working with Arch 2014-04-03 17:41:41 +02:00
Danny Al-Gaaf
b55d4d6b99 util/archquery.py: remove unnecessary semicolon
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-05-27 14:30:08 +02:00
Marcus Huewe
5a8baf9b88 - util.ar: do not import StringIO from the cStringIO module
The class ArFile inherits from StringIO but StringIO from cStringIO
is just a function (this got broken by commit 87d354e1a0).
2013-04-22 09:24:48 +02:00
Michal Vyskocil
7f2031558c python3 compatibility: print function
The most visible change in python3 - removal of print statement and all
the crufty
   print >> sys.stderr, foo,

The from __future__ import print_function makes it available in python
2.6
2013-04-16 10:51:41 +02:00
Michal Vyskocil
87d354e1a0 python3 compatibility: import proper modules
Some modules (httplib, StringIO, ...) were renamed in python3. This
patch try to import the proper symbols from python3 and then fallback to
python2 in a case ImportError will appear.

There is one exception, python 2.7 got the io module with StringIO, but
it allow unicode arguments only. Therefor the old module is poked before
new one.
2013-04-16 10:51:18 +02:00
Michal Vyskocil
c612e8d47e python3 compatibility: use relative imports
Use relative imports when using module's own modules - this makes a
clear distinction between already developed copy and installed package.
2013-04-16 10:51:18 +02:00
Michal Vyskocil
3a93ac6d10 python3 compatibility: except
changes 'except FooError, fe' to 'except FooError as fe'

available in python 2.6
2013-04-16 10:51:17 +02:00