-
Notifications
You must be signed in to change notification settings - Fork 0
/
cower_script.py
executable file
·68 lines (47 loc) · 1.54 KB
/
cower_script.py
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
68
#! /usr/bin/python3
''' Script to install packages from AUR downloaded via cower
Copyright 2017, Victor Otieno
Licensed under MIT license'''
import os
build_directory = '~/builds'
build_directory = os.path.expanduser(build_directory)
cower_command = 'cower -vdu'
def print_info(string):
print('[-] ' + string)
def print_error(string):
print('[X] ' + string)
def get_input(string):
return input(string)
def install(packages):
packages = sorted(packages)
if not packages:
print_info('No packages to install.')
else:
print_info('Installing packages...')
for package in packages:
os.chdir(package)
os.system('makepkg -sri')
os.chdir('..')
os.system('rm -r {}'.format(package))
print_info('Done. \n')
def main():
os.chdir(build_directory)
for paths, directories, files in os.walk('.'):
if directories:
print_info('Found existing packages:')
response = get_input(
'Do you want to install these packages: Y or N \n')
if response.lower() == 'y':
install(directories)
else:
print_info('Deleting existing packages...')
for directory in directories:
os.system('rm -r {}'.format(directory))
print_info('Done. \n')
print_info('Checking for updates:')
os.system(cower_command)
print_info('Done. \n')
packages = os.listdir()
install(packages)
if __name__ == '__main__':
main()