Skip to content

Waydroid creates untracked pyc files when run

Description:

Waydroid creates untracked pyc files in system folders because it runs python with root permissions.

Additional info:

  • package version(s): extra/waydroid 1.5.4-2
  • config and/or log files: N/A
  • link to upstream bug report, if any: N/A

Steps to reproduce:

This was previously discovered and confirmed with multiple versions of aur/waydroid. I am not retesting with the extra package because I don't see anything in the PKGBUILD that mitigates the problem.

  1. Install waydroid
  2. Set up and run it
  3. find /usr/lib/waydroid -name '*.pyc'

Fix

This is a solution I've applied to some AUR packages with similar problem. Add following (or similar) to the package function, after files have been installed.

  python -m compileall -f -p / -s "$pkgdir" "$pkgdir/"
  python -O -m compileall -f -p / -s "$pkgdir" "$pkgdir/"
  python -OO -m compileall -f -p / -s "$pkgdir" "$pkgdir/"

The python version also needs to be limited to prevent creation of untracked pyc files after new python minor releases. Add to the package function:

  local _pyver_major _pyver_minor
  _pyver_major=$(python -c 'import sys; print(sys.version_info.major)')
  _pyver_minor=$(python -c 'import sys; print(sys.version_info.minor)')

  eval "depends+=(
    'python>=${_pyver_major}.${_pyver_minor}'
    'python<${_pyver_major}.$((_pyver_minor + 1))'
  )"

Note: eval "depends+=(...)" instead of depends+=() is to prevent makepkg -printsrcinfo from generating nonsense:

  depends = python>=.
  depends = python<.1

With above solution, package will need to be rebuilt after new python minor releases (major.minor.patch).

Edited by xiota
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information