I've looked a bit into it and found some interesting things.

First, there is an upstream (as I've understood) "deps.sh" file, which
pulls "cramfs-tools" and installs "cramfsck" as well as "mkcramfs" (haven't found mentions of mkcramfs being used anywhere).
I'm not understanding the Debian's package system at all, but at least
in the package's source repo that I've checked out there is no mention of "deps.sh" anywhere else except the "Dockerfile" that is also provided by upstream.

I've attached a patch. It is not to be forwarded upstream as it really
is a fix for how the package is in Debian repository. I could've added those lines so that binwalk would try to use one tool and then the other, spamming the console with warnings as it goes, but it does not seem like a good approach to me.

Please note that there is a difference in how fsck.cramfs extracts
the file compared to cramfsck: cramfsck keeps all symlinks as they are while fsck.cramfs replaces symlinks that point out of extraction dir to point to /dev/null.

If you want to go down "fsck.cramfs" route then it is also required to deal with it not being available in /usr/bin as well as adding dependency to util-linux. I'm sorry but I've experienced enough of package buildsystem for today so I hope that someone who knows it better could do it. Modifying "debian/control" file just didn't work for whatever reason. I will also note that in case of failure the "clean" target at "dpkg-buildpackage" does not clean the leftover "__pycache__" directories as well as:
 - testing/tests/.coverage
 - testing/tests/.config/
 - src/binwalk.egg-info/
which results in errors while trying to rebuild package once more, but it is very likely that I'm just using wrong tools for the job.

Maybe a better approach would be to actually do what "deps.sh" file wants to do -- download the cramfs-tools and compile cramfsck. It's a small binary after all, which does exactly what the original author intended (bad symlinks are more descriptive than /dev/null, if a bit dangerous).

If you need any additional info/tests/whatnot then feel free to write back. Sorry if I'm doing something wrong, the intention is to help with the problem I've found but I'm new to the Debian processes.
Description: Use fsck.cramfs instead of cramfsck
 As cramfs-tools is not installed in Debian the cramfsck is
 unavailable, but we have util-linux and fsck.cramfs from it which
 can serve the same purpose.
 The util-linux is added as a recommended dependency.
Author: Shorrer <shor...@yandex.by>
Bug: https://github.com/ReFirmLabs/binwalk/issues/623
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050604
Forwarded: no
Last-Update: 2023-08-27
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: python3-binwalk/src/binwalk/config/extract.conf
===================================================================
--- python3-binwalk.orig/src/binwalk/config/extract.conf
+++ python3-binwalk/src/binwalk/config/extract.conf
@@ -59,9 +59,9 @@
 ^squashfs filesystem:squashfs:sasquatch -p 1 -le -d '%%squashfs-root%%' 
'%e':0:False
 ^squashfs filesystem:squashfs:sasquatch -p 1 -be -d '%%squashfs-root%%' 
'%e':0:False
 
-# Try cramfsck first; if that fails, swap the file system and try again
-^cramfs filesystem:cramfs:cramfsck -x '%%cramfs-root%%' '%e':0:False
-^cramfs filesystem:cramfs:cramfsswap '%e' '%e.swap' && cramfsck -x 
'%%cramfs-root%%' '%e.swap':0:False
+# Try fsck.cramfs first; if that fails, swap the file system and try again
+^cramfs filesystem:cramfs:fsck.cramfs --extract='%%cramfs-root%%' '%e':0:False
+^cramfs filesystem:cramfs:cramfsswap '%e' '%e.swap' && fsck.cramfs 
--extract='%%cramfs-root%%' '%e.swap':0:False
 
 # Extract EXT filesystems using sleuth kit
 ^linux ext:ext:tsk_recover -i raw -f ext -a -v '%e' '%%ext-root%%':0:False

Reply via email to