Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bdist_deb: catch a cpio 2.13 bug #2402

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions cx_Freeze/command/bdist_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def run(self) -> None:
rpm_filename = None
for command, _, filename in self.distribution.dist_files:
if command == "bdist_rpm":
rpm_filename = filename
rpm_filename = os.path.basename(filename)
break
if rpm_filename is None:
msg = "could not build rpm"
Expand All @@ -87,14 +87,32 @@ def run(self) -> None:

# convert rpm to deb (by default in dist directory)
logging.info("building DEB")
cmd = ["alien", "--to-deb", os.path.basename(rpm_filename)]
cmd = ["alien", "--to-deb", rpm_filename]
if os.getuid() != 0:
cmd.insert(0, "fakeroot")
if self.dry_run:
self.spawn(cmd)
else:
logging.info(subprocess.list2cmdline(cmd))
output = subprocess.check_output(cmd, text=True, cwd=self.dist_dir)
process = subprocess.run(
cmd,
text=True,
capture_output=True,
check=False,
cwd=self.dist_dir,
)
if process.returncode != 0:
msg = process.stderr.splitlines()[0]
if msg.startswith(f"Unpacking of '{rpm_filename}' failed at"):
info = [
"\n\t\x08Please check if you have `cpio 2.13` on "
"Ubuntu 22.04.",
"\t\x08You can try to install a previous version:",
"\t\x08$ sudo apt-get install cpio=2.13+dfsg-7",
]
msg += "\n".join(info)
raise ExecError(msg)
output = process.stdout
logging.info(output)
filename = output.splitlines()[0].split()[0]
filename = os.path.join(self.dist_dir, filename)
Expand Down
12 changes: 8 additions & 4 deletions tests/test_command_bdist_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ def test_bdist_deb_simple(datafiles: Path) -> None:
check=False,
cwd=datafiles,
)
print(process.stdout)
if process.returncode != 0:
if "failed to find 'alien'" in process.stderr:
msg = process.stderr
if "failed to find 'alien'" in msg:
pytest.xfail("alien not installed")
elif "Unpacking of '" in msg and "' failed at" in msg:
pytest.xfail("cpio 2.13 bug")
else:
pytest.fail(process.stderr)

Expand All @@ -114,10 +116,12 @@ def test_bdist_deb(datafiles: Path) -> None:
check=False,
cwd=datafiles,
)
print(process.stdout)
if process.returncode != 0:
if "failed to find 'alien'" in process.stderr:
msg = process.stderr
if "failed to find 'alien'" in msg:
pytest.xfail("alien not installed")
elif "Unpacking of '" in msg and "' failed at" in msg:
pytest.xfail("cpio 2.13 bug")
else:
pytest.fail(process.stderr)

Expand Down