poky: subtree update:2dcd1f2a21..9d1b332292

Alejandro Hernandez Samaniego (2):
      baremetal-helloworld: Enable RISC-V 64 port
      baremetal-image: Fix post process command rootfs_update_timestamp

Alexander Kanavin (94):
      python3: add markdown/smartypants/typogrify modules
      gi-docgen: add a recipe and class
      gdk-pixbuf/pango: replace gtk-doc with gi-docgen
      vala: upgrade 0.50.4 -> 0.52.2
      xkbcomp: upgrade 1.4.4 -> 1.4.5
      stress-ng: upgrade 0.12.05 -> 0.12.06
      xserver-xorg: upgrade 1.20.10 -> 1.20.11
      xorgproto: upgrade 2020.1 -> 2021.3
      dpkg: update 1.20.7.1 -> 1.20.9
      puzzles: update to latest revision
      cmake: update 3.19.5 -> 3.20.1
      meson: update 0.57.1 -> 0.57.2
      systemd: backport a patch to avoid unnecessary rsync dependency with latest meson
      pulseaudio: unbreak build with latest meson
      libdnf: upgrade 0.58.0 -> 0.62.0
      bluez5: upgrade 5.56 -> 5.58
      libxkbcommon: update 1.0.3 -> 1.2.1
      libgudev: update 234 -> 236
      vulkan-samples: update to latest revision
      gnupg: upgrade 2.2.27 -> 2.3.1
      virglrenderer: update 0.8.2 -> 0.9.1
      webkitgtk: update 2.30.6 -> 2.32.0
      acl: upgrade 2.2.53 -> 2.3.1
      bind: upgrade 9.16.12 -> 9.16.13
      bison: upgrade 3.7.5 -> 3.7.6
      createrepo-c: upgrade 0.17.0 -> 0.17.2
      cronie: upgrade 1.5.5 -> 1.5.7
      dnf: upgrade 4.6.0 -> 4.7.0
      e2fsprogs: upgrade 1.46.1 -> 1.46.2
      gnu-efi: upgrade 3.0.12 -> 3.0.13
      systemd-boot: backport a fix to address failures with new gnu-efi
      gobject-introspection: upgrade 1.66.1 -> 1.68.0
      gtk+3: upgrade 3.24.25 -> 3.24.28
      harfbuzz: upgrade 2.7.4 -> 2.8.0
      less: upgrade 563 -> 581
      libfm: upgrade 1.3.1 -> 1.3.2
      libinput: upgrade 1.16.4 -> 1.17.1
      libwpe: upgrade 1.8.0 -> 1.10.0
      libxres: upgrade 1.2.0 -> 1.2.1
      linux-firmware: upgrade 20210208 -> 20210315
      pango: upgrade 1.48.2 -> 1.48.4
      piglit: upgrade to latest revision
      pkgconf: upgrade 1.7.3 -> 1.7.4
      python3-hypothesis: upgrade 6.2.0 -> 6.9.1
      python3-importlib-metadata: upgrade 3.4.0 -> 3.10.1
      python3-pytest: upgrade 6.2.2 -> 6.2.3
      python3-setuptools-scm: upgrade 5.0.1 -> 6.0.1
      x264: upgrade to latest revision
      ptest: add a test for orphaned ptests, and restore ones found by it
      swig: fix upstream version check
      liberation-fonts: fix upstream version check
      Revert "go: Use dl.google.com for SRC_URI"
      powertop: update 2.13 -> 2.14
      mesa: add lmsensors PACKAGECONFIG
      ffmpeg: update 4.3.2 -> 4.4
      qemu: use 4 cores in qemu guests
      avahi: disable gtk bits
      gdk-pixbuf: rewrite the cross-build support for tests
      gnome: drop upstream even condition from a few recipes
      expat: upgrade 2.2.10 -> 2.3.0
      meson.bbclass: split python routines into a separate class
      gstreamer1.0-plugins-base: backport a patch to fix meson 0.58 builds
      meson: update 0.57.2 -> 0.58.0
      qemu: backport a patch to fix meson 0.58 builds
      nativesdk-meson: correctly set cpu_family
      bitbake: fetch2/wget: when checking latest versions, consider all numerical directories
      mklibs: remove recipes and class
      local.conf: Drop support for mklibs
      u-boot: upgrade 2021.01 -> 2021.04
      gdk-pixbuf: update a patch status
      systemd: update 247.6 -> 248.3
      systemd-conf: do not version in lockstep with systemd
      gnu-config: update to latest revision
      mmc-utils: update to latest revision
      python3-smartypants: fix upstream version check
      at: upgrade 3.2.1 -> 3.2.2
      gnomebase: trim the SRC_URI directory from the back
      gsettings-desktop-schemas: upgrade 3.38.0 -> 40.0
      igt-gpu-tools: upgrade 1.25 -> 1.26
      mesa: update 21.0.3 -> 21.1.1
      vulkan-samples: update to latest revision
      libgpg-error: update 1.41 -> 1.42
      webkitgtk: update 2.32.0 -> 2.32.1
      glib-2.0: update 2.68.1 -> 2.68.2
      apt: upgrade 2.2.2 -> 2.2.3
      cmake: update 3.20.1 -> 3.20.2
      libdnf: update 0.62.0 -> 0.63.0
      harfbuzz: update 2.8.0 -> 2.8.1
      curl: update 7.76.0 -> 7.76.1
      systemtap: update 4.4 -> 4.5
      wayland: package target binaries into -tools, not into -dev
      ptest: add newly discovered missing runtime dependencies across recipes
      images: remove sato/weston ptest images
      images: add ptest images based on core-image-minimal

