grüß euch,
ich möchte mir das skript
pacman2aria2 aus dem AUR anpassen, und zwar mit meiner mirrorlist statt dem reflector… nur hab ich keine ahnung wie ichs bewerkstelligen kann, ich möchte nämlich pakete parallel runter laden, jetzt wo ich endlich eine schnellere verbindung ins netz hab^^
#!/usr/bin/env python3
import os.path, sys
from operator import itemgetter
from random import shuffle
from Reflector import MirrorStatus, parse_args, process_options
MIRROR_URL_FORMAT = MirrorStatus.MIRROR_URL_FORMAT
REPOSITORIES = MirrorStatus.REPOSITORIES
ARCHITECTURES = MirrorStatus.ARCHITECTURES
if __name__ == "__main__":
# Prepend a simple help message to clarify the Reflector help message.
if '-h' in sys.argv or '--help' in sys.argv:
print('''USAGE:
pacman -Sp --print-format '%r %l' ... | {0} <reflector options> | aria2c -i - ...
{0} accepts a formatted list of pacman package URLs from STDIN and then uses
Reflector to generate a download list that can be passed to aria2c.
The following help message is directly from Reflector. Most options apply,
including all filtering options.
REFLECTOR HELP MESSAGE
'''.format(sys.argv[0]))
options = parse_args()
# keys: repo names, values: package URLs
packages = {}
# For tallying architectures to make the best guess of the host architecture.
# This is to avoid relying on specific executables, system features, or pacman
# configuration file parsing.
arches = dict.fromkeys(ARCHITECTURES, 0)
for line in sys.stdin.readlines():
# Ignore Pacman spam.
if not '.pkg.' in line:
continue
repo, url = line.strip().split(' ', 2)
try:
packages[repo].append(url)
except KeyError:
packages[repo] = [url]
for arch in ARCHITECTURES:
# Mirror repo URLs will contain /$arch/.
if "/%s/" % arch in url:
arches[arch] += 1
# Packages will contain "-$arch.pkg."
if "-%s.pkg." % arch in url:
arches[arch] += 1
# Determine the most likely architecture.
# In the event that values in the arches dictionary are 0 due to "any" packages,
# then it shouldn't matter which architecture we use, so this should be fairly
# reliable.
arch = sorted(arches.items(), key=itemgetter(1), reverse=True)[0][0]
if packages:
# Get the mirrors.
ms, mirrors = process_options(options)
mirrors = [ m['url'] for m in mirrors ]
# Print out the Aria2 input file.
for repo, urls in packages.items():
if repo in REPOSITORIES:
for url in urls:
# Shuffle the mirrors to balance the load.
shuffle(mirrors)
urlbase = os.path.basename(url)
print( '\t'.join( [ MIRROR_URL_FORMAT.format(m, repo, arch) + '/' + urlbase for m in mirrors ] ) )
else:
for url in urls:
print( url )
das funktioniert so leider nicht:
if packages:
# Get the mirrors.
ms, mirrors = process_options(options)
mirrors = /etc/pacman.d/mirrorlist