-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtux.rb
executable file
·148 lines (116 loc) · 2.57 KB
/
tux.rb
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env ruby
require_relative 'which'
require_relative 'PkgMgrs'
args=ARGV
argsShift=[]
for i in args do
argsShift.push(i)
end
argsShift.shift
for i in argsShift do
pkgArgs = "#{pkgArgs} #{i}"
end
#package managers to check for
pkgMgrs = ["#{$debianBased}",
"#{$archLinux}",
"#{$voidLinux}"]
#iterate over list of package managers
#pass this to which(), take result and set it to pkgMgr
for i in pkgMgrs do
if which(i) then
pkgMgr=i
break
end
end
# since some package managers have hyphens
# and since methods can't have hyphens,
# we take out any existing hyphens and replace them with underscores
pkgMgr = pkgMgr.tr('-', '_')
# check for and execute methods with the same name as pkgMgr contains
send(pkgMgr)
#pull variables from currently loaded method, e.g pacman()
install = "#{$installCmd} #{pkgArgs}"
reinstall = "#{$reinstallCmd} #{pkgArgs}"
search = "#{$searchCmd} #{pkgArgs}"
update = "#{$updateCmd} #{pkgArgs}"
remove = "#{$removeCmd} #{pkgArgs}"
force_remove = "#{$recursiveRemoveCmd} #{pkgArgs}"
sync = "#{$syncCmd} #{pkgArgs}"
supdate = "#{$syncANDupdateCmd} #{pkgArgs}"
clean = "#{$cleanCmd}"
case args[0]
# Install Options
when
"i",
"-i",
"-S",
"add",
"get",
"install"; system ("sudo #{install}")
when
"ri",
"-ri",
"reinstall"; system ("sudo #{reinstall}")
# Search options
when
"s",
"se",
"-s",
"-Ss",
"find",
"search"; system (search)
# Update options (without syncing)
when
"u",
"up",
"-u",
"-Su",
"upgrade"; system ("sudo #{update}")
# Remove options
when
"r",
"rm",
"-R",
"remove",
"delete"; system ("sudo #{remove}")
when
"-rf",
"-Rdd",
"force-remove"; system ("sudo #{force_remove}")
when
"c",
"-c",
"clean"; system ("sudo #{clean}")
# Sync options
when
"sy",
"-Sy",
"sync",
"refresh"; system ("sudo #{sync}")
# Update options (with syncing)
when
"su",
"sup",
"-Syu",
"syncup"; system ("sudo #{supdate}")
when
"-v",
"--version"; puts """
tux v0.1 - Universal package manager wrapper
\u00A9 2015 Justin Moore
"""
else
puts """
Usage : tux [options] [arguments]
Options:
i, -S, install Install a package
ri, -ri, reinstall Reinstall a package
r, -R, remove Remove a package
c, -c, clean Remove orphan packages
s, -Ss, search Search remote repository
sy, -Sy, sync Sync package list from remote repository
u, -Su, upgrade Upgrade packages on the system
su, -Syu, sup Sync package list and upgrade system
-v, --version Show current version
"""
end