2023-11-15 21:31:08 +01:00
|
|
|
# Copyright 2011 Corentin Chary <corentin.chary@gmail.com>
|
|
|
|
# Copyright 2020-2023 src_prepare group
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
|
2012-09-21 19:03:53 +02:00
|
|
|
import bz2
|
2023-11-14 22:04:18 +01:00
|
|
|
import re
|
|
|
|
import urllib.error
|
|
|
|
import urllib.parse
|
|
|
|
import urllib.request
|
2012-09-21 19:03:53 +02:00
|
|
|
import zlib
|
2012-09-14 16:56:52 +02:00
|
|
|
|
|
|
|
import portage
|
|
|
|
|
2023-11-14 22:04:18 +01:00
|
|
|
from euscan import helpers, mangling, output
|
2012-09-14 16:56:52 +02:00
|
|
|
|
|
|
|
HANDLER_NAME = "deb"
|
|
|
|
CONFIDENCE = 100
|
|
|
|
PRIORITY = 90
|
|
|
|
|
|
|
|
|
|
|
|
def can_handle(pkg, url=None):
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def scan_pkg(pkg, options):
|
|
|
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
|
|
|
|
2023-11-14 22:03:53 +01:00
|
|
|
packages_url, package_name = options["data"].strip().split(" ", 1)
|
2012-09-14 16:56:52 +02:00
|
|
|
|
|
|
|
output.einfo("Using Debian Packages: " + packages_url)
|
|
|
|
|
2019-12-05 17:46:19 +01:00
|
|
|
fp = urllib.request.urlopen(packages_url)
|
2012-09-14 16:56:52 +02:00
|
|
|
content = fp.read()
|
|
|
|
|
2012-09-21 19:03:53 +02:00
|
|
|
# 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)
|
2012-09-14 16:56:52 +02:00
|
|
|
|
|
|
|
content = content.split("\n\n")
|
|
|
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
for package_info in content:
|
2012-09-21 19:03:53 +02:00
|
|
|
package_line = re.search(r"^Package: (.*)$", package_info, re.M)
|
|
|
|
version_line = re.search(r"^Version: (.*)$", package_info, re.M)
|
|
|
|
if package_line and package_line.group(1) == package_name:
|
|
|
|
if version_line:
|
|
|
|
result.append(version_line.group(1))
|
2012-09-14 16:56:52 +02:00
|
|
|
|
|
|
|
ret = []
|
|
|
|
for up_pv in result:
|
|
|
|
url = "" # TODO: How to find the url?
|
|
|
|
pv = mangling.mangle_version(up_pv, options)
|
|
|
|
if helpers.version_filtered(cp, ver, pv):
|
|
|
|
continue
|
|
|
|
ret.append((url, pv, HANDLER_NAME, CONFIDENCE))
|
|
|
|
return ret
|