Closed automorphism88 closed 6 years ago
I made the new fix-paths-in-binary.sed
script a little more robust than was strictly required for this ebuild, so that it can be more easily used with other ebuilds:
/etc/printcap.local
is replaced with /etc/printcap
, even though with this ebuild, that replacement is only necessary in a shell script (which is patched by the modified fix-paths.sed
instead as it's a text file).b
command is used to deal with multiple matches in a single null-byte delimited string, even though that doesn't occur with either of the binaries that need to be patched in this case. It's not possible to just use the g
flag to the s
command, as is done with fix-paths.sed
for text files, since we need to make sure the appropriate number of null bytes are added to the end of the string. So, instead, after a replacement, we just branch back to the top of the sed script to look for additional matches in that "line" (i.e. null-delimited string, due to the sed -z
option).Note that the sed -z
option is absolutely necessary with this script (as indicated by the shebang, though that's basically just a comment, since the script isn't executed directly, but via sed -f
), to ensure that the padding null bytes are added in the correct location. To use these sed scripts with other ebuilds, just choose the appropriate one depending on the file being patched (fix-paths.sed
for text files and fix-paths-in-binary.sed
for binaries) and make sure to use the sed -z
option when patching binaries. I envision eventually wrapping this in an eclass function to recursively search a directory (e.g. ${S}
), automatically determine whether each file within is text or binary, and patch it accordingly.
Thanks for the pull request and again for the very informative explanation.
This fixes a few bugs in the ebuild I previously submitted. In particular, printing through the CUPS wrapper worked, but CUPS settings, e.g., for paper size, were not applied properly. This was due to two problems:
/opt/brother/Printers/MFC7460DN/inf/brMFC7460DNrc
needs to be owned bylp:lp
instead ofroot:root
. I also set the mode to 0600 to match the behavior of the upstream install script./usr/local
paths need to be replaced in additional files, including the precompiled binaries. Luckily, this isn't a problem, since the/opt
path is shorter, allowing strings to be padded at the end with null bytes.