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

net-print/brother-mfc7460dn-bin: Fix CUPS settings #53

Merged

Conversation

automorphism88
Copy link
Contributor

@automorphism88 automorphism88 commented Apr 20, 2018

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:

  1. The file /opt/brother/Printers/MFC7460DN/inf/brMFC7460DNrc needs to be owned by lp:lp instead of root:root. I also set the mode to 0600 to match the behavior of the upstream install script.
  2. The /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.

@automorphism88 automorphism88 force-pushed the mfc7460dn branch 14 times, most recently from 07757eb to a4a28e7 Compare April 21, 2018 16:07
@automorphism88
Copy link
Contributor Author

automorphism88 commented Apr 21, 2018

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).
  • The 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.

@stefan-langenmaier stefan-langenmaier merged commit 5a9d0a8 into stefan-langenmaier:master May 2, 2018
@stefan-langenmaier
Copy link
Owner

Thanks for the pull request and again for the very informative explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants