Hello community, here is the log from the commit of package opi for openSUSE:Factory checked in at 2019-05-10 09:19:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/opi (Old) and /work/SRC/openSUSE:Factory/.opi.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "opi" Fri May 10 09:19:38 2019 rev:3 rq:701786 version:0.3.2 Changes: -------- --- /work/SRC/openSUSE:Factory/opi/opi.changes 2019-05-05 21:21:27.637283931 +0200 +++ /work/SRC/openSUSE:Factory/.opi.new.5148/opi.changes 2019-05-10 09:19:39.732452900 +0200 @@ -1,0 +2,23 @@ +Thu May 9 11:21:50 UTC 2019 - Yunhe Guo <i...@guoyunhe.me> + +- Version 0.3.1 + * Fixed + - `opi opi` cannot find `opi` + +------------------------------------------------------------------- +Thu May 9 06:46:48 UTC 2019 - Yunhe Guo <i...@guoyunhe.me> + +- Version 0.3.1 + * Fixed + - Remove quotes from version number. So Leap and SLE can search packages. + +------------------------------------------------------------------- +Wed May 8 20:57:51 UTC 2019 - Yunhe Guo <i...@guoyunhe.me> + +- Version 0.3.0 + * Added + - Support SLE + * Changed + - Better print column alignment + +------------------------------------------------------------------- Old: ---- opi-0.2.0.tar.gz New: ---- opi-0.3.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ opi.spec ++++++ --- /var/tmp/diff_new_pack.vnygCn/_old 2019-05-10 09:19:40.176453587 +0200 +++ /var/tmp/diff_new_pack.vnygCn/_new 2019-05-10 09:19:40.176453587 +0200 @@ -17,7 +17,7 @@ Name: opi -Version: 0.2.0 +Version: 0.3.2 Release: 0 Summary: OBS Package Installer (CLI) License: GPL-3.0 ++++++ opi-0.2.0.tar.gz -> opi-0.3.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.2.0/CHANGELOG.md new/opi-0.3.2/CHANGELOG.md --- old/opi-0.2.0/CHANGELOG.md 2019-05-03 13:08:23.000000000 +0200 +++ new/opi-0.3.2/CHANGELOG.md 2019-05-09 13:19:14.000000000 +0200 @@ -7,6 +7,28 @@ ## [Unreleased] +## [0.3.2] + +### Fixed + +- `opi opi` cannot find `opi` [#9](https://github.com/openSUSE-zh/opi/issues/9) + +## [0.3.1] + +### Fixed + +- Remove quotes from version number. So Leap and SLE can search packages. + +## [0.3.0] + +### Added + +- Support SLE [#8](https://github.com/openSUSE-zh/opi/issues/8) + +### Changed + +- Better print column alignment + ## [0.2.0] ### Added @@ -38,8 +60,11 @@ - Choose package and install - Keep or remove repository after installation -[Unreleased]: https://github.com/openSUSE-zh/opi/compare/v0.2.0...HEAD -[0.1.2]: https://github.com/openSUSE-zh/opi/compare/v0.1.2...v0.2.0 +[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 [0.1.2]: https://github.com/openSUSE-zh/opi/compare/v0.1.1...v0.1.2 [0.1.1]: https://github.com/openSUSE-zh/opi/compare/v0.1.0...v0.1.1 [0.1.0]: https://github.com/openSUSE-zh/opi/releases/tag/v0.1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.2.0/opi new/opi-0.3.2/opi --- old/opi-0.2.0/opi 2019-05-03 13:08:23.000000000 +0200 +++ new/opi-0.3.2/opi 2019-05-09 13:19:14.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/usr/bin/perl # # OPI - openSUSE Build Service Package Installer # @@ -73,17 +73,12 @@ # # Print package name options # -my $i = 1; -foreach my $n (@binary_names) { - print "$i. $n\n"; - $i++; -} +print_package_names(@binary_names); # # Select a package name option # -print "Choose a number: "; my $selected_name_number = type_a_number(1, scalar(@binary_names)); my $selected_name = $binary_names[$selected_name_number - 1]; @@ -95,18 +90,12 @@ # # Print binary package options # -$i = 1; -foreach my $b (@binary_options) { - print_binary_option($b, $i); - print "\n"; - $i++; -} +print_binary_options(@binary_options); # # Select a binary package option # -print "Choose a number: "; my $selected_binary_number = type_a_number(1, scalar(@binary_options)); my $selected_binary = $binary_options[$selected_binary_number - 1]; @@ -121,15 +110,27 @@ # install_binary($selected_binary); + +=begin functions + +Get system information + +=cut + sub get_distribution { my $config = Config::Tiny->read('/etc/os-release'); my $name = $config->{_}->{NAME}; my $version = $config->{_}->{VERSION}; $name = substr $name, 1, -1; # Remove quotes + if ($version) { + $version = substr $version, 1, -1; # Remove quotes + } if ($name eq 'openSUSE Tumbleweed') { return 'openSUSE:Factory'; } elsif ($name eq 'openSUSE Leap') { return 'openSUSE:Leap:' . $version; + } elsif (substr($name, 0, 3) eq 'SLE') { + return 'SLE' . $version; } else { print "Your distribution $name $version is not supported.\n"; exit 1; @@ -148,9 +149,18 @@ return $&; } + +=begin functions + +Receive user inputs + +=cut + sub type_a_number { - my $min = $_[0]; - my $max = $_[1]; + my $min = shift; + my $max = shift; + my $message = shift; + print $message || "Choose a number: "; my $typed_number = <STDIN>; chomp $typed_number; if ($typed_number =~ /^(\d+)$/) { @@ -160,34 +170,89 @@ } } - print "Number must be between $min and $max. Please try again: "; - return type_a_number(@_); + return type_a_number($min, $max, "Number must be between $min and $max. Please try again: "); +} + +sub ask_yes_or_no { + print $_[0]; + + if (lc($_[1]) eq 'y') { + print '(Y/n) '; + } else { + print '(y/N) '; + } + + my $yes_no = <STDIN>; + chomp $yes_no; + $yes_no = lc(substr($yes_no, 0, 1)); + + if (lc($_[1]) eq 'y') { + return $yes_no ne 'n'; + } else { + return $yes_no eq 'y'; + } +} + +sub ask_keep_repo { + my $repo = $_[0]; + unless ( ask_yes_or_no("Do you want to keep these repositories? ", 'y') ) { + system "sudo zypper removerepo $repo"; + } +} + +=begin functions + +Print package lists + +=cut + +sub print_package_names { + my $i = 1; + foreach my $n (@_) { + printf("%2d. %s\n", $i, $n); + $i++; + } +} + +sub print_binary_options { + my $i = 1; + foreach my $b (@_) { + print_binary_option($b, $i); + $i++; + } } sub print_binary_option { - my $binary = $_[0]; - my $number = $_[1]; + my $binary = shift; + my $number = shift; my $color; my $symbol; if (is_official_project($binary->{project})) { $color = 'green'; - $symbol = '✓'; + $symbol = '+'; } elsif (is_personal_project($binary->{project})) { $color = 'red'; - $symbol = '?'; + $symbol = '!'; } else { $color = 'cyan'; - $symbol = '+'; + $symbol = '?'; } + my $colored_name = colored(substr($binary->{project}, 0, 39) . ' ' . $symbol, $color); + if ($number) { - print "$number. "; + printf("%2d. %-50s | %-10s | %-10s\n", $number, $colored_name, $binary->{version}, $binary->{arch}); + } else { + print $colored_name, " | ", $binary->{version}, " | ", $binary->{arch}; } - - print colored($binary->{project} . ' ' . $symbol, $color); - print " | $binary->{version} | $binary->{arch}"; } +=begin functions + +Search OBS API + +=cut + sub prepare_query_string { my $query_string = join "', '", @_; $query_string = "'" . $query_string . "'"; @@ -235,6 +300,11 @@ next; } + # Filter out branch projects + if ( $binary->{project} =~ /:branches:/m ) { + next; + } + # Filter out debuginfo, debugsource, buildsymbols packages if ( substr($binary->{'name'}, -10) eq '-debuginfo' ) { next; @@ -271,11 +341,17 @@ } } +=begin functions + +Handle binary data + +=cut + sub get_binary_names { my @names = (); foreach my $bin (@_) { my $name = $bin->{'name'}; - if (! grep /($name)/, @names) { + if (! grep /^$name$/, @names) { push @names, $name; } } @@ -283,34 +359,31 @@ } 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 { @@ -339,33 +412,11 @@ return @filtered_binary_list; } +=begin functions -sub ask_yes_or_no { - print $_[0]; +Add repository and install packages - if (lc($_[1]) eq 'y') { - print '(Y/n) '; - } else { - print '(y/N) '; - } - - my $yes_no = <STDIN>; - chomp $yes_no; - $yes_no = lc(substr($yes_no, 0, 1)); - - if (lc($_[1]) eq 'y') { - return $yes_no ne 'n'; - } else { - return $yes_no eq 'y'; - } -} - -sub ask_keep_repo { - my $repo = $_[0]; - unless ( ask_yes_or_no("Do you want to keep these repositories? ", 'y') ) { - system "sudo zypper removerepo $repo"; - } -} +=cut sub install_binary { my $binary = $_[0]; @@ -393,7 +444,7 @@ } sub install_packman_codecs { - unless ( ask_yes_or_no("Do you want install codecs from Packman reposiroty? ", 'y') ) { + unless ( ask_yes_or_no("Do you want to install codecs from Packman repository? ", 'y') ) { return; } @@ -436,7 +487,7 @@ } sub install_vs_code { - unless ( ask_yes_or_no("Do you want install VS Code from Microsoft reposiroty? ", 'y') ) { + unless ( ask_yes_or_no("Do you want to install VS Code from Microsoft repository? ", 'y') ) { return; } @@ -453,7 +504,7 @@ } sub install_skype { - unless ( ask_yes_or_no("Do you want install Skype from Microsoft reposiroty? ", 'y') ) { + unless ( ask_yes_or_no("Do you want to install Skype from Microsoft repository? ", 'y') ) { return; }