Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import os
import subprocess
base = [f.rsplit('-', 3)[0] for f in os.listdir('..') if f.endswith('.xz')]
downloaded = {'sh'}
def clean(p):
return p.split('>=')[0].split('=')[0]
def deps(pkg):
if pkg == 'awk':
pkg = 'gawk'
out = subprocess.check_output(
'pacman -Si "{0}"|grep "Depends On"'.format(pkg),
shell=True,
)
return [clean(p) for p in
out[len('Depends On : '):].decode().strip().split()
if p not in ['None', 'libncursesw.so=6-64']]
def provides(pkg):
if pkg == 'awk':
pkg = 'gawk'
out = subprocess.check_output(
'pacman -Si "{0}"|grep "Provides :"'.format(pkg),
shell=True,
)
return [clean(p) for p in out[len("Provides : "):].decode().strip().split()
if p not in ['None']]
def download(dep):
link = subprocess.check_output('pacman -Sp {0}'.format(dep),
shell=True).decode().strip()
path = link.rsplit(os.sep)[-1]
if not os.path.exists(path):
print("downloading {0}".format(dep))
subprocess.check_output('wget {0}'.format(link), shell=True)
def resolve(pkg):
if pkg in downloaded:
return
print("resolving {0}".format(pkg))
dependencies = deps(pkg)
for dep in dependencies:
resolve(dep)
download(dep)
downloaded.add(pkg)
for provided in provides(pkg):
downloaded.add(provided)
for pkg in base:
resolve(pkg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.