Skip to content

Commit 3f26d12

Browse files
committed
feat(apt): add apt functions
1 parent 396744a commit 3f26d12

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/bb-functions.d/apt.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apt::addRepo()
2727
for repo in "$@"
2828
do
2929
echoLog "Adding APT Repository '$repo': " -n
30-
if add-apt-repository "$repo" -y; then echoLog "SUCCESS!" -c; else errorLog "FAILED!" -c; fi
30+
if sudo add-apt-repository "$repo" -y; then echoLog "SUCCESS!" -c; else errorLog "FAILED!" -c; fi
3131
done
3232
}
3333
# ------------------------------------------------------------------
@@ -62,10 +62,10 @@ apt::install()
6262

6363
if [[ "$log" -eq 1 ]] && [[ -f "$BB_LOG" ]]; then
6464
echoLog "Running 'apt-get clean': " -n
65-
if apt-get clean -qq -y; then echoLog "SUCCESS!" -c; else exitLog "FAILED!" -c; fi
65+
if sudo apt-get clean -qq -y; then echoLog "SUCCESS!" -c; else exitLog "FAILED!" -c; fi
6666
else
6767
echo -n "Running 'apt-get clean': "
68-
if apt-get clean -qq -y; then echoSuccess "SUCCESS!"; else echoError "FAILED!"; fi
68+
if sudo apt-get clean -qq -y; then echoSuccess "SUCCESS!"; else echoError "FAILED!"; fi
6969
fi
7070
}
7171
# ------------------------------------------------------------------
@@ -107,10 +107,10 @@ apt::installPkg()
107107

108108
if [[ "$log" -eq 1 ]] && [[ -f "$BB_LOG" ]]; then
109109
echoLog "Installing package '$package': " -n
110-
if apt install -qq -y; then echoLog "SUCCESS!" -c; else exitLog "FAILED!" -c; [[ "$fail" -eq 1 ]] && return 1; fi
110+
if sudo apt install -qq -y; then echoLog "SUCCESS!" -c; else exitLog "FAILED!" -c; [[ "$fail" -eq 1 ]] && return 1; fi
111111
else
112112
echo -n "Installing package '$package': "
113-
if apt install -qq -y; then echoSuccess "SUCCESS!"; else echoError "FAILED!"; [[ "$fail" -eq 1 ]] && return 1; fi
113+
if sudo apt install -qq -y; then echoSuccess "SUCCESS!"; else echoError "FAILED!"; [[ "$fail" -eq 1 ]] && return 1; fi
114114
fi
115115
}
116116
# ------------------------------------------------------------------
@@ -139,10 +139,10 @@ apt::remove()
139139

140140
if [[ "${log}" -eq 1 ]] && [[ -f "$BB_LOG" ]]; then
141141
echoLog "Running 'apt-get autoremove && apt-get autoclean': " -n
142-
if apt-get autoremove && apt-get autoclean -qq -y; then echoLog "SUCCESS!" -c; else errorLog "FAILED!" -c;fi
142+
if sudo apt-get autoremove && apt-get autoclean -qq -y; then echoLog "SUCCESS!" -c; else errorLog "FAILED!" -c;fi
143143
else
144144
echo -n "Running 'apt-get autoremove && apt-get autoclean': "
145-
if apt-get autoremove && apt-get autoclean -qq -y; then echoSuccess "SUCCESS!" -c; else echoError "FAILED!" -c;fi
145+
if sudo apt-get autoremove && apt-get autoclean -qq -y; then echoSuccess "SUCCESS!" -c; else echoError "FAILED!" -c;fi
146146
fi
147147
}
148148
# ------------------------------------------------------------------
@@ -179,10 +179,10 @@ apt::removePkg()
179179

180180
if [[ "$log" -eq 1 ]] && [[ -f "$BB_LOG" ]]; then
181181
echoLog "Removing package '$package': " -n
182-
if apt purge -qq -y; then echoLog "SUCCESS!" -c; else exitLog "FAILED!" -c; fi
182+
if sudo apt purge -qq -y; then echoLog "SUCCESS!" -c; else exitLog "FAILED!" -c; fi
183183
else
184184
echo -n "Installing package '$package': "
185-
if apt purge -qq -y; then echoSuccess "SUCCESS!"; else echoError "FAILED!"; fi
185+
if sudo apt purge -qq -y; then echoSuccess "SUCCESS!"; else echoError "FAILED!"; fi
186186
fi
187187
}
188188
# ------------------------------------------------------------------
@@ -191,15 +191,15 @@ apt::removePkg()
191191
apt::findPkg()
192192
{
193193
[[ -z "$1" ]] && errorReturn "apt::findPkg :: Cowardly refusing to search for nothing!"
194-
apt-cache search "${1}"
194+
sudo apt-cache search "${1}"
195195
}
196196
# ------------------------------------------------------------------
197197
# apt::showPkg
198198
# ------------------------------------------------------------------
199199
apt::showPkg()
200200
{
201201
[[ -z "$1" ]] && errorReturn "apt::showPkg :: Cowardly refusing to show nothing!"
202-
apt-cache show "${1}"
202+
sudo apt-cache show "${1}"
203203
}
204204
# ------------------------------------------------------------------
205205
# apt::list
@@ -212,10 +212,10 @@ apt::list()
212212

213213
case "$1" in
214214
-a|--available|available)
215-
cmd="apt-cache search ."
215+
cmd="sudo apt-cache search ."
216216
;;
217217
-i|--installed|installed)
218-
cmd="apt list --installed"
218+
cmd="sudo apt list --installed"
219219
;;
220220
*)
221221
errorReturn "apt::list :: Invalid Argument '$1'!"

0 commit comments

Comments
 (0)