mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-04 09:21:12 -05:00
PkgInfo: drop CentOS fetcher
This has broken in CentOS 8 and isn't feasible to maintain anymore, given the lack of a proper API.
This commit is contained in:
parent
8ddf4a101a
commit
bcf43ba48d
@ -1,6 +1,5 @@
|
|||||||
Fetches package information from the repositories of various \*nix distributions. Currently it supports:
|
Fetches package information from the repositories of various \*nix distributions. Currently it supports:
|
||||||
- Arch Linux
|
- Arch Linux
|
||||||
- CentOS (via a separate `centos` command)
|
|
||||||
- Debian
|
- Debian
|
||||||
- Fedora
|
- Fedora
|
||||||
- FreeBSD
|
- FreeBSD
|
||||||
@ -86,19 +85,6 @@ The `pkgsearch` command provides package searches on various distros. This suppo
|
|||||||
<atlas> Found 55 results: cosmic/universe (1:6.0.3-0ubuntu1 [amd64, i386]), cosmic (1:6.0.3-0ubuntu1 [source]), bionic/universe (1:6.0.3-0ubuntu1 [amd64, i386]), bionic (1:6.0.3-0ubuntu1 [source]), artful-updates/universe (1:5.4.6-0ubuntu0.17.10.1 [amd64, i386]), artful-updates (1:5.4.6-0ubuntu0.17.10.1 [source]), artful-security/universe (1:5.4.5-0ubuntu0.17.10.5 [amd64, i386]), artful-security (7 more messages)
|
<atlas> Found 55 results: cosmic/universe (1:6.0.3-0ubuntu1 [amd64, i386]), cosmic (1:6.0.3-0ubuntu1 [source]), bionic/universe (1:6.0.3-0ubuntu1 [amd64, i386]), bionic (1:6.0.3-0ubuntu1 [source]), artful-updates/universe (1:5.4.6-0ubuntu0.17.10.1 [amd64, i386]), artful-updates (1:5.4.6-0ubuntu0.17.10.1 [source]), artful-security/universe (1:5.4.5-0ubuntu0.17.10.5 [amd64, i386]), artful-security (7 more messages)
|
||||||
```
|
```
|
||||||
|
|
||||||
### CentOS packages
|
|
||||||
|
|
||||||
**Synopsis**: `centos <release> [<repository> <package name>] [--arch <arch>] [--startswith|--exact]`
|
|
||||||
|
|
||||||
This lookup command is provided as a separate command due to very limited searching abilities through the CentOS website.
|
|
||||||
|
|
||||||
```
|
|
||||||
<GLolol> `centos 7 os zsh
|
|
||||||
<Atlas> Available RPMs: zsh-5.0.2-7.el7.x86_64.rpm and zsh-html-5.0.2-7.el7.x86_64.rpm
|
|
||||||
<GLolol> `centos 7 os python
|
|
||||||
<Atlas> Available RPMs: MySQL-python-1.2.3-11.el7.x86_64.rpm, OpenIPMI-python-2.0.19-11.el7.x86_64.rpm, abrt-addon-python-2.1.11-19.el7.centos.0.3.x86_64.rpm, abrt-python-2.1.11-19.el7.centos.0.3.x86_64.rpm, abrt-python-doc-2.1.11-19.el7.centos.0.3.noarch.rpm, antlr-python-2.7.7-30.el7.noarch.rpm, at-spi-python-1.32.0-12.el7.x86_64.rpm, audit-libs-python-2.4.1-5.el7.x86_64.rpm, (25 more messages)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Implementation Details
|
## Implementation Details
|
||||||
|
|
||||||
This plugin uses the following APIs:
|
This plugin uses the following APIs:
|
||||||
|
@ -683,90 +683,6 @@ class PkgInfo(callbacks.Plugin):
|
|||||||
e = "No results found."
|
e = "No results found."
|
||||||
irc.error(e)
|
irc.error(e)
|
||||||
|
|
||||||
@wrap(['positiveInt', additional('somethingWithoutSpaces'), additional('somethingWithoutSpaces'),
|
|
||||||
getopts({'arch': 'somethingWithoutSpaces', 'exact': '', 'startswith': ''})])
|
|
||||||
def centos(self, irc, msg, args, release, repo, query, opts):
|
|
||||||
"""<release> [<repository> <package name>] [--arch <arch>] [--startswith|--exact]
|
|
||||||
|
|
||||||
Looks up <package> in CentOS's repositories. <release> is the release
|
|
||||||
version (6, 7, etc.), and <repository> is the repository name.
|
|
||||||
You can find a list of possible repository names here:
|
|
||||||
http://mirror.centos.org/centos/7/ (each folder is a repository).
|
|
||||||
|
|
||||||
Supported values for <arch> include x86_64 and i386 (prior to CentOS 7),
|
|
||||||
and defaults to x86_64.
|
|
||||||
|
|
||||||
If <repository> is not given, a list of available ones will be shown instead.
|
|
||||||
|
|
||||||
If --startswith is given, results starting with the given query are shown. If --exact
|
|
||||||
is given, only exact matches are shown."""
|
|
||||||
|
|
||||||
# TL;DR CentOS doesn't have a package lookup interface, but only an autoindexed
|
|
||||||
# file server... We must find all repositories, package URLs, etc. that way.
|
|
||||||
opts = dict(opts)
|
|
||||||
exact = opts.get('exact')
|
|
||||||
startswith = opts.get('startswith')
|
|
||||||
arch = opts.get('arch') or 'x86_64'
|
|
||||||
|
|
||||||
url = 'http://mirror.centos.org/centos/%s' % release
|
|
||||||
if repo:
|
|
||||||
if query:
|
|
||||||
query = query.lower()
|
|
||||||
# Both repo and package name were given, so look in folders there.
|
|
||||||
# Note: different CentOS versions different paths for their pool, ugh.
|
|
||||||
for folder in ('Packages', 'RPMS', 'openstack-juno', 'openstack-kilo',
|
|
||||||
'CentOS'):
|
|
||||||
url = 'http://mirror.centos.org/centos/%s/%s/%s/%s/' % \
|
|
||||||
(release, repo, arch, folder)
|
|
||||||
self.log.debug("PkgInfo: trying url %s for 'centos' command", url)
|
|
||||||
try:
|
|
||||||
fd = utils.web.getUrl(url).decode("utf-8")
|
|
||||||
except utils.web.Error:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
irc.error('Unknown repository %r.' % repo, Raise=True)
|
|
||||||
else:
|
|
||||||
# Giving a repository but no package name is useless. Usually there
|
|
||||||
# are too many results to display without filtering anyways.
|
|
||||||
irc.error("Missing package query.", Raise=True)
|
|
||||||
else: # No repository given; list the ones available.
|
|
||||||
fd = utils.web.getUrl(url).decode("utf-8")
|
|
||||||
|
|
||||||
soup = BeautifulSoup(fd)
|
|
||||||
# The first two tables are for the navigation bar; the third is the actual autoindex
|
|
||||||
# content.
|
|
||||||
res = []
|
|
||||||
packagetable = soup.find_all('table')[2]
|
|
||||||
|
|
||||||
for tr in packagetable.find_all('tr')[3:]:
|
|
||||||
try:
|
|
||||||
entry = tr.find_all('td')[1].a.text
|
|
||||||
except IndexError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
entry = entry.lower()
|
|
||||||
if not query: # No query filter given; show everything.
|
|
||||||
res.append(entry)
|
|
||||||
elif exact: # Match a package name in the format 'name'-version
|
|
||||||
package_pattern = '^{}-[0-9]+'.format(query)
|
|
||||||
if re.search(package_pattern, entry):
|
|
||||||
res.append(entry)
|
|
||||||
continue
|
|
||||||
elif startswith:
|
|
||||||
if entry.startswith(query): # startswith() match
|
|
||||||
res.append(entry)
|
|
||||||
continue
|
|
||||||
elif query in entry: # Default substring search
|
|
||||||
res.append(entry)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if res:
|
|
||||||
irc.reply(format('Found %n: %L; View more at: %u', (len(res), 'result'), res, url))
|
|
||||||
else:
|
|
||||||
irc.error('No results found.')
|
|
||||||
|
|
||||||
Class = PkgInfo
|
Class = PkgInfo
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2014-2017, James Lu
|
# Copyright (c) 2014-2019, James Lu
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -96,11 +96,4 @@ class PkgInfoTestCase(PluginTestCase):
|
|||||||
def test_filesearch(self):
|
def test_filesearch(self):
|
||||||
self.assertRegexp('filesearch sid supybot', 'limnoria')
|
self.assertRegexp('filesearch sid supybot', 'limnoria')
|
||||||
|
|
||||||
def test_centos(self):
|
|
||||||
self.assertRegexp('centos 7 os git-', 'git-all')
|
|
||||||
self.assertRegexp('centos 6 os bash --arch i386', 'i686.rpm')
|
|
||||||
self.assertNotError('centos 7 extras python')
|
|
||||||
# This should be stripped.
|
|
||||||
self.assertNotRegexp('centos 7 extras "a"', 'Parent Directory')
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user