commit opi for openSUSE:Factory
Hello community, here is the log from the commit of package opi for openSUSE:Factory checked in at 2019-05-24 11:30:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/opi (Old) and /work/SRC/openSUSE:Factory/.opi.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "opi" Fri May 24 11:30:05 2019 rev:4 rq:704744 version:0.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/opi/opi.changes 2019-05-10 09:19:39.732452900 +0200 +++ /work/SRC/openSUSE:Factory/.opi.new.5148/opi.changes 2019-05-24 11:30:11.749424845 +0200 @@ -1,0 +2,14 @@ +Wed May 22 13:09:33 UTC 2019 - Yunhe Guo <i@guoyunhe.me> + +- Version 0.5.0 + * Added + - API proxy server to prevent hard-coded passwords in the script + +------------------------------------------------------------------- +Tue May 21 11:58:53 UTC 2019 - Yunhe Guo <i@guoyunhe.me> + +- Version 0.4.0 + * Added + - PMBS (Packman Build Service) support + +------------------------------------------------------------------- Old: ---- opi-0.3.2.tar.gz New: ---- opi-0.5.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ opi.spec ++++++ --- /var/tmp/diff_new_pack.SNh5UY/_old 2019-05-24 11:30:12.429424670 +0200 +++ /var/tmp/diff_new_pack.SNh5UY/_new 2019-05-24 11:30:12.433424669 +0200 @@ -17,7 +17,7 @@ Name: opi -Version: 0.3.2 +Version: 0.5.0 Release: 0 Summary: OBS Package Installer (CLI) License: GPL-3.0 ++++++ opi-0.3.2.tar.gz -> opi-0.5.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/CHANGELOG.md new/opi-0.5.0/CHANGELOG.md --- old/opi-0.3.2/CHANGELOG.md 2019-05-09 13:19:14.000000000 +0200 +++ new/opi-0.5.0/CHANGELOG.md 2019-05-22 15:07:16.000000000 +0200 @@ -7,6 +7,18 @@ ## [Unreleased] +## [0.5.0] + +### Added + +- API proxy server to prevent hard-coded passwords in the script [#4](https://github.com/openSUSE-zh/opi/issues/4) + +## [0.4.0] + +### Added + +- PMBS (Packman Build Service) support [#5](https://github.com/openSUSE-zh/opi/issues/5) + ## [0.3.2] ### Fixed @@ -60,7 +72,9 @@ - Choose package and install - Keep or remove repository after installation -[Unreleased]: https://github.com/openSUSE-zh/opi/compare/v0.3.2...HEAD +[Unreleased]: https://github.com/openSUSE-zh/opi/compare/v0.5.0...HEAD +[0.5.0]: https://github.com/openSUSE-zh/opi/compare/v0.4.0...v0.5.0 +[0.4.0]: https://github.com/openSUSE-zh/opi/compare/v0.3.2...v0.4.0 [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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/README.md new/opi-0.5.0/README.md --- old/opi-0.3.2/README.md 2019-05-09 13:19:14.000000000 +0200 +++ new/opi-0.5.0/README.md 2019-05-22 15:07:16.000000000 +0200 @@ -2,6 +2,11 @@ **O**BS **P**ackage **I**nstaller +Search and install almost all packages available for openSUSE and SLE: + +1. openSUSE Build Service +2. Packman + ## System Requirements - openSUSE Tumbleweed, openSUSE Leap 42.1+, SLE 12+ @@ -13,8 +18,24 @@ ## Install +### openSUSE Tumbleweed + +``` +sudo zypper install opi ``` -sudo zypper addrepo https://download.opensuse.org/repositories/home:guoyunhe/openSUSE_Tumbleweed... + +## Leap and SLE + +``` +# Leap 15.0 +sudo zypper addrepo https://download.opensuse.org/repositories/home:guoyunhe/openSUSE_Leap_15.0/... +# Leap 15.1 +sudo zypper addrepo https://download.opensuse.org/repositories/home:guoyunhe/openSUSE_Leap_15.1/... +# Leap 42.3 +sudo zypper addrepo https://download.opensuse.org/repositories/home:guoyunhe/openSUSE_Leap_42.3/... +# SLE 15 +sudo zypper addrepo https://download.opensuse.org/repositories/home:guoyunhe/SLE_15/home:guoyunh... + sudo zypper refresh sudo zypper install opi ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/opi new/opi-0.5.0/opi --- old/opi-0.3.2/opi 2019-05-09 13:19:14.000000000 +0200 +++ new/opi-0.5.0/opi 2019-05-22 15:07:16.000000000 +0200 @@ -54,15 +54,15 @@ # # API configuration # -my $username = 'wiki_hermes'; -my $password = 'w_h_p1'; -my $server = "https://$username:$password\@api.opensuse.org"; - +my $obs_apiroot = 'https://api.opensuse.org'; +my $pmbs_apiroot = 'https://pmbs.links2linux.de'; # # Search packages # -my @bins = search_published_binary(@ARGV); +my @obs = search_published_binary('openSUSE', $obs_apiroot, @ARGV); +my @pmbs = search_published_binary('Packman', $pmbs_apiroot, @ARGV); +my @bins = sort_binaries(@obs, @pmbs); my @binary_names = get_binary_names(@bins); if (!scalar(@bins)) { @@ -118,6 +118,7 @@ =cut sub get_distribution { + my $prefix = shift; my $config = Config::Tiny->read('/etc/os-release'); my $name = $config->{_}->{NAME}; my $version = $config->{_}->{VERSION}; @@ -126,15 +127,19 @@ $version = substr $version, 1, -1; # Remove quotes } if ($name eq 'openSUSE Tumbleweed') { - return 'openSUSE:Factory'; + $name = 'openSUSE:Factory'; } elsif ($name eq 'openSUSE Leap') { - return 'openSUSE:Leap:' . $version; + $name = 'openSUSE:Leap:' . $version; } elsif (substr($name, 0, 3) eq 'SLE') { - return 'SLE' . $version; + $name = 'SLE' . $version; } else { print "Your distribution $name $version is not supported.\n"; exit 1; } + if ($prefix) { + $name = 'openSUSE.org:' . $name; + } + return $name; } sub get_architecture { @@ -238,10 +243,16 @@ $symbol = '?'; } - my $colored_name = colored(substr($binary->{project}, 0, 39) . ' ' . $symbol, $color); + my $project = $binary->{project}; + my $obs_instance = $binary->{obs_instance}; + if ($obs_instance ne 'openSUSE') { + $project = "$obs_instance $project"; + } + + my $colored_name = colored(substr($project, 0, 39) . ' ' . $symbol, $color); if ($number) { - printf("%2d. %-50s | %-10s | %-10s\n", $number, $colored_name, $binary->{version}, $binary->{arch}); + printf("%2d. %-50s | %-10s | %-10s\n", $number, $colored_name, substr($binary->{version}, 0, 10), $binary->{arch}); } else { print $colored_name, " | ", $binary->{version}, " | ", $binary->{arch}; } @@ -261,16 +272,23 @@ } sub search_published_binary { - my $distribution = get_distribution(); + my $obs_instance = shift; + my $obs_apiroot = shift; + + my $distribution = get_distribution($obs_instance ne 'openSUSE'); + + my $proxy_root = 'https://guoyunhe.me/opi/proxy/index.php'; my $endpoint = '/search/published/binary/id'; my $query_string = prepare_query_string(@_); my $xpath = "contains-ic(\@name, $query_string) and path/project='$distribution'"; - my $url = $server . $endpoint . '?match=' . uri_escape($xpath); + my $url = $obs_apiroot . $endpoint . '?match=' . uri_escape($xpath); + + my $prox_url = $proxy_root . '?obs_api_link=' . uri_escape($url) . '&obs_instance=' . $obs_instance; - my $req = HTTP::Request->new(GET => $url); + my $req = HTTP::Request->new(GET => $prox_url); my $ua = LWP::UserAgent->new; my $resp = $ua->request($req); if ($resp->is_success) { @@ -284,6 +302,7 @@ foreach my $binary ($dom->findnodes('/collection/binary')) { my %binary_data; + $binary_data{'obs_instance'} = $obs_instance; $binary_data{'name'} = $binary->getAttribute('name'); $binary_data{'project'} = $binary->getAttribute('project'); $binary_data{'package'} = $binary->getAttribute('package'); @@ -295,33 +314,43 @@ $binary_data{'filepath'} = $binary->getAttribute('filepath'); $binary_data{'baseproject'} = $binary->getAttribute('baseproject'); $binary_data{'type'} = $binary->getAttribute('type'); - # Filter out ghost binary (package has been deleted, but binary still exists) + + # Filter out ghost binary + # (package has been deleted, but binary still exists) if ( ! $binary_data{'package'} ) { next; } # Filter out branch projects - if ( $binary->{project} =~ /:branches:/m ) { + if ( $binary_data{'project'} =~ /:branches:/m ) { + next; + } + + # Filter out Packman personal projects + if ( + $binary_data{'obs_instance'} ne 'openSUSE' + && is_personal_project($binary_data{'project'}) + ) { next; } # Filter out debuginfo, debugsource, buildsymbols packages - if ( substr($binary->{'name'}, -10) eq '-debuginfo' ) { + if ( substr($binary_data{'name'}, -10) eq '-debuginfo' ) { next; - } elsif ( substr($binary->{'name'}, -12) eq '-debugsource' ) { + } elsif ( substr($binary_data{'name'}, -12) eq '-debugsource' ) { next; - } elsif ( substr($binary->{'name'}, -13) eq '-buildsymbols' ) { + } elsif ( substr($binary_data{'name'}, -13) eq '-buildsymbols' ) { next; } # Filter out source packages - if ( $binary->{'arch'} eq 'src' ) { + if ( $binary_data{'arch'} eq 'src' ) { next; } # Filter architecture - unless ( $binary->{'arch'} eq $arch || $binary->{'arch'} eq 'noarch') { - unless ( $binary->{'arch'} eq 'i586' && $arch eq 'x86_64' ) { + unless ( $binary_data{'arch'} eq $arch || $binary_data{'arch'} eq 'noarch') { + unless ( $binary_data{'arch'} eq 'i586' && $arch eq 'x86_64' ) { next; } } @@ -329,7 +358,7 @@ push @collection, \%binary_data; } - return sort { -get_binary_weight($a) <=> -get_binary_weight($b) } @collection; + return @collection; } else { if ($resp->code == 413) { @@ -358,6 +387,10 @@ return @names; } +sub sort_binaries { + return sort { -get_binary_weight($a) <=> -get_binary_weight($b) } @_; +} + sub get_binary_weight { my $binary = shift; my $weight = 0; @@ -419,14 +452,21 @@ =cut sub install_binary { - my $binary = $_[0]; + my $binary = shift; my $name = $binary->{name}; + my $obs_instance = $binary->{obs_instance}; my $arch = $binary->{arch}; my $project = $binary->{project}; my $repository = $binary->{repository}; + # Install Packman packages + if ($obs_instance eq 'Packman') { + add_packman_repo(); + + install_packman_packages("$name.$arch"); + } # Install official packages. Don't add repositories - if (is_official_project($project)) { + elsif (is_official_project($project)) { system "sudo zypper install $name.$arch"; } # Install experimental and personal packages @@ -448,9 +488,9 @@ return; } - add_packman_essentials_repo(); + add_packman_repo(1); - install_packman_essentials_packages( + install_packman_packages( 'ffmpeg', 'gstreamer-plugins-bad', 'gstreamer-plugins-libav', @@ -467,7 +507,8 @@ exit; } -sub add_packman_essentials_repo { +sub add_packman_repo { + my $dup = shift; my $prefix = get_distribution(); $prefix =~ s/:/_/ig; @@ -476,14 +517,17 @@ $prefix = 'openSUSE_Tumbleweed'; } - system "sudo zypper addrepo --refresh --priority 90 https://ftp.gwdg.de/pub/linux/misc/packman/suse/$prefix/Essentials/packman-e..."; + system "sudo zypper addrepo --refresh --priority 90 https://ftp.gwdg.de/pub/linux/misc/packman/suse/$prefix/packman.repo"; system "sudo zypper refresh"; - system "sudo zypper dist-upgrade --from packman-essentials --allow-downgrade --allow-vendor-change"; + + if ($dup) { + system "sudo zypper dist-upgrade --from packman --allow-downgrade --allow-vendor-change"; + } } -sub install_packman_essentials_packages { +sub install_packman_packages { my $packages = join ' ', @_; - system "sudo zypper install --repo packman-essentials $packages"; + system "sudo zypper install --repo packman $packages"; } sub install_vs_code { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/proxy/.gitignore new/opi-0.5.0/proxy/.gitignore --- old/opi-0.3.2/proxy/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/opi-0.5.0/proxy/.gitignore 2019-05-22 15:07:16.000000000 +0200 @@ -0,0 +1,2 @@ +vendor +config.php diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/proxy/composer.json new/opi-0.5.0/proxy/composer.json --- old/opi-0.3.2/proxy/composer.json 1970-01-01 01:00:00.000000000 +0100 +++ new/opi-0.5.0/proxy/composer.json 2019-05-22 15:07:16.000000000 +0200 @@ -0,0 +1,5 @@ +{ + "require": { + "davedevelopment/stiphle": "^0.9.2" + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/proxy/composer.lock new/opi-0.5.0/proxy/composer.lock --- old/opi-0.3.2/proxy/composer.lock 1970-01-01 01:00:00.000000000 +0100 +++ new/opi-0.5.0/proxy/composer.lock 2019-05-22 15:07:16.000000000 +0200 @@ -0,0 +1,70 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "8be3fec76a27c45a4bf9c51a99f497b1", + "packages": [ + { + "name": "davedevelopment/stiphle", + "version": "0.9.2", + "source": { + "type": "git", + "url": "https://github.com/davedevelopment/stiphle.git", + "reference": "76151e6474741adee258c1a4860a0460e319563b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/davedevelopment/stiphle/zipball/76151e6474741ad...", + "reference": "76151e6474741adee258c1a4860a0460e319563b", + "shasum": "" + }, + "require": { + "php": ">=5.3.1" + }, + "require-dev": { + "phpunit/phpunit": "^5.5", + "predis/predis": "^1.1" + }, + "suggest": { + "doctrine/cache": "~1.0", + "predis/predis": "~1.1" + }, + "type": "library", + "autoload": { + "psr-0": { + "Stiphle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Simple rate limiting/throttling for php", + "homepage": "http://github.com/davedevelopment/stiphle", + "keywords": [ + "rate limit", + "rate limiting", + "throttle", + "throttling" + ], + "time": "2017-08-16T07:58:18+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/proxy/config.example.php new/opi-0.5.0/proxy/config.example.php --- old/opi-0.3.2/proxy/config.example.php 1970-01-01 01:00:00.000000000 +0100 +++ new/opi-0.5.0/proxy/config.example.php 2019-05-22 15:07:16.000000000 +0200 @@ -0,0 +1,8 @@ +<?php + +# Copy and rename this file to 'config.php' and fill in your API credentials + +$obs_username = ''; +$obs_password = ''; +$pmbs_username = ''; +$pmbs_password = ''; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opi-0.3.2/proxy/index.php new/opi-0.5.0/proxy/index.php --- old/opi-0.3.2/proxy/index.php 1970-01-01 01:00:00.000000000 +0100 +++ new/opi-0.5.0/proxy/index.php 2019-05-22 15:07:16.000000000 +0200 @@ -0,0 +1,23 @@ +<?php + +# Test it with `php -S localhost:8000 index.php` + +require __DIR__ . '/vendor/autoload.php'; +require __DIR__ . '/config.php'; + +# TODO add API rate limits. + +$obs_api_link = $_GET['obs_api_link']; +$obs_instance = $_GET['obs_instance']; # OBS / Packman + +if ($obs_instance === 'openSUSE') { + $username = $obs_username; + $password = $obs_password; +} elseif ($obs_instance === 'Packman') { + $username = $pmbs_username; + $password = $pmbs_password; +} + +$obs_api_link = str_replace('://', "://$username:$password@", $obs_api_link); + +echo file_get_contents($obs_api_link);
participants (1)
-
root