diff --git a/ChangeLog b/ChangeLog index a38f687..6bdd21b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ # Change Log +## [1.2] - 2017-08-12 +### Changed +- Check that ebuilds matched by the atom accept the given useflags to avoid + typos + ## [1.1] - 2017-01-12 ### Added - Possibility to configure file pattern in /etc/chuse.conf @@ -42,6 +47,8 @@ - Default modifier is now "+" instead of error on missing modifier - Made PEP8 compliant -[1.0.2]: https://github.com/apinsard/chuse/compare/1.0.1...1.0.2 -[1.0.1]: https://github.com/apinsard/chuse/compare/1.0...1.0.1 -[1.0]: https://github.com/apinsard/chuse/compare/0.1...1.0 +[1.2]: https://gitlab.com/apinsard/chuse/compare/1.1...1.2 +[1.1]: https://gitlab.com/apinsard/chuse/compare/1.0.2...1.1 +[1.0.2]: https://gitlab.com/apinsard/chuse/compare/1.0.1...1.0.2 +[1.0.1]: https://gitlab.com/apinsard/chuse/compare/1.0...1.0.1 +[1.0]: https://gitlab.com/apinsard/chuse/compare/0.1...1.0 diff --git a/README.md b/README.md index 2bb2495..a8321db 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ a clean structure. On the other hand, you rarely have more than 10 lines in your Installation ------------ -Chuse is available from the [sapher overlay][1]. It is also available in the main Funtoo tree. +Chuse is available from [flora overlay][1]. It is also available in the main Funtoo tree. Once you have added this overlay, just emerge `chuse`. @@ -65,8 +65,9 @@ Usage chuse [-f|--force] [[modifier] ...] [--because ] Alter use flags. By default, if the given atom doesn't match any existing ebuild, - an error will be raised. Use -f/--force option to disable this behavior. If no flag - is specified, the current rules matching the underlying atom will be displayed. + or if one of the given useflags doesn't seem to exist, an error will be raised. + Use -f/--force option to disable this behavior. If no flag is specified, the + current rules matching the underlying atom will be displayed. chuse Print current flags set and history. chuse (-h|--help) @@ -123,7 +124,16 @@ the --force (shortly -f) option to disable this behavior: $ sudo chuse unexisting/package +foo -bar Error: This atom does not match any existing ebuild. Use --force option - to proceed anyway + to proceed anyway. $ sudo chuse -f unexisting/package +foo -bar -[1]: https://github.com/apinsard/sapher-overlay +As of version 1.2, useflags existence is also checked: + + $ sudo chuse dev-db/postgresql python -fanfan_la_tulipe dartagnan + Error: No ebuild matched by the given atom accepts such use flags: + dartagnan, fanfan_la_tulipe. Make sure you did not make a typo, or use + --force option to proceed anyway. + $ sudo chuse -f dev-db/postgresql python -fanfan_la_tulipe dartagnan + + +[1]: https://github.com/funtoo/flora diff --git a/chuse b/chuse index e83d0f4..286046c 100755 --- a/chuse +++ b/chuse @@ -25,7 +25,7 @@ __author__ = "Antoine Pinsard" __copyright__ = "Copyright (C) 2017 Antoine Pinsard" __credits__ = ["Antoine Pinsard"] __license__ = "GPL-2" -__version__ = "1.1" +__version__ = "1.2" __maintainer__ = "Antoine Pinsard" __email__ = "antoine.pinsard@gmail.com" __status__ = "Production" @@ -72,8 +72,9 @@ def usage(): uinfo = ( "chuse [-f|--force] [[modifier] ...] [--because ]\n" " Alter use flags. By default, if the given atom doesn't match any existing ebuild,\n" - " an error will be raised. Use -f/--force option to disable this behavior. If no flag\n" - " is specified, the current rules matching the underlying atom will be displayed.\n" + " or if one of the given useflags doesn't seem to exist, an error will be raised.\n" + " Use -f/--force option to disable this behavior. If no flag is specified, the\n" + " current rules matching the underlying atom will be displayed.\n" "chuse \n" " Print current flags set and history.\n" "chuse (-h|--help)\n" @@ -98,7 +99,7 @@ def usage(): def version_info(): - webpage = "https://github.com/apinsard/chuse" + webpage = "https://gitlab.com/apinsard/chuse" vinfo = ("Chuse version %(version)s, %(copyright)s\n" "Chuse comes with ABSOLUTELY NO WARRANTY\n" "This is free software, and you are welcome to redistribute it\n" @@ -203,7 +204,7 @@ def read_current_flags(atom): break # Another matching line would be foolish except FileNotFoundError: pass # Then there is no flag for now - except NotADirectory: + except NotADirectoryError: raise PackageUseError() return useflags @@ -244,7 +245,7 @@ def write_changes(atom, flags, comment): os.makedirs(os.path.dirname(filename)) except FileExistsError: pass # Then we don't need to create it - except NotADirectory: + except NotADirectoryError: raise PackageUseError() if not found_existing_atom: @@ -443,6 +444,16 @@ def main(): if reason: comment += '\n' + reason + if not force: + unexisting_flags = set(new_flags.keys()).difference( + atom.list_possible_useflags()) + if unexisting_flags: + error(( + "No ebuild matched by the given atom accepts such use " + "flags: {}. Make sure you did not make a typo, or use " + "--force option to proceed anyway." + ).format(', '.join(unexisting_flags))) + try: write_changes(atom, new_flags, comment) except PackageUseError as e: diff --git a/chuse.pod b/chuse.pod index 05b8dec..e8a1a9f 100644 --- a/chuse.pod +++ b/chuse.pod @@ -48,7 +48,8 @@ this and if you can reset default in the future for instance). =item B<-f --force> -Force writting changes even if no ebuild seems to satisfy the given atom. +Force writting changes even if no ebuild seems to satisfy the given atom or +none of the matched ebuilds seems to accept one of the given useflags. =item B<--dump> @@ -130,12 +131,20 @@ the --force (shortly -f) option to disable this behavior: $ sudo chuse unexisting/package +foo -bar Error: This atom does not match any existing ebuild. Use --force option - to proceed anyway + to proceed anyway. $ sudo chuse -f unexisting/package +foo -bar +As of version 1.2, useflags existence is also checked: + + $ sudo chuse dev-db/postgresql python -fanfan_la_tulipe dartagnan + Error: No ebuild matched by the given atom accepts such use flags: + dartagnan, fanfan_la_tulipe. Make sure you did not make a typo, or use + --force option to proceed anyway. + $ sudo chuse -f dev-db/postgresql python -fanfan_la_tulipe dartagnan + =head1 BUGS -Please report bugs on github L +Please report bugs on gitlab L =head1 AUTHOR @@ -143,7 +152,7 @@ Antoine Pinsard =head1 VERSION -1.1 +1.2 =head1 SEE ALSO