-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpacman.sh
107 lines (90 loc) · 2.97 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
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
_patch_help() {
if [[ "$*" == "pacman" ]]; then
:;
else
$@ --help | sed '/^usage:/ {s/{.*}//;s/(s)/.../}'
fi
}
_patch_table() {
table="$( \
_patch_table_edit_options \
'--sysroot(<dir>)' \
)"
if [[ "$*" == "pacman" ]]; then
echo "$table" | \
_patch_table_edit_commands \
';;' \
'(--database, -D);Operate on the package database.' \
'(--files, -F);Query the files database.' \
'(--query, -Q);Query the package database' \
'(--remove, -R);Remove package(s) from the system' \
'(--sync, -S);Synchronize packages' \
'(--deptest, -T);Check dependencies' \
'(--upgrade, -U);Upgrade or add package(s) to the system and install the required dependencies from sync repositories.' \
elif [[ "$*" == "pacman --database" ]]; then
echo "$table" | \
_patch_table_edit_arguments 'package;[`_choice_database`]'
elif [[ "$*" == "pacman --files" ]]; then
echo "$table" | \
_patch_table_edit_arguments 'file;[`_choice_file_database`]'
elif [[ "$*" == "pacman --query" ]]; then
echo "$table" | \
_patch_table_edit_options \
'--file(<package-file>)' \
'--groups;[`_choice_package_group`]' \
| \
_patch_table_edit_arguments 'package;[`_choice_installed_package`]'
elif [[ "$*" == "pacman --remove" ]]; then
echo "$table" | \
_patch_table_edit_arguments 'package;[`_choice_installed_package`]'
elif [[ "$*" == "pacman --sync" ]]; then
echo "$table" | \
_patch_table_edit_options \
'--groups;[`_choice_package_group`]' \
'--ignore;[`_choice_package`]' \
'--ignoregroup;[`_choice_package_group`]' \
'--list;[`_choice_repo`]' \
| \
_patch_table_edit_arguments 'package;[`_choice_sync_package`]'
elif [[ "$*" == "pacman --deptest" ]]; then
echo "$table" | \
_patch_table_edit_arguments 'package;[`_choice_package`]'
elif [[ "$*" == "pacman --upgrade" ]]; then
echo "$table" | \
_patch_table_edit_options \
'--ignore;[`_choice_package`]' \
'--ignoregroup;[`_choice_package_group`]' \
else
echo "$table"
fi
}
_choice_database() {
if [[ "$argc_asdeps" -eq 1 ]] \
|| [[ "$argc_asexplicit" -eq 1 ]] \
|| [[ "$argc_check" -eq 1 ]] \
; then
_choice_installed_package
fi
}
_choice_file_database() {
if _argc_util_has_path_prefix; then
_argc_util_comp_path
return
fi
_choice_package
}
_choice_package_group() {
pacman -Sg
}
_choice_installed_package() {
pacman -Q | sed 's/ /\t/'
}
_choice_repo() {
cat /etc/pacman.conf | sed -n -e '/^\[options\]/ d' -e '/^\[.*\]/ s/^\[\(.*\)\]/\1/p'
}
_choice_package() {
pacman -Ssq
}
_choice_sync_package() {
_argc_util_parallel _choice_package ::: _choice_package_group
}