Andreas Müller (1):
      gstreamer1.0-plugins-good: fix build with gcc11

Andrej Valek (1):
      expat: upgrade 2.3.0 -> 2.4.1

Anuj Mittal (1):
      lsb-release: fix reproducibility failure

Armin Kuster (5):
      bitbake: hashserv/server.py: drop unused imports
      bitbake: hashserver/client.py: drop unused imports
      poky.yaml: fedora33: add missing pkgs
      systemctl: Stop tracebacks use formated error messages
      package_manager/rpm: decode systemctl failures

Bastian Krause (1):
      ccache: version bump 4.2.1 -> 4.3

Bruce Ashfield (18):
      linux-yocto/5.4: qemuppc32: reduce serial shutdown issues
      kern-tools: Kconfiglib: add support for bare 'modules' keyword
      lttng-modules: update devupstream to v2.13-rc
      lttng-modules: update to v2.12.6
      kernel-yocto: provide debug / summary information for metadata
      linux-yocto/5.10: update to v5.10.35
      linux-yocto/5.4: update to v5.4.117
      linux-yocto/5.10: ktypes/standard: disable obsolete crypto options by default
      linux-yocto/5.10: update to v5.10.36
      linux-yocto/5.4: update to v5.4.118
      linux-yocto/5.10: update to v5.10.37
      linux-yocto/5.4: update to v5.4.119
      kernel-devsrc: adjust NM and OBJTOOL variables for target
      linux-yocto/5.10: update to v5.10.38
      linux-yocto-dev: bump to v5.13+
      linux-yocto/5.4: update to v5.4.120
      linux-yocto/5.10: update to v5.10.41
      linux-yocto/5.4: update to v5.4.123

Carlos Rafael Giani (1):
      ffmpeg: Add libopus packageconfig

Changqing Li (2):
      unfs3: correct configure option
      pkgconfig: update SRC_URI

Chen Qi (3):
      db: update CVE_PRODUCT
      rt-tests: update SRCREV
      xxhash: backport patch to fix special char problem

Daniel McGregor (3):
      lib/oe/gpg_sign.py: Fix gpg verification
      sstate: Ignore sstate signing key
      bison: Make libtextstyle and libreadline optional

Daniel Wagenknecht (1):
      kernel-dev: document KCONFIG_MODE

Douglas Royds (3):
      Revert "icecc: Don't use icecc when INHIBIT_DEFAULT_DEPS is set"
      icecc: Demote "could not get ICECC_CC" warning to note
      icecc-create-env: Silence warning: invalid ICECC_ENV_EXEC

Drew Moseley (1):
      manuals: fix a few incorrect option specifications.

Guillaume Champagne (1):
      image-live.bbclass: order do_bootimg after do_rootfs

Joshua Watt (1):
      zstd: Add patch to fix MinGW builds

Kai Kang (1):
      grub2.inc: remove '-O2' from CFLAGS

Khem Raj (17):
      swig: Upgrade to 4.0.2
      python3-markdown: Upgrade to 3.3.4
      ffmpeg: Fix build on mips
      npth: Check for pthread_create for including lpthread
      gcc: Add target gcc include search for musl config too
      gcc: Extend .gccrelocprefix section support to musl configs
      gcc: Refresh patch to fix patch fuzz
      musl: Fix __NR_fstatat syscall name for riscv
      libxfixes: Update to 6.0.0 release
      xorgproto: Upgrade to 2021.4 release
      glibc: Update to latest 2.33 branch
      systemd: Fix 248.3 on musl
      glibc: Enable memory tagging for aarch64
      gcc: Update to latest on release/gcc-11 branch
      apt: Add missing <array> header
      ovmf: Fix VLA warnings with GCC 11
      libucontext: Switch to meson build system

