Skip to content

Commit

Permalink
Added useflags check thanks to appi 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
apinsard committed Aug 12, 2017
1 parent 209619d commit 221a10a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 18 deletions.
13 changes: 10 additions & 3 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down Expand Up @@ -65,8 +65,9 @@ Usage

chuse [-f|--force] <atom> [[modifier]<flag> ...] [--because <reason>]
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 <atom>
Print current flags set and history.
chuse (-h|--help)
Expand Down Expand Up @@ -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
23 changes: 17 additions & 6 deletions chuse
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = "[email protected]"
__status__ = "Production"
Expand Down Expand Up @@ -72,8 +72,9 @@ def usage():
uinfo = (
"chuse [-f|--force] <atom> [[modifier]<flag> ...] [--because <reason>]\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 <atom>\n"
" Print current flags set and history.\n"
"chuse (-h|--help)\n"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 13 additions & 4 deletions chuse.pod
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -130,20 +131,28 @@ 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<https://github.com/apinsard/chuse/issues>
Please report bugs on gitlab L<https://gitlab.com/apinsard/chuse/issues>

=head1 AUTHOR

Antoine Pinsard <[email protected]>

=head1 VERSION

1.1
1.2

=head1 SEE ALSO

Expand Down

0 comments on commit 221a10a

Please sign in to comment.