From 73f9dd3b9279754bf7124495394db63e337e2943 Mon Sep 17 00:00:00 2001 From: Guo Yunhe Date: Thu, 9 May 2019 14:19:14 +0300 Subject: [PATCH] Fix #9 `opi opi` not found --- CHANGELOG.md | 9 ++++++++- opi | 29 +++++++++++++---------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82bba0a..3474d0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.3.2] + +### Fixed + +- `opi opi` cannot find `opi` [#9](https://github.com/openSUSE-zh/opi/issues/9) + ## [0.3.1] ### Fixed @@ -54,7 +60,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Choose package and install - Keep or remove repository after installation -[Unreleased]: https://github.com/openSUSE-zh/opi/compare/v0.3.1...HEAD +[Unreleased]: https://github.com/openSUSE-zh/opi/compare/v0.3.2...HEAD +[0.3.2]: https://github.com/openSUSE-zh/opi/compare/v0.3.1...v0.3.2 [0.3.1]: https://github.com/openSUSE-zh/opi/compare/v0.3.0...v0.3.1 [0.3.0]: https://github.com/openSUSE-zh/opi/compare/v0.2.0...v0.3.0 [0.2.0]: https://github.com/openSUSE-zh/opi/compare/v0.1.2...v0.2.0 diff --git a/opi b/opi index a8dad29..ffe8f76 100755 --- a/opi +++ b/opi @@ -351,7 +351,7 @@ sub get_binary_names { my @names = (); foreach my $bin (@_) { my $name = $bin->{'name'}; - if (! grep /($name)/, @names) { + if (! grep /^$name$/, @names) { push @names, $name; } } @@ -359,34 +359,31 @@ sub get_binary_names { } sub get_binary_weight { - my $binary = $_[0]; - my $weights = { - official => 0, - main => 0, - dashes => 0, - arch => 0, - }; + my $binary = shift; + my $weight = 0; if ( is_official_project($binary->{'project'}) ) { - $weights->{official} = 20000; + $weight += 20000; } elsif ( is_personal_project($binary->{'project'}) ) { - $weights->{official} = 0; + $weight += 0; } else { - $weights->{official} = 10000; + $weight += 10000; } if ( $binary->{'name'} eq $binary->{'package'} ) { - $weights->{main} = 1000; + $weight += 1000; } my $dash_count = () = $binary->{'name'} =~ /-/g; - $weights->{dashes} = 100 * (0.5**$dash_count); + $weight += 100 * (0.5**$dash_count); - if ($binary->{'arch'} eq 'x86_64') { - $weights->{arch} = 10; + unless (get_architecture() eq 'x86_64' && $binary->{'arch'} eq 'i586') { + $weight += 10; } - return $weights->{official} + $weights->{main} + $weights->{dashes} + $weights->{arch}; + $weight += - length $binary->{name}; + + return $weight; } sub is_official_project {