1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 17:26:15 +02:00
Commit Graph

3129 Commits

Author SHA1 Message Date
Marcus Huewe
276d6e2439 Do not use the chardet module in util.helper.decode_it
In general, decode_it is used to get a str from an arbitrary bytes
instance. For this, decode_it used the chardet module (if present)
to detect the underlying encoding (if the bytes instance corresponds
to a "supported" encoding). The drawback of this detection is that
it can take quite some time in case of a large bytes instance, which
represents no "supported" encoding (see #669 and #746).
Instead of doing a potentially "time consuming" detection, either
assume an utf-8 encoding or a latin-1 encoding. Rationale: it is just
not worth the effort to detect a _potential_ encoding because we have
no clue what the _correct_ encoding is. For instance, consider the
following bytes instance:

b'This character group is not supported: [abc\xc3\xbf]'

It represents a valid utf-8 and latin-1 encoding. What is the "correct"
one? We don't know... Even if you interpret the bytes instance as a
human you cannot give a definite answer (implicit assumption: there is
no additional context available).
That is, if we cannot give a definite answer in case of two potential
encodings, there is no point in bringing even more potential encodings
into play. Hence, do not use the chardet module.

Note: the rationale for trying utf-8 first is that utf-8 is pretty
much in vogue these days and, hence, the chances are "high" that we
guess the "correct" encoding.

Fixes: #669 ("check in huge shell archives is insanely slow")
Fixes: #746 ("Very slow local buildlog parsing")
2020-06-04 13:12:22 +02:00
Adam Williamson
13a13a87c4 Fix ElementTree imports for Python 3.9
Importing `cElementTree` has been deprecated since Python 3.3 -
importing `ElementTree` automatically uses the fastest
implementation available - and is finally removed in Python 3.9.
Importing cElementTree directly (not as part of xml) is an even
older relic, it's for Ye Time Before ElementTree Was Added To
Python and it was instead an external module...which was before
Python 2.5.

We still need to work with Python 2.7 for now, so we use a try/
except to handle both 2.7 and 3.9 cases. Also, let's not repeat
this import 12 times in one file for some reason.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2020-06-02 15:13:10 -07:00
lethliel
e99b2942ef increase version number in core.py 2020-05-29 20:35:00 +02:00
lethliel
0e70579113 release 0.169.1 2020-05-29 20:28:42 +02:00
Marcus Huewe
1d26cb3079 Merge branch 'ccache' of https://github.com/sjamgade/osc
Add "--ccache" option to "osc getbinaries".
2020-05-27 16:09:06 +02:00
lethliel
22ac336f8b open 0.170.0 development 2020-05-27 14:50:37 +02:00
lethliel
42b4992ecb release 0.169.0 2020-05-27 14:49:10 +02:00
lethliel
a79c54418b fix security issue (bsc#1122675) no / in filename
This checks if the filename of a downloaded file has
been modified (for example by a MITM attack) to contain
slashes. This could mean that the file is compromised
and that the attacker tries to overwrite system files.
2020-05-27 11:17:40 +02:00
Sumit Jamgade
5557a06e5b add and implement ccache option for getbinaries
If this option is used, the api is asked to list ccache archive if
present, osc will then download the archive.
2020-05-25 09:03:33 +02:00
Marco Strigl
3967133022
Merge pull request #793 from sjamgade/ccache_path
add option pkg-ccache to be passed to build-cmd
2020-05-22 15:55:48 +02:00
Fabian Vogt
f3d07eab3f Fix kiwi build with --prefer-pkgs
The buildinfo contains packages from the local dir, so it needs the list of
local packages to work correctly.
2020-05-20 11:34:27 +02:00
Sumit Jamgade
5dd853e302 add option pkg-ccache to be passed to build-cmd
this option is a /path/to/_ccache.tar. The patch just forwards that
option to the build script.
2020-05-19 16:15:49 +02:00
Marcus Huewe
6b5b0fd55d Merge branch 'fix_help_depends_on' of https://github.com/lethliel/osc
Split dependson and whatdependson into two commands. This way, both
commands are part of "osc --help".
2020-05-19 12:56:55 +02:00
lethliel
798e3e4f63 split dependson/whatdependon in two commands
split the code of do_dependson into two separate commands (just for
the osc help overview)

They are doing the opposite of each other.

Duplicate code was moved to _dependson()

do_whatdependson and do_dependson just call _dependson with an option
reverse set to None or 1.
2020-05-19 12:50:15 +02:00
Marcus Huewe
9b2cbfead0 Merge branch 'fix_osc_api_without_arguments' of https://github.com/lethliel/osc
Fix handling of incorrect CLI arguments (python3).
2020-05-18 20:05:25 +02:00
lethliel
69b1233316 add regex for python3 missing arguments err
add new regex and check for missing arguments.
The error message in python3 differs from the one in python2.

python3:
do_api() missing 1 required positional argument: 'url'

python2:
do_api() takes exactly 4 arguments (3 given)

To be compatible with python2 two checks are needed.
2020-05-18 19:46:22 +02:00
12e0b67117 complete --shell-cmd support parts to get it working 2020-05-12 13:16:29 +02:00
5d6351b1bd Support git@ (private github) or git:// URLs correctly 2020-05-05 10:54:43 +02:00
lethliel
9a3fda8471 quote prj, repository, arch and package
quote the arguments before creating the apiurl.
This prevents weird behaviour when any has an '#'
at the end.
2020-04-28 14:47:40 +02:00
William Brown
bdb0c8033c Add ccache argument for oscrc 2020-04-14 14:50:24 +10:00
lethliel
81acc39c9f e.reason is a string not a integer decimal 2020-04-01 12:48:12 +02:00
Marcus Huewe
894f1c281a Merge branch 'packagequery_bytes_fixes' of https://github.com/marcus-h/osc
bytes fixes/cleanups in the packagequery and repodata modules.
2020-03-25 19:39:11 +01:00
lethliel
b99c4486e8 update news and open new development milestone 2020-03-23 13:50:01 +01:00
Marcus Huewe
55aef1a014 Convert repodata.RepoDataQueryResult to a bytes API
The repodata.RepoDataQueryResult is supposed to be a bytes API and
that's what our users (see build module) expect.
Note that the repodata.RepoDataQueryResult.path method still returns
a str. That's what the rpmquery.RpmQuery, debquery.DebQuery, and
archquery.ArchQuery classes also do (if the "path" was initially
passed as a str).

Fixes: #760 ("osc build fails when called with --prefer-pkgs where the
       passed directory is a repodata repository or a subdirectory of one")
2020-03-15 18:30:28 +01:00
Marcus Huewe
cd51f47a77 Return bytes in packagequery.PackageQueryResult.evr() instead of a str
The packagequery.PackageQueryResult class is supposed to provide a
bytes API. Hence, packagequery.PackageQueryResult.evr() should return
bytes instead of a str. Also, adjust the single caller in the build
module.
2020-03-15 18:30:00 +01:00
lethliel
3914b8c5e8 release 0.168.2 2020-03-13 07:44:34 +01:00
Marcus Huewe
33bbc57b5f Fix the previously introduced escaping via the html module
This is a follow-up commit for commit
6dbf103e10 ("Use html.escape instead
removed cgi.escape"), which breaks the python2 backward compatibility
(since the "html" module is not available by default) and also breaks
the code in general (due to missing html imports).

The fix is based on the proposed fix in [1].

Fixes: boo#1166537 ("osc rq accept - forwarding request causes backtrace")

[1] https://github.com/openSUSE/osc/pull/764
2020-03-12 23:00:47 +01:00
6dbf103e10
Use html.escape instead removed cgi.escape
Fixes:

`Traceback (most recent call last):
  File "/usr/bin/osc", line 41, in <module>
    r = babysitter.run(osccli)
  File "/usr/lib/python3.8/site-packages/osc/babysitter.py", line 64, in run
    return prg.main(argv)
  File "/usr/lib/python3.8/site-packages/osc/cmdln.py", line 344, in main
    return self.cmd(args)
  File "/usr/lib/python3.8/site-packages/osc/cmdln.py", line 367, in cmd
    retval = self.onecmd(argv)
  File "/usr/lib/python3.8/site-packages/osc/cmdln.py", line 501, in onecmd
    return self._dispatch_cmd(handler, argv)
  File "/usr/lib/python3.8/site-packages/osc/cmdln.py", line 1232, in _dispatch_cmd
    return handler(argv[0], opts, *args)
  File "/usr/lib/python3.8/site-packages/osc/commandline.py", line 1458, in do_submitrequest
    result = create_submit_request(apiurl,
  File "/usr/lib/python3.8/site-packages/osc/core.py", line 4244, in create_submit_request
    cgi.escape(message))
AttributeError: module 'cgi' has no attribute 'escape'
`
`cgi.escape` was deprecated in python 3.2
2020-03-11 16:58:04 +01:00
lethliel
a8641a47c8 release 0.168.0 2020-03-04 10:21:17 +01:00
Jan Chren
fa205be798
Suggest correct python-keyring package version
On Tumbleweed, `zypper in python-keyring` installs python2 version, while `osc` runs on python3.
After this change, user will be pointed to the correct version.
2020-02-29 00:28:20 +00:00
Marcus Huewe
c3e7428631 Merge branch 'master' of https://github.com/matthewdva/osc
Fix "osc importsrcpkg --name <name>". Do not try to decode a str.
2020-02-26 21:46:42 +01:00
Marcus Huewe
4e8e0492e8 Fix arch zst magic in util.packagequery
The correct zst magic is b'(\xb5/\xfd' (4 bytes) (that's what obs-build
is also using).

Kudos to Tobias Ellinghaus for spotting this.

Fixes: #756 ("zst detection fails")
2020-02-26 20:04:26 +01:00
Matthew D
9ba0d8adcd Fix -n / --name flag on importsrcpkg command.
osc importsrcpkg -n <pacname> does not work.  If the option is supplied, osc
mistakenly trys to "decode" the pac object.  This patch limit the decode
call when pac is not a string.

Refactored fix based on suggestions from marcus-h
2020-02-24 00:23:14 -05:00
175bcb4613
Remove compat code for Python < 2.6 2020-02-21 15:09:58 +01:00
Marcus Huewe
20f2f40614 Merge branch 'fix_748' of https://github.com/lethliel/osc
Add missing oscerr import in util.helper. Oops.
2020-02-20 09:10:57 +01:00
lethliel
95c68dc3f0 import oscerr in helper.py 2020-02-20 08:45:02 +01:00
Nicholas Brown
75ba922eb2 custom exception if importing m2crypto fails
fixes #743
2020-02-18 17:35:29 +00:00
Marcus Huewe
5185026084 Merge branch 'fix_name_display' of https://github.com/lethliel/osc
Old keyring versions of the KeyringBackend class have no name method (the
name method was added in 2016). In this case, the class name is used as the
backend name.
2020-02-14 09:52:20 +01:00
lethliel
6a20fd8bf5 fix list of backends for old python-keyring
old python-keyring classes have no name method.
This is used instead:

return self._keyring_backend.__class__.__name__
2020-02-14 09:35:07 +01:00
Marcus Huewe
9b0dcf3535 Merge branch 'master' of https://github.com/sbahling/osc
Use configparser.ConfigParser instead of configparser.SafeConfigParser,
since the latter will be removed in future python versions. No functional
changes because SafeConfigParser is a ConfigParser except that its __init__
prints a DeprecationWarning.
2020-02-09 15:57:49 +01:00
Scott Bahling
b9adde96b6 Rename SafeConfigParser to ConfigParser
configparser.SafeConfigParser has been changed to configparser.ConfigParser
upstream in Python 3.2. Warnings are saying that the alias will be
removed in future versions.

Signed-off-by: Scott Bahling <sbahling@suse.com>
2020-02-07 12:04:49 +01:00
Marcus Huewe
32859d6803 Merge branch 'handle-string-conversion' of https://github.com/krig/osc
Add core.parse_meta_to_string helper to work around the insane
implementation of core.meta_exists. Since core.meta_exists may return
a list of bytes, a str, a list of str etc., we ultimately convert the
data to str before passing it ET.fromstring(...).

In case of bytes, the explicit decoding is OK because it is assumed to
be a valid utf-8 encoding (the data represents an xml).

Note: at the moment core.parse_meta_to_string is also called even if it
is not necessary (it is only necessary if the "create" parameter of a
corresponding core.meta_exists call is True).

Note 2: this is just a temporary workaround and, eventually, we will make
the implementation of core.meta_exists more reasonable. When doing so,
we will also remove "public" function core.parse_meta_to_string again.
(Yes, this breaks API but the core.meta_exists change will also break the
API in some sense - so that's OK.)
2020-02-07 10:27:10 +01:00
Marcus Huewe
fb9e64c2f1 Merge branch 'handle_empty_releas_in_rpmquery' of https://github.com/lethliel/osc
Do not pass None as a release to RpmQuery.filename. The release might
be None in case of a kiwi build (the returned canonname is not used in
case of kiwi build).
2020-02-07 10:23:35 +01:00
Kristoffer Grönlund
16a3fcfabf Handle bytes vs. str error when parsing meta (#683)
In all the cases where meta_exists returns either
string data, bytes data or a list, the output needs
to be parsed correctly.

Signed-off-by: Kristoffer Grönlund <kgronlund@suse.com>
2020-02-07 10:02:27 +01:00
lethliel
f5aa389e38 handle empty release in build.py
This is very unlikely but in very rare cases this
can happen.

Builing kiwi images containing debian is one case.
In this case we do not know what is inside the kiwi
file and osc build assumes buildtype 'rpm' to generate
a package list which get's thrown away anyway.

Now we just check for release
2020-02-07 09:41:23 +01:00
Marco Strigl
9449745b5e
Merge pull request #673 from lethliel/fix_non_colon_checkout_on_prj_level
fix checkout_no_colon on project level
2020-02-07 09:27:00 +01:00
lethliel
cf6939e68a fix checkout_no_colon on project level
prj_dir was not altered when issuing osc co on
project level.

Solution: Replace ":" with "/" on project level when
no output_dir is given
2020-02-07 09:21:36 +01:00
Marcus Huewe
4d0c9f2dc6 Merge branch 'print_additional_APIURL_links' of https://github.com/lethliel/osc
Add a "print_web_links" option. If enabled, a webui url is printed after
certain operations. For now, it is only used in "do_submitrequest" in order
to print the webui url that can be used to view the newly created request
(note: the print_web_links option is not considered in the "cd prj; osc sr"
case).
2020-02-06 21:26:20 +01:00
lethliel
f079be17c2 print web url links for creating requests
This will print the direct url to show the created request.
New general bool option 'print_web_links' must be set to enable
this.

Right now this is only for creating requests. More to follow.
2020-02-06 13:57:38 +01:00
Marco Strigl
d279dfbedb
Merge pull request #723 from lethliel/improve_error_message_on_ssl_version_mismatch
improve SSLError message
2020-02-06 13:31:54 +01:00