Martin Jansa (4):
      gcc-sanitizers: Package up static hwasan files as well
      webkitgtk: fix build without opengl in DISTRO_FEATURES
      binutils: backport DWARF-5 support for gold
      sstatesig.py: make it fatal error when sstate manifest isn't found

Michael Halstead (3):
      releases: update to include 3.2.4
      uninative: Upgrade to 3.2 (gcc11 support)
      releases: update to include 3.3.1

Michael Opdenacker (8):
      manuals: reduce verbosity with "worry about" expression
      manuals: reduce verbosity related to "the following" expression
      ref-manual: simplify style
      kernel-dev manual: simplify style
      dev-manual: simplify style
      sdk-manual: simplify style and fix formating
      overview-manual: simplify style and add missings references
      manuals: simplify style

Mike Crowe (2):
      npm.bbclass: Allow nodedir to be overridden by NPM_NODEDIR
      libnotify: Make gtk+3 dependency optional

Ming Liu (4):
      kernel-fitimage.bbclass: fix a wrong conditional check
      initramfs-framework:rootfs: fix wrong indentions
      kernel-fitimage.bbclass: drop unit addresses from bootscr sections
      uboot-sign/kernel-fitimage: split generate_rsa_keys task

Nikolay Papenkov (1):
      flex: correct license information

Nisha Parrakat (1):
      squashfs-tools: package squashfs-fs.h

Peter Kjellerstedt (3):
      libcap: Configure Make variables correctly without a horrible hack
      util-linux.inc: Do not modify BPN
      native.bbclass: Do not remove "-native" in the middle of recipe names

Petr Vorel (1):
      ltp: Update to 20210524

Richard Purdie (92):
      oeqa/qemurunner: Fix binary vs str issue
      oeqa/qemurunner: Improve handling of run_serial for shutdown commands
      ptest-packagelists: Add expat-ptest to fast ptests
      puzzles: Upstream changed to main branch for development
      grub2: Add CVE whitelist entries for issues fixed in 2.06
      glibc: Document and whitelist CVE-2019-1010022-25
      qemu: Exclude CVE-2017-5957 from cve-check
      qemu: Exclude CVE-2007-0998 from cve-check
      qemu: Exclude CVE-2018-18438 from cve-check
      jquery: Exclude CVE-2007-2379 from cve-check
      logrotate: Exclude CVE-2011-1548,1549,1550 from cve-check
      openssh: Exclude CVE-2007-2768 from cve-check
      ovmf: Improve reproducibility by enabling prefix mapping
      bind: Exclude CVE-2019-6470 from cve-check
      openssh: Exclude CVE-2008-3844 from cve-check
      unzip: Exclude CVE-2008-0888 from cve-check
      cpio: Exclude CVE-2010-4226 from cve-check
      xinetd: Exclude CVE-2013-4342 from cve-check
      ghostscript: Exclude CVE-2013-6629 from cve-check
      bluez: Exclude CVE-2020-12352 CVE-2020-24490 from cve-check
      tiff: Exclude CVE-2015-7313 from cve-check
      ovmf: Disable lto to aid reproducibility
      ovmf: Fix other reproducibility issues
      rpm: Exclude CVE-2021-20271 from cve-check
      coreutils: Exclude CVE-2016-2781 from cve-check
      librsvg: Exclude CVE-2018-1000041 from cve-check
      avahi: Exclude CVE-2021-26720 from cve-check
      qemu: Set SMP to 4 cpus for arm/x86 only
      qemuboot-x86: Switch to IvyBridge and q35 instead of pc
      qemu-x86: Add commandline options to improve boot
      sstate: Handle manifest 'corruption' issue
      lttng-ust: Upgrade 2.12.1 -> 2.12.2
      qemu: Upgrade 5.2.0 -> 6.0.0
      python3-markupsafe: Upgrade 1.1.1 -> 2.0.0
      python3-jinja2: Upgrade 2.11.3 -> 3.0.0
      ofono: upgrade 1.31 -> 1.32
      libnss-mdns: upgrade 0.14.1 -> 0.15
      python3-git: upgrade 3.1.14 -> 3.1.17
      bind: upgrade 9.16.13 -> 9.16.15
      vala: upgrade 0.52.2 -> 0.52.3
      libjpeg-turbo: upgrade 2.0.6 -> 2.1.0
      btrfs-tools: upgrade 5.12 -> 5.12.1
      python3-hypothesis: upgrade 6.9.1 -> 6.12.0
      python3-numpy: upgrade 1.20.2 -> 1.20.3
      gtk+3: upgrade 3.24.28 -> 3.24.29
      sudo: upgrade 1.9.6p1 -> 1.9.7
      stress-ng: upgrade 0.12.06 -> 0.12.08
      less: upgrade 581 -> 586
      libtirpc: upgrade 1.3.1 -> 1.3.2
      libinput: upgrade 1.17.1 -> 1.17.2
      zstd: upgrade 1.4.9 -> 1.5.0
      hdparm: upgrade 9.61 -> 9.62
      libxkbcommon: upgrade 1.2.1 -> 1.3.0
      spirv-tools: upgrade 2020.7 -> 2021.1
      diffoscope: upgrade 172 -> 175
      mpg123: upgrade 1.26.5 -> 1.27.2
      sqlite3: upgrade 3.35.3 -> 3.35.5
      wayland-protocols: upgrade 1.20 -> 1.21
      shaderc: upgrade 2020.5 -> 2021.0
      wpebackend-fdo: upgrade 1.8.3 -> 1.8.4
      libxcrypt-compat: upgrade 4.4.19 -> 4.4.20
      Revert "cml1.bbclass: Return sorted list of cfg files"
      bitbake: server/process: Handle error in heartbeat funciton in OOM case
      glibc: Add 8GB VM usage cap for usermode test suite
      cve-extra-exclusions.inc: add exclusion list for intractable CVE's
      rpm: Drop CVE exclusion as database fixed to handle
      cve-extra-exclusions: Fix typos
      grub: Exclude CVE-2019-14865 from cve-check
      cve-extra-exclusions.inc: Clean up merged CPE updates
      ltp: Disable problematic tests causing autobuilder hangs
      python3-setuptools: upgrade 56.0.0 -> 56.2.0
      distro/maintainers: Fix up the ptest image entries
      oeqa/runtime/rpm: Drop log message counting test component
      linux-firmware: upgrade 20210315 -> 20210511
      libxcrypt: Upgrade 4.4.20 -> 4.4.22
      iproute2: upgrade 5.11.0 -> 5.12.0
      libx11: upgrade 1.7.0 -> 1.7.1
      python3-hypothesis: upgrade 6.12.0 -> 6.13.7
      pango: upgrade 1.48.4 -> 1.48.5
      python3-importlib-metadata: upgrade 4.0.1 -> 4.3.0
      libmodulemd: upgrade 2.12.0 -> 2.12.1
      vte: upgrade 0.64.0 -> 0.64.1
      libinput: upgrade 1.17.2 -> 1.17.3
      gi-docgen: upgrade 2021.5 -> 2021.6
      kmod: upgrade 28 -> 29
      xorgproto: upgrade 2021.4 -> 2021.4.99.1
      libpcre2: upgrade 10.36 -> 10.37
      libepoxy: upgrade 1.5.5 -> 1.5.8
      python3-jinja2: upgrade 3.0.0 -> 3.0.1
      curl: upgrade 7.76.1 -> 7.77.0
      python3-setuptools: upgrade 56.2.0 -> 57.0.0
      oeqa/qemurunner: Improve timeout handling

Richard Weinberger (1):
      Add support for erofs filesystems

Robert Joslyn (3):
      liberation-fonts: Update to 2.1.4
      epiphany: Update to 40.1
      btrfs-tools: Update to 5.12

Robert P. J. Day (8):
      sdk-manual: couple minor fixes in using.rst
      sdk-manual: various cleanups to intro.rst
      ref-manual: delete references to dead LSB compliance
      ref-manual: delete extraneous back quote
      image.bbclass: fix comment "pacackages" -> "packages"
      meta/lib/oe/rootfs.py: Fix typo "Restoreing" -> "Restoring"
      bitbake.conf: alphabetize contents of ASSUME_PROVIDED
      ref-manual: add links to some variables in glossary

Romain Naour (1):
      dejagnu: needs expect at runtime

Ross Burton (12):
      cairo: backport patch for CVE-2020-35492
      libnotify: whitelist CVE-2013-7381 (specific to the NodeJS bindings)
      builder: whitelist CVE-2008-4178 (a different builder)
      libarchive: disable redundant libxml2 PACKAGECONFIG
      meson: update patch status
      cups: whitelist CVE-2021-25317
      libsolv: add missing db dependency
      rpm: turn Berkeley DB hard dependency into PACKAGECONFIG
      python3: update status on upstreamed patch
      ref-manual: Ubuntu 20.04 is also LTS
      package_rpm: pass XZ_THREADS to rpm
      gcc: revert libstc++-gdb.py installation changes

Samuli Piippo (3):
      gcc-cross-canadian: add symlinks for ld.bfd and ld.gold
      libarchive: enable zstd support
      cmake-native: enabled zstd support

Stefan Ghinea (1):
      boost: fix do_fetch failure

Steve Sakoman (1):
      expat: set CVE_PRODUCT

Tony Tascioglu (3):
      libxml2: Reformat runtest.patch
      libxml2: Add bash dependency for ptests.
      libxml2: Update to 2.9.12

Trevor Gamblin (2):
      python3: upgrade 3.9.4 -> 3.9.5
      bind: upgrade 9.16.15 -> 9.16.16

Ulrich Ölmann (1):
      local.conf.sample: fix typo

Vinícius Ossanes Aquino (1):
      lttng-modules: backport patches to fix build against 5.12+ kernel

Yann Dirson (1):
      linux-firmware: include all relevant files in -bcm4356

hongxu (1):
      gdk-pixbuf: fix nativesdk do_configure failed

wangmy (21):
      python3-pygments: upgrade 2.8.1 -> 2.9.0
      at-spi2-core: upgrade 2.40.0 -> 2.40.1
      ell: upgrade 0.39 -> 0.40
      kexec-tools: upgrade 2.0.21 -> 2.0.22
      go: upgrade 1.16.3 -> 1.16.4
      python3-attrs: upgrade 20.3.0 -> 21.2.0
      python3-six: upgrade 1.15.0 -> 1.16.0
      vulkan-samples: update to latest revision
      vulkan-headers: upgrade 1.2.170.0 -> 1.2.176.0
      vulkan-tools: upgrade 1.2.170.0 -> 1.2.176.0
      vulkan-loader: upgrade 1.2.170.0 -> 1.2.176.0
      distcc: upgrade 3.3.5 -> 3.4
      libdrm: upgrade 2.4.105 -> 2.4.106
      libidn2: upgrade 2.3.0 -> 2.3.1
      libtasn1: upgrade 4.16.0 -> 4.17.0
      python3-libarchive-c: upgrade 2.9 -> 3.0
      python3-markupsafe: upgrade 2.0.0 -> 2.0.1
      python3-more-itertools: upgrade 8.7.0 -> 8.8.0
      python3-pytest: upgrade 6.2.3 -> 6.2.4
      logrotate: upgrade 3.18.0 -> 3.18.1
      stress-ng: upgrade 0.12.08 -> 0.12.09

zhengruoqin (10):
      busybox: upgrade 1.33.0 -> 1.33.1
      rng-tools: upgrade 6.11 -> 6.12
      rpcbind: upgrade 1.2.5 -> 1.2.6
      sysklogd: upgrade 2.2.2 -> 2.2.3
      python3-importlib-metadata: upgrade 3.10.1 -> 4.0.1
      python3-sortedcontainers: upgrade 2.3.0 -> 2.4.0
      rxvt-unicode: upgrade 9.22 -> 9.26
      libedit: upgrade 20210419-3.1 -> 20210522-3.1
      libtest-needs-perl: upgrade 0.002006 -> 0.002009
      libucontext: upgrade 0.10 -> 1.1

Change-Id: I5e5148036ac2a7918974733e5751c3392139b17e
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/poky/meta/recipes-devtools/python/python3_3.9.5.bb b/poky/meta/recipes-devtools/python/python3_3.9.5.bb
new file mode 100644
index 0000000..f4002f2
--- /dev/null
+++ b/poky/meta/recipes-devtools/python/python3_3.9.5.bb
@@ -0,0 +1,385 @@
+SUMMARY = "The Python Programming Language"
+HOMEPAGE = "http://www.python.org"
+DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively."
+LICENSE = "PSFv2"
+SECTION = "devel/python"
+
+LIC_FILES_CHKSUM = "file://LICENSE;md5=c22d2438294c784731bf9dd224a467b7"
+
+SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
+           file://run-ptest \
+           file://create_manifest3.py \
+           file://get_module_deps3.py \
+           file://python3-manifest.json \
+           file://check_build_completeness.py \
+           file://reformat_sysconfig.py \
+           file://cgi_py.patch \
+           file://0001-Do-not-add-usr-lib-termcap-to-linker-flags-to-avoid-.patch \
+           ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \
+           file://0001-Do-not-use-the-shell-version-of-python-config-that-w.patch \
+           file://python-config.patch \
+           file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \
+           file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \
+           file://0001-Makefile-fix-Issue36464-parallel-build-race-problem.patch \
+           file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \
+           file://crosspythonpath.patch \
+           file://0001-Use-FLAG_REF-always-for-interned-strings.patch \
+           file://0001-test_locale.py-correct-the-test-output-format.patch \
+           file://0017-setup.py-do-not-report-missing-dependencies-for-disa.patch \
+           file://0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch \
+           file://0001-Makefile-do-not-compile-.pyc-in-parallel.patch \
+           file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \
+           file://0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch \
+           file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \
+           "
+
+SRC_URI_append_class-native = " \
+           file://0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch \
+           file://12-distutils-prefix-is-inside-staging-area.patch \
+           file://0001-Don-t-search-system-for-headers-libraries.patch \
+           "
+SRC_URI[sha256sum] = "0c5a140665436ec3dbfbb79e2dfb6d192655f26ef4a29aeffcb6d1820d716d83"
+
+# exclude pre-releases for both python 2.x and 3.x
+UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar"
+UPSTREAM_CHECK_URI = "https://www.python.org/downloads/source/"
+
+CVE_PRODUCT = "python"
+
+# Upstream consider this expected behaviour
+CVE_CHECK_WHITELIST += "CVE-2007-4559"
+# This is not exploitable when glibc has CVE-2016-10739 fixed.
+CVE_CHECK_WHITELIST += "CVE-2019-18348"
+
+# This is windows only issue.
+CVE_CHECK_WHITELIST += "CVE-2020-15523"
+
+PYTHON_MAJMIN = "3.9"
+
+S = "${WORKDIR}/Python-${PV}"
+
+BBCLASSEXTEND = "native nativesdk"
+
+inherit autotools pkgconfig qemu ptest multilib_header update-alternatives
+
+MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}"
+
+ALTERNATIVE_${PN}-dev = "python3-config"
+ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config"
+ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}"
+
+
+DEPENDS = "bzip2-replacement-native libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux libtirpc libnsl2 autoconf-archive-native"
+DEPENDS_append_class-target = " python3-native"
+DEPENDS_append_class-nativesdk = " python3-native"
+
+EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib}"
+EXTRA_OECONF_append_class-native = " --bindir=${bindir}/${PN}"
+
+export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/"
+
+EXTRANATIVEPATH += "python3-native"
+
+# LTO will be enabled via packageconfig depending upong distro features
+LTO_class-target = ""
+
+CACHED_CONFIGUREVARS = " \
+                ac_cv_file__dev_ptmx=yes \
+                ac_cv_file__dev_ptc=no \
+                ac_cv_working_tzset=yes \
+"
+
+def possibly_include_pgo(d):
+    # PGO currently causes builds to not be reproducible, so disable it for
+    # now. See YOCTO #13407
+    if bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d) and d.getVar('BUILD_REPRODUCIBLE_BINARIES') != '1':
+        return 'pgo'
+    
+    return ''
+
+PACKAGECONFIG_class-target ??= "readline ${@possibly_include_pgo(d)} gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}"
+PACKAGECONFIG_class-native ??= "readline gdbm"
+PACKAGECONFIG_class-nativesdk ??= "readline gdbm"
+PACKAGECONFIG[readline] = ",,readline"
+# Use profile guided optimisation by running PyBench inside qemu-user
+PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native"
+PACKAGECONFIG[tk] = ",,tk"
+PACKAGECONFIG[gdbm] = ",,gdbm"
+PACKAGECONFIG[lto] = "--with-lto,,"
+
+do_configure_prepend () {
+    mkdir -p ${B}/Modules
+    cat > ${B}/Modules/Setup.local << EOF
+*disabled*
+${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)}
+${@bb.utils.contains('PACKAGECONFIG', 'readline', '', 'readline', d)}
+EOF
+}
+
+CPPFLAGS_append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid"
+
+EXTRA_OEMAKE = '\
+  STAGING_LIBDIR=${STAGING_LIBDIR} \
+  STAGING_INCDIR=${STAGING_INCDIR} \
+  LIB=${baselib} \
+'
+
+do_compile_prepend_class-target() {
+       if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
+                qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}"
+                cat >pgo-wrapper <<EOF
+#!/bin/sh
+cd ${B}
+$qemu_binary "\$@"
+EOF
+                chmod +x pgo-wrapper
+        fi
+}
+
+do_install_prepend() {
+        ${WORKDIR}/check_build_completeness.py ${T}/log.do_compile
+}
+
+do_install_append_class-target() {
+        oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h
+}
+
+do_install_append_class-native() {
+        # Make sure we use /usr/bin/env python
+        for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do
+                sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
+        done
+        # Add a symlink to the native Python so that scripts can just invoke
+        # "nativepython" and get the right one without needing absolute paths
+        # (these often end up too long for the #! parser in the kernel as the
+        # buffer is 128 bytes long).
+        ln -s python3-native/python3 ${D}${bindir}/nativepython3
+}
+
+do_install_append() {
+        mkdir -p ${D}${libdir}/python-sysconfigdata
+        sysconfigfile=`find ${D} -name _sysconfig*.py`
+        cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
+
+        sed -i  \
+                -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \
+                -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
+                -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
+                -e "/^ 'INCLDIRSTOMAKE'/{N; s,/usr/include,${STAGING_INCDIR},g}" \
+                -e "/^ 'INCLUDEPY'/s,/usr/include,${STAGING_INCDIR},g" \
+                ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
+
+        # Unfortunately the following pyc files are non-deterministc due to 'frozenset'
+        # being written without strict ordering, even with PYTHONHASHSEED = 0
+        # Upstream is discussing ways to solve the issue properly, until then let's
+        # just not install the problematic files.
+        # More info: http://benno.id.au/blog/2013/01/15/python-determinism
+        rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython*
+        rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython*
+}
+
+do_install_append_class-nativesdk () {
+    # Make sure we use /usr/bin/env python
+    for PYTHSCRIPT in `grep -rIl ${bindir}/python ${D}${bindir}`; do
+         sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
+    done
+    create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
+}
+
+SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
+PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
+
+py_package_preprocess () {
+        # Remove references to buildmachine paths in target Makefile and _sysconfigdata
+        sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
+                -e 's|${DEBUG_PREFIX_MAP}||g' \
+                -e 's:${HOSTTOOLS_DIR}/::g' \
+                -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
+                -e 's:${RECIPE_SYSROOT}::g' \
+                -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
+                ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \
+                ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \
+                ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config
+
+        # Reformat _sysconfigdata after modifying it so that it remains
+        # reproducible
+        for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
+            python3 ${WORKDIR}/reformat_sysconfig.py $c
+        done
+
+        # Recompile _sysconfigdata after modifying it
+        cd ${PKGD}
+        sysconfigfile=`find . -name _sysconfigdata_*.py`
+        ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
+             -c "from py_compile import compile; compile('$sysconfigfile')"
+        ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
+             -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)"
+        ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
+             -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)"
+        cd -
+
+        mv ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}
+        
+        #Remove the unneeded copy of target sysconfig data
+        rm -rf ${PKGD}/${libdir}/python-sysconfigdata
+}
+
+# We want bytecode precompiled .py files (.pyc's) by default
+# but the user may set it on their own conf
+INCLUDE_PYCS ?= "1"
+
+python(){
+    import collections, json
+
+    filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json')
+    # This python changes the datastore based on the contents of a file, so mark
+    # that dependency.
+    bb.parse.mark_dependency(d, filename)
+
+    with open(filename) as manifest_file:
+        manifest_str =  manifest_file.read()
+        json_start = manifest_str.find('# EOC') + 6
+        manifest_file.seek(json_start)
+        manifest_str = manifest_file.read()
+        python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
+
+    # First set RPROVIDES for -native case
+    # Hardcoded since it cant be python3-native-foo, should be python3-foo-native
+    pn = 'python3'
+    rprovides = (d.getVar('RPROVIDES') or "").split()
+
+    # ${PN}-misc-native is not in the manifest
+    rprovides.append(pn + '-misc-native')
+
+    for key in python_manifest:
+        pypackage = pn + '-' + key + '-native'
+        if pypackage not in rprovides:
+              rprovides.append(pypackage)
+
+    d.setVar('RPROVIDES_class-native', ' '.join(rprovides))
+
+    # Then work on the target
+    include_pycs = d.getVar('INCLUDE_PYCS')
+
+    packages = d.getVar('PACKAGES').split()
+    pn = d.getVar('PN')
+
+    newpackages=[]
+    for key in python_manifest:
+        pypackage = pn + '-' + key
+
+        if pypackage not in packages:
+            # We need to prepend, otherwise python-misc gets everything
+            # so we use a new variable
+            newpackages.append(pypackage)
+
+        # "Build" python's manifest FILES, RDEPENDS and SUMMARY
+        d.setVar('FILES_' + pypackage, '')
+        for value in python_manifest[key]['files']:
+            d.appendVar('FILES_' + pypackage, ' ' + value)
+
+        # Add cached files
+        if include_pycs == '1':
+            for value in python_manifest[key]['cached']:
+                    d.appendVar('FILES_' + pypackage, ' ' + value)
+
+        for value in python_manifest[key]['rdepends']:
+            # Make it work with or without $PN
+            if '${PN}' in value:
+                value=value.split('-', 1)[1]
+            d.appendVar('RDEPENDS_' + pypackage, ' ' + pn + '-' + value)
+
+        for value in python_manifest[key].get('rrecommends', ()):
+            if '${PN}' in value:
+                value=value.split('-', 1)[1]
+            d.appendVar('RRECOMMENDS_' + pypackage, ' ' + pn + '-' + value)
+
+        d.setVar('SUMMARY_' + pypackage, python_manifest[key]['summary'])
+
+    # Prepending so to avoid python-misc getting everything
+    packages = newpackages + packages
+    d.setVar('PACKAGES', ' '.join(packages))
+    d.setVar('ALLOW_EMPTY_${PN}-modules', '1')
+    d.setVar('ALLOW_EMPTY_${PN}-pkgutil', '1')
+}
+
+# Files needed to create a new manifest
+
+do_create_manifest() {
+    # This task should be run with every new release of Python.
+    # We must ensure that PACKAGECONFIG enables everything when creating
+    # a new manifest, this is to base our new manifest on a complete
+    # native python build, containing all dependencies, otherwise the task
+    # wont be able to find the required files.
+    # e.g. BerkeleyDB is an optional build dependency so it may or may not
+    # be present, we must ensure it is.
+
+    cd ${WORKDIR}
+    # This needs to be executed by python-native and NOT by HOST's python
+    nativepython3 create_manifest3.py ${PYTHON_MAJMIN}
+    cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json
+}
+
+# bitbake python -c create_manifest
+# Make sure we have native python ready when we create a new manifest
+addtask do_create_manifest after do_patch do_prepare_recipe_sysroot
+
+# manual dependency additions
+RRECOMMENDS_${PN}-core_append_class-nativesdk = " nativesdk-python3-modules"
+RRECOMMENDS_${PN}-crypt_append_class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
+RRECOMMENDS_${PN}-crypt_append_class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
+
+# For historical reasons PN is empty and provided by python3-modules
+FILES_${PN} = ""
+RPROVIDES_${PN}-modules = "${PN}"
+
+FILES_${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3"
+FILES_${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}"
+
+# provide python-pyvenv from python3-venv
+RPROVIDES_${PN}-venv += "${MLPREFIX}python3-pyvenv"
+
+# package libpython3
+PACKAGES =+ "libpython3 libpython3-staticdev"
+FILES_libpython3 = "${libdir}/libpython*.so.*"
+FILES_libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a"
+INSANE_SKIP_${PN}-dev += "dev-elf"
+INSANE_SKIP_${PN}-ptest = "dev-deps"
+
+# catch all the rest (unsorted)
+PACKAGES += "${PN}-misc"
+RDEPENDS_${PN}-misc += "\
+  ${PN}-core \
+  ${PN}-email \
+  ${PN}-codecs \
+  ${PN}-pydoc \
+  ${PN}-pickle \
+  ${PN}-audio \
+  ${PN}-numbers \
+"
+RDEPENDS_${PN}-modules_append_class-target = " ${MLPREFIX}python3-misc"
+RDEPENDS_${PN}-modules_append_class-nativesdk = " ${MLPREFIX}python3-misc"
+FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload"
+
+# catch manpage
+PACKAGES += "${PN}-man"
+FILES_${PN}-man = "${datadir}/man"
+
+# See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395
+RDEPENDS_libpython3_append_libc-glibc = " libgcc"
+RDEPENDS_${PN}-ctypes_append_libc-glibc = " ${MLPREFIX}ldconfig"
+RDEPENDS_${PN}-ptest = "${PN}-modules ${PN}-tests ${PN}-dev unzip bzip2 libgcc tzdata-europe coreutils sed"
+RDEPENDS_${PN}-ptest_append_libc-glibc = " locale-base-tr-tr.iso-8859-9"
+RDEPENDS_${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', 'tk tk-lib', '', d)}"
+RDEPENDS_${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter tcl', '', d)}"
+RDEPENDS_${PN}-dev = ""
+RDEPENDS_${PN}-pydoc += "${PN}-io"
+
+RDEPENDS_${PN}-tests_append_class-target = " ${MLPREFIX}bash"
+RDEPENDS_${PN}-tests_append_class-nativesdk = " ${MLPREFIX}bash"
+
+# Python's tests contain large numbers of files we don't need in the recipe sysroots
+SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup"
+py3_sysroot_cleanup () {
+	rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test
+}