euscan: deb handler - adding support for Packages.gz or Packages.bz2 and version detection fix
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
fd204f7b1f
commit
26fae25aec
3
TODO
3
TODO
@ -38,8 +38,7 @@ euscan
|
|||||||
### handlers
|
### handlers
|
||||||
|
|
||||||
- remote-id type deb repository:
|
- remote-id type deb repository:
|
||||||
- Fix handler to support Packages.gz or Packages.bz2
|
- find out how to get download url (not sure it's possible)
|
||||||
- find out how to get download url
|
|
||||||
|
|
||||||
### remote-id
|
### remote-id
|
||||||
- Propose new remote-id: deb
|
- Propose new remote-id: deb
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import re
|
import re
|
||||||
|
import bz2
|
||||||
|
import zlib
|
||||||
|
|
||||||
import portage
|
import portage
|
||||||
|
|
||||||
@ -24,17 +26,22 @@ def scan_pkg(pkg, options):
|
|||||||
fp = urllib.urlopen(packages_url)
|
fp = urllib.urlopen(packages_url)
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
|
|
||||||
# TODO: Add support for .gz and .bz2 Packages file
|
# Support for .gz and .bz2 Packages file
|
||||||
|
if packages_url.endswith(".bz2"):
|
||||||
|
content = bz2.decompress(content)
|
||||||
|
if packages_url.endswith(".gz"):
|
||||||
|
content = zlib.decompress(content, 16 + zlib.MAX_WBITS)
|
||||||
|
|
||||||
content = content.split("\n\n")
|
content = content.split("\n\n")
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
for package_info in content:
|
for package_info in content:
|
||||||
for line in package_info.split("\n"):
|
package_line = re.search(r"^Package: (.*)$", package_info, re.M)
|
||||||
res = re.search("^Version: (.*)$", line)
|
version_line = re.search(r"^Version: (.*)$", package_info, re.M)
|
||||||
if res:
|
if package_line and package_line.group(1) == package_name:
|
||||||
result.append(res.group(1))
|
if version_line:
|
||||||
|
result.append(version_line.group(1))
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
for up_pv in result:
|
for up_pv in result:
|
||||||
|
Loading…
Reference in New Issue
Block a user