-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacman.sh
executable file
·63 lines (53 loc) · 2.26 KB
/
pacman.sh
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
#!/bin/bash
################################################################################################
# Filename: .../dotfiles/pacman.sh #
# Purpose: File that manage the package manager pacman #
# Authors: Giulio Coa <34110430+giulioc008@users.noreply.github.com>, Christian Mondo #
# License: This file is licensed under the LGPLv3. #
# Pre-requisites: #
# * pacman #
# * sudo #
################################################################################################
if ! command -v sudo > /dev/null 2> /dev/null; then
echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: ${bold_red:-}sudo isn't installed${reset:-}" > /dev/stderr
exit 1
elif ! command -v pacman > /dev/null 2> /dev/null; then
echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: ${bold_red:-}pacman isn't installed${reset:-}" > /dev/stderr
exit 1
fi
# Remove all the cached packages that are not currently installed and the unused sync database
pacman-clear() {
sudo pacman --sync --clean
}
# Remove all cached file
pacman-clear-all() {
sudo pacman --sync --clean --clean
}
# Install list of packages without reinstall the already installed ones
pacman-install() {
# the parameter $@ is the list of package that you want install
sudo pacman --sync --needed "$@"
}
# List explicitly installed packages
pacman-list-installed() {
sudo pacman --query --explicit --native
}
# List installed packages
pacman-list-installed-all() {
sudo pacman --query --native
}
# Remove packages, their dependencies not required and configurations
pacman-remove() {
# the parameter $@ is the list of package that you want remove
sudo pacman --remove --nosave --recursive "$@" \
&& pacman-clear
}
# Upgrade all packages
pacman-upgrade() {
# PackageKit support
if command -v pkcon > /dev/null 2> /dev/null; then
sudo pkcon refresh && sudo pkcon update
fi
sudo pacman --sync --refresh --sysupgrade \
&& pacman-clear
}