11602 Commits

Author SHA1 Message Date
Mario Fetka 77cb4a0df5 tools: add LOONGARCH and other modern archs to elf_class_strtoint
Go and other cross-compilation toolchains ship binaries for architectures
not previously listed (LOONGARCH, S390, ALPHA, SH64, SH). scanelf reports
these verbatim; add them so metadata extraction does not fail on packages
like dev-lang/go that include cross-arch ELF files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
326
2026-07-02 00:15:15 +02:00
Mario Fetka 45f999a8ad portage_plugin: skip UNKNOWN_TYPE entries in NEEDED.ELF.2 parsing
scanelf reports UNKNOWN_TYPE for non-standard or non-ELF binaries (e.g.
proprietary Teensy tools in arduino-bin). elf_class_strtoint() raised
ValueError which aborted metadata extraction for the whole package.
Skip unrecognised ELF class entries instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 00:13:04 +02:00
Mario Fetka b5c94a24ef portage_plugin: skip get_binpkg_format() on empty temp file
When rescue spmsync truncates the temp file to zero bytes before writing
XPAK metadata, calling get_binpkg_format() triggers seek(-16, 2) on an
empty file which prints an [Errno 22] stderr warning for every package.
Skip the format detection when the file is empty — it can only be xpak.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 00:07:57 +02:00
Mario Fetka d7ddf15fac rescue spmsync: fix handlePackage failure when installed DB is missing
Two fixes for `equo rescue spmsync` on a system without an existing
installed packages DB:

1. client/interfaces/methods.py: Stop falling back to a GenericRepository
   (in-memory, read-only for handlePackage) when the DB file is absent.
   Instead let SQLite create the file; call initializeRepository() on a
   freshly created DB so validate() succeeds.  Corrupted DBs still fall
   back to RAM via the existing DatabaseError/SystemDatabaseError path.

2. spm/portage_plugin: Also catch OSError (not just tarfile.ReadError)
   when uncompress_tarball fails on a pure-XPAK temp file; Python 3.14
   raises OSError in this case rather than tarfile.ReadError.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 00:04:31 +02:00
Mario Fetka 655f2f26d2 solo/help: fix Python 3.14 argparse positional argument crash
Python 3.14 rejects action='store_true' on positional arguments.
The add_argument calls in _show_help() are display-only (never parsed),
so the action kwarg was unnecessary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 23:31:46 +02:00
Mario Fetka 07afb5d722 db/sql.py, spm/skel.py: executemany + type hints
- sql.py: convert setCategoryDescription() INSERT loop to executemany()
  (only remaining INSERT-in-loop; rest of sql.py already used executemany)
- spm/plugins/skel.py: add from __future__ import annotations and type
  annotations to all 25 abstract interface methods (return types, param types)
  using Python 3.10+ union syntax (X | None instead of Optional[X])

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 12:09:19 +02:00
Mario Fetka 8719186730 modernization: SQLite WAL, subprocess.run, TODO.md
- db/sqlite.py: enable WAL journal mode per connection — concurrent
  readers no longer block writers
- Replace subprocess.call() with subprocess.run() in 8 files
  (output.py, qa.py, tools.py, client/misc.py, client/interfaces/db.py,
  portage_plugin, solo/conf.py)
- Replace os.popen() with subprocess.run() in tools.py and
  core/settings/base.py
- Add TODO.md documenting deferred logging module integration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 12:02:23 +02:00
Mario Fetka fc1d71db8e const.py, rigo: remove remaining Python 2 dead code
Simplify const_isfileobj(), const_isnumber(), const_debug_write()
and remove unreachable code in rigo/rigo/utils.py::prepare_markup().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 11:52:21 +02:00
Mario Fetka 7072c00a77 Python 3 modernization: low-hanging fruit cleanup
- hashlib: add usedforsecurity=False to all md5/sha1/sha256/sha512 calls
  (FIPS-mode compatibility, ~34 call sites across 13 files)
- join([listcomp]): convert to generator expressions (~15 sites)
- class Foo(object): -> class Foo: across all files (Python 3 style)
- collections.OrderedDict() -> {} in db/skel.py (Python 3.7+ dicts ordered)
- open() without context manager: fix 3 bare open/close in misc.py
- Exception chaining: add 'from err' to raise statements in portage_plugin
- const_is_python3() dead code removal:
  * Simplify 7 compat functions in const.py (const_is_python3,
    const_get_stringtype, const_isunicode, const_israwstring,
    const_get_buffer, const_convert_to_unicode, const_convert_to_rawstring,
    const_isstring, const_get_int) — remove Python 2 branches
  * Remove 100+ const_is_python3() if/else branches across 27 files,
    keeping only the Python 3 path
  * Remove cPickle import in dump.py, use plain pickle with fix_imports=True
  * Remove urllib2 dead imports in misc.py, fetchers.py
  * Clean up const_is_python3 from all import lines

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 11:51:29 +02:00
Mario Fetka 8c7ccdb0ee portage_plugin: EAPI 8/GPKG support and counter_tick() fix
- Fix counter_tick(): portage 3.x removed the root/mycpv arguments,
  now a zero-argument call returning the new counter value directly
