From e453cbc7349bdb362e47030ba79a12c9b87ec6e3 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Sun, 21 Oct 2018 00:13:58 +0200 Subject: [PATCH 1/2] Create data_tarfile with add instead of addfile Makes it possible to add symlinks and directories --- termux-create-package | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/termux-create-package b/termux-create-package index 5a01765..1585934 100755 --- a/termux-create-package +++ b/termux-create-package @@ -65,22 +65,8 @@ def write_data_tar(tar_path, installation_prefix, package_files): "Create a data.tar.xz from the specified package files." with tarfile.open(tar_path, mode='w:xz') as data_tarfile: for input_file_path in package_files: - file_stat = os.stat(input_file_path) - - # The tar file path should not start with slash: - if installation_prefix.startswith('/'): - installation_prefix = installation_prefix[1:] - if not installation_prefix.endswith('/'): - installation_prefix += '/' - output_file = installation_prefix + package_files[input_file_path] - info = tarfile.TarInfo(name=output_file) - - info.mode = file_stat.st_mode - info.mtime = file_stat.st_mtime - info.size = file_stat.st_size - with open(input_file_path, 'rb') as input_file: - data_tarfile.addfile(tarinfo=info, fileobj=input_file) + data_tarfile.add(input_file, archname=output_file, recursive=False) def create_debfile(debfile_output, directory): "Create a debfile from a directory containing control and data tar files." From 621803cb10e51e7e6f1af4a6a3e8b503ce590d13 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Mon, 29 Oct 2018 21:40:55 +0100 Subject: [PATCH 2/2] Fix typo archname -> arcname --- termux-create-package | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/termux-create-package b/termux-create-package index 1585934..5e2ea43 100755 --- a/termux-create-package +++ b/termux-create-package @@ -66,7 +66,7 @@ def write_data_tar(tar_path, installation_prefix, package_files): with tarfile.open(tar_path, mode='w:xz') as data_tarfile: for input_file_path in package_files: output_file = installation_prefix + package_files[input_file_path] - data_tarfile.add(input_file, archname=output_file, recursive=False) + data_tarfile.add(input_file_path, arcname=output_file, recursive=False) def create_debfile(debfile_output, directory): "Create a debfile from a directory containing control and data tar files."