-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpackages
executable file
·67 lines (53 loc) · 1.76 KB
/
packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
from collections import namedtuple
import csv
import subprocess
def dependencies():
PackageTuple = namedtuple('Package', 'name aur')
with open('./packages.csv') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
if row[1] == '0':
aur = False
else:
aur = True
yield PackageTuple(name=row[0], aur=aur)
class Pacman:
def query(self):
"""
Get the result of 'pacman -Q' as a list of tuples, this is a generator.
@returns Yields a named tuple with .name and .version
"""
PackageTuple = namedtuple('Package', 'name version')
stdout = subprocess.run(["pacman", "-Q"], stdout=subprocess.PIPE).stdout
stdout = stdout.decode('utf8')
for line in stdout.split('\n'):
if line == '':
continue
parts = line.split(' ')
yield PackageTuple(name=parts[0], version=parts[1])
if __name__ == '__main__':
pacman = Pacman()
deps = list(dependencies())
uninstalled = list(deps)
for dep in deps:
for pkg in pacman.query():
if dep.name == pkg.name:
uninstalled.remove(dep)
aur = []
official = []
for pkg in uninstalled:
if pkg.aur:
aur.append(pkg)
else:
official.append(pkg)
if aur:
print("Please install the following packages from the AUR:")
for pkg in aur:
print(" - {}".format(pkg.name))
if official:
print("Please install the following packages")
for pkg in official:
print(" - {}".format(pkg.name))
if not aur and not official:
print("All dependencies are installed")