- Add IDEPEND (EAPI 8 install-time deps) to xpak_entries, extraction
  dict, _calculate_dependencies and dep_keys (mapped to bdepend_id)
- Add GPKG binary package format support (.gpkg.tar) alongside xpak:
  extract_package_metadata() detects format via get_binpkg_format() and
  uses PortageGPKG.unpack_metadata()/decompress() for gpkg packages;
  append_metadata_to_package() uses PortageGPKG.update_metadata() for gpkg
- Add "gpkg.tar" to binary_packages_extensions()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 11:28:02 +02:00
Mario Fetka 22faa269e4 portage_plugin: use public portage 3.0.77 APIs
- Remove portage.const._ENABLE_SET_CONFIG = True (default True since portage 2.2+)
- Replace portdbapi._aux_cache.clear() with flush_cache() only (redundant clear
  before new instance creation)
- Replace vardbapi._clear_cache() with vardbapi.flush_cache() (public API)
- Replace portdbapi._aux_cache_keys with portage.auxdbkeys (public module-level tuple)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 11:10:13 +02:00
Mario Fetka 4e0d448aef Python 3.12+/3.13 and portage 3.0.77 compatibility fixes
- Replace deprecated Thread.isAlive() with is_alive() (Python 3.12)
- Fix invalid escape sequences in regex strings (SyntaxWarning → SyntaxError)
- Replace removed unittest aliases: assertEquals→assertEqual,
  assertNotEquals→assertNotEqual, assert_→assertTrue,
  assertRaisesRegexp→assertRaisesRegex (Python 3.12)
- Replace portage's removed clear_caches() with flush_cache()
- Fix locks.py: reset TLS state on exception in _file_lock_create
  to prevent stale shared-lock state poisoning subsequent acquisitions
- Skip os.chown() when gid is None or caller lacks permission
- Fix FastRSS attribute ordering for consistent minidom re-parse behavior
- Update test expected XML to match Python 3.8+ minidom attribute order

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 10:53:13 +02:00
Daniele Rondina aeff7dd466 .ci: Fix init of profiles 2020-09-07 23:16:15 +02:00
Joost Ruis a439266377 Update .ci 325 2020-08-29 15:50:22 +02:00
Joost Ruis d8a17877bc Update .ci
Drop pyhton2 from tests
2020-08-29 15:00:55 +02:00
Joost Ruis d4a4d55ccf async became a keyword in python 3.7
Thus we renamed it to async_mode. Please see https://docs.python.org/3/whatsnew/3.7.html
2020-08-29 14:28:04 +02:00
Gokturk Yuksek 6f5502fd51 lib/entropy/tools.py: add support for RISCV ELF class (#89)
Signed-off-by: Göktürk Yüksek <gokturk@gentoo.org>
2020-04-08 21:51:02 +02:00
Gokturk Yuksek 10bf6c8cd0 conf/client.conf: s/treaten/treated/ (#88)
Signed-off-by: Göktürk Yüksek <gokturk@gentoo.org>
2020-04-07 22:11:24 +02:00
Sławomir Nizio 0019b6e68a [entropy.misc, rigo] fix file-like objects with Python 3
FakeOutFile and LogFile need .buffer like Python 3 "text" file objects
which is needed when in rigo standard output/error is replaced, and then
it reaches Portage which does this:

	    if sys.hexversion >= 0x3000000 and fd in (sys.stdout, sys.stderr):
		    fd = fd.buffer
    fd.write(mystr)

(/usr/lib64/python3.6/site-packages/portage/util/__init__.py).

Entropy internal code did not need this.

Note, after this commit, changes done previously:
    1)
    commit 0869912ec4

	[entropy.spm] Rigo related Python 3 fix

	  File "/usr/lib64/python3.6/site-packages/entropy/spm/plugins/interfaces/portage_plugin/__init__.py", line 101, in _pusher
	    self._std.buffer.write(chunk)
	AttributeError: 'FakeOutFile' object has no attribute 'buffer'

    2)
    commit 8700aade27

	[entropy.spm, rigo] Rigo related Python 3 fixes

	1)
	  File "/usr/lib/python-exec/python3.6/RigoDaemon_app.py", line 362, in _pusher
	    fobj.write(chunk)
	TypeError: write() argument must be str, not bytes

	2)
	  File "/usr/lib64/python3.6/site-packages/entropy/spm/plugins/interfaces/portage_plugin/__init__.py", line 77, in __init__
	    self.buffer = Writer(self, self._std.buffer)
	AttributeError: 'FakeOutFile' object has no attribute 'buffer'

    (...)

