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

Improve generated .ebuild output #132

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

hololeap
Copy link
Member

This is a PR for generally improving the quality of generated .ebuild files. Example .ebuild files have been added for "golden" testing. Moving forward, these will serve as guidelines or templates for how we want .ebuild files to look.

We can leverage the use of the prettyprinter package, which won't add much dependency footprint since it is also needed by optparse-applicative. This will be very useful for improving the showEBuild function (shown partially here).

-- | Pretty-print an 'EBuild' as a 'String'.
showEBuild :: TC.UTCTime -> EBuild -> String
showEBuild now ebuild =
ss ("# Copyright 1999-" ++ this_year ++ " Gentoo Authors"). nl.
ss "# Distributed under the terms of the GNU General Public License v2". nl.
nl.


@hololeap hololeap requested a review from solpeth August 25, 2023 05:55
@hololeap
Copy link
Member Author

hololeap commented Aug 25, 2023

@solpeth, I'd like you to take a look at the golden/example .ebuild files I included and let me know if you have any input on the formatting.

I selected these because they should cover the full range of issues we've been experiencing for generated ebuilds. They will serve as a template for how generated ebuilds should look:


Edit: @thesamesam if you have any input on how to improve the formatting of these example ebuilds, I'd be interested in your opinion.

@hololeap
Copy link
Member Author

.out files are simply data dumps, which were generated by pretty-simple outputting live EBuilds. They can be read from the file directly as EBuild data.

This data is fed into showEBuild, whose output is then compared to the corresponding golden .ebuild file.

@hololeap hololeap marked this pull request as ready for review August 25, 2023 06:24
hololeap and others added 14 commits March 4, 2024 19:32
This will assist testing by allowing EBuild data to be read from a file

Signed-off-by: hololeap <[email protected]>
Add "golden" tests which compare generated output to example ebuild
files. This will help aid development of improvements for ebuild output.

Signed-off-by: hololeap <[email protected]>
- Use an asterisk at the end of the version when possible
- Add newline to DEPEND
- Avoid backslashes by passing an array to src_configure
- Drop trailing .0 components

Thanks-to: Sam James <[email protected]>
Signed-off-by: hololeap <[email protected]>
Some rendering utility functions and Prettyprinter re-exports

Signed-off-by: hololeap <[email protected]>
Drop unused functions in Portage.Ebuild and associated test

Signed-off-by: hololeap <[email protected]>
LinesBuilder is a custom Monad that works by building up a list of
prettyprinter Docs and then concats them with vcat. It is helpful for
when a logical piece of the ebuild may use a variable number of lines,
including no lines at all (for instance when no CABAL_HACKAGE_REVISION
or CABAL_PN are used).

Improve some formatting

Signed-off-by: hololeap <[email protected]>
@hololeap
Copy link
Member Author

hololeap commented Aug 9, 2024

@049940

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