forked from icy/pacapt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pacapt
executable file
·2571 lines (2112 loc) · 44.1 KB
/
pacapt
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# Purpose: A wrapper for all Unix package managers
# License: Fair license (http://www.opensource.org/licenses/fair)
# Source : http://github.com/icy/pacapt/
# Version: 2.4.4
# Authors: Anh K. Huynh et al.
# Copyright (C) 2010 - 2021 \
# | 10sr (10sr)
# | Alexander Dupuy (dupuy)
# | Anh K. Huynh (icy)
# | Antony Lee (anntzer)
# | Alex Lyon (Arcterus)
# | Carl X. Su (bcbcarl)
# | Cuong Manh Le (Gnouc)
# | Daniel YC Lin (dlintw)
# | Danny George (dangets)
# | Darshit Shah (darnir)
# | Dmitry Kudriavtsev (dkudriavtsev)
# | Eric Crosson (EricCrosson)
# | Evan Relf (evanrelf)
# | GijsTimmers (GijsTimmers)
# | Hà-Dương Nguyễn (cmpitg)
# | Huy Ngô (NgoHuy)
# | James Pearson (xiongchiamiov)
# | Janne Heß (dasJ)
# | Jiawei Zhou (4679)
# | Karol Blazewicz
# | Kevin Brubeck (unhammer)
# | Konrad Borowski (xfix)
# | Kylie McClain (somasis)
# | Gen Li (Rami3L)
# | Valerio Pizzi (Pival81)
# | Siôn Le Roux (sinisterstuf)
# | Thiago Perrotta (thiagowfx)
# | Vojtech Letal (letalvoj)
#
# Usage of the works is permitted provided that this instrument is
# retained with the works, so that any entity that uses the works is
# notified of this instrument.
#
# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
#
_print_pacapt_version() {
cat <<_EOF_
pacapt version '2.4.4'
Copyright (C) 2010 - 2021 \\
| 10sr (10sr)
| Alexander Dupuy (dupuy)
| Anh K. Huynh (icy)
| Antony Lee (anntzer)
| Alex Lyon (Arcterus)
| Carl X. Su (bcbcarl)
| Cuong Manh Le (Gnouc)
| Daniel YC Lin (dlintw)
| Danny George (dangets)
| Darshit Shah (darnir)
| Dmitry Kudriavtsev (dkudriavtsev)
| Eric Crosson (EricCrosson)
| Evan Relf (evanrelf)
| GijsTimmers (GijsTimmers)
| Hà-Dương Nguyễn (cmpitg)
| Huy Ngô (NgoHuy)
| James Pearson (xiongchiamiov)
| Janne Heß (dasJ)
| Jiawei Zhou (4679)
| Karol Blazewicz
| Kevin Brubeck (unhammer)
| Konrad Borowski (xfix)
| Kylie McClain (somasis)
| Gen Li (Rami3L)
| Valerio Pizzi (Pival81)
| Siôn Le Roux (sinisterstuf)
| Thiago Perrotta (thiagowfx)
| Vojtech Letal (letalvoj)
Usage of the works is permitted provided that this
instrument is retained with the works, so that any
entity that uses the works is notified of this instrument.
DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
_EOF_
}
export PACAPT_VERSION='2.4.4'
_help() {
cat <<'EOF'
NAME
pacapt - An `ArchLinux`'s pacman-like wrapper for many package managers.
SYNTAX
$ pacapt <option(s)> <operation(s)> <package(s)>
BASIC OPTIONS
-h or --help print this help message
-P print supported operations
-V print version information
SYSGET STYLE OPERATIONS
update Update package database
upgrade Upgrade system
install <options> <packages> Install some packages
search <options> <package> Search some package
remove <options> <packages> Remove some packages
autoremove Remove orphans (WIP; may not work correctly)
clean Clean package manager caches
PACMAN STYLE OPERATIONS
Query
-Q list all installed packages
-Qc <package> show package's changelog
-Qe [<package>] only list explicitly installed packages
-Qi <package> print package status
-Ql <package> list package's files
-Qm list installed packages that aren't available
in any installation source
-Qo <file> query package that provides <file>
-Qp <file> query a package file (don't use package database)
-Qs <package> search for installed package
Synchronize
-S <package> install package(s)
-Sg list groups
-Sg <group> list packages in group
-Ss <package> search for packages
-Su upgrade the system
-Sy update package database
-Suy update package database, then upgrade the system
Remove / Clean up
-R <packages> remove some packages
-Sc delete old downloaded packages
-Scc delete all downloaded packages
-Sccc clean variant files.
(debian) See also http://dragula.viettug.org/blogs/646
Upgrade
-U upgrade or add package from local file path (or remote uri)
OPTIONS
-w download packages but don't install them
--noconfirm don't wait for user's confirmation
EXAMPLES
1. To install a package from Debian's backports repository
$ pacapt -S foobar -t lenny-backports
$ pacapt -S -- -t lenny-backports foobar
2. To update package database and then update your system
$ pacapt -Syu
3. To download a package without installing it
$ pacapt -Sw foobar
ENVIRONMENT
PACAPT_DEBUG
This is useful for debugging purpose. The variable can be set to `auto`
or any valid packager. For example, on `Debian` system the two following
commands are the same and they will print out what the script would do:
PACAPT_DEBUG=auto pacman -Su
PACAPT_DEBUG=dpkg pacman -Su
NOTES
When being executed on Arch-based system, the tool simply invokes
the system package manager (`/usr/bin/pacman`).
Though you can specify option by its own word, for example,
$ pacapt -S -y -u
it's always the best to combine them
$ pacapt -Syu
READMORE
Please visit https://github.com/icy/pacapt.
EOF
}
_error() {
echo >&2 "Error: $*"
return 1
}
_warn() {
echo >&2 "Warning: $*"
return 0
}
_die() {
echo >&2 "$@"
exit 1
}
_not_implemented() {
# shellcheck disable=2153
echo >&2 "${_PACMAN}: '${_POPT}:${_SOPT}:${_TOPT}' operation is invalid or not implemented."
return 1
}
_removing_is_dangerous() {
echo >&2 "${_PACMAN}: removing with '$*' is too dangerous"
return 1
}
_issue2pacman() {
local _pacman
_pacman="$1"; shift
# The following line is added by Daniel YC Lin to support SunOS.
#
# [ `uname` = "$1" ] && _PACMAN="$_pacman" && return
#
# This is quite tricky and fast, however I don't think it works
# on Linux/BSD systems. To avoid extra check, I slightly modify
# the code to make sure it's only applicable on SunOS.
#
[[ "$(uname)" == "SunOS" ]] && _PACMAN="$_pacman" && return
$GREP -qis "$@" /etc/issue \
&& _PACMAN="$_pacman" && return
$GREP -qis "$@" /etc/os-release \
&& _PACMAN="$_pacman" && return
}
_PACMAN_detect() {
_PACMAN_found_from_script_name && return
_issue2pacman sun_tools "SunOS" && return
_issue2pacman pacman "Arch Linux" && return
_issue2pacman dpkg "Debian GNU/Linux" && return
_issue2pacman dpkg "Ubuntu" && return
_issue2pacman cave "Exherbo Linux" && return
_issue2pacman yum "CentOS" && return
_issue2pacman yum "Red Hat" && return
#
# FIXME: The multiple package issue.
#
# On #63, Huy commented out this line. This is because new generation
# of Fedora uses `dnf`, and `yum` becomes a legacy tool. On old Fedora
# system, `yum` is still detectable by looking up `yum` binary.
#
# I'm not sure how to support this case easily. Let's wait, e.g, 5 years
# from now to make `dnf` becomes a default? Oh no!
#
# And here why `pacman` is still smart. Debian has a set of tools.
# Fedora has `yum` (and a set of add-ons). Now Fedora moves to `dnf`.
# This means that a package manager is not a heart of a system ;)
#
# _issue2pacman yum "Fedora" && return
_issue2pacman zypper "SUSE" && return
_issue2pacman pkg_tools "OpenBSD" && return
_issue2pacman pkg_tools "Bitrig" && return
_issue2pacman apk "Alpine Linux" && return
[[ -z "$_PACMAN" ]] || return
# Prevent a loop when this script is installed on non-standard system
if [[ -x "/usr/bin/pacman" ]]; then
$GREP -q "${FUNCNAME[0]}" '/usr/bin/pacman' >/dev/null 2>&1
[[ $? -ge 1 ]] && _PACMAN="pacman" \
&& return
fi
[[ -x "/usr/bin/apt-get" ]] && _PACMAN="dpkg" && return
[[ -x "/data/data/com.termux/files/usr/bin/apt-get" ]] && _PACMAN="dpkg" && return
[[ -x "/usr/bin/cave" ]] && _PACMAN="cave" && return
[[ -x "/usr/bin/dnf" ]] && _PACMAN="dnf" && return
[[ -x "/usr/bin/yum" ]] && _PACMAN="yum" && return
[[ -x "/opt/local/bin/port" ]] && _PACMAN="macports" && return
[[ -x "/usr/bin/emerge" ]] && _PACMAN="portage" && return
[[ -x "/usr/bin/zypper" ]] && _PACMAN="zypper" && return
[[ -x "/usr/sbin/pkg" ]] && _PACMAN="pkgng" && return
# make sure pkg_add is after pkgng, FreeBSD base comes with it until converted
[[ -x "/usr/sbin/pkg_add" ]] && _PACMAN="pkg_tools" && return
[[ -x "/usr/sbin/pkgadd" ]] && _PACMAN="sun_tools" && return
[[ -x "/sbin/apk" ]] && _PACMAN="apk" && return
[[ -x "/usr/bin/tazpkg" ]] && _PACMAN="tazpkg" && return
[[ -x "/usr/bin/swupd" ]] && _PACMAN="swupd" && return
command -v brew >/dev/null && _PACMAN="homebrew" && return
return 1
}
_translate_w() {
echo "$_EOPT" | $GREP -q ":w:" || return 0
local _opt=
local _ret=0
case "$_PACMAN" in
"dpkg") _opt="-d";;
"cave") _opt="-f";;
"macports") _opt="fetch";;
"portage") _opt="--fetchonly";;
"zypper") _opt="--download-only";;
"pkgng") _opt="fetch";;
"yum") _opt="--downloadonly";
if ! rpm -q 'yum-downloadonly' >/dev/null 2>&1; then
_error "'yum-downloadonly' package is required when '-w' is used."
_ret=1
fi
;;
"tazpkg")
_error "$_PACMAN: Use '$_PACMAN get' to download and save packages to current directory."
_ret=1
;;
"apk") _opt="fetch";;
*)
_opt=""
_ret=1
_error "$_PACMAN: Option '-w' is not supported/implemented."
;;
esac
echo $_opt
return "$_ret"
}
_translate_debug() {
echo "$_EOPT" | $GREP -q ":v:" || return 0
case "$_PACMAN" in
"tazpkg")
_error "$_PACMAN: Option '-v' (debug) is not supported/implemented by tazpkg"
return 1
;;
esac
echo "-v"
}
_translate_noconfirm() {
echo "$_EOPT" | $GREP -q ":noconfirm:" || return 0
local _opt=
local _ret=0
case "$_PACMAN" in
# FIXME: Update environment DEBIAN_FRONTEND=noninteractive
# FIXME: There is also --force-yes for a stronger case
"dpkg") _opt="--yes";;
"dnf") _opt="--assumeyes";;
"yum") _opt="--assumeyes";;
# FIXME: pacman has 'assume-yes' and 'assume-no'
# FIXME: zypper has better mode. Similar to dpkg (Debian).
"zypper") _opt="--no-confirm";;
"pkgng") _opt="-y";;
"tazpkg") _opt="--auto";;
*)
_opt=""
_ret=1
_error "$_PACMAN: Option '--noconfirm' is not supported/implemented."
;;
esac
echo $_opt
return $_ret
}
_translate_all() {
local _args=""
local _debug=
local _noconfirm=
_debug="$(_translate_debug)"
_noconfirm="$(_translate_noconfirm)"
_args="$(_translate_w)" || return 1
_args="${_args}${_noconfirm:+ }${_noconfirm}" || return 1
_args="${_args}${_debug:+ }${_debug}" || return 1
export _EOPT="${_args# }"
}
_print_supported_operations() {
local _pacman="$1"
echo -n "pacapt($_pacman): available operations:"
# shellcheck disable=2016
$GREP -E "^${_pacman}_[^ \\t]+\\(\\)" "$0" \
| $AWK -F '(' '{print $1}' \
| sed -e "s/${_pacman}_//g" \
| while read -r O; do
echo -n " $O"
done
echo
}
export _SUPPORTED_EXTERNALS="
:conda
:tlmgr
:texlive
:gem
:npm
:pip
"
readonly _SUPPORTED_EXTERNALS
_PACMAN_found_from_script_name() {
local _tmp_name=
local _pacman=
_tmp_name="${BASH_SOURCE[0]:-?}"
if [[ "$_tmp_name" == "?" ]]; then
_error "Unable to get script name."
return 1
fi
_tmp_name="${_tmp_name##*/}" # base name (remove everything before the last `/`)
_tmp_name="${_tmp_name%.*}" # remove extension if any (remove everything from the last `.`)
_pacman="${_tmp_name##*-}" # remove every thing before the last `-`
if grep -Eq -e ":$_pacman[[:space:]]*" <<< "$_SUPPORTED_EXTERNALS"; then
export _PACMAN="$_pacman"
return 0
else
export _PACMAN=""
return 1
fi
}
_apk_init() {
:
}
apk_Q() {
if [[ -z "$_TOPT" ]]; then
apk info
else
_not_implemented
fi
}
apk_Qi() {
apk info -a -- "$@"
}
apk_Ql() {
apk info -L -- "$@"
}
apk_Qo() {
apk info --who-owns -- "$@"
}
apk_Qs() {
apk info -- "*${*}*"
}
apk_Qu() {
apk version -l '<'
}
apk_R() {
apk del -- "$@"
}
apk_Rn() {
apk del --purge -- "$@"
}
apk_Rns() {
apk del --purge -r -- "$@"
}
apk_Rs() {
apk del -r -- "$@"
}
apk_S() {
case ${_EOPT} in
# Download only
("fetch") shift
apk fetch -- "$@" ;;
(*) apk add $_TOPT -- "$@" ;;
esac
}
apk_Sc() {
apk cache -v clean
}
apk_Scc() {
rm -rf /var/cache/apk/*
}
apk_Sccc() {
apk_Scc
}
apk_Si() {
apk_Qi "$@"
}
apk_Sii() {
apk info -r -- "$@"
}
apk_Sl() {
apk search -v -- "$@"
}
apk_Ss() {
apk_Sl "$@"
}
apk_Su() {
apk upgrade
}
apk_Suy() {
if [ "$#" -gt 0 ]; then
apk add -U -u -- "$@"
else
apk upgrade -U -a
fi
}
apk_Sy() {
apk update
}
apk_Sw() {
apk fetch -- "$@"
}
apk_U() {
apk add --allow-untrusted -- "$@"
}
_cave_init() {
shopt -u globstar
}
cave_Q() {
if [[ "$_TOPT" == "q" ]]; then
cave show -f "${@:-world}" \
| grep -v '^$'
else
cave show -f "${@:-world}"
fi
}
cave_Qi() {
cave show "$@"
}
cave_Ql() {
if [[ -n "$*" ]]; then
cave contents "$@"
return
fi
cave show -f "${@:-world}" \
| grep -v '^$' \
| while read -r _pkg; do
if [[ "$_TOPT" == "q" ]]; then
cave --color no contents "$_pkg"
else
cave contents "$_pkg"
fi
done
}
cave_Qo() {
cave owner "$@"
}
cave_Qp() {
_not_implemented
}
cave_Qu() {
if [[ -z "$*" ]];then
cave resolve -c world \
| grep '^u.*' \
| while read -r _pkg; do
echo "$_pkg" | cut -d'u' -f2-
done
else
cave resolve -c world \
| grep '^u.*' \
| grep -- "$@"
fi
}
cave_Qs() {
cave show -f world | grep -- "$@"
}
cave_Rs() {
if [[ "$_TOPT" == "" ]]; then
cave uninstall -r "$@" \
&& echo "Control-C to stop uninstalling..." \
&& sleep 2s \
&& cave uninstall -xr "$@"
else
cave purge "$@" \
&& echo "Control-C to stop uninstalling (+ dependencies)..." \
&& sleep 2s \
&& cave purge -x "$@"
fi
}
cave_Rn() {
_not_implemented
}
cave_Rns() {
_not_implemented
}
cave_R() {
cave uninstall "$@" \
&& echo "Control-C to stop uninstalling..." \
&& sleep 2s \
&& cave uninstall -x "$@"
}
cave_Si() {
cave show "$@"
}
cave_Suy() {
cave sync && cave resolve -c "${@:-world}" \
&& echo "Control-C to stop upgrading..." \
&& sleep 2s \
&& cave resolve -cx "${@:-world}"
}
cave_Su() {
cave resolve -c "$@" \
&& echo "Control-C to stop upgrading..." \
&& sleep 2s \
&& cave resolve -cx "$@"
}
cave_Sy() {
cave sync "$@"
}
cave_Ss() {
cave search "$@"
}
cave_Sc() {
cave fix-cache "$@"
}
cave_Scc() {
cave fix-cache "$@"
}
cave_Sccc() {
#rm -fv /var/cache/paludis/*
_not_implemented
}
cave_S() {
cave resolve $_TOPT "$@" \
&& echo "Control-C to stop installing..." \
&& sleep 2s \
&& cave resolve -x $_TOPT "$@"
}
cave_U() {
_not_implemented
}
_conda_init() {
:
}
conda_Q() {
if [[ $# -gt 0 ]]; then
conda list "$(python -c 'import sys; print("^" + "|".join(sys.argv[1:]) + "$")' "$@")"
else
conda list
fi
}
conda_R() {
conda remove "$@"
}
conda_S() {
conda install "$@"
}
conda_Sc() {
conda clean --all "$@"
}
conda_Si() {
conda search "$@" --info
}
conda_Ss() {
conda search "*$@*"
}
conda_Suy() {
conda update --all "$@"
}
_dnf_init() {
:
}
dnf_S() {
dnf install $_TOPT "$@"
}
dnf_Sc() {
dnf clean expire-cache "$@"
}
dnf_Scc() {
dnf clean packages "$@"
}
dnf_Sccc() {
dnf clean all "$@"
}
dnf_Si() {
dnf info "$@" && dnf repoquery --deplist "$@"
}
dnf_Sg() {
if [[ $# -gt 0 ]]; then
dnf group info "$@"
else
dnf group list
fi
}
dnf_Sl() {
dnf list available "$@"
}
dnf_Ss() {
dnf search "$@"
}
dnf_Su() {
dnf upgrade "$@"
}
dnf_Suy() {
dnf upgrade "$@"
}
dnf_Sw() {
dnf download "$@"
}
dnf_Sy() {
dnf clean expire-cache && dnf check-update
}
dnf_Q() {
if [[ "$_TOPT" == "q" ]]; then
rpm -qa --qf "%{NAME}\\n"
elif [[ "$_TOPT" == "" ]]; then
rpm -qa --qf "%{NAME} %{VERSION}\\n"
else
_not_implemented
fi
}
dnf_Qc() {
rpm -q --changelog "$@"
}
dnf_Qe() {
dnf repoquery --userinstalled "$@"
}
dnf_Qi() {
dnf info --installed "$@" && dnf repoquery --deplist "$@"
}
dnf_Ql() {
rpm -ql "$@"
}
dnf_Qm() {
dnf list extras
}
dnf_Qo() {
rpm -qf "$@"
}
dnf_Qp() {
rpm -qp "$@"
}
dnf_Qs() {
rpm -qa "*${*}*"
}
dnf_Qu() {
dnf list updates "$@"
}
dnf_R() {
dnf remove "$@"
}
dnf_U() {
dnf install "$@"
}
_dpkg_init() {
:
}
dpkg_Q() {
if [[ "$_TOPT" == "q" ]]; then
dpkg -l \
| grep -E '^[hi]i' \
| awk '{print $2}'
elif [[ "$_TOPT" == "" ]]; then
dpkg -l "$@" \
| grep -E '^[hi]i'
else
_not_implemented
fi
}
dpkg_Qi() {
dpkg-query -s "$@"
}
dpkg_Ql() {
if [[ -n "$*" ]]; then
dpkg-query -L "$@"
return
fi
dpkg -l \
| grep -E '^[hi]i' \
| awk '{print $2}' \
| while read -r _pkg; do
if [[ "$_TOPT" == "q" ]]; then
dpkg-query -L "$_pkg"
else
dpkg-query -L "$_pkg" \
| while read -r _line; do
echo "$_pkg $_line"
done
fi
done
}
dpkg_Qo() {
dpkg-query -S "$@"
}
dpkg_Qp() {
dpkg-deb -I "$@"
}
dpkg_Qu() {
apt-get upgrade --trivial-only "$@"
}
dpkg_Qs() {
# dpkg >= 1.16.2 dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\t${Version}\t${binary:Summary}\n'
dpkg-query -W -f='${Status} ${Package}\t${Version}\t${Description}\n' \
| grep -E '^((hold)|(install)|(deinstall))' \
| sed -r -e 's#^(\w+ ){3}##g' \
| grep -Ei "${@:-.}"
}
dpkg_Rs() {
if [[ "$_TOPT" == "" ]]; then
apt-get autoremove "$@"
else
_not_implemented
fi
}
dpkg_Rn() {
apt-get purge "$@"
}
dpkg_Rns() {
apt-get --purge autoremove "$@"
}
dpkg_R() {
apt-get remove "$@"
}
dpkg_Si() {
apt-cache show "$@"
}
dpkg_Suy() {
apt-get update \
&& apt-get upgrade "$@" \
&& apt-get dist-upgrade "$@"
}
dpkg_Su() {
apt-get upgrade "$@" \
&& apt-get dist-upgrade "$@"
}
dpkg_Sy() {
apt-get update "$@"
}
dpkg_Ss() {
apt-cache search "$@"
}
dpkg_Sc() {
apt-get clean "$@"
}
dpkg_Scc() {
apt-get autoclean "$@"
}
dpkg_S() {
apt-get install $_TOPT "$@"
}
dpkg_U() {
dpkg -i "$@"
}
dpkg_Sii() {
apt-cache rdepends "$@"
}
dpkg_Sccc() {
rm -fv /var/cache/apt/*.bin
rm -fv /var/cache/apt/archives/*.*
rm -fv /var/lib/apt/lists/*.*
apt-get autoclean
}
_homebrew_init() {
:
}
homebrew_Qi() {
brew info "$@"
}
homebrew_Ql() {
brew list "$@"
}
homebrew_Qo() {
local pkg prefix cellar