could be likely reverted; not tested, it could be better to have them anyway to
avoid futher re/encoding/checks if conversions are needed (subjective).

Fixes bug 5899.
2020-03-21 22:20:27 +01:00
Sławomir Nizio b9e17e16cd [entropy.client] fix equo pkg quickpkg
- Python 3 fix
- re-encoding the path actually made it skip files with funny names
2020-03-17 19:45:26 +01:00
Sławomir Nizio e01746bc38 [rigo] Python 3 fix in config files viewer / editor 2020-03-13 21:48:16 +01:00
Sławomir Nizio 09cb7b3496 [solo.commands.query] fix "equo query orphans" with Python 3 2020-03-13 20:18:04 +01:00
Sławomir Nizio 0869912ec4 [entropy.spm] Rigo related Python 3 fix
File "/usr/lib64/python3.6/site-packages/entropy/spm/plugins/interfaces/portage_plugin/__init__.py", line 101, in _pusher
    self._std.buffer.write(chunk)
AttributeError: 'FakeOutFile' object has no attribute 'buffer'
2020-02-12 21:46:19 +01:00
Sławomir Nizio 8700aade27 [entropy.spm, rigo] Rigo related Python 3 fixes
1)
  File "/usr/lib/python-exec/python3.6/RigoDaemon_app.py", line 362, in _pusher
    fobj.write(chunk)
TypeError: write() argument must be str, not bytes

2)
  File "/usr/lib64/python3.6/site-packages/entropy/spm/plugins/interfaces/portage_plugin/__init__.py", line 77, in __init__
    self.buffer = Writer(self, self._std.buffer)
AttributeError: 'FakeOutFile' object has no attribute 'buffer'
2020-02-11 22:26:20 +01:00
Sławomir Nizio c06eb76644 [entropy.server] gpg related fix for Python 3
With Python 3, data in sqlite from packagesignatures.gpg column was binary on
read (because it was binary on write) but a string was actually required.

The problem was visible with GPG signed packages: when injected into database
using eit with Python 3, it would then explode during equo update/install on
client side.

error from Python 2:

      File "/usr/lib64/python2.7/site-packages/entropy/client/interfaces/package/actions/fetch.py", line 1063, in do_signatures_validation
	if hash_val in signatures:
    TypeError: writable buffers are not hashable

error from Python 3:

      File "/usr/lib64/python3.6/site-packages/entropy/client/interfaces/package/actions/fetch.py", line 1023, in do_compare_gpg
	tmp_f.write(hash_val)
    TypeError: write() argument must be str, not bytes
2020-02-09 22:18:26 +01:00
Ettore Di Giacinto c56c1eb446 Tagging Entropy version 324 324 2020-02-07 16:25:44 +01:00
Ettore Di Giacinto 23f2e55879 Release Entropy 324 2020-02-07 16:25:39 +01:00
geaaru 5d58a8c501 Merge pull request #87 from geaaru/master
Fix retrieve of kernel list when virtual/linux-binary contains RDEPEND with OR
2020-02-04 13:53:14 +01:00
Daniele Rondina 4649660050 kswitch: Added a new way to retrieve list of kernels
Added a new way to retrieve list of kernel available
that uses directory /etc/kernels/availables/{sabayon,sabayon-lts}.
If this directory is present is not used current logic for
retrieve the list of kernel.

Under /etc/kernels/avaiables/ directory files with 'lts' extension
are used for retrieve list of LTS kernels.

An user could return his kernel list just if he creates and
maintains his file in a similar format:

$# cat /etc/kernel/availables/mykernel
sys-kernel/linux-sabayon:4.9
sys-kernel/linux-mykernel:4.4

This logic now is used as an additional feature after retrieve
the existing kernels based on virtual/linux-binary or
virtual/linux-binary-lts.
2020-02-04 13:40:03 +01:00
Daniele Rondina c9b1daece1 kswitch: Fix parsing of kernel list
Now virtual/linux-binary and virtual/linux-binary-lts have
kernel list in OR. So we need retrieve the list and split
result string by ';'.
2020-02-04 13:38:23 +01:00
Geaaru 5aec1b48e5 [kernel-switcher] Refactor 2020-01-24 23:23:07 +01:00
Sławomir Nizio 08da648a20 [entropy.client] fixes for "dictionary changed size during iteration" 2019-12-18 22:20:29 +01:00
Ettore Di Giacinto 47fc1e9f9a Tagging Entropy version 323 323 2019-12-16 23:38:50 +01:00
Ettore Di Giacinto 285876cc86 Release Entropy 323 2019-12-16 23:38:39 +01:00
Enlik 31c8df4017 Merge pull request #86 from Enlik/moar-py3
More Python 3 fixes
2019-12-14 00:07:53 +01:00
Sławomir Nizio bad4b21f1a [entropy.client.misc, entropy.output] fixes for Python 3
ConfigurationFiles._load_maybe_add (equo.client.misc): path is in bytes here

_std_write (entropy.output): fixes crash in equo conf update with "Replace
original with update" when there is an error in which case msg can be bytes:

  File ".../entropy/lib/entropy/tools.py", line 687, in movefile
    print_generic("!!! Failed to move", src, "to", dest)
  File ".../entropy/lib/entropy/output.py", line 596, in print_generic
    _std_write(msg, stderr = stderr)
  File ".../entropy/lib/entropy/output.py", line 493, in _std_write
    obj.write(msg)
2019-12-13 21:06:23 +01:00
Sławomir Nizio 2aa2c69e2b correct exception handling / error reporting with Python 3 2019-12-13 01:32:09 +01:00
Sławomir Nizio 4ab520925a [entropy.output] fix for Python 3 in input_box()
myresult = readtext(input_text+": ", password = password).decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'
2019-12-11 22:54:00 +01:00
Sławomir Nizio 7abd4dad80 [entropy.qa] fix test_shared_objects() with Python 3
Other parts of this function and called ones work or can work with
strings.
2019-12-06 01:04:04 +01:00
Sławomir Nizio d65f09fcf8 [rigo] correct Vte.Terminal.feed with Python 3
With Python 3, prepare_markup() doesn't now convert string to bytes.
2019-12-05 23:28:27 +01:00
Sławomir Nizio 842979cbba [magneto, rigo] Python 3 fixes in _dbus_to_string 2019-12-05 22:41:53 +01:00
Sławomir Nizio e2de60dbc3 [entropy.client.services] Python 3 fix 2019-12-05 22:36:09 +01:00
Sławomir Nizio 97409d12d5 [rigo] Python 3 fixes 2019-12-05 22:34:42 +01:00
Sławomir Nizio e26d11b5f6 Python 3 fixes: open() and so, not file() 2019-12-04 22:01:22 +01:00
Enlik 952eefa4c6 Merge pull request #85 from Enlik/dirchiter
[entropy.server] correct close_repositories() with Python 3
2019-11-29 00:46:04 +01:00
Sławomir Nizio fc13fa3727 [entropy.server] correct close_repositories() with Python 3
Function callers, in order (during eit commit):

1. filename='lib/entropy/server/interfaces/main.py', function='switch_default_repository', code_context=[' self.close_repositories()\n'], index=0)
2. filename='server/eit/commands/command.py', function='_call_exclusive', code_context=[' server.close_repositories()\n'], index=0)
3. filename='lib/entropy/client/interfaces/client.py', function='destroy', code_context=[' self.close_repositories(mask_clear = False)\n'], index=0)
4. filename='lib/entropy/server/interfaces/main.py', function='destroy', code_context=[' self.close_repositories()\n'], index=0)

Third one triggers packages set synchronization (which would cause "dictionary
changed size during iteration"), and marks sets as being synchronized.

Fourth does not trigger sets synchronization, so closes all repositories
without new ones being opened in the meantime.

Side note:
It's similar to this in "client," lib/entropy/client/interfaces/methods.py:

    def close_repositories(self, mask_clear = True):
	...
            # list() -> python3 support
            for item, val in list(repo_cache.items()):
		...
		repo_cache.pop(item).close(_token = repository_id)
		...

but (based on shallow look), it doesn't do as much magic; just calls .pop()
(not sure if there are similar side effects in close() there, though), so the
explanation may possibly apply to the lib/entropy/server function only.
2019-11-14 01:16:17 +01:00
Ettore Di Giacinto 1fa4045ced Tagging Entropy version 322 322 2019-11-10 15:53:56 +01:00
Ettore Di Giacinto d2328561d9 Release Entropy 322 2019-11-10 15:53:52 +01:00
Ettore Di Giacinto 1d32745082 Merge pull request #83 from Enlik/py3-fixes
[entropy.client.misc] correct ConfigurationFiles with Python 3
2019-11-10 15:53:05 +01:00
Ettore Di Giacinto cf50abb578 Merge pull request #82 from Enlik/qfile-no-plib
[entropy.spm] search_path_owners (qfile) fixes
2019-11-10 15:48:32 +01:00