We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[package] msys2/20190524: PKG_CONFIG_PATH environment variable is not passed
The `PKG_CONFIG_PATH` environment variable is not passed tot the msys2 environment.
This causes the `pkg_config` generator not to work.

The `PKG_CONFIG_PATH` environment variable is always  `/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig`

Is this a bug or am I missing something?

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **msys2/20190524**
  * Operating System+version: **Windows 10**
  * Conan version: **conan 1.21.0**
  * Python version: **Python 3.8.0**

### Steps to reproduce (Include if Applicable)
In Windows 10, build the following recipe:
```
from conans import ConanFile, tools
import os


class DummyConan(ConanFile):
    name = "dummy"
    version = "0.1"

    requires = ""

    def build_requirements(self):
        if tools.os_info.is_windows and not "CONAN_BASH_PATH" in os.environ:
            self.build_requires("msys2/20190524")
            # self.build_requires("msys2/20161025")

    def build(self):
        env = {
            "PKG_CONFIG_PATH": "PKG_CONFIG_PATH from conan",
            "DUMMY_ENV": "DUMMY_ENV from conan",
        }
        with tools.environment_append(env):
            self.run("echo $PKG_CONFIG_PATH", win_bash=tools.os_info.is_windows)
            self.run("echo $DUMMY_ENV", win_bash=tools.os_info.is_windows)
```
(the behavior is the same for `msys2/20161025`)

This prints ` /mingw64/lib/pkgconfig:/mingw64/share/pkgconfig` for `PKG_CONFIG_PATH`.
And `DUMMY_ENV from conan` for `DUMMY_ENV`.


### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
dummy/0.1: Calling build()
dummy/0.1: run_in_windows_bash: C:\.conan\1982c6\1\bin\usr\bin\bash.exe --login -c ^"cd \^"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\^" ^&^& PATH=\^"/c/.conan/1982c6/1/bin/usr/bin:$PATH\^" ^&^& echo $PKG_CONFIG_PATH ^"
dummy/0.1:
----Running------
> C:\.conan\1982c6\1\bin\usr\bin\bash.exe --login -c ^"cd \^"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\^" ^&^& PATH=\^"/c/.conan/1982c6/1/bin/usr/bin:$PATH\^" ^&^& echo $PKG_CONFIG_PATH ^"
-----------------
dummy/0.1: /mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
dummy/0.1: run_in_windows_bash: C:\.conan\1982c6\1\bin\usr\bin\bash.exe --login -c ^"cd \^"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\^" ^&^& PATH=\^"/c/.conan/1982c6/1/bin/usr/bin:$PATH\^" ^&^& echo $DUMMY_ENV ^"
dummy/0.1:
----Running------
> C:\.conan\1982c6\1\bin\usr\bin\bash.exe --login -c ^"cd \^"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\^" ^&^& PATH=\^"/c/.conan/1982c6/1/bin/usr/bin:$PATH\^" ^&^& echo $DUMMY_ENV ^"
-----------------
dummy/0.1: DUMMY_ENV from conan
dummy/0.1: Package '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' built
dummy/0.1: Build folder C:\Users\maarten\.conan\data\dummy\0.1\_\_\build\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
dummy/0.1: Generated conaninfo.txt
dummy/0.1: Generated conanbuildinfo.txt
dummy/0.1: Generating the package
dummy/0.1: Package folder C:\Users\maarten\.conan\data\dummy\0.1\_\_\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
```

</details>


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `recipes/msys2/all/conanfile.py`
Content:
```
1 from conans import ConanFile, tools
2 from conans.errors import ConanInvalidConfiguration
3 import os
4 import shutil
5 
6 
7 class MSYS2Conan(ConanFile):
8     name = "msys2"
9     description = "MSYS2 is a software distro and building platform for Windows"
10     url = "https://github.com/conan-io/conan-center-index"
11     homepage = "http://www.msys2.org"
12     license = "MSYS license"
13     topics = ("conan", "msys", "unix", "subsystem")
14     build_requires = "7zip/19.00"
15     short_paths = True
16     options = {"exclude_files": "ANY",  # Comma separated list of file patterns to exclude from the package
17                "packages": "ANY",  # Comma separated
18                "additional_packages": "ANY"}    # Comma separated
19     default_options = {"exclude_files": "*/link.exe",
20                        "packages": "base-devel,binutils,gcc",
21                        "additional_packages": None}
22     settings = "os_build", "arch_build"
23 
24     def configure(self):
25         if self.settings.os_build != "Windows":
26             raise ConanInvalidConfiguration("Only Windows supported")
27 
28     def source(self):
29         # build tools have to download files in build method when the
30         # source files downloaded will be different based on architecture or OS
31         pass
32 
33     def _download(self, url, sha256):
34         from six.moves.urllib.parse import urlparse
35         filename = os.path.basename(urlparse(url).path)
36         tools.download(url, filename)
37         tools.check_sha256(filename, sha256)
38         return filename
39 
40     def build(self):
41         arch = 0 if self.settings.arch_build == "x86" else 1  # index in the sources list
42         url = self.conan_data["sources"][self.version][arch]["url"]
43         sha256 = self.conan_data["sources"][self.version][arch]["sha256"]
44         filename = self._download(**self.conan_data["sources"][self.version][arch])
45         tar_name = filename.replace(".xz", "")
46         self.run("7z.exe x {0}".format(filename))
47         self.run("7z.exe x {0}".format(tar_name))
48         os.unlink(filename)
49         os.unlink(tar_name)
50 
51         msys_dir = "msys64" if self.settings.arch_build == "x86_64" else "msys32"
52 
53         packages = []
54         if self.options.packages:
55             packages.extend(str(self.options.packages).split(","))
56         if self.options.additional_packages:
57             packages.extend(str(self.options.additional_packages).split(","))
58 
59         with tools.chdir(os.path.join(msys_dir, "usr", "bin")):
60             for package in packages:
61                 self.run('bash -l -c "pacman -S %s --noconfirm"' % package)
62 
63         # create /tmp dir in order to avoid
64         # bash.exe: warning: could not find /tmp, please create!
65         tmp_dir = os.path.join(msys_dir, 'tmp')
66         if not os.path.isdir(tmp_dir):
67             os.makedirs(tmp_dir)
68         tmp_name = os.path.join(tmp_dir, 'dummy')
69         with open(tmp_name, 'a'):
70             os.utime(tmp_name, None)
71 
72     def package(self):
73         msys_dir = "msys64" if self.settings.arch_build == "x86_64" else "msys32"
74         excludes = None
75         if self.options.exclude_files:
76             excludes = tuple(str(self.options.exclude_files).split(","))
77         self.copy("*", dst="bin", src=msys_dir, excludes=excludes)
78         shutil.copytree(os.path.join(self.package_folder, "bin", "usr", "share", "licenses"),
79                         os.path.join(self.package_folder, "licenses"))
80 
81 
82     def package_info(self):
83         msys_root = os.path.join(self.package_folder, "bin")
84         msys_bin = os.path.join(msys_root, "usr", "bin")
85 
86         self.output.info("Creating MSYS_ROOT env var : %s" % msys_root)
87         self.env_info.MSYS_ROOT = msys_root
88 
89         self.output.info("Creating MSYS_BIN env var : %s" % msys_bin)
90         self.env_info.MSYS_BIN = msys_bin
91 
92         self.output.info("Appending PATH env var with : " + msys_bin)
93         self.env_info.path.append(msys_bin)
94
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/recipes/msys2/all/conanfile.py b/recipes/msys2/all/conanfile.py
--- a/recipes/msys2/all/conanfile.py
+++ b/recipes/msys2/all/conanfile.py
@@ -37,6 +37,10 @@
         tools.check_sha256(filename, sha256)
         return filename
 
+    @property
+    def _msys_dir(self):
+        return "msys64" if self.settings.arch_build == "x86_64" else "msys32"
+
     def build(self):
         arch = 0 if self.settings.arch_build == "x86" else 1  # index in the sources list
         url = self.conan_data["sources"][self.version][arch]["url"]
@@ -48,33 +52,34 @@
         os.unlink(filename)
         os.unlink(tar_name)
 
-        msys_dir = "msys64" if self.settings.arch_build == "x86_64" else "msys32"
-
         packages = []
         if self.options.packages:
             packages.extend(str(self.options.packages).split(","))
         if self.options.additional_packages:
             packages.extend(str(self.options.additional_packages).split(","))
 
-        with tools.chdir(os.path.join(msys_dir, "usr", "bin")):
+        with tools.chdir(os.path.join(self._msys_dir, "usr", "bin")):
             for package in packages:
                 self.run('bash -l -c "pacman -S %s --noconfirm"' % package)
 
         # create /tmp dir in order to avoid
         # bash.exe: warning: could not find /tmp, please create!
-        tmp_dir = os.path.join(msys_dir, 'tmp')
+        tmp_dir = os.path.join(self._msys_dir, 'tmp')
         if not os.path.isdir(tmp_dir):
             os.makedirs(tmp_dir)
         tmp_name = os.path.join(tmp_dir, 'dummy')
         with open(tmp_name, 'a'):
             os.utime(tmp_name, None)
 
+        # Prepend the PKG_CONFIG_PATH environment variable with an eventual PKG_CONFIG_PATH environment variable
+        tools.replace_in_file(os.path.join(self._msys_dir, "etc", "profile"),
+                              'PKG_CONFIG_PATH="', 'PKG_CONFIG_PATH="$PKG_CONFIG_PATH:')
+
     def package(self):
-        msys_dir = "msys64" if self.settings.arch_build == "x86_64" else "msys32"
         excludes = None
         if self.options.exclude_files:
             excludes = tuple(str(self.options.exclude_files).split(","))
-        self.copy("*", dst="bin", src=msys_dir, excludes=excludes)
+        self.copy("*", dst="bin", src=self._msys_dir, excludes=excludes)
         shutil.copytree(os.path.join(self.package_folder, "bin", "usr", "share", "licenses"),
                         os.path.join(self.package_folder, "licenses"))

{"golden_diff": "diff --git a/recipes/msys2/all/conanfile.py b/recipes/msys2/all/conanfile.py\n--- a/recipes/msys2/all/conanfile.py\n+++ b/recipes/msys2/all/conanfile.py\n@@ -37,6 +37,10 @@\n         tools.check_sha256(filename, sha256)\n         return filename\n \n+    @property\n+    def _msys_dir(self):\n+        return \"msys64\" if self.settings.arch_build == \"x86_64\" else \"msys32\"\n+\n     def build(self):\n         arch = 0 if self.settings.arch_build == \"x86\" else 1  # index in the sources list\n         url = self.conan_data[\"sources\"][self.version][arch][\"url\"]\n@@ -48,33 +52,34 @@\n         os.unlink(filename)\n         os.unlink(tar_name)\n \n-        msys_dir = \"msys64\" if self.settings.arch_build == \"x86_64\" else \"msys32\"\n-\n         packages = []\n         if self.options.packages:\n             packages.extend(str(self.options.packages).split(\",\"))\n         if self.options.additional_packages:\n             packages.extend(str(self.options.additional_packages).split(\",\"))\n \n-        with tools.chdir(os.path.join(msys_dir, \"usr\", \"bin\")):\n+        with tools.chdir(os.path.join(self._msys_dir, \"usr\", \"bin\")):\n             for package in packages:\n                 self.run('bash -l -c \"pacman -S %s --noconfirm\"' % package)\n \n         # create /tmp dir in order to avoid\n         # bash.exe: warning: could not find /tmp, please create!\n-        tmp_dir = os.path.join(msys_dir, 'tmp')\n+        tmp_dir = os.path.join(self._msys_dir, 'tmp')\n         if not os.path.isdir(tmp_dir):\n             os.makedirs(tmp_dir)\n         tmp_name = os.path.join(tmp_dir, 'dummy')\n         with open(tmp_name, 'a'):\n             os.utime(tmp_name, None)\n \n+        # Prepend the PKG_CONFIG_PATH environment variable with an eventual PKG_CONFIG_PATH environment variable\n+        tools.replace_in_file(os.path.join(self._msys_dir, \"etc\", \"profile\"),\n+                              'PKG_CONFIG_PATH=\"', 'PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH:')\n+\n     def package(self):\n-        msys_dir = \"msys64\" if self.settings.arch_build == \"x86_64\" else \"msys32\"\n         excludes = None\n         if self.options.exclude_files:\n             excludes = tuple(str(self.options.exclude_files).split(\",\"))\n-        self.copy(\"*\", dst=\"bin\", src=msys_dir, excludes=excludes)\n+        self.copy(\"*\", dst=\"bin\", src=self._msys_dir, excludes=excludes)\n         shutil.copytree(os.path.join(self.package_folder, \"bin\", \"usr\", \"share\", \"licenses\"),\n                         os.path.join(self.package_folder, \"licenses\"))\n", "issue": "[package] msys2/20190524: PKG_CONFIG_PATH environment variable is not passed\nThe `PKG_CONFIG_PATH` environment variable is not passed tot the msys2 environment.\r\nThis causes the `pkg_config` generator not to work.\r\n\r\nThe `PKG_CONFIG_PATH` environment variable is always  `/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig`\r\n\r\nIs this a bug or am I missing something?\r\n\r\n### Package and Environment Details (include every applicable attribute)\r\n  * Package Name/Version: **msys2/20190524**\r\n  * Operating System+version: **Windows 10**\r\n  * Conan version: **conan 1.21.0**\r\n  * Python version: **Python 3.8.0**\r\n\r\n### Steps to reproduce (Include if Applicable)\r\nIn Windows 10, build the following recipe:\r\n```\r\nfrom conans import ConanFile, tools\r\nimport os\r\n\r\n\r\nclass DummyConan(ConanFile):\r\n    name = \"dummy\"\r\n    version = \"0.1\"\r\n\r\n    requires = \"\"\r\n\r\n    def build_requirements(self):\r\n        if tools.os_info.is_windows and not \"CONAN_BASH_PATH\" in os.environ:\r\n            self.build_requires(\"msys2/20190524\")\r\n            # self.build_requires(\"msys2/20161025\")\r\n\r\n    def build(self):\r\n        env = {\r\n            \"PKG_CONFIG_PATH\": \"PKG_CONFIG_PATH from conan\",\r\n            \"DUMMY_ENV\": \"DUMMY_ENV from conan\",\r\n        }\r\n        with tools.environment_append(env):\r\n            self.run(\"echo $PKG_CONFIG_PATH\", win_bash=tools.os_info.is_windows)\r\n            self.run(\"echo $DUMMY_ENV\", win_bash=tools.os_info.is_windows)\r\n```\r\n(the behavior is the same for `msys2/20161025`)\r\n\r\nThis prints ` /mingw64/lib/pkgconfig:/mingw64/share/pkgconfig` for `PKG_CONFIG_PATH`.\r\nAnd `DUMMY_ENV from conan` for `DUMMY_ENV`.\r\n\r\n\r\n### Logs (Include/Attach if Applicable)\r\n<details><summary>Click to expand log</summary>\r\n\r\n```\r\ndummy/0.1: Calling build()\r\ndummy/0.1: run_in_windows_bash: C:\\.conan\\1982c6\\1\\bin\\usr\\bin\\bash.exe --login -c ^\"cd \\^\"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\^\" ^&^& PATH=\\^\"/c/.conan/1982c6/1/bin/usr/bin:$PATH\\^\" ^&^& echo $PKG_CONFIG_PATH ^\"\r\ndummy/0.1:\r\n----Running------\r\n> C:\\.conan\\1982c6\\1\\bin\\usr\\bin\\bash.exe --login -c ^\"cd \\^\"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\^\" ^&^& PATH=\\^\"/c/.conan/1982c6/1/bin/usr/bin:$PATH\\^\" ^&^& echo $PKG_CONFIG_PATH ^\"\r\n-----------------\r\ndummy/0.1: /mingw64/lib/pkgconfig:/mingw64/share/pkgconfig\r\ndummy/0.1: run_in_windows_bash: C:\\.conan\\1982c6\\1\\bin\\usr\\bin\\bash.exe --login -c ^\"cd \\^\"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\^\" ^&^& PATH=\\^\"/c/.conan/1982c6/1/bin/usr/bin:$PATH\\^\" ^&^& echo $DUMMY_ENV ^\"\r\ndummy/0.1:\r\n----Running------\r\n> C:\\.conan\\1982c6\\1\\bin\\usr\\bin\\bash.exe --login -c ^\"cd \\^\"/c/users/maarten/.conan/data/dummy/0.1/_/_/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\^\" ^&^& PATH=\\^\"/c/.conan/1982c6/1/bin/usr/bin:$PATH\\^\" ^&^& echo $DUMMY_ENV ^\"\r\n-----------------\r\ndummy/0.1: DUMMY_ENV from conan\r\ndummy/0.1: Package '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' built\r\ndummy/0.1: Build folder C:\\Users\\maarten\\.conan\\data\\dummy\\0.1\\_\\_\\build\\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\r\ndummy/0.1: Generated conaninfo.txt\r\ndummy/0.1: Generated conanbuildinfo.txt\r\ndummy/0.1: Generating the package\r\ndummy/0.1: Package folder C:\\Users\\maarten\\.conan\\data\\dummy\\0.1\\_\\_\\package\\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\r\n```\r\n\r\n</details>\r\n\n", "before_files": [{"content": "from conans import ConanFile, tools\nfrom conans.errors import ConanInvalidConfiguration\nimport os\nimport shutil\n\n\nclass MSYS2Conan(ConanFile):\n    name = \"msys2\"\n    description = \"MSYS2 is a software distro and building platform for Windows\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"http://www.msys2.org\"\n    license = \"MSYS license\"\n    topics = (\"conan\", \"msys\", \"unix\", \"subsystem\")\n    build_requires = \"7zip/19.00\"\n    short_paths = True\n    options = {\"exclude_files\": \"ANY\",  # Comma separated list of file patterns to exclude from the package\n               \"packages\": \"ANY\",  # Comma separated\n               \"additional_packages\": \"ANY\"}    # Comma separated\n    default_options = {\"exclude_files\": \"*/link.exe\",\n                       \"packages\": \"base-devel,binutils,gcc\",\n                       \"additional_packages\": None}\n    settings = \"os_build\", \"arch_build\"\n\n    def configure(self):\n        if self.settings.os_build != \"Windows\":\n            raise ConanInvalidConfiguration(\"Only Windows supported\")\n\n    def source(self):\n        # build tools have to download files in build method when the\n        # source files downloaded will be different based on architecture or OS\n        pass\n\n    def _download(self, url, sha256):\n        from six.moves.urllib.parse import urlparse\n        filename = os.path.basename(urlparse(url).path)\n        tools.download(url, filename)\n        tools.check_sha256(filename, sha256)\n        return filename\n\n    def build(self):\n        arch = 0 if self.settings.arch_build == \"x86\" else 1  # index in the sources list\n        url = self.conan_data[\"sources\"][self.version][arch][\"url\"]\n        sha256 = self.conan_data[\"sources\"][self.version][arch][\"sha256\"]\n        filename = self._download(**self.conan_data[\"sources\"][self.version][arch])\n        tar_name = filename.replace(\".xz\", \"\")\n        self.run(\"7z.exe x {0}\".format(filename))\n        self.run(\"7z.exe x {0}\".format(tar_name))\n        os.unlink(filename)\n        os.unlink(tar_name)\n\n        msys_dir = \"msys64\" if self.settings.arch_build == \"x86_64\" else \"msys32\"\n\n        packages = []\n        if self.options.packages:\n            packages.extend(str(self.options.packages).split(\",\"))\n        if self.options.additional_packages:\n            packages.extend(str(self.options.additional_packages).split(\",\"))\n\n        with tools.chdir(os.path.join(msys_dir, \"usr\", \"bin\")):\n            for package in packages:\n                self.run('bash -l -c \"pacman -S %s --noconfirm\"' % package)\n\n        # create /tmp dir in order to avoid\n        # bash.exe: warning: could not find /tmp, please create!\n        tmp_dir = os.path.join(msys_dir, 'tmp')\n        if not os.path.isdir(tmp_dir):\n            os.makedirs(tmp_dir)\n        tmp_name = os.path.join(tmp_dir, 'dummy')\n        with open(tmp_name, 'a'):\n            os.utime(tmp_name, None)\n\n    def package(self):\n        msys_dir = \"msys64\" if self.settings.arch_build == \"x86_64\" else \"msys32\"\n        excludes = None\n        if self.options.exclude_files:\n            excludes = tuple(str(self.options.exclude_files).split(\",\"))\n        self.copy(\"*\", dst=\"bin\", src=msys_dir, excludes=excludes)\n        shutil.copytree(os.path.join(self.package_folder, \"bin\", \"usr\", \"share\", \"licenses\"),\n                        os.path.join(self.package_folder, \"licenses\"))\n\n\n    def package_info(self):\n        msys_root = os.path.join(self.package_folder, \"bin\")\n        msys_bin = os.path.join(msys_root, \"usr\", \"bin\")\n\n        self.output.info(\"Creating MSYS_ROOT env var : %s\" % msys_root)\n        self.env_info.MSYS_ROOT = msys_root\n\n        self.output.info(\"Creating MSYS_BIN env var : %s\" % msys_bin)\n        self.env_info.MSYS_BIN = msys_bin\n\n        self.output.info(\"Appending PATH env var with : \" + msys_bin)\n        self.env_info.path.append(msys_bin)\n", "path": "recipes/msys2/all/conanfile.py"}], "after_files": [{"content": "from conans import ConanFile, tools\nfrom conans.errors import ConanInvalidConfiguration\nimport os\nimport shutil\n\n\nclass MSYS2Conan(ConanFile):\n    name = \"msys2\"\n    description = \"MSYS2 is a software distro and building platform for Windows\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"http://www.msys2.org\"\n    license = \"MSYS license\"\n    topics = (\"conan\", \"msys\", \"unix\", \"subsystem\")\n    build_requires = \"7zip/19.00\"\n    short_paths = True\n    options = {\"exclude_files\": \"ANY\",  # Comma separated list of file patterns to exclude from the package\n               \"packages\": \"ANY\",  # Comma separated\n               \"additional_packages\": \"ANY\"}    # Comma separated\n    default_options = {\"exclude_files\": \"*/link.exe\",\n                       \"packages\": \"base-devel,binutils,gcc\",\n                       \"additional_packages\": None}\n    settings = \"os_build\", \"arch_build\"\n\n    def configure(self):\n        if self.settings.os_build != \"Windows\":\n            raise ConanInvalidConfiguration(\"Only Windows supported\")\n\n    def source(self):\n        # build tools have to download files in build method when the\n        # source files downloaded will be different based on architecture or OS\n        pass\n\n    def _download(self, url, sha256):\n        from six.moves.urllib.parse import urlparse\n        filename = os.path.basename(urlparse(url).path)\n        tools.download(url, filename)\n        tools.check_sha256(filename, sha256)\n        return filename\n\n    @property\n    def _msys_dir(self):\n        return \"msys64\" if self.settings.arch_build == \"x86_64\" else \"msys32\"\n\n    def build(self):\n        arch = 0 if self.settings.arch_build == \"x86\" else 1  # index in the sources list\n        url = self.conan_data[\"sources\"][self.version][arch][\"url\"]\n        sha256 = self.conan_data[\"sources\"][self.version][arch][\"sha256\"]\n        filename = self._download(**self.conan_data[\"sources\"][self.version][arch])\n        tar_name = filename.replace(\".xz\", \"\")\n        self.run(\"7z.exe x {0}\".format(filename))\n        self.run(\"7z.exe x {0}\".format(tar_name))\n        os.unlink(filename)\n        os.unlink(tar_name)\n\n        packages = []\n        if self.options.packages:\n            packages.extend(str(self.options.packages).split(\",\"))\n        if self.options.additional_packages:\n            packages.extend(str(self.options.additional_packages).split(\",\"))\n\n        with tools.chdir(os.path.join(self._msys_dir, \"usr\", \"bin\")):\n            for package in packages:\n                self.run('bash -l -c \"pacman -S %s --noconfirm\"' % package)\n\n        # create /tmp dir in order to avoid\n        # bash.exe: warning: could not find /tmp, please create!\n        tmp_dir = os.path.join(self._msys_dir, 'tmp')\n        if not os.path.isdir(tmp_dir):\n            os.makedirs(tmp_dir)\n        tmp_name = os.path.join(tmp_dir, 'dummy')\n        with open(tmp_name, 'a'):\n            os.utime(tmp_name, None)\n\n        # Prepend the PKG_CONFIG_PATH environment variable with an eventual PKG_CONFIG_PATH environment variable\n        tools.replace_in_file(os.path.join(self._msys_dir, \"etc\", \"profile\"),\n                              'PKG_CONFIG_PATH=\"', 'PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH:')\n\n    def package(self):\n        excludes = None\n        if self.options.exclude_files:\n            excludes = tuple(str(self.options.exclude_files).split(\",\"))\n        self.copy(\"*\", dst=\"bin\", src=self._msys_dir, excludes=excludes)\n        shutil.copytree(os.path.join(self.package_folder, \"bin\", \"usr\", \"share\", \"licenses\"),\n                        os.path.join(self.package_folder, \"licenses\"))\n\n\n    def package_info(self):\n        msys_root = os.path.join(self.package_folder, \"bin\")\n        msys_bin = os.path.join(msys_root, \"usr\", \"bin\")\n\n        self.output.info(\"Creating MSYS_ROOT env var : %s\" % msys_root)\n        self.env_info.MSYS_ROOT = msys_root\n\n        self.output.info(\"Creating MSYS_BIN env var : %s\" % msys_bin)\n        self.env_info.MSYS_BIN = msys_bin\n\n        self.output.info(\"Appending PATH env var with : \" + msys_bin)\n        self.env_info.path.append(msys_bin)\n", "path": "recipes/msys2/all/conanfile.py"}]}