This repository has been archived by the owner on May 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
/
pacaur
executable file
·2309 lines (2093 loc) · 102 KB
/
pacaur
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
#!/bin/bash
#
# pacaur: an AUR helper that minimizes user interaction
#
version="4.7.90"
#
# Config
#
# sanitize
unset aur cleancache devel edit info installpkg foreign needed noconfirm nodeps noedit
unset operation pac pacQ pacS quiet rebuild refresh repo search selective upgrade
# internationalization
LC_COLLATE=C # getopts sorting
TEXTDOMAIN='pacaur'
TEXTDOMAINDIR='/usr/share/locale'
# determine config location
if [[ -n "${XDG_CONFIG_DIRS}" ]]; then
for i in ${XDG_CONFIG_DIRS//:/ }; do
[[ -d "$i/pacaur" ]] && export XDG_CONFIG_DIRS="$i" && break
done
fi
configdir="${XDG_CONFIG_DIRS:-/etc/xdg}/pacaur"
userconfigdir="${XDG_CONFIG_HOME:-${HOME}/.config}/pacaur"
userpacmandir="${XDG_CONFIG_HOME:-${HOME}/.config}/pacman"
usercachedir="${XDG_CACHE_HOME:-${HOME}/.cache}/pacaur"
tmpdir="${XDG_RUNTIME_DIR:-/tmp}"
# preserve environment variables
[[ -n ${PACMAN} ]] && _PACMAN=${PACMAN}
[[ -n ${PKGDEST} ]] && _PKGDEST=${PKGDEST}
[[ -n ${SRCDEST} ]] && _SRCDEST=${SRCDEST}
[[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=${SRCPKGDEST}
[[ -n ${LOGDEST} ]] && _LOGDEST=${LOGDEST}
[[ -n ${BUILDDIR} ]] && _BUILDDIR=${BUILDDIR}
[[ -n ${PKGEXT} ]] && _PKGEXT=${PKGEXT}
[[ -n ${SRCEXT} ]] && _SRCEXT=${SRCEXT}
[[ -n ${GPGKEY} ]] && _GPGKEY=${GPGKEY}
[[ -n ${PACKAGER} ]] && _PACKAGER=${PACKAGER}
[[ -n ${CARCH} ]] && _CARCH=${CARCH}
# source makepkg variables
if [[ -r "$MAKEPKG_CONF" ]]; then
source "$MAKEPKG_CONF"
else
source /etc/makepkg.conf
if [[ -r "$userpacmandir/makepkg.conf" ]]; then
source "$userpacmandir/makepkg.conf"
elif [[ -r "$HOME/.makepkg.conf" ]]; then
source "$HOME/.makepkg.conf"
fi
fi
# restore environment variables
PACMAN=${_PACMAN:-$PACMAN}
PKGDEST=${_PKGDEST:-$PKGDEST}
SRCDEST=${_SRCDEST:-$SRCDEST}
SRCPKGDEST=${_SRCPKGDEST:-$SRCPKGDEST}
LOGDEST=${_LOGDEST:-$LOGDEST}
BUILDDIR=${_BUILDDIR:-$BUILDDIR}
PKGEXT=${_PKGEXT:-$PKGEXT}
SRCEXT=${_SRCEXT:-$SRCEXT}
GPGKEY=${_GPGKEY:-$GPGKEY}
PACKAGER=${_PACKAGER:-$PACKAGER}
CARCH=${_CARCH:-$CARCH}
# set default config variables
editor="${VISUAL:-${EDITOR:-nano}}" # build files editor
displaybuildfiles=diff # display build files (none|diff|full)
fallback=true # pacman fallback to the AUR
silent=false # silence output
sortby=popularity # sort method (name|votes|popularity)
sortorder=descending # sort order (ascending|descending)
sudoloop=true # prevent sudo timeout
# set variables
pacmanbin="${PACMAN:-pacman}" # pacman binary
clonedir="${AURDEST:-$usercachedir}" # clone directory
# set AUR variables
aururl="aur.archlinux.org"
aurrpc="/rpc/?type=info&v=5"
# source xdg config
source "$configdir/config"
[[ -r "$userconfigdir/config" ]] && source "$userconfigdir/config"
# set up directories
[[ ! -d "$clonedir" ]] && mkdir -p "$clonedir" -m 700
#
# Functions
#
ClassifyPkgs() {
local noaurpkgs norepopkgs
# global aurpkgs repopkgs
if [[ $fallback = true ]]; then
[[ $repo ]] && repopkgs=(${pkgs[@]})
if [[ $aur ]]; then
for i in "${pkgs[@]}"; do
[[ $i == aur/* ]] && aurpkgs+=(${i:4}) && continue # search aur/pkgs in AUR
aurpkgs+=($i)
done
fi
if [[ ! $repo && ! $aur ]]; then
unset noaurpkgs
for i in "${pkgs[@]}"; do
[[ $i == aur/* ]] && aurpkgs+=(${i:4}) && continue # search aur/pkgs in AUR
noaurpkgs+=($i)
done
[[ -n "${noaurpkgs[@]}" ]] && norepopkgs=($(LC_ALL=C $pacmanbin -Sp ${noaurpkgs[@]} 2>&1 >/dev/null | awk '{print $NF}'))
for i in "${norepopkgs[@]}"; do
[[ ! " ${noaurpkgs[@]} " =~ [a-zA-Z0-9\.\+-]+\/$i[^a-zA-Z0-9\.\+-] ]] && aurpkgs+=($i) # do not search repo/pkgs in AUR
done
repopkgs=($(grep -xvf <(printf '%s\n' "${aurpkgs[@]}") <(printf '%s\n' "${noaurpkgs[@]}")))
fi
else
if [[ ! $aur ]]; then
repopkgs=(${pkgs[@]})
else
for i in "${pkgs[@]}"; do
[[ $i == aur/* ]] && aurpkgs+=(${i:4}) && continue # search aur/pkgs in AUR
aurpkgs+=($i)
done
fi
fi
}
Core() {
GetIgnoredPkgs
GetIgnoredGrps
[[ $upgrade ]] && UpgradeAur
IgnoreChecks
DepsSolver
IgnoreDepsChecks
ProviderChecks
ConflictChecks
ReinstallChecks
OutofdateChecks
OrphanChecks
Prompt
MakePkgs
}
UpgradeAur() {
local foreignpkgs allaurpkgs allaurpkgsAver allaurpkgsQver aurforeignpkgs i json
# global aurpkgs
Note "i" $"${colorW}Starting AUR upgrade...${reset}"
# selective upgrade switch
if [[ $selective && -n ${pkgs[@]} ]]; then
aurpkgs+=(${pkgs[@]})
else
foreignpkgs=($($pacmanbin -Qmq))
SetJson ${foreignpkgs[@]}
allaurpkgs=($(GetJson "var" "$json" "Name"))
allaurpkgsAver=($(GetJson "var" "$json" "Version"))
allaurpkgsQver=($(expac -Q '%v' ${allaurpkgs[@]}))
for i in "${!allaurpkgs[@]}"; do
[[ $(vercmp "${allaurpkgsAver[$i]}" "${allaurpkgsQver[$i]}") -gt 0 ]] && aurpkgs+=(${allaurpkgs[$i]});
done
fi
# foreign packages check
aurforeignpkgs=($(grep -xvf <(printf '%s\n' "${allaurpkgs[@]}") <(printf '%s\n' "${foreignpkgs[@]}")))
for i in "${aurforeignpkgs[@]}"; do
Note "w" $"${colorW}$i${reset} is ${colorY}not present${reset} in AUR -- skipping"
done
# add devel packages
if [[ $devel ]]; then
for i in "${allaurpkgs[@]}"; do
[[ -n "$(grep -E "\-(cvs|svn|git|hg|bzr|darcs|daily.*|nightly.*)$" <<< $i)" ]] && aurpkgs+=($i)
done
fi
# avoid possible duplicate
aurpkgs=($(tr ' ' '\n' <<< ${aurpkgs[@]} | sort -u))
NothingToDo ${aurpkgs[@]}
}
IgnoreChecks() {
local checkaurpkgs checkaurpkgsAver checkaurpkgsAgrp checkaurpkgsQver checkaurpkgsQgrp i json
# global aurpkgs rmaurpkgs
[[ -z "${ignoredpkgs[@]}" && -z "${ignoredgrps[@]}" ]] && return
# remove AUR pkgs versioning
for i in "${!aurpkgs[@]}"; do
aurpkgsnover[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${aurpkgs[$i]})
done
# check targets
SetJson ${aurpkgsnover[@]}
checkaurpkgs=($(GetJson "var" "$json" "Name"))
errdeps+=($(grep -xvf <(printf '%s\n' "${aurpkgsnover[@]}") <(printf '%s\n' "${checkaurpkgs[@]}")))
errdeps+=($(grep -xvf <(printf '%s\n' "${checkaurpkgs[@]}") <(printf '%s\n' "${aurpkgsnover[@]}")))
unset aurpkgsnover
checkaurpkgsAver=($(GetJson "var" "$json" "Version"))
checkaurpkgsQver=($(expac -Q '%v' "${checkaurpkgs[@]}"))
for i in "${!checkaurpkgs[@]}"; do
[[ -n "$(grep -E "\-(cvs|svn|git|hg|bzr|darcs|daily.*|nightly.*)$" <<< ${checkaurpkgs[$i]})" ]] && checkaurpkgsAver[$i]=$"latest"
done
for i in "${!checkaurpkgs[@]}"; do
unset isignored
if [[ " ${ignoredpkgs[@]} " =~ " ${checkaurpkgs[$i]} " ]]; then
isignored=true
elif [[ -n "${ignoredgrps[@]}" ]]; then
unset checkaurpkgsAgrp checkaurpkgsQgrp
checkaurpkgsAgrp=($(GetJson "arrayvar" "$json" "Groups" "${checkaurpkgs[$i]}"))
for j in "${checkaurpkgsAgrp[@]}"; do
[[ " ${ignoredgrps[@]} " =~ " $j " ]] && isignored=true
done
checkaurpkgsQgrp=($(expac -Q '%G' "${checkaurpkgs[$i]}"))
for j in "${checkaurpkgsQgrp[@]}"; do
[[ " ${ignoredgrps[@]} " =~ " $j " ]] && isignored=true
done
fi
if [[ $isignored = true ]]; then
if [[ ! $upgrade ]]; then
if [[ ! $noconfirm ]]; then
if ! Proceed "y" $"${checkaurpkgs[$i]} is in IgnorePkg/IgnoreGroup. Install anyway?"; then
Note "w" $"skipping target: ${colorW}${checkaurpkgs[$i]}${reset}"
rmaurpkgs+=(${checkaurpkgs[$i]})
continue
fi
else
Note "w" $"skipping target: ${colorW}${checkaurpkgs[$i]}${reset}"
rmaurpkgs+=(${checkaurpkgs[$i]})
continue
fi
else
Note "w" $"${colorW}${checkaurpkgs[$i]}${reset}: ignoring package upgrade (${colorR}${checkaurpkgsQver[$i]}${reset} => ${colorG}${checkaurpkgsAver[$i]}${reset})"
rmaurpkgs+=(${checkaurpkgs[$i]})
continue
fi
fi
aurpkgsnover+=(${checkaurpkgs[$i]})
done
aurpkgs=(${aurpkgsnover[@]})
NothingToDo ${aurpkgs[@]}
}
DepsSolver() {
local i aurpkgsname aurpkgsver aurpkgsaurver aurpkgsconflicts
# global aurpkgs aurpkgsnover aurpkgsproviders aurdeps deps json errdeps errdepsnover foreignpkgs repodeps depsAname depsAver depsAood depsQver
Note "i" $"resolving dependencies..."
# remove AUR pkgs versioning
for i in "${!aurpkgs[@]}"; do
aurpkgsnover[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${aurpkgs[$i]})
done
# set unversionned json
SetJson ${aurpkgsnover[@]}
# set targets providers
aurpkgsproviders=(${aurpkgsnover[@]})
aurpkgsproviders+=($(GetJson "array" "$json" "Provides"))
for i in "${!aurpkgsproviders[@]}"; do
aurpkgsproviders[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${aurpkgsproviders[$i]})
done
# check targets conflicts
aurpkgsconflicts=($(GetJson "array" "$json" "Conflicts"))
if [[ -n "${aurpkgsconflicts[@]}" ]]; then
for i in "${!aurpkgsconflicts[@]}"; do
aurpkgsconflicts[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${aurpkgsconflicts[$i]})
done
aurpkgsconflicts=($(grep -xf <(printf '%s\n' "${aurpkgsproviders[@]}") <(printf '%s\n' "${aurpkgsconflicts[@]}")))
aurpkgsconflicts=($(tr ' ' '\n' <<< ${aurpkgsconflicts[@]} | LC_COLLATE=C sort -u))
for i in "${aurpkgsconflicts[@]}"; do
[[ ! " ${aurpkgsnover[@]} " =~ " $i " ]] && continue
[[ " $(GetJson "arrayvar" "$json" "Conflicts" "$i") " =~ " $i " ]] && continue
Note "f" $"unresolvable package conflicts detected"
Note "e" $"failed to prepare transaction (conflicting dependencies: $i)"
done
fi
deps=(${aurpkgsnover[@]})
[[ -z "${foreignpkgs[@]}" ]] && foreignpkgs=($($pacmanbin -Qmq))
FindDepsAur ${aurpkgsnover[@]}
# avoid possible duplicate
deps=($(grep -xvf <(printf '%s\n' "${aurdepspkgs[@]}") <(printf '%s\n' "${deps[@]}")))
deps+=(${aurdepspkgs[@]})
# ensure correct dependency order
SetJson ${deps[@]}
SortDepsAur ${aurpkgs[@]}
deps=($(tsort <<< ${tsortdeps[@]}))
# error check
if (($? > 0)); then
Note "e" $"dependency cycle detected"
fi
# get AUR packages info
depsAname=($(GetJson "var" "$json" "Name"))
depsAver=($(GetJson "var" "$json" "Version"))
depsAood=($(GetJson "var" "$json" "OutOfDate"))
depsAmain=($(GetJson "var" "$json" "Maintainer"))
for i in "${!depsAname[@]}"; do
depsQver[$i]=$(expac -Qs '%v' "^${depsAname[$i]}$" | head -1)
[[ -z "${depsQver[$i]}" ]] && depsQver[$i]="#" # avoid empty elements shift
[[ -n "$(grep -E "\-(cvs|svn|git|hg|bzr|darcs|daily.*|nightly.*)$" <<< ${depsAname[$i]})" ]] && depsAver[$i]=$"latest"
done
# no results check
if [[ -n "${errdeps[@]}" ]]; then
for i in "${!errdepsnover[@]}"; do
if [[ " ${aurpkgsnover[@]} " =~ " ${errdepsnover[$i]} " ]]; then
Note "f" $"no results found for ${errdeps[$i]}"
else
unset tsorterrdeps errdepslist currenterrdep
# find relevant tsorted deps chain
for j in "${deps[@]}"; do
tsorterrdeps+=($j)
[[ " $j " = " ${errdepsnover[$i]} " ]] && break
done
# reverse deps order
tsorterrdeps=($(awk '{for (i=NF;i>=1;i--) print $i}' <<< ${tsorterrdeps[@]} | awk -F "\n" '{print}'))
errdepslist+=(${tsorterrdeps[0]})
FindDepsAurError ${tsorterrdeps[@]}
errdepslist=($(awk '{for (i=NF;i>=1;i--) print $i}' <<< ${errdepslist[@]} | awk -F "\n" '{print}'))
Note "f" $"no results found for ${errdeps[$i]} (dependency tree: ${errdepslist[*]})"
fi
done
exit 1
fi
# return all binary deps
FindDepsRepo ${repodeps[@]}
# avoid possible duplicate
repodepspkgs=($(tr ' ' '\n' <<< ${repodepspkgs[@]} | sort -u))
}
FindDepsAur() {
local depspkgs depspkgstmp depspkgsaurtmp repodepstmp builtpkg vcsdepspkgs assumedepspkgs
local aurversionpkgs aurversionpkgsname aurversionpkgsver aurversionpkgsaurver i j json
# global aurpkgsnover depspkgsaur errdeps depsAname depsAver repodeps aurdepspkgs prevdepspkgsaur foreignpkgs
[[ $nodeps && $count -ge 2 ]] && return
# set json
unset aurversionpkgs
if [[ -z "${depspkgsaur[@]}" ]]; then
SetJson ${aurpkgsnover[@]}
aurversionpkgs=(${aurpkgs[@]})
else
SetJson ${depspkgsaur[@]}
aurversionpkgs=(${prevdepspkgsaur[@]})
fi
# versioning check
if [[ -n "${aurversionpkgs[@]}" ]]; then
for i in "${!aurversionpkgs[@]}"; do
unset aurversionpkgsname aurversionpkgsver aurversionpkgsaurver
aurversionpkgsname=${aurversionpkgs[$i]} && aurversionpkgsname=${aurversionpkgsname%[><]*} && aurversionpkgsname=${aurversionpkgsname%=*}
aurversionpkgsver=${aurversionpkgs[$i]} && aurversionpkgsver=${aurversionpkgsver#*=} && aurversionpkgsver=${aurversionpkgsver#*[><]}
aurversionpkgsaurver=$(GetJson "varvar" "$json" "Version" "$aurversionpkgsname")
# not found in AUR nor repo
if [[ ! $aurversionpkgsaurver ]]; then
[[ ! " ${errdeps[@]} " =~ " ${aurversionpkgs[$i]} " ]] && errdeps+=(${aurversionpkgs[$i]})
continue
fi
case "${aurversionpkgs[$i]}" in
*">"*|*"<"*|*"="*)
# found in AUR but version not correct
case "${aurversionpkgs[$i]}" in
*">="*) [[ $(vercmp "$aurversionpkgsaurver" "$aurversionpkgsver") -ge 0 ]] && continue;;
*"<="*) [[ $(vercmp "$aurversionpkgsaurver" "$aurversionpkgsver") -le 0 ]] && continue;;
*">"*) [[ $(vercmp "$aurversionpkgsaurver" "$aurversionpkgsver") -gt 0 ]] && continue;;
*"<"*) [[ $(vercmp "$aurversionpkgsaurver" "$aurversionpkgsver") -lt 0 ]] && continue;;
*"="*) [[ $(vercmp "$aurversionpkgsaurver" "$aurversionpkgsver") -eq 0 ]] && continue;;
esac
[[ ! " ${errdeps[@]} " =~ " ${aurversionpkgs[$i]} " ]] && errdeps+=(${aurversionpkgs[$i]})
;;
*) continue;;
esac
done
fi
depspkgs=($(GetJson "array" "$json" "Depends"))
# cached packages makedeps check
if [[ ! $PKGDEST || $rebuild || $foreign ]]; then
depspkgs+=($(GetJson "array" "$json" "MakeDepends"))
depspkgs+=($(GetJson "array" "$json" "CheckDepends"))
else
[[ -z "${depspkgsaur[@]}" ]] && depspkgsaurtmp=(${aurpkgs[@]}) || depspkgsaurtmp=(${depspkgsaur[@]})
for i in "${!depspkgsaurtmp[@]}"; do
depsAname=$(GetJson "varvar" "$json" "Name" "${depspkgsaurtmp[$i]}")
depsAver=$(GetJson "varvar" "$json" "Version" "${depspkgsaurtmp[$i]}")
GetBuiltPkg "$depsAname-$depsAver" "$PKGDEST"
if [[ ! $builtpkg ]]; then
depspkgs+=($(GetJson "arrayvar" "$json" "MakeDepends" "${depspkgsaurtmp[$i]}"))
depspkgs+=($(GetJson "arrayvar" "$json" "CheckDepends" "${depspkgsaurtmp[$i]}"))
fi
unset builtpkg
done
fi
# remove deps provided by targets
if [[ -n "${aurpkgsproviders[@]}" ]]; then
depspkgs=($(grep -xvf <(printf '%s\n' "${aurpkgsproviders[@]}") <(printf '%s\n' "${depspkgs[@]}")))
fi
# workaround for limited RPC support of architecture dependent fields
if [[ ${CARCH} == 'i686' ]]; then
depspkgstmp=(${depspkgs[@]})
for i in "${!depspkgstmp[@]}"; do
[[ -n "$(grep -E "^lib32\-" <<< ${depspkgstmp[$i]})" ]] && depspkgs=($(tr ' ' '\n' <<< ${depspkgs[@]} | sed "s/^${depspkgstmp[$i]}$//g"))
[[ -n "$(grep -E "^gcc-multilib$" <<< ${depspkgstmp[$i]})" ]] && depspkgs=($(tr ' ' '\n' <<< ${depspkgs[@]} | sed "s/^${depspkgstmp[$i]}$//g"))
done
fi
# remove installed deps
if [[ ! $foreign && ! $devel ]]; then
depspkgs=($($pacmanbin -T ${depspkgs[@]} | sort -u))
else
# remove versioning and check providers
unset vcsdepspkgs
for i in "${!depspkgs[@]}"; do
depspkgs[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${depspkgs[$i]})
unset j && j=$(expac -Qs '%n %P' "^${depspkgs[$i]}$" | head -1 | grep -E "([^a-zA-Z0-9_@\.\+-]${depspkgs[$i]}|^${depspkgs[$i]})" | grep -E "(${depspkgs[$i]}[^a-zA-Z0-9\.\+-]|${depspkgs[$i]}$)" | awk '{print $1}')
if [[ -n "$j" ]]; then
depspkgs[$i]="$j"
[[ $devel ]] && [[ ! " ${ignoredpkgs[@]} " =~ " $j " ]] && [[ -n "$(grep -E "\-(cvs|svn|git|hg|bzr|darcs|daily.*|nightly.*)$" <<< $j)" ]] && vcsdepspkgs+=($j)
else
foreignpkgs+=(${depspkgs[$i]})
fi
done
# reorder devel
if [[ $devel ]]; then
[[ ! $foreign ]] && depspkgs=($($pacmanbin -T ${depspkgs[@]} | sort -u))
depspkgstmp=($(grep -xvf <(printf '%s\n' "${depspkgs[@]}") <(printf '%s\n' "${vcsdepspkgs[@]}")))
depspkgstmp+=($(grep -xvf <(printf '%s\n' "${vcsdepspkgs[@]}") <(printf '%s\n' "${depspkgs[@]}")))
depspkgs=($(tr ' ' '\n' <<< ${depspkgstmp[@]} | LC_COLLATE=C sort -u))
fi
# remove installed binary packages only
if [[ $foreign ]]; then
depspkgs=($(grep -xf <(printf '%s\n' "${depspkgs[@]}") <(printf '%s\n' "${foreignpkgs[@]}")))
fi
fi
# split binary and AUR depends pkgs
unset depspkgsaur
if [[ -n "${depspkgs[@]}" ]]; then
# remove all pkgs versioning
if [[ $nodeps && $count -eq 1 ]]; then
for i in "${!depspkgs[@]}"; do
depspkgs[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${depspkgs[$i]})
done
# assume installed deps
elif [[ -n "${assumeinstalled[@]}" ]]; then
# remove versioning
for i in "${!assumeinstalled[@]}"; do
unset assumedepspkgs
assumeinstalled[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${assumeinstalled[$i]})
for j in "${!depspkgs[@]}"; do
assumedepspkgs[$j]=$(awk -F ">|<|=" '{print $1}' <<< ${depspkgs[$j]})
[[ " ${assumedepspkgs[@]} " =~ " ${assumeinstalled[$i]} " ]] && depspkgs[$j]=${assumeinstalled[$i]};
done
done
depspkgs=($(grep -xvf <(printf '%s\n' "${assumeinstalled[@]}") <(printf '%s\n' "${depspkgs[@]}")))
fi
if [[ -n "${depspkgs[@]}" ]]; then
depspkgsaur=($(LC_ALL=C $pacmanbin -Sp ${depspkgs[@]} 2>&1 >/dev/null | awk '{print $NF}'))
repodeps+=($(grep -xvf <(printf '%s\n' "${depspkgsaur[@]}") <(printf '%s\n' "${depspkgs[@]}")))
fi
fi
unset depspkgs
# remove duplicate
if [[ -n "${depspkgsaur[@]}" ]]; then
depspkgsaur=($(grep -xvf <(printf '%s\n' "${aurdepspkgs[@]}") <(printf '%s\n' "${depspkgsaur[@]}")))
fi
# dependency cycle check
[[ -n "${prevdepspkgsaur[@]}" ]] && [[ "${prevdepspkgsaur[*]}" == "${depspkgsaur[*]}" ]] && Note "e" $"dependency cycle detected (${depspkgsaur[*]})"
if [[ -n "${depspkgsaur[@]}" ]]; then
# store for AUR version check
[[ ! $nodeps ]] && prevdepspkgsaur=(${depspkgsaur[@]})
# remove AUR pkgs versioning
for i in "${!depspkgsaur[@]}"; do
depspkgsaur[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${depspkgsaur[$i]})
done
# remove duplicate
depspkgsaur=($(tr ' ' '\n' <<< ${depspkgsaur[@]} | sort -u))
fi
if [[ -n "${depspkgsaur[@]}" ]]; then
aurdepspkgs+=(${depspkgsaur[@]})
FindDepsAur ${depspkgsaur[@]}
fi
}
SortDepsAur() {
local i j sortaurpkgs sortdepspkgs sortdepspkgsaur
# global checkedsortdepspkgsaur allcheckedsortdepspkgsaur json errdepsnover
[[ -z "${checkedsortdepspkgsaur[@]}" ]] && sortaurpkgs=(${aurpkgs[@]}) || sortaurpkgs=(${checkedsortdepspkgsaur[@]})
unset checkedsortdepspkgsaur
for i in "${!sortaurpkgs[@]}"; do
unset sortdepspkgs sortdepspkgsaur
sortdepspkgs+=($(GetJson "arrayvar" "$json" "Depends" "${sortaurpkgs[$i]}"))
sortdepspkgs+=($(GetJson "arrayvar" "$json" "MakeDepends" "${sortaurpkgs[$i]}"))
sortdepspkgs+=($(GetJson "arrayvar" "$json" "CheckDepends" "${sortaurpkgs[$i]}"))
# remove versioning
for j in "${!errdeps[@]}"; do
errdepsnover[$j]=$(awk -F ">|<|=" '{print $1}' <<< ${errdeps[$j]})
done
# check AUR deps only
for j in "${!sortdepspkgs[@]}"; do
sortdepspkgs[$j]=$(awk -F ">|<|=" '{print $1}' <<< ${sortdepspkgs[$j]})
sortdepspkgsaur+=($(GetJson "varvar" "$json" "Name" "${sortdepspkgs[$j]}"))
# add erroneous AUR deps
[[ " ${errdepsnover[@]} " =~ " ${sortdepspkgs[$j]} " ]] && sortdepspkgsaur+=("${sortdepspkgs[$j]}")
done
# prepare tsort list
if [[ -z "${sortdepspkgsaur[@]}" ]]; then
tsortdeps+=("${sortaurpkgs[$i]} ${sortaurpkgs[$i]}")
else
for j in "${!sortdepspkgsaur[@]}"; do
tsortdeps+=("${sortaurpkgs[$i]} ${sortdepspkgsaur[$j]}")
done
fi
# filter non checked deps
sortdepspkgsaur=($(grep -xvf <(printf '%s\n' "${allcheckedsortdepspkgsaur[@]}") <(printf '%s\n' "${sortdepspkgsaur[@]}")))
if [[ -n "${sortdepspkgsaur[@]}" ]]; then
checkedsortdepspkgsaur+=(${sortdepspkgsaur[@]})
allcheckedsortdepspkgsaur+=(${sortdepspkgsaur[@]})
allcheckedsortdepspkgsaur=($(tr ' ' '\n' <<< ${allcheckedsortdepspkgsaur[@]} | sort -u))
fi
done
if [[ -n "${checkedsortdepspkgsaur[@]}" ]]; then
checkedsortdepspkgsaur=($(tr ' ' '\n' <<< ${checkedsortdepspkgsaur[@]} | sort -u))
SortDepsAur ${checkedsortdepspkgsaur[@]}
fi
}
FindDepsAurError() {
local i nexterrdep nextallerrdeps
# global errdepsnover errdepslist tsorterrdeps currenterrdep
for i in "${tsorterrdeps[@]}"; do
[[ ! " ${errdepsnover[@]} " =~ " $i " ]] && [[ ! " ${errdepslist[@]} " =~ " $i " ]] && nexterrdep="$i" && break
done
[[ -z "${currenterrdep[@]}" ]] && currenterrdep=${tsorterrdeps[0]}
if [[ ! " ${aurpkgs[@]} " =~ " $nexterrdep " ]]; then
nextallerrdeps=($(GetJson "arrayvar" "$json" "Depends" "$nexterrdep"))
nextallerrdeps+=($(GetJson "arrayvar" "$json" "MakeDepends" "$nexterrdep"))
nextallerrdeps+=($(GetJson "arrayvar" "$json" "CheckDepends" "$nexterrdep"))
# remove versioning
for i in "${!nextallerrdeps[@]}"; do
nextallerrdeps[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${nextallerrdeps[$i]})
done
if [[ " ${nextallerrdeps[@]} " =~ " $currenterrdep " ]]; then
errdepslist+=("$nexterrdep")
currenterrdep=${tsorterrdeps[0]}
fi
tsorterrdeps=(${tsorterrdeps[@]:1})
FindDepsAurError ${tsorterrdeps[@]}
else
for i in "${!aurpkgs[@]}"; do
nextallerrdeps=($(GetJson "arrayvar" "$json" "Depends" "${aurpkgs[$i]}"))
nextallerrdeps+=($(GetJson "arrayvar" "$json" "MakeDepends" "${aurpkgs[$i]}"))
nextallerrdeps+=($(GetJson "arrayvar" "$json" "CheckDepends" "${aurpkgs[$i]}"))
# remove versioning
for j in "${!nextallerrdeps[@]}"; do
nextallerrdeps[$j]=$(awk -F ">|<|=" '{print $1}' <<< ${nextallerrdeps[$j]})
done
if [[ " ${nextallerrdeps[@]} " =~ " $currenterrdep " ]]; then
errdepslist+=("${aurpkgs[$i]}")
fi
done
fi
}
FindDepsRepo() {
local allrepodepspkgs repodepspkgstmp
# global repodeps repodepspkgs
[[ -z "${repodeps[@]}" ]] && return
# reduce root binary deps
repodeps=($(tr ' ' '\n' <<< ${repodeps[@]} | sort -u))
# add initial repodeps
[[ -z "${repodepspkgs[@]}" ]] && repodepspkgs=(${repodeps[@]})
# get non installed repo deps
unset allrepodepspkgs repodepspkgstmp
[[ -n "${repodeps[@]}" ]] && allrepodepspkgs=($(expac -S -1 '%E' ${repodeps[@]})) # no version check needed as all deps are binary
[[ -n "${allrepodepspkgs[@]}" ]] && repodepspkgstmp=($($pacmanbin -T ${allrepodepspkgs[@]} | sort -u))
# remove duplicate
if [[ -n "${repodepspkgstmp[@]}" ]]; then
repodepspkgstmp=($(grep -xvf <(printf '%s\n' "${repodepspkgs[@]}") <(printf '%s\n' "${repodepspkgstmp[@]}")))
fi
if [[ -n "${repodepspkgstmp[@]}" ]]; then
repodepspkgs+=(${repodepspkgstmp[@]})
repodeps=(${repodepspkgstmp[@]})
FindDepsRepo ${repodeps[@]}
fi
}
FindDepsRepoProvider() {
local allrepodepspkgs providerrepodepspkgstmp
# global repodeps repodepspkgs
[[ -z "${providerspkgs[@]}" ]] && return
# reduce root binary deps
providerspkgs=($(tr ' ' '\n' <<< ${providerspkgs[@]} | sort -u))
# get non installed repo deps
unset allproviderrepodepspkgs providerrepodepspkgstmp
[[ -n "${providerspkgs[@]}" ]] && allproviderrepodepspkgs=($(expac -S -1 '%E' ${providerspkgs[@]})) # no version check needed as all deps are binary
[[ -n "${allproviderrepodepspkgs[@]}" ]] && providerrepodepspkgstmp=($($pacmanbin -T ${allproviderrepodepspkgs[@]} | sort -u))
# remove duplicate
if [[ -n "${providerrepodepspkgstmp[@]}" ]]; then
providerrepodepspkgstmp=($(grep -xvf <(printf '%s\n' "${repodepspkgs[@]}") <(printf '%s\n' "${providerrepodepspkgstmp[@]}")))
fi
if [[ -n "${providerrepodepspkgstmp[@]}" ]]; then
repodepspkgs+=(${providerrepodepspkgstmp[@]})
providerspkgs=(${providerrepodepspkgstmp[@]})
FindDepsRepoProvider ${providerspkgs[@]}
fi
}
IgnoreDepsChecks() {
local i
# global ignoredpkgs aurpkgs aurdepspkgs aurdepspkgsAgrp aurdepspkgsQgrp repodepspkgsSgrp repodepspkgsQgrp rmaurpkgs deps repodepspkgs
[[ -z "${ignoredpkgs[@]}" && -z "${ignoredgrps[@]}" ]] && return
# add checked targets and preserve tsorted order
deps=(${deps[@]:0:${#aurpkgs[@]}})
# check dependencies
for i in "${repodepspkgs[@]}"; do
unset isignored
if [[ " ${ignoredpkgs[@]} " =~ " $i " ]]; then
isignored=true
elif [[ -n "${ignoredgrps[@]}" ]]; then
unset repodepspkgsSgrp repodepspkgsQgrp
repodepspkgsSgrp=($(expac -S -1 '%G' "$i"))
for j in "${repodepspkgsSgrp[@]}"; do
[[ " ${ignoredgrps[@]} " =~ " $j " ]] && isignored=true
done
repodepspkgsQgrp=($(expac -Q '%G' "$i"))
for j in "${repodepspkgsQgrp[@]}"; do
[[ " ${ignoredgrps[@]} " =~ " $j " ]] && isignored=true
done
fi
if [[ $isignored = true ]]; then
if [[ ! $upgrade ]]; then
Note "w" $"skipping target: ${colorW}$i${reset}"
else
Note "w" $"${colorW}$i${reset}: ignoring package upgrade"
fi
Note "e" $"Unresolved dependency '${colorW}$i${reset}'"
fi
done
for i in "${aurdepspkgs[@]}"; do
# skip already checked dependencies
[[ " ${aurpkgs[@]} " =~ " $i " ]] && continue
[[ " ${rmaurpkgs[@]} " =~ " $i " ]] && Note "e" $"Unresolved dependency '${colorW}$i${reset}'"
unset isignored
if [[ " ${ignoredpkgs[@]} " =~ " $i " ]]; then
isignored=true
elif [[ -n "${ignoredgrps[@]}" ]]; then
unset aurdepspkgsAgrp aurdepspkgsQgrp
aurdepspkgsAgrp=($(GetJson "arrayvar" "$json" "Groups" "$i"))
for j in "${aurdepspkgsAgrp[@]}"; do
[[ " ${ignoredgrps[@]} " =~ " $j " ]] && isignored=true
done
aurdepspkgsQgrp=($(expac -Q '%G' "$i"))
for j in "${aurdepspkgsQgrp[@]}"; do
[[ " ${ignoredgrps[@]} " =~ " $j " ]] && isignored=true
done
fi
if [[ $isignored = true ]]; then
if [[ ! $noconfirm ]]; then
if ! Proceed "y" $"$i dependency is in IgnorePkg/IgnoreGroup. Install anyway?"; then
Note "w" $"skipping target: ${colorW}$i${reset}"
Note "e" $"Unresolved dependency '${colorW}$i${reset}'"
fi
else
if [[ ! $upgrade ]]; then
Note "w" $"skipping target: ${colorW}$i${reset}"
else
Note "w" $"${colorW}$i${reset}: ignoring package upgrade"
fi
Note "e" $"Unresolved dependency '${colorW}$i${reset}'"
fi
fi
deps+=($i)
done
}
ProviderChecks() {
local allproviders providersdeps providersdepsnover providers repodepspkgsprovided providerspkgs provided nb providersnb
# global repodepspkgs repoprovidersconflictingpkgs repodepsSver repodepsSrepo repodepsQver
[[ -z "${repodepspkgs[@]}" ]] && return
# filter directly provided deps
noprovidersdeps=($(expac -S -1 '%n' ${repodepspkgs[@]}))
providersdeps=($(grep -xvf <(printf '%s\n' "${noprovidersdeps[@]}") <(printf '%s\n' "${repodepspkgs[@]}")))
# remove installed providers
providersdeps=($($pacmanbin -T ${providersdeps[@]} | sort -u))
for i in "${!providersdeps[@]}"; do
# check versioning
unset providersdepsname providersdepsver providersdepsSname providersdepsSver
providersdepsname=${providersdeps[$i]} && providersdepsname=${providersdepsname%[><]*} && providersdepsname=${providersdepsname%=*}
providersdepsver=${providersdeps[$i]} && providersdepsver=${providersdepsver#*=} && providersdepsver=${providersdepsver#*[><]}
providersdepsSname=($(expac -Ss '%n' ^${providersdepsname[$i]}$))
providersdepsSver=($(expac -Ss '%v' ^${providersdepsname[$i]}$))
case "${providersdeps[$i]}" in
*">"*|*"<"*|*"="*)
for j in "${!providersdepsSname[@]}"; do
# found in repo but version not correct
case "${providersdeps[$i]}" in
*">="*) [[ $(vercmp "$providersdepsver" "${providersdepsSver[j]}") -ge 0 ]] && continue;;
*"<="*) [[ $(vercmp "$providersdepsver" "${providersdepsSver[j]}") -le 0 ]] && continue;;
*">"*) [[ $(vercmp "$providersdepsver" "${providersdepsSver[j]}") -gt 0 ]] && continue;;
*"<"*) [[ $(vercmp "$providersdepsver" "${providersdepsSver[j]}") -lt 0 ]] && continue;;
*"="*) [[ $(vercmp "$providersdepsver" "${providersdepsSver[j]}") -eq 0 ]] && continue;;
esac
providersdepsnover+=("${providersdepsSname[j]}")
done
;;
esac
# remove versioning
providersdeps[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${providersdeps[$i]})
# list providers
providers=($(expac -Ss '%n' "^${providersdeps[$i]}$" | sort -u))
# filter out non matching versioned providers
[[ -n "${providersdepsnover[@]}" ]] && providers=($(grep -xf <(printf '%s\n' "${providersdepsnover[@]}") <(printf '%s\n' "${providers[@]}")))
# skip if provided in dependency chain
unset repodepspkgsprovided
for j in "${!providers[@]}"; do
[[ " ${repodepspkgs[@]} " =~ " ${providers[$j]} " ]] && repodepspkgsprovided='true'
done
[[ $repodepspkgsprovided ]] && continue
# skip if already provided
if [[ -n "${providerspkgs[@]}" ]]; then
providerspkgs=($(tr ' ' '|' <<< ${providerspkgs[@]}))
provided+=($(expac -Ss '%S' "^(${providerspkgs[*]})$"))
[[ " ${provided[@]} " =~ " ${providersdeps[$i]} " ]] && continue
fi
if [[ ! $noconfirm && ${#providers[@]} -gt 1 ]]; then
Note "i" $"${colorW}There are ${#providers[@]} providers available for ${providersdeps[$i]}:${reset}"
expac -S -1 ' %!) %n (%r) ' "${providers[@]}"
local nb=-1
providersnb=$(( ${#providers[@]} -1 )) # count from 0
while [[ $nb -lt 0 || $nb -ge ${#providers} ]]; do
printf "\n%s " $"Enter a number (default=0):"
case "$TERM" in
dumb)
read -r nb
;;
*)
read -r -n "$(echo -n $providersnb | wc -m)" nb
echo
;;
esac
case $nb in
[0-9]|[0-9][0-9])
if [[ $nb -lt 0 || $nb -ge ${#providers[@]} ]]; then
echo && Note "f" $"invalid value: $nb is not between 0 and $providersnb" && ((i--))
else
break
fi;;
'') nb=0;;
*) Note "f" $"invalid number: $nb";;
esac
done
else
local nb=0
fi
providerspkgs+=(${providers[$nb]})
done
# add selected providers to repo deps
repodepspkgs+=(${providerspkgs[@]})
# store for installation
repoprovidersconflictingpkgs+=(${providerspkgs[@]})
FindDepsRepoProvider ${providerspkgs[@]}
# get binary packages info
if [[ -n "${repodepspkgs[@]}" ]]; then
repodepspkgs=($(expac -S -1 '%n' "${repodepspkgs[@]}" | LC_COLLATE=C sort -u))
repodepsSver=($(expac -S -1 '%v' "${repodepspkgs[@]}"))
repodepsQver=($(expac -Q '%v' "${repodepspkgs[@]}"))
repodepsSrepo=($(expac -S -1 '%r/%n' "${repodepspkgs[@]}"))
fi
}
ConflictChecks() {
local allQprovides allQconflicts Aprovides Aconflicts aurconflicts aurAconflicts Qrequires i j k
local repodepsprovides repodepsconflicts checkedrepodepsconflicts repodepsconflictsname repodepsconflictsver localver repoconflictingpkgs
# global deps depsAname json aurdepspkgs aurconflictingpkgs aurconflictingpkgsrm depsQver repodepspkgs repoconflictingpkgsrm repoprovidersconflictingpkgs
Note "i" $"looking for inter-conflicts..."
allQprovides=($(expac -Q '%n'))
allQprovides+=($(expac -Q '%S')) # no versioning
allQconflicts=($(expac -Q '%C'))
# AUR conflicts
Aprovides=(${depsAname[@]})
Aprovides+=($(GetJson "array" "$json" "Provides"))
Aconflicts=($(GetJson "array" "$json" "Conflicts"))
# remove AUR versioning
for i in "${!Aprovides[@]}"; do
Aprovides[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${Aprovides[$i]})
done
for i in "${!Aconflicts[@]}"; do
Aconflicts[$i]=$(awk -F ">|<|=" '{print $1}' <<< ${Aconflicts[$i]})
done
aurconflicts=($(grep -xf <(printf '%s\n' "${Aprovides[@]}") <(printf '%s\n' "${allQconflicts[@]}")))
aurconflicts+=($(grep -xf <(printf '%s\n' "${Aconflicts[@]}") <(printf '%s\n' "${allQprovides[@]}")))
aurconflicts=($(tr ' ' '\n' <<< ${aurconflicts[@]} | LC_COLLATE=C sort -u))
for i in "${aurconflicts[@]}"; do
unset aurAconflicts
[[ " ${depsAname[@]} " =~ " $i " ]] && aurAconflicts=($i)
for j in "${depsAname[@]}"; do
[[ " $(GetJson "arrayvar" "$json" "Conflicts" "$j") " =~ " $i " ]] && aurAconflicts+=($j)
done
for j in "${aurAconflicts[@]}"; do
unset k Aprovides
k=$(expac -Qs '%n %P' "^$i$" | head -1 | grep -E "([^a-zA-Z0-9_@\.\+-]$i|^$i)" | grep -E "($i[^a-zA-Z0-9\.\+-]|$i$)" | awk '{print $1}')
[[ ! $installpkg && ! " ${aurdepspkgs[@]} " =~ " $j " ]] && continue # skip if downloading target only
[[ "$j" == "$k" || -z "$k" ]] && continue # skip if reinstalling or if no conflict exists
Aprovides=($j)
if [[ ! $noconfirm && ! " ${aurconflictingpkgs[@]} " =~ " $k " ]]; then
if ! Proceed "n" $"$j and $k are in conflict ($i). Remove $k?"; then
aurconflictingpkgs+=($j $k)
aurconflictingpkgsrm+=($k)
for l in "${!depsAname[@]}"; do
[[ " ${depsAname[$l]} " =~ "$k" ]] && depsQver[$l]=$(expac -Qs '%v' "^$k$" | head -1)
done
Aprovides+=($(GetJson "arrayvar" "$json" "Provides" "$j"))
# remove AUR versioning
for l in "${!Aprovides[@]}"; do
Aprovides[$l]=$(awk -F ">|<|=" '{print $1}' <<< ${Aprovides[$l]})
done
[[ ! " ${Aprovides[@]} " =~ " $k " && ! " ${aurconflictingpkgsrm[@]} " =~ " $k " ]] && CheckRequires $k
break
else
Note "f" $"unresolvable package conflicts detected"
Note "f" $"failed to prepare transaction (conflicting dependencies)"
if [[ $upgrade ]]; then
Qrequires=($(expac -Q '%N' "$i"))
Note "e" $"$j and $k are in conflict (required by ${Qrequires[*]})"
else
Note "e" $"$j and $k are in conflict"
fi
fi
fi
Aprovides+=($(GetJson "arrayvar" "$json" "Provides" "$j"))
# remove AUR versioning
for l in "${!Aprovides[@]}"; do
Aprovides[$l]=$(awk -F ">|<|=" '{print $1}' <<< ${Aprovides[$l]})
done
[[ ! " ${Aprovides[@]} " =~ " $k " && ! " ${aurconflictingpkgsrm[@]} " =~ " $k " ]] && CheckRequires $k
done
done
NothingToDo ${deps[@]}
# repo conflicts
if [[ -n "${repodepspkgs[@]}" ]]; then
repodepsprovides=(${repodepspkgs[@]})
repodepsprovides+=($(expac -S -1 '%S' "${repodepspkgs[@]}")) # no versioning
repodepsconflicts=($(expac -S -1 '%H' "${repodepspkgs[@]}"))
# versioning check
unset checkedrepodepsconflicts
for i in "${!repodepsconflicts[@]}"; do
unset repodepsconflictsname repodepsconflictsver localver
repodepsconflictsname=${repodepsconflicts[$i]} && repodepsconflictsname=${repodepsconflictsname%[><]*} && repodepsconflictsname=${repodepsconflictsname%=*}
repodepsconflictsver=${repodepsconflicts[$i]} && repodepsconflictsver=${repodepsconflictsver#*=} && repodepsconflictsver=${repodepsconflictsver#*[><]}
[[ $repodepsconflictsname ]] && localver=$(expac -Q '%v' $repodepsconflictsname)
if [[ $localver ]]; then
case "${repodepsconflicts[$i]}" in
*">="*) [[ $(vercmp "$repodepsconflictsver" "$localver") -ge 0 ]] && continue;;
*"<="*) [[ $(vercmp "$repodepsconflictsver" "$localver") -le 0 ]] && continue;;
*">"*) [[ $(vercmp "$repodepsconflictsver" "$localver") -gt 0 ]] && continue;;
*"<"*) [[ $(vercmp "$repodepsconflictsver" "$localver") -lt 0 ]] && continue;;
*"="*) [[ $(vercmp "$repodepsconflictsver" "$localver") -eq 0 ]] && continue;;
esac
checkedrepodepsconflicts+=($repodepsconflictsname)
fi
done
repoconflicts+=($(grep -xf <(printf '%s\n' "${repodepsprovides[@]}") <(printf '%s\n' "${allQconflicts[@]}")))
repoconflicts+=($(grep -xf <(printf '%s\n' "${checkedrepodepsconflicts[@]}") <(printf '%s\n' "${allQprovides[@]}")))
repoconflicts=($(tr ' ' '\n' <<< ${repoconflicts[@]} | LC_COLLATE=C sort -u))
fi
for i in "${repoconflicts[@]}"; do
unset Qprovides
repoSconflicts=($(expac -S -1 '%n %C %S' "${repodepspkgs[@]}" | grep -E "[^a-zA-Z0-9_@\.\+-]$i" | grep -E "($i[^a-zA-Z0-9\.\+-]|$i$)" | awk '{print $1}'))
for j in "${repoSconflicts[@]}"; do
unset k && k=$(expac -Qs '%n %P' "^$i$" | head -1 | grep -E "([^a-zA-Z0-9_@\.\+-]$i|^$i)" | grep -E "($i[^a-zA-Z0-9\.\+-]|$i$)" | awk '{print $1}')
[[ "$j" == "$k" || -z "$k" ]] && continue # skip when no conflict with repopkgs
if [[ ! $noconfirm && ! " ${repoconflictingpkgs[@]} " =~ " $k " ]]; then
if ! Proceed "n" $"$j and $k are in conflict ($i). Remove $k?"; then
repoconflictingpkgs+=($j $k)
repoconflictingpkgsrm+=($k)
repoprovidersconflictingpkgs+=($j)
Qprovides=($(expac -Ss '%S' "^$k$"))
[[ ! " ${Qprovides[@]} " =~ " $k " && ! " ${repoconflictingpkgsrm[@]} " =~ " $k " ]] && CheckRequires $k
break
else
Note "f" $"unresolvable package conflicts detected"
Note "f" $"failed to prepare transaction (conflicting dependencies)"
if [[ $upgrade ]]; then
Qrequires=($(expac -Q '%N' "$i"))
Note "e" $"$j and $k are in conflict (required by ${Qrequires[*]})"
else
Note "e" $"$j and $k are in conflict"
fi
fi
fi
Qprovides=($(expac -Ss '%S' "^$k$"))
[[ ! " ${Qprovides[@]} " =~ " $k " ]] && CheckRequires $k
done
done
}
ReinstallChecks() {
local i depsAtmp
# global aurpkgs aurdepspkgs deps aurconflictingpkgs depsAname depsQver depsAver depsAood depsAmain
depsAtmp=(${depsAname[@]})
for i in "${!depsAtmp[@]}"; do
[[ ! $foreign ]] && [[ ! " ${aurpkgs[@]} " =~ " ${depsAname[$i]} " || " ${aurconflictingpkgs[@]} " =~ " ${depsAname[$i]} " ]] && continue
[[ -z "${depsQver[$i]}" || "${depsQver[$i]}" = '#' || $(vercmp "${depsAver[$i]}" "${depsQver[$i]}") -gt 0 ]] && continue
[[ ! $installpkg && ! " ${aurdepspkgs[@]} " =~ " ${depsAname[$i]} " ]] && continue
if [[ -n "$(grep -E "\-(cvs|svn|git|hg|bzr|darcs|daily.*|nightly.*)$" <<< ${depsAname[$i]})" ]]; then
Note "w" $"${colorW}${depsAname[$i]}${reset} latest revision -- fetching"
else
if [[ ! $needed ]]; then
Note "w" $"${colorW}${depsAname[$i]}-${depsQver[$i]}${reset} is up to date -- reinstalling"
else