forked from platformio/platformio-core
Fix issue with package packing when re-map is used and manifest is missed in "include" (copy it now)
This commit is contained in:
@ -12,6 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@ -77,12 +78,7 @@ class PackagePacker(object):
|
|||||||
elif os.path.isdir(dst):
|
elif os.path.isdir(dst):
|
||||||
dst = os.path.join(dst, filename)
|
dst = os.path.join(dst, filename)
|
||||||
|
|
||||||
return self._create_tarball(
|
return self._create_tarball(src, dst, manifest)
|
||||||
src,
|
|
||||||
dst,
|
|
||||||
include=manifest.get("export", {}).get("include"),
|
|
||||||
exclude=manifest.get("export", {}).get("exclude"),
|
|
||||||
)
|
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(tmp_dir)
|
shutil.rmtree(tmp_dir)
|
||||||
|
|
||||||
@ -114,7 +110,9 @@ class PackagePacker(object):
|
|||||||
|
|
||||||
return src
|
return src
|
||||||
|
|
||||||
def _create_tarball(self, src, dst, include=None, exclude=None):
|
def _create_tarball(self, src, dst, manifest):
|
||||||
|
include = manifest.get("export", {}).get("include")
|
||||||
|
exclude = manifest.get("export", {}).get("exclude")
|
||||||
# remap root
|
# remap root
|
||||||
if (
|
if (
|
||||||
include
|
include
|
||||||
@ -122,6 +120,10 @@ class PackagePacker(object):
|
|||||||
and os.path.isdir(os.path.join(src, include[0]))
|
and os.path.isdir(os.path.join(src, include[0]))
|
||||||
):
|
):
|
||||||
src = os.path.join(src, include[0])
|
src = os.path.join(src, include[0])
|
||||||
|
with open(os.path.join(src, "library.json"), "w") as fp:
|
||||||
|
manifest_updated = manifest.copy()
|
||||||
|
del manifest_updated["export"]["include"]
|
||||||
|
json.dump(manifest_updated, fp, indent=2, ensure_ascii=False)
|
||||||
include = None
|
include = None
|
||||||
|
|
||||||
src_filters = self.compute_src_filters(include, exclude)
|
src_filters = self.compute_src_filters(include, exclude)
|
||||||
|
@ -61,7 +61,10 @@ def test_filters(tmpdir_factory):
|
|||||||
)
|
)
|
||||||
p = PackagePacker(str(pkg_dir))
|
p = PackagePacker(str(pkg_dir))
|
||||||
with tarfile.open(p.pack(str(pkg_dir)), "r:gz") as tar:
|
with tarfile.open(p.pack(str(pkg_dir)), "r:gz") as tar:
|
||||||
assert set(tar.getnames()) == set(["util/helpers.cpp", "main.cpp"])
|
assert set(tar.getnames()) == set(
|
||||||
|
["util/helpers.cpp", "main.cpp", "library.json"]
|
||||||
|
)
|
||||||
|
os.unlink(str(src_dir.join("library.json")))
|
||||||
|
|
||||||
# test include "src" and "include"
|
# test include "src" and "include"
|
||||||
pkg_dir.join("library.json").write(
|
pkg_dir.join("library.json").write(
|
||||||
|
Reference in New Issue
Block a user