--- /dev/null
+From bd629777539347ab8da89616d6cd724c44c04f5c Mon Sep 17 00:00:00 2001
+From: Michael Tremer <michael.tremer@ipfire.org>
+Date: Tue, 2 Oct 2012 23:11:56 +0200
+Subject: [PATCH 5/6] Fix caching scriptlets.
+
+Fixes #10117.
+
+Scriptlets have not been executed when the package has
+not been available (i.e. had to be downloaded).
+---
+ python/pakfire/actions.py | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/python/pakfire/actions.py b/python/pakfire/actions.py
+index 9fda261..b8d0fb3 100644
+--- a/python/pakfire/actions.py
++++ b/python/pakfire/actions.py
+@@ -140,8 +140,17 @@ class ActionScript(Action):
+ script_action = None
+
+ def init(self):
+- # Load the scriplet.
+- self.scriptlet = self.pkg.get_scriptlet(self.script_action)
++ self._scriptlet = None
++
++ @property
++ def scriptlet(self):
++ """
++ Load the scriplet.
++ """
++ if self._scriptlet is None:
++ self._scriptlet = self.pkg.get_scriptlet(self.script_action)
++
++ return self._scriptlet
+
+ def get_lang(self):
+ if not self.scriptlet:
+--
+1.7.11.4
+
--- /dev/null
+From e9e430d4fd5b09327f57651726ffac1b7874ae01 Mon Sep 17 00:00:00 2001
+From: Michael Tremer <michael.tremer@ipfire.org>
+Date: Wed, 3 Oct 2012 00:45:11 +0200
+Subject: [PATCH 6/6] python: Byte-compile all files in sitelib.
+
+For files which are located elsewhere, it is required
+to call:
+ python_bytecompile <path1> <path2>... (Python 2)
+or
+ python3_bytecompile <path1> <path2>... (Python 3)
+---
+ macros/build.macro | 12 ++++++-
+ macros/python.macro | 3 ++
+ tools/py-compile | 90 +++++++++++++++++++++++++++++------------------------
+ 3 files changed, 64 insertions(+), 41 deletions(-)
+
+diff --git a/macros/build.macro b/macros/build.macro
+index 6987068..4e4d830 100644
+--- a/macros/build.macro
++++ b/macros/build.macro
+@@ -46,7 +46,17 @@ def MACRO_INSTALL_LOGROTATE_FILES
+ end
+
+ def MACRO_PYTHON_COMPILE
+- # XXX TODO
++ if [ -x "%{python3}" ]; then
++ %{python3_bytecompile} \
++ %{BUILDROOT}%{python3_sitearch} \
++ %{BUILDROOT}%{python3_sitelib}
++ fi
++
++ if [ -x "%{python}" ]; then
++ %{python_bytecompile} \
++ %{BUILDROOT}%{python_sitearch} \
++ %{BUILDROOT}%{python_sitelib}
++ fi
+ end
+
+ MACRO_PERL_CLEANUP
+diff --git a/macros/python.macro b/macros/python.macro
+index 1b417f2..15c1209 100644
+--- a/macros/python.macro
++++ b/macros/python.macro
+@@ -1,7 +1,9 @@
+ # A bunch of predefined things for Python.
++python_bytecompile_script = /usr/lib/pakfire/py-compile
+
+ # Python 3 constants.
+ python3 = /usr/bin/python3
++python3_bytecompile = %{python_bytecompile_script} --python=%{python3}
+
+ python3_sitearch = %(%{python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
+ python3_sitelib = %(%{python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
+@@ -9,6 +11,7 @@ python3_version = %(%{python3} -c "import sys; sys.stdout.write(sys.version[:3]
+
+ # Python 2 constants.
+ python = /usr/bin/python2
++python_bytecompile = %{python_bytecompile_script} --python=%{python}
+
+ python_sitearch = %(%{python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")
+ python_sitelib = %(%{python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
+diff --git a/tools/py-compile b/tools/py-compile
+index 66c33ed..5ccd8f9 100755
+--- a/tools/py-compile
++++ b/tools/py-compile
+@@ -1,48 +1,58 @@
+ #!/bin/sh
+
+-PYTHON=$(which python 2>/dev/null)
++python_interpreter="python"
++paths=""
++
++while [ $# -gt 0 ]; do
++ case "${1}" in
++ --python=*)
++ python_interpreter=${1#--python=}
++ ;;
++ *)
++ paths="${paths} ${1}"
++ ;;
++ esac
++ shift
++done
+
+-if [ -z "${PYTHON}" ]; then
+- # Python is not present. Fail silently.
+- exit 0
++if [ -z "${paths}" ]; then
++ echo >&2 "No path specified!"
++ exit 1
+ fi
+
+-files=""
+-for i in $*; do
+- if [ -e ${i}c ] && [ -e ${i}o ]; then
+- continue # all files we want are already there
+- fi
+- files="$files $i"
+-done
++if [ "${python_interpreter:0:1}" != "/" ]; then
++ python_interpreter=$(which ${python_interpreter} 2>/dev/null)
++fi
+
+-if [ -z "${files}" ]; then
+- # No files need to be proceeded.
+- exit 0
++if [ ! -x "${python_interpreter}" ]; then
++ echo >&2 "Python interpreter is not executable: ${python_interpreter}"
++ exit 1
+ fi
+
+-$PYTHON -c "
+-import sys, os, string, py_compile
+-
+-files = '''$files'''
+-print 'Byte-compiling python modules...'
+-for file in string.split(files):
+- if not os.path.exists(file) or not (len(file) >= 3 and file[-3:] == '.py'):
+- continue
+- print file,
+- sys.stdout.flush()
+- py_compile.compile(file)
+-print" || exit $?
+-
+-# this will fail for python < 1.5, but that doesn't matter ...
+-$PYTHON -O -c "
+-import sys, os, string, py_compile
+-
+-files = '''$files'''
+-print 'Byte-compiling python modules (optimised versions) ...'
+-for file in string.split(files):
+- if not os.path.exists(file) or not (len(file) >= 3 and file[-3:] == '.py'):
+- continue
+- print file,
+- sys.stdout.flush()
+- py_compile.compile(file)
+-print" 2>/dev/null || :
++tempfile=$(mktemp)
++trap "rm -f ${tempfile}" EXIT
++
++cat > ${tempfile} <<EOF
++import py_compile
++import sys
++
++for file in sys.argv[1:]:
++ py_compile.compile(file, doraise=0)
++EOF
++
++filelist=$(find ${paths} -type f -a -name "*.py")
++
++# Compile with optimization.
++${python_interpreter} -O ${tempfile} ${filelist}
++
++# Compile without optimization.
++${python_interpreter} ${tempfile} ${filelist}
++
++# Hardlink identical files.
++for pyc in $(find ${paths} -type f -a -name "*.pyc"); do
++ pyo="${pyc/.pyc/.pyo}"
++
++ if cmp -s "${pyc}" "${pyo}"; then
++ ln -f "${pyc}" "${pyo}"
++ fi
++done
+--
+1.7.11.4
+