Repository: conan-io/conan-center-index

Issue:
[package] m4/1.4.19: Fails test_package with latest Conan 2.0
### Description

Trying to build with the latest version of the CCI m4 recipe results in the following error when using Conan 2

> -------- Installing (downloading, building) binaries... --------
> cmake/3.24.2: Already installed!
> m4/1.4.19: Already installed!
> m4/1.4.19: Appending PATH environment variable: /home/marc/.conan2/p/4c23d7e6a6e4b9b7/p/bin
> WARN: The use of 'env_info' is deprecated in Conan 2.0 and will be removed in Conan 2.X. Please, update your recipes unless you are maintaining compatibility with Conan 1.X
> ERROR: m4/1.4.19: 'NoneType' object has no attribute 'append'. No default values are set for components. You are probably trying to manipulate a component attribute in the 'package_info' method without defining it previously
> ERROR: Conan-2.0 test failed for 'm4'

### Package and Environment Details

* Package Name/Version: **m4/1.4.19**
* Operating System+version: **Debian 10**
* Compiler+version: **GCC 8**
* Docker image: **N/A**
* Conan version: **conan 2.0.0-dev beta5+**
* Python version: **Python 3.7.3**


### Conan profile

Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
[options]
cmake*:bootstrap=True
[tool_requires]
!openssl*: cmake/3.24.2

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
[options]
cmake*:bootstrap=True
[tool_requires]
!openssl*: cmake/3.24.2


### Steps to reproduce

conan-2.0 test -pr:b tools.jinja -pr:h tools.jinja test_package m4/1.4.19

### Logs

<details><summary>Click to expand log</summary>

```
conan-2.0 test -pr:b tools.jinja -pr:h tools.jinja test_package m4/1.4.19

-------- Input profiles --------
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
[options]
cmake*:bootstrap=True
[tool_requires]
!openssl*: cmake/3.24.2

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
[options]
cmake*:bootstrap=True
[tool_requires]
!openssl*: cmake/3.24.2


-------- test_package: Computing dependency graph --------
Graph root
    m4/1.4.19 (test package): /tmp/tmp.Hu84j8HryY/m4/test_package/conanfile.py
Build requirements
    cmake/3.24.2#623afae5289cadc0b9f11a8f43eae83b - Cache
    m4/1.4.19#d5e4c4ec85145f2a2bfea4bceef5e56a - Cache
    openssl/1.1.1s#b304462aeda9923b735e6b37368c233e - Cache

-------- test_package: Computing necessary packages --------
Build requirements
    cmake/3.24.2#623afae5289cadc0b9f11a8f43eae83b:ccbf287e38142241463d713141c76d0c18207a9d#5e10a6d92143344f25472aa9178b24fc - Cache
    m4/1.4.19#d5e4c4ec85145f2a2bfea4bceef5e56a:3593751651824fb813502c69c971267624ced41a#028e06b2ec8f151ba5ee47e640cc2c5c - Cache
    openssl/1.1.1s#b304462aeda9923b735e6b37368c233e:896855b1e3b5961bfcc08e699116d9ed588cac00#7fbe50a5f635dbba8a47e75cf8b42165 - Skip

-------- test_package: Installing packages --------

-------- Installing (downloading, building) binaries... --------
cmake/3.24.2: Already installed!
m4/1.4.19: Already installed!
m4/1.4.19: Appending PATH environment variable: /home/marc/.conan2/p/4c23d7e6a6e4b9b7/p/bin
WARN: The use of 'env_info' is deprecated in Conan 2.0 and will be removed in Conan 2.X. Please, update your recipes unless you are maintaining compatibility with Conan 1.X
ERROR: m4/1.4.19: 'NoneType' object has no attribute 'append'. No default values are set for components. You are probably trying to manipulate a component attribute in the 'package_info' method without defining it previously
ERROR: Conan-2.0 test failed for 'm4'
```

</details>



Discussion:
Will propose fix shortly.
AFAIK, if this fix is related to env_info, it will be rejected. conan client v2 beta should be fixed, not recipe.

Resolving patch:
diff --git a/recipes/m4/all/conanfile.py b/recipes/m4/all/conanfile.py
--- a/recipes/m4/all/conanfile.py
+++ b/recipes/m4/all/conanfile.py
@@ -6,12 +6,14 @@
 from conan.tools.microsoft import is_msvc, unix_path
 from conan.tools.scm import Version
 import os
+import shutil
 
-required_conan_version = ">=1.52.0"
+required_conan_version = ">=1.55.0"
 
 
 class M4Conan(ConanFile):
     name = "m4"
+    package_type = "application"
     description = "GNU M4 is an implementation of the traditional Unix macro processor"
     topics = ("macro", "preprocessor")
     homepage = "https://www.gnu.org/software/m4/"
@@ -34,9 +36,9 @@ def package_id(self):
 
     def build_requirements(self):
         if self._settings_build.os == "Windows":
-            if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool):
-                self.tool_requires("msys2/cci.latest")
             self.win_bash = True
+            if not self.conf.get("tools.microsoft.bash:path", check_type=str):
+                self.tool_requires("msys2/cci.latest")
 
     def source(self):
         get(self, **self.conan_data["sources"][self.version],
@@ -87,11 +89,12 @@ def generate(self):
 
     def _patch_sources(self):
         apply_conandata_patches(self)
-        # dummy file for configure
-        help2man = os.path.join(self.source_folder, "help2man")
-        save(self, help2man, "#!/usr/bin/env bash\n:")
-        if os.name == "posix":
-            os.chmod(help2man, os.stat(help2man).st_mode | 0o111)
+        if shutil.which("help2man") == None:
+            # dummy file for configure
+            help2man = os.path.join(self.source_folder, "help2man")
+            save(self, help2man, "#!/usr/bin/env bash\n:")
+            if os.name == "posix":
+                os.chmod(help2man, os.stat(help2man).st_mode | 0o111)
 
     def build(self):
         self._patch_sources()
@@ -102,8 +105,7 @@ def build(self):
     def package(self):
         copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
         autotools = Autotools(self)
-        # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed
-        autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"])
+        autotools.install()
         rmdir(self, os.path.join(self.package_folder, "share"))
 
     def package_info(self):


Test patch:
diff --git a/recipes/m4/all/test_package/conanfile.py b/recipes/m4/all/test_package/conanfile.py
--- a/recipes/m4/all/test_package/conanfile.py
+++ b/recipes/m4/all/test_package/conanfile.py
@@ -32,5 +32,5 @@ def test(self):
         self.run(f"m4 -R {self.source_folder}/frozen.m4f {self.source_folder}/test.m4")
 
         output = StringIO()
-        self.run(f"m4 -P {self._m4_input_path}", output=output)
+        self.run(f"m4 -P {self._m4_input_path}", output)
         assert "Harry, Jr. met Sally" in output.getvalue()