Hello community,

here is the log from the commit of package python-msm for openSUSE:Factory 
checked in at 2018-08-13 09:54:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-msm (Old)
 and      /work/SRC/openSUSE:Factory/.python-msm.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-msm"

Mon Aug 13 09:54:35 2018 rev:2 rq:628780 version:0.5.17

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-msm/python-msm.changes    2018-07-31 
16:02:10.671829643 +0200
+++ /work/SRC/openSUSE:Factory/.python-msm.new/python-msm.changes       
2018-08-13 09:54:40.406872502 +0200
@@ -1,0 +2,10 @@
+Sat Aug 11 12:54:30 UTC 2018 - [email protected]
+
+- Add do-not-run-pip-or-requirements-script.patch to make msm not run pip
+  or the requirements script when installing a skill. pip is not used
+  by the rest of the mycroft packages and then running scripts from the
+  web isn't nice security-wise.
+- Add add-local-patch-support.patch to be able to fix issues with skills
+  when they're installed.
+
+-------------------------------------------------------------------

New:
----
  add-local-patch-support.patch
  do-not-run-pip-or-requirements-script.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-msm.spec ++++++
--- /var/tmp/diff_new_pack.0wEmxM/_old  2018-08-13 09:54:41.170874049 +0200
+++ /var/tmp/diff_new_pack.0wEmxM/_new  2018-08-13 09:54:41.170874049 +0200
@@ -15,6 +15,7 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
+%define skip_python2 1
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-msm
@@ -28,14 +29,15 @@
 Source99:       
https://raw.githubusercontent.com/MycroftAI/mycroft-skills-manager/master/LICENSE
 Patch0:         fix-skills-directories.patch
 Patch1:         fix-dependencies.patch
+Patch2:         do-not-run-pip-or-requirements-script.patch
+Patch3:         add-local-patch-support.patch
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
 Requires:       python-GitPython
-%ifpython2
-Requires:       python-typing
-%endif
+Requires:       patch
 BuildArch:      noarch
+
 %python_subpackages
 
 %description
@@ -46,7 +48,8 @@
 %setup -q -n msm-%{version}
 %patch0 -p1
 %patch1 -p1
-
+%patch2 -p1
+%patch3 -p1
 cp %{SOURCE99} .
 
 %build

++++++ add-local-patch-support.patch ++++++
Index: msm-0.5.17/msm/skill_entry.py
===================================================================
--- msm-0.5.17.orig/msm/skill_entry.py
+++ msm-0.5.17/msm/skill_entry.py
@@ -39,6 +39,8 @@ from msm.exceptions import PipRequiremen
     SystemRequirementsException, AlreadyInstalled, SkillModified, \
     AlreadyRemoved, RemoveException, CloneException
 from msm.util import Git
+from msm.local_patches_utils import apply_skill_patch, \
+    reverse_skill_patch, remove_applied_skill_patch
 
 LOG = logging.getLogger(__name__)
 
@@ -242,6 +244,7 @@ class SkillEntry(object):
         try:
             move(tmp_location, self.path)
 
+            apply_skill_patch(self.name, self.path)
             self.run_requirements_sh()
             self.run_pip()
         finally:
@@ -274,6 +277,7 @@ class SkillEntry(object):
         with git_to_msm_exceptions():
             sha_before = git.rev_parse('HEAD')
 
+            reverse_skill_patch(self.name, self.path)
             modified_files = git.status(porcelain=True, untracked='no')
             if modified_files != '':
                 raise SkillModified('Uncommitted changes:\n' + modified_files)
@@ -285,6 +289,7 @@ class SkillEntry(object):
                 git.checkout(self._find_sha_branch())
 
             git.merge(self.sha or 'origin/HEAD', ff_only=True)
+            apply_skill_patch(self.name, self.path)
 
         sha_after = git.rev_parse('HEAD')
 
@@ -301,6 +306,7 @@ class SkillEntry(object):
             raise AlreadyRemoved(self.name)
         try:
             rmtree(self.path)
+            remove_applied_skill_patch(self.name)
         except OSError as e:
             raise RemoveException(str(e))
 
Index: msm-0.5.17/msm/local_patches_utils.py
===================================================================
--- /dev/null
+++ msm-0.5.17/msm/local_patches_utils.py
@@ -0,0 +1,99 @@
+# Copyright (c) 2018 Mycroft AI, Inc.
+#
+# This file is part of Mycroft Light
+# (see https://github.com/MatthewScholefield/mycroft-light).
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import logging
+import os
+from os.path import join, expanduser, isfile, isdir
+import subprocess
+import shutil
+
+
+LOG = logging.getLogger(__name__)
+
+
+skill_patches_folder = '/usr/share/mycroft-core/skill-patches/'
+applied_patch_folder = join(expanduser('~'), '.mycroft/applied-skill-patches')
+
+
+def apply_skill_patch(name, path='.'):
+    patchfile=join(skill_patches_folder, name + '.patch')
+
+    if not isfile(patchfile):
+        return
+
+    if not isdir(applied_patch_folder):
+        os.makedirs(applied_patch_folder)
+
+    LOG.info("Applying %s" % (patchfile))
+    try:
+        subprocess.run(["patch", "-f", "-p1", "-i", patchfile],
+                       stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+                       check=True, cwd=path)
+    except subprocess.CalledProcessError as e:
+        LOG.error("Couldn't apply patch %s" % patchfile)
+        LOG.error(e)
+        LOG.error(e.stdout)
+        LOG.error(e.stderr)
+    else:
+        try:
+            shutil.copy(patchfile, applied_patch_folder)
+        except OSError as e:
+            LOG.error("Couldn't copy %s to applied patch folder %s" %
+                      (patchfile, applied_patch_folder))
+            LOG.error(e)
+
+
+def reverse_skill_patch(name, path='.'):
+    patchfile=join(applied_patch_folder, name + '.patch')
+
+    if not isfile(patchfile):
+        return
+
+    LOG.info("Reversing %s" % (patchfile))
+    try:
+        subprocess.run(["patch", "-f", "-p1", "-R", "-i", patchfile],
+                       stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+                       check=True, cwd=path)
+    except subprocess.CalledProcessError as e:
+        LOG.error("Couldn't reverse patch %s" % patchfile)
+        LOG.error(e)
+        LOG.error(e.stdout)
+        LOG.error(e.stderr)
+    else:
+        try:
+            os.unlink(patchfile)
+        except OSError as e:
+            LOG.error("Couldn't remove %s" % patchfile)
+            LOG.error(e)
+
+
+def remove_applied_skill_patch(name):
+    patchfile=join(applied_patch_folder, name + '.patch')
+
+    if not isfile(patchfile):
+        return
+
+    LOG.info("Removing %s" % (patchfile))
+    try:
+        os.unlink(patchfile)
+    except OSError as e:
+        LOG.error("Couldn't remove %s" % patchfile)
+        LOG.error(e)
++++++ do-not-run-pip-or-requirements-script.patch ++++++
Index: msm-0.5.17/msm/skill_entry.py
===================================================================
--- msm-0.5.17.orig/msm/skill_entry.py
+++ msm-0.5.17/msm/skill_entry.py
@@ -154,6 +154,8 @@ class SkillEntry(object):
         requirements_file = join(self.path, "requirements.txt")
         if not exists(requirements_file):
             return False
+        LOG.info("Please check manually the requirements file at " + 
requirements_file)
+        return False
 
         LOG.info('Installing requirements.txt for ' + self.name)
         can_pip = os.access(dirname(sys.executable), os.W_OK | os.X_OK)
@@ -184,6 +186,8 @@ class SkillEntry(object):
         setup_script = join(self.path, "requirements.sh")
         if not exists(setup_script):
             return False
+        LOG.info("Please check manually the setup script at " + setup_script)
+        return False
 
         with work_dir(self.path):
             rc = subprocess.call(["bash", setup_script])
++++++ fix-skills-directories.patch ++++++
--- /var/tmp/diff_new_pack.0wEmxM/_old  2018-08-13 09:54:41.202874114 +0200
+++ /var/tmp/diff_new_pack.0wEmxM/_new  2018-08-13 09:54:41.202874114 +0200
@@ -19,7 +19,7 @@
 +# limitations under the License.
 +#
 +
-+from os.path import exists, isfile, expanduser, join
++from os.path import join, exists, isfile, expanduser
 +from .json_helper import load_commented_json
 +
 +SYSTEM_CONFIG = '/etc/mycroft/mycroft.conf'
@@ -57,12 +57,12 @@
 +        config = LocalConf(config_file)
 +        directory = config.get('skills').get(key)
 +        return directory
-+            
++
 +    return None
 +
 +def get_skills_directory():
 +    return get_skills_configuration_value('directory') or 
"/opt/mycroft/skills"
-+            
++
 +def get_skills_repo_directory():
 +    return get_skills_configuration_value('repo_directory') or 
"/opt/mycroft/.skills-repo"
 Index: msm-0.5.17/msm/mycroft_skills_manager.py
@@ -159,3 +159,24 @@
 +        nocomment.append(line)
 +
 +    return " ".join(nocomment)
+Index: msm-0.5.17/msm/skill_repo.py
+===================================================================
+--- msm-0.5.17.orig/msm/skill_repo.py
++++ msm-0.5.17/msm/skill_repo.py
+@@ -29,6 +29,7 @@ from git.exc import GitCommandError
+ from msm import git_to_msm_exceptions
+ from msm.exceptions import MsmException
+ from msm.util import Git
++from msm.configuration import get_skills_repo_directory
+ import logging
+ 
+ LOG = logging.getLogger(__name__)
+@@ -36,7 +37,7 @@ LOG = logging.getLogger(__name__)
+ 
+ class SkillRepo(object):
+     def __init__(self, path=None, url=None, branch=None):
+-        self.path = path or "/opt/mycroft/.skills-repo"
++        self.path = path or get_skills_repo_directory()
+         self.url = url or "https://github.com/MycroftAI/mycroft-skills";
+         self.branch = branch or "18.02"
+         self.repo_info = {}


Reply via email to