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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
|
#!/bin/bash
# The Archlinux User Repository eXplorer.
# A simple bash script for easily managing AUR installs.
# Copyright (C) 2026 the aurx contributors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses.
# Tier 0 functions.
usage() {
cat <<- EOF
usage: ${EXECUTABLE_NAME} [OPERATION] [OPTION].. [PACKAGE]..
The Archlinux User Repository eXplorer.
Operations:
install install any package from AUR or the source path.
remove remove packages from the system and internal list.
update force install any package from AUR and delete source after.
search query the AUR database via the HTTP RPC API.
suggest completion results via the AUR HTTP RPC API.
completion generate completion for the specified shell.
list search for all locally installed AUR packages.
Options:
general:
-a --all add all installed packages to the operation.
-c --config [JSON_STRING] JSON configuration for aurx.
same options as explicit, but capitalized and with
underscores instead of hyphens, e.g. TMP_PATH.
It has the highest priority and beautified JSON works too.
-f --force forces the operation, where appliable.
-h --help display this information and exit.
--persistent-path [PATH] path for persistent data. ("\${HOME}/.aurx/cfg")
-t --tmp-path [PATH] temp filesystem for various operations. ("/tmp/aurx")
--verbosity [LEVEL] level of verbosity. (2)
0 - none, 1 - stderr, 2 - all.
-v --version display current version and exit.
install:
--cleanup delete sources after successful installs.
--clean-operation delete sources after unsucessful installs.
-x --comparison-criteria [CRITERIA] criteria to use when comparing packages. ("rpc")
"rpc" - AUR HTTP RPC API, "pkgbuild" - source path PKGBUILD.
-d --download-only download the source from AUR and stop.
-G --git-opts [OPTS].. opts to give in to git operations. ("")
-M --makepkg-opts [OPTS].. opts to give in to makepkg installs. ("-sirc")
--overwrite-existing overwrite eventually existing sources.
--source-path [PATH] work directory for builds.("\${HOME}/.aurx/src")
-V --verify-versions compare target versions to installed ones.
--wipe-existing wipe eventually existing sources.
remove:
-R --remove-opts [OPTS].. opts to give in to pacman for removing package. ("-R")
search:
-C --curl-opts opts to give in to curl.
timeouts can be overwritten with this.
--maintained filter out unmaintained packages.
--no-mark-installed don't show the '[installed]' mark.
--no-mark-update do not check for updates while searching.
--no-out-of-date filter out all out of date packages.
--order-by [ORDER] how to order search results. ("descending")
"ascending", "descending".
-o --output [TYPE] how to output search results. ("formatted")
"formatted", "json", "json-lines".
-p --parallel [COUNT] how many requests to do simultaneously. (50)
--search-results [COUNT] number of results to display from search queries. (20)
--search-criteria [CRITERIA] criteria to use in search queries. ("name")
"name", "name-desc", "depends", "checkdepends",
"optdepends", "makedepends", "maintainer",
"submitter", "provides", "conflicts", "replaces",
"keywords", "groups", "comaintainers".
--sort-by [KEY] key to sort results by. ("popularity")
"popularity", "firstsubmitted", "lastmodified", "votes".
suggest:
-C --curl-opts opts to give in to curl.
timeouts can be overwritten with this.
--order-by [ORDER] how to order suggest results. ("descending")
"ascending", "descending".
--search-results [COUNT] number of results to suggest, max 20. (20)
-o --output [TYPE] how to output suggest results. ("formatted")
"formatted", "json-lines".
update:
--block-overwrite don't overwrite existing sources.
-x --comparison-criteria [CRITERIA] criteria to use when comparing packages. ("rpc")
"rpc" - AUR HTTP RPC API, "pkgbuild" - source path PKGBUILD.
--keep-sources don't cleanup after successful updates.
--keep-failed-sources don't cleanup after unsuccessful updates.
-M --makepkg-opts [OPTS] opts to give in to makepkg installs. ("-sirc")
list:
--no-mark-installed don't show the '[installed]' mark.
--no-mark-update do not check for updates while searching.
-p --parallel [COUNT] how many requests to do simultaneously. (10)
completion:
-e --executable-name [NAME] the name of the executable to be used for completion. ("aurx")
Environment variables:
Capitalized long option names with AURX_ prefix, for example: AURX_SEARCH_CRITERIA.
The explicit options have the highest priority.
EOF
}
print_error() {
local GIVEN_ERROR="${1}"
case "${GIVEN_ERROR}" in
10 )
echo "[!] Could not remove files for target: \"${SELECTED_PACKAGE}\"." >&2
echo "[i] Check file permissions." >&2
;;
11 )
echo "[!] Could not pull repository: \"${SELECTED_PACKAGE}\"." >&2
;;
12 )
echo "[!] Could not clone git repository of \"${SELECTED_PACKAGE}\"." >&2
;;
13 )
echo "[!] Could not build \"${SELECTED_PACKAGE}\"." >&2
;;
14 )
echo "[!] Could not write \"${SELECTED_PACKAGE}\" to the package_list." >&2
;;
20 )
echo "[!] Could not remove \"${SELECTED_PACKAGE}\" from system." >&2
;;
21 )
echo "[!] Could not remove \"${SELECTED_PACKAGE}\" from the package_list." >&2
;;
30 )
echo "[!] Could not gather AUR HTTP data." >&2
;;
31 )
echo "[!] Could not filter AUR HTTP responses." >&2
;;
32 )
echo "[!] Could not print AUR HTTP data." >&2
;;
40 )
echo "[!] Could not get suggest results." >&2
;;
50|51 )
echo "[-] getopt not working properly." >&2
;;
52 )
echo "[-] Unknown search criteria: \"${SEARCH_CRITERIA}\"." >&2
echo "[i] Possible options are: name, name-desc, depends, checkdepends, optdepends, makedepends, maintainer, submitter, provides, conflicts, replaces, keywords, groups, comaintainers." >&2
;;
53 )
echo "[-] Unknown error while parsing options." >&2
;;
54 )
echo "[-] No operation selected. Possible options are: ${POSSIBLE_OPERATIONS[*]}." >&2
;;
55 )
echo "[-] Unknown operation: \"${CURRENT_OPERATION}\". Possible options are: ${POSSIBLE_OPERATIONS[*]}." >&2
;;
56 )
echo "[-] No parameters found and the current \"${CURRENT_OPERATION}\" operation requires at least one." >&2
;;
57 )
echo "[!] Can't install or update packages as root." >&2
;;
58 )
echo "[-] Unknown verbosity level \"${VERBOSITY}\"." >&2
echo "[i] Possible options are: 0 - nothing, 1 - stderr, 2 - all" >&2
;;
59 )
echo "[-] The following required packages are not installed: ${ABSENT_PACKAGES[*]}." >&2
;;
60 )
echo "[-] Shell type \"${SHELL_TYPE}\" is not supported." >&2
;;
61 )
echo "[-] Uknown error code ${ERROR_CODE} received." >&2
;;
62 )
echo "[-] Completion for \"${COMPLETION_TYPE}\" is not available." >&2
;;
63 )
echo "[-] pushd failed at \"${PWD}\"." >&2
;;
64 )
echo "[-] popd failed at \"${PWD}\"." >&2
;;
65 )
echo "[-] Unknown sort-by value: \"${SORT_BY}\"." >&2
echo "[i] Possible options are: firstsubmitted, lastmodified, votes, popularity." >&2
;;
66 )
echo "[-] Unknown order-by value: \"${ORDER_BY}\"." >&2
echo "[i] Possible options are: ascending, descending." >&2
;;
67 )
echo "[-] Could not pull repository: \"${SELECTED_PACKAGE}\"." >&2
;;
68 )
echo "[-] Unknown comparison criteria: \"${COMPARISON_CRITERIA}\"." >&2
echo "[i] Possible options are: pkgbuild, rpc." >&2
;;
70 )
echo "[-] Could not find PKGBUILD for \"${SELECTED_PACKAGE}\" with comparison criteria \"pkgbuild\"." >&2
;;
71 )
echo "[-] Internal error during execution phase." >&2
;;
72 )
echo "[-] Could not create required directory \"${REQUIRED_DIRECTORY}\"." >&2
;;
73 )
echo "[-] Could not touch required file \"${REQUIRED_FILE}\"." >&2
;;
74 )
echo "[-] Could not establish a connection to the AUR RPC HTTP API." >&2
;;
75 )
echo "[-] Unknown output: \"${OUTPUT}\"." >&2
echo "[i] Possible options are: formatted, json-lines, json." >&2
;;
76 )
local TEMP_PACKAGES
TEMP_PACKAGES="$(echo ${PACKAGES_NOT_FOUND[*]})"
echo "[!] Could not find ${TEMP_PACKAGES}." >&2
;;
77 )
echo "[!] The suggest operation can not output json." >&2
echo "[i] Possible options are: formatted, json-lines." >&2
;;
78 )
echo "[!] \"${CFG_VAR}\" config value has stacked values. Discarding." >&2
;;
79 )
echo "[!] \"${CFG_VAR}\" config key unknown. Discarding." >&2
;;
80 )
echo "[-] Your kernel has been upgraded recently. Please reboot." >&2
;;
* )
echo "[-] No error message found for error ${GIVEN_ERROR}." >&2
;;
esac
}
print_version() {
echo "${INTERNAL_VERSION}"
}
generate_config_json() {
cat <<- EOF | jq -cr
{
"ALL": false,
"BLOCK_OVERWRITE": false,
"CLEAN_OPERATION": false,
"CLEANUP": false,
"COMPARISON_CRITERIA": "rpc",
"CURL_OPTS": [],
"DOWNLOAD_ONLY": false,
"EXECUTABLE_NAME": "aurx",
"FORCE": false,
"GIT_OPTS": [],
"KEEP_FAILED_SOURCES": false,
"KEEP_SOURCES": false,
"MAINTAINED": false,
"MAKEPKG_OPTS": ["-sirc"],
"NO_MARK_INSTALLED": false,
"NO_MARK_UPDATE": false,
"NO_OUT_OF_DATE": false,
"ORDER_BY": "descending",
"OUTPUT": "formatted",
"OVERWRITE_EXISTING": false,
"PARALLEL": 50,
"PERSISTENT_PATH": "${HOME?HOME not defined.}/.aurx/cfg",
"REMOVE_OPTS": ["-R"],
"SEARCH_CRITERIA": "name",
"SEARCH_RESULTS": 20,
"SORT_BY": "popularity",
"SOURCE_PATH": "${HOME?HOME not defined.}/.aurx/src",
"TMP_PATH": "/tmp/aurx",
"VERBOSITY": 2,
"VERIFY_VERSIONS": false,
"WIPE_EXISTING": false
}
EOF
}
aurx_completion() {
local SHELL_TYPE="${1}"
case "${SHELL_TYPE}" in
bash )
cat <<- EOS
_aurx_completion() {
local CURRENT_WORD="\${COMP_WORDS[COMP_CWORD]}"
local LAST_WORD="\${COMP_WORDS[COMP_CWORD-1]}"
COMPREPLY=()
local POSSIBLE_OPERATIONS="${POSSIBLE_OPERATIONS[*]}"
local GENERAL_OPTIONS="${GENERAL_OPTIONS[*]}"
local INSTALL_OPTIONS="${INSTALL_OPTIONS[*]}"
local REMOVE_OPTIONS="${REMOVE_OPTIONS[*]}"
local UPDATE_OPTIONS="${UPDATE_OPTIONS[*]}"
local SEARCH_OPTIONS="${SEARCH_OPTIONS[*]}"
local SUGGEST_OPTIONS="${SUGGEST_OPTIONS[*]}"
local COMPLETION_OPTIONS="${COMPLETION_OPTIONS[*]}"
local LIST_OPTIONS="${LIST_OPTIONS[*]}"
local AVAILABLE_COMPLETIONS="${AVAILABLE_COMPLETIONS[*]}"
local COMPARISON_CRITERIA_VALUES="${COMPARISON_CRITERIA_VALUES[*]}"
local OUTPUT_VALUES="${OUTPUT_VALUES[*]}"
local OUTPUT_SUGGEST_VALUES="${OUTPUT_SUGGEST_VALUES[*]}"
local ORDER_BY_VALUES="${ORDER_BY_VALUES[*]}"
local SEARCH_CRITERIA_VALUES="${SEARCH_CRITERIA_VALUES[*]}"
local SORT_BY_VALUES="${SORT_BY_VALUES[*]}"
if [[ \${CURRENT_WORD} == -* ]]; then
COMPREPLY=( \$(compgen -W "\${GENERAL_OPTIONS}" -- "\${CURRENT_WORD}") )
if [[ \${COMP_WORDS[*]} =~ " install " ]]; then
COMPREPLY+=( \$(compgen -W "\${INSTALL_OPTIONS}" -- "\${CURRENT_WORD}") )
elif [[ \${COMP_WORDS[*]} =~ " remove " ]]; then
COMPREPLY+=( \$(compgen -W "\${REMOVE_OPTIONS}" -- "\${CURRENT_WORD}") )
elif [[ \${COMP_WORDS[*]} =~ " update " ]]; then
COMPREPLY+=( \$(compgen -W "\${UPDATE_OPTIONS}" -- "\${CURRENT_WORD}") )
elif [[ \${COMP_WORDS[*]} =~ " search " ]]; then
COMPREPLY+=( \$(compgen -W "\${SEARCH_OPTIONS}" -- "\${CURRENT_WORD}") )
elif [[ \${COMP_WORDS[*]} =~ " suggest " ]]; then
COMPREPLY+=( \$(compgen -W "\${SUGGEST_OPTIONS}" -- "\${CURRENT_WORD}") )
elif [[ \${COMP_WORDS[*]} =~ " completion " ]]; then
COMPREPLY+=( \$(compgen -W "\${COMPLETION_OPTIONS}" -- "\${CURRENT_WORD}") )
elif [[ \${COMP_WORDS[*]} =~ " list " ]]; then
COMPREPLY+=( \$(compgen -W "\${LIST_OPTIONS}" -- "\${CURRENT_WORD}") )
fi
elif [[ \${LAST_WORD} == "--search-criteria" ]]; then
COMPREPLY=( \$(compgen -W "\${SEARCH_CRITERIA_VALUES}" -- "\${CURRENT_WORD}") )
elif [[ \${LAST_WORD} == "--comparison-criteria" ]]; then
COMPREPLY=( \$(compgen -W "\${COMPARISON_CRITERIA_VALUES}" -- "\${CURRENT_WORD}") )
elif [[ \${LAST_WORD} == "--output" ]] && [[ \${COMP_WORDS[*]} =~ " search " ]]; then
COMPREPLY=( \$(compgen -W "\${OUTPUT_VALUES}" -- "\${CURRENT_WORD}") )
elif [[ \${LAST_WORD} == "--output" ]] && [[ \${COMP_WORDS[*]} =~ " suggest " ]]; then
COMPREPLY=( \$(compgen -W "\${OUTPUT_SUGGEST_VALUES}" -- "\${CURRENT_WORD}") )
elif [[ \${LAST_WORD} == "--order-by" ]]; then
COMPREPLY=( \$(compgen -W "\${ORDER_BY_VALUES}" -- "\${CURRENT_WORD}") )
elif [[ \${LAST_WORD} == "--sort-by" ]]; then
COMPREPLY=( \$(compgen -W "\${SORT_BY_VALUES}" -- "\${CURRENT_WORD}") )
elif [[ \${LAST_WORD} == "--source-path" ]] || [[ \${LAST_WORD} == "--persistent-path" ]] || [[ \${LAST_WORD} == "--tmp-path" ]]; then
COMPREPLY=( \$(compgen -d -- "\${CURRENT_WORD}") )
elif [[ -z \$(echo \${COMP_WORDS[*]} \${POSSIBLE_OPERATIONS[*]} | tr " " "\n" | sort | uniq -D) ]]; then
COMPREPLY=( \$(compgen -W "\${POSSIBLE_OPERATIONS}" -- "\${CURRENT_WORD}") )
elif [[ \${#CURRENT_WORD} -ge 3 ]] && [[ ! -z \$(echo \${COMP_WORDS[*]} " install search " | tr " " "\n" | sort | uniq -D) ]]; then
COMPREPLY=( \$(compgen -W "\$(${EXECUTABLE_NAME} suggest \${CURRENT_WORD} | tr '\n' ' ')" -- "\${CURRENT_WORD}") )
elif [[ ! -z \$(echo \${COMP_WORDS[*]} " remove update " | tr " " "\n" | sort | uniq -D) ]]; then
COMPREPLY=( \$(compgen -W "\$(cat ${PERSISTENT_PATH}/package_list | tr '\n' ' ')" -- "\${CURRENT_WORD}") )
elif [[ ! -z \$(echo \${COMP_WORDS[*]} " completion " | tr " " "\n" | sort | uniq -D) ]]; then
COMPREPLY=( \$(compgen -W "\${AVAILABLE_COMPLETIONS}" -- "\${CURRENT_WORD}") )
fi
for PLANNED_REPLY in \${COMPREPLY[*]}; do
if [[ \${COMP_WORDS[*]} =~ " \${PLANNED_REPLY} " ]]; then
TEMP_COMPREPLY=\${COMPREPLY[*]}
COMPREPLY=( \${TEMP_COMPREPLY//"\${PLANNED_REPLY}"/} )
fi
done
return 0
}
complete -F _aurx_completion ${EXECUTABLE_NAME}
EOS
;;
esac
}
launch_sanity_checks() {
# Check if installed kernel is the same version as the running one.
if [[ $(vercmp "$(pacman -Q linux | cut -d ' ' -f 2)" "$(uname -r)") -ne 0 ]]; then
print_error 80
exit 80
fi
if [[ ! "${POSSIBLE_OPERATIONS[*]}" =~ ${CURRENT_OPERATION} ]]; then
print_error 55
exit 55
fi
# Root + install/update exception.
if [[ ${UID} -eq 0 ]] && [[ " install update " =~ ${CURRENT_OPERATION} ]]; then
print_error 57
exit 57
fi
if [[ ! "${COMPARISON_CRITERIA_VALUES[*]}" =~ ${COMPARISON_CRITERIA} ]]; then
print_error 68
exit 68
fi
case "${SORT_BY}" in
firstsubmitted )
SORT_BY="FirstSubmitted"
;;
lastmodified )
SORT_BY="LastModified"
;;
votes )
SORT_BY="NumVotes"
;;
popularity )
SORT_BY="Popularity"
;;
* )
print_error 65
exit 65
;;
esac
if [[ ! "${ORDER_BY_VALUES[*]}" =~ ${ORDER_BY} ]]; then
print_error 66
exit 66
fi
case "${CURRENT_OPERATION}" in
search )
if [[ ! "${OUTPUT_VALUES[*]}" =~ ${OUTPUT} ]]; then
print_error 75
exit 75
fi
;;
suggest )
if [[ ! "${OUTPUT_SUGGEST_VALUES[*]}" =~ ${OUTPUT} ]]; then
print_error 77
exit 77
fi
;;
* )
;;
esac
if [[ ! "${SEARCH_CRITERIA_VALUES[*]}" =~ ${SEARCH_CRITERIA} ]]; then
print_error 52
exit 52
fi
case "${VERBOSITY}" in
0 )
STDOUT_DESTINATION=/dev/null
STDERR_DESTINATION=/dev/null
;;
1 )
STDOUT_DESTINATION=/dev/null
STDERR_DESTINATION=/dev/stderr
;;
2 )
STDOUT_DESTINATION=/dev/stdout
STDERR_DESTINATION=/dev/stderr
;;
* )
print_error 58
exit 58
;;
esac
}
launch_system_checks() {
case "${CURRENT_OPERATION}" in
install | update )
REQUIRED_PACKAGES=('curl' 'echo' 'git' 'grep' 'jq' 'pacman' 'sed' 'tee')
;;
remove )
REQUIRED_PACKAGES=('grep' 'pacman' 'sed')
;;
search | completion | list | suggest )
REQUIRED_PACKAGES=('curl' 'echo' 'jq')
;;
* )
;;
esac
ABSENT_PACKAGES=()
for REQUIRED_PACKAGE in "${REQUIRED_PACKAGES[@]}"; do
if [[ ! $(command -v "${REQUIRED_PACKAGE}") ]]; then
ABSENT_PACKAGES+=( "${REQUIRED_PACKAGE}" )
fi
done
if [[ -n "${ABSENT_PACKAGES[*]}" ]]; then
print_error 59
exit 59
fi
REQUIRED_DIRECTORIES=("${TMP_PATH?TMP_PATH not defined.}" \
"${SOURCE_PATH?SOURCE_PATH not defined.}" \
"${PERSISTENT_PATH?PERSISTENT_PATH not defined.}")
for REQUIRED_DIRECTORY in "${REQUIRED_DIRECTORIES[@]}"; do
if [[ ! -d "${REQUIRED_DIRECTORY}" ]]; then
if ! mkdir -p "${REQUIRED_DIRECTORY}"; then
print_error 72
exit 72
fi
fi
done
REQUIRED_FILES=("${PERSISTENT_PATH?PERSISTENT_PATH not defined.}/package_list")
for REQUIRED_FILE in "${REQUIRED_FILES[@]}"; do
if [[ ! -f "${REQUIRED_FILE}" ]]; then
if ! touch "${REQUIRED_FILE}"; then
print_error 73
exit 73
fi
fi
done
}
apply_all_opt() {
if ${ALL}; then
while IFS= read -r TARGET_PACKAGE; do
if [[ -n "${TARGET_PACKAGE}" ]]; then
TARGET_PACKAGES+=( "${TARGET_PACKAGE}" )
fi
done < "${PERSISTENT_PATH}"/package_list
fi
}
load_config() {
CONFIG_JSON_STRING="${*}"
for CFG_ENV_VAR in $(echo "${CONFIG_JSON_STRING}" | jq -cr 'to_entries | .[]'); do
CFG_VAR=$(echo "${CFG_ENV_VAR}" | jq -cr '.key')
CFG_VAR_VALUE=$(echo "${CFG_ENV_VAR}" | jq -cr '.value')
if [[ "${INTERNAL_VARIABLES[*]}" =~ ${CFG_VAR} ]]; then
if [[ -n $(echo "${CFG_VAR_VALUE}" | jq 'path(..) | select(length > 0)' 2> /dev/null) ]]; then
print_error 78
continue
fi
local VARIABLE_EVALUATION
VARIABLE_EVALUATION="${CFG_VAR}=${CFG_VAR_VALUE}"
eval "${VARIABLE_EVALUATION}"
elif [[ "${INTERNAL_ARRAYS[*]}" =~ ${CFG_VAR} ]]; then
if [[ -n $(echo "${CFG_VAR_VALUE}" | jq 'path(..) | select(length > 1)' 2> /dev/null) ]]; then
print_error 78
continue
fi
for CFG_VAR_TMP_VALUE in $(echo "${CFG_VAR_VALUE}" | jq -cr '.[]'); do
local ARRAY_EVALUATION
ARRAY_EVALUATION="${CFG_VAR}+=(\"${CFG_VAR_TMP_VALUE}\")"
eval "${ARRAY_EVALUATION}"
done
else
print_error 79
fi
done
}
load_env_vars() {
for INTERNAL_VARIABLE in "${INTERNAL_VARIABLES[@]}"; do
TEST_EVALUATION=$(eval "echo \${AURX_${INTERNAL_VARIABLE}}")
if [[ -n "${TEST_EVALUATION}" ]]; then
eval "${INTERNAL_VARIABLE}=\${AURX_${INTERNAL_VARIABLE}}"
fi
done
for INTERNAL_ARRAY in "${INTERNAL_ARRAYS[@]}"; do
TEST_EVALUATION=$(eval "echo \${AURX_${INTERNAL_ARRAY}}")
if [[ -n "${TEST_EVALUATION}" ]]; then
eval "${INTERNAL_ARRAY}=()"
for ARRAY_ELEMENT in ${TEST_EVALUATION}; do
eval "${INTERNAL_ARRAY}+=(${ARRAY_ELEMENT})"
done
fi
done
}
load_explicit_opts() {
getopt --test 1> /dev/null && true
if [[ ${?} -ne 4 ]]; then
print_error 50
exit 50
fi
LONGOPTS=''
LONGOPTS+='all,block-overwrite,cleanup,clean-operation,download-only,force,help,keep-sources,keep-failed-sources,maintained,no-mark-installed,no-mark-update,no-out-of-date,overwrite-existing,verify-versions,version,wipe-existing'
LONGOPTS+=',comparison-criteria:,config:,curl-opts:,executable-name:,git-opts:,makepkg-opts:,output:,order-by:,parallel:,persistent-path:,remove-opts:,search-criteria:,search-results:,sort-by:,source-path:,tmp-path:,verbosity:'
OPTIONS=''
OPTIONS+='adfhvV'
OPTIONS+='e:G:c:C:M:o:p:R:t:x:'
if ! PARSED_OPTIONS=$(getopt --options="${OPTIONS}" --longoptions="${LONGOPTS}" --name "${0}" -- "${@}"); then
print_error 51
exit 51
fi
eval set -- "${PARSED_OPTIONS}"
while true; do
case "${1}" in
-a|--all )
ALL=true
shift
;;
--block-overwrite )
BLOCK_OVERWRITE=true
shift
;;
--cleanup )
CLEANUP=true
shift
;;
--clean-operation )
CLEAN_OPERATION=true
shift
;;
-x|--comparison-criteria )
COMPARISON_CRITERIA="${2}"
shift 2
;;
-c|--config )
CONFIG="${2}"
shift 2
;;
-C|--curl-opts )
CURL_OPTS=()
for OPT in ${2}; do
CURL_OPTS+=("${OPT}")
done
shift 2
;;
-d|--download-only )
DOWNLOAD_ONLY=true
shift
;;
-e|--executable-name )
EXECUTABLE_NAME="${2}"
shift 2
;;
-f|--force )
FORCE=true
shift
;;
-G|--git-opts )
GIT_OPTS=()
for OPT in ${2}; do
GIT_OPTS+=("${OPT}")
done
shift 2
;;
-h|--help )
usage
exit 0
;;
--keep-sources )
KEEP_SOURCES=true
shift
;;
--keep-failed-sources )
KEEP_FAILED_SOURCES=true
shift
;;
--maintained )
MAINTAINED=true
shift
;;
-M|--makepkg-opts )
MAKEPKG_OPTS=()
for OPT in ${2}; do
MAKEPKG_OPTS+=("${OPT}")
done
shift 2
;;
--no-mark-update )
NO_MARK_UPDATE=true
shift
;;
--no-mark-installed )
NO_MARK_INSTALLED=true
shift
;;
--no-out-of-date )
NO_OUT_OF_DATE=true
shift
;;
-o|--output )
OUTPUT="${2}"
shift 2
;;
--overwrite-existing )
OVERWRITE_EXISTING=true
shift
;;
--order-by )
ORDER_BY="${2}"
shift 2
;;
--persistent-path )
PERSISTENT_PATH="${2}"
shift 2
;;
-p|--parallel )
PARALLEL="${2}"
shift 2
;;
-R|--remove-opts )
REMOVE_OPTS=()
for OPT in ${2}; do
REMOVE_OPTS+=("${OPT}")
done
shift 2
;;
--search-results )
SEARCH_RESULTS="${2}"
shift 2
;;
--sort-by )
SORT_BY="${2}"
shift 2
;;
--source-path )
SOURCE_PATH="${2}"
shift 2
;;
--search-criteria )
SEARCH_CRITERIA="${2}"
shift 2
;;
-t|--tmp-path )
TMP_PATH="${2}"
shift 2
;;
--verbosity )
VERBOSITY="${2}"
shift 2
;;
-V|--verify-versions )
VERIFY_VERSIONS=true
shift
;;
-v|--version )
print_version
exit 0
;;
--wipe-existing )
WIPE_EXISTING=true
shift
;;
-- )
shift
break
;;
* )
print_error 53
exit 53
;;
esac
done
# Current operation parse.
if [[ ${#} -eq 0 ]]; then
print_error 54
exit 54
fi
CURRENT_OPERATION="${1}"
shift
# Take all packages.
TARGET_PACKAGES=("${@}")
}
load_piped_packages() {
if ! [[ -t 0 ]]; then
while read -r STDIN_OPT; do
TARGET_PACKAGES+=("${STDIN_OPT}")
done
fi
}
# Tier 1 functions.
compare_versions() {
local TARGET_PACKAGE="${1}"
local INSTALLED_VERSION
INSTALLED_VERSION=$(pacman -Qi "${TARGET_PACKAGE}" 2> /dev/null \
| grep -e "Version" | awk '{ print $3 }')
case "${COMPARISON_CRITERIA}" in
pkgbuild )
if [[ ! -f "${SOURCE_PATH}"/"${TARGET_PACKAGE}"/PKGBUILD ]]; then
print_error 70
exit 70
fi
local LATEST_VERSION
local PKGVER
local PKGREL
PKGVER=$(sed -n 's/pkgver=\(.*\)/\1/p' "${SOURCE_PATH:?SOURCE_PATH not defined.}"/"${TARGET_PACKAGE}/PKGBUILD")
PKGREL=$(sed -n 's/pkgrel=\(.*\)/\1/p' "${SOURCE_PATH:?SOURCE_PATH not defined.}"/"${TARGET_PACKAGE}/PKGBUILD")
LATEST_VERSION="${PKGVER}-${PKGREL}"
;;
rpc )
local LATEST_VERSION
if ! LATEST_VERSION=$(curl --connect-timeout 60 --max-time 180 "${CURL_OPTS[@]}" \
"https://aur.archlinux.org/rpc/v5/info?arg[]=${TARGET_PACKAGE}" 2> /dev/null \
| jq -r .results.[0].Version); then
print_error 74
exit 74
fi
;;
* )
print_error 68
exit 68
;;
esac
if [[ "${LATEST_VERSION}" == "${INSTALLED_VERSION}" ]] && ! ${FORCE}; then
return 1
fi
return 0
}
clone_git_repo() {
local TARGET_PACKAGE="${1}"
if ! pushd "${SOURCE_PATH}" 1> /dev/null; then
print_error 63
exit 63
fi
git "${GIT_OPTS[@]}" clone "https://aur.archlinux.org/${TARGET_PACKAGE}.git"
if [[ -z $(ls "${SOURCE_PATH}"/"${TARGET_PACKAGE}") ]]; then
if ! popd 1> /dev/null; then
print_error 64
exit 64
fi
return 1
fi
if ! popd 1> /dev/null; then
print_error 64
exit 64
fi
return 0
}
pull_git_repo() {
local TARGET_PACKAGE="${1}"
if ! pushd "${SOURCE_PATH}"/"${TARGET_PACKAGE}" 1> /dev/null; then
print_error 63
exit 63
fi
if ! git "${GIT_OPTS[@]}" pull; then
if ! popd 1> /dev/null; then
print_error 64
exit 64
fi
return 1
fi
if ! popd 1> /dev/null; then
print_error 64
exit 64
fi
return 0
}
build_makepkg_package() {
local TARGET_PACKAGE="${1}"
if ! pushd "${SOURCE_PATH}"/"${TARGET_PACKAGE}" 1> /dev/null; then
print_error 63
exit 63
fi
if ! makepkg "${MAKEPKG_OPTS[@]}"; then
if ! popd 1> /dev/null; then
print_error 64
exit 64
fi
return 1
fi
if ! popd 1> /dev/null; then
print_error 64
exit 64
fi
}
remove_from_system() {
local TARGET_PACKAGE="${1}"
if [[ $(pacman -Qi "${TARGET_PACKAGE}" 2>/dev/null) ]]; then
sudo pacman "${REMOVE_OPTS[@]}" "${TARGET_PACKAGE}"
else
return 0
fi
if [[ $(pacman -Qi "${TARGET_PACKAGE}" 2> /dev/null) ]]; then
return 1
fi
return 0
}
remove_from_package_list() {
local TARGET_PACKAGE="${1}"
if grep -qe "^${TARGET_PACKAGE}$" "${PERSISTENT_PATH}"/package_list 2> /dev/null; then
sed -i "/^${TARGET_PACKAGE}$/d" "${PERSISTENT_PATH:?PERSISTENT_PATH not defined.}"/package_list
else
return 0
fi
if grep -qe "^${TARGET_PACKAGE}$" "${PERSISTENT_PATH}"/package_list; then
return 2
fi
return 0
}
write_package_list() {
local TARGET_PACKAGE="${1}"
if ! grep -qe "${TARGET_PACKAGE}" "${PERSISTENT_PATH}"/package_list 2> /dev/null; then
echo "${TARGET_PACKAGE}" | tee -a "${PERSISTENT_PATH:?PERSISTENT_PATH not defined.}"/package_list 1> /dev/null
fi
if ! grep -qe "${TARGET_PACKAGE}" "${PERSISTENT_PATH}"/package_list; then
return 1
fi
return 0
}
aur_rpc_suggest() {
local TARGET_KEYWORD="${1}"
if ! RESULTS=$(curl --connect-timeout 5 --max-time 10 "${CURL_OPTS[@]}" \
"https://aur.archlinux.org/rpc/v5/suggest/${TARGET_KEYWORD}" 2> /dev/null); then
print_error 74
exit 74
fi
if [[ "${ORDER_BY}" == "ascending" ]]; then
RESULTS=$(echo "${RESULTS}" | jq -cr 'reverse')
fi
case "${OUTPUT}" in
formatted )
echo "${RESULTS}" | jq -crM ".[:${SEARCH_RESULTS}] | .[]"
;;
json-lines )
echo "${RESULTS}" | jq -crM ".[:${SEARCH_RESULTS}]"
;;
json )
print_error 77
exit 77
;;
* )
print_error 75
exit 75
;;
esac
}
gather_aur_data() {
local TARGET_KEYWORDS="${*}"
local RESULTS
declare -a REQUESTS
# Avoid duplicate keywords as curl will overwrite them and the script will look for extra results.
TARGET_KEYWORDS=$(echo "${TARGET_KEYWORDS}" | tr ' ' '\n' | sort -u | tr '\n' ' ')
for TARGET_KEYWORD in ${TARGET_KEYWORDS}; do
REQUESTS+=( "https://aur.archlinux.org/rpc/v5/search/${TARGET_KEYWORD}?by=${SEARCH_CRITERIA}" )
REQUESTS+=( "-o${TMP_PATH?TMP_PATH not defined.}/temp_request_${TARGET_KEYWORD}" )
done
if ! curl --connect-timeout 60 --max-time 180 --parallel --parallel-immediate --parallel-max "${PARALLEL}" \
"${CURL_OPTS[@]}" "${REQUESTS[@]}" 2> /dev/null; then
print_error 74
exit 74
fi
RESULTS=$(
for TARGET_KEYWORD in ${TARGET_KEYWORDS}; do
RESULT=$(< "${TMP_PATH}/temp_request_${TARGET_KEYWORD}")
echo "${RESULT}" | jq -cr --arg SEARCHED_KEYWORD "${TARGET_KEYWORD}" '. + {"searchedkeyword": $SEARCHED_KEYWORD}'
rm -rf "${TMP_PATH?TMP_PATH not defined.}/temp_request_${TARGET_KEYWORD}"
done | jq -sc
)
echo "${RESULTS}"
}
filter_aur_data() {
local AUR_DATA="${*}"
local LOCAL_STATUS
# Break down every entry in the curl results.
local IFS=$'\n'
for ENTRY in $(echo "${AUR_DATA}" | jq -cr ".[]"); do
RESULTS=$(echo "${ENTRY}" | jq -cr '.results')
RESULT_COUNT=$(echo "${ENTRY}" | jq -cr '.resultcount')
if [[ ${RESULT_COUNT} -gt 0 ]] \
&& [[ ${RESULT_COUNT} -gt ${SEARCH_RESULTS} ]]; then
ENTRY=$(echo "${ENTRY}" \
| jq -cr --arg SEARCH_RESULTS "${SEARCH_RESULTS}" '.resultcount = $SEARCH_RESULTS')
fi
# Apply aurx filters on the results section of the entry.
RESULTS=$(echo "${RESULTS}" | jq -cr "sort_by(.${SORT_BY})")
if [[ "${ORDER_BY}" == "descending" ]]; then
RESULTS=$(echo "${RESULTS}" | jq -cr 'reverse')
fi
if ${NO_OUT_OF_DATE}; then
RESULTS=$(echo "${RESULTS}" | jq -cr '[.[] | select(.OutOfDate == null)]')
fi
if ${MAINTAINED}; then
RESULTS=$(echo "${RESULTS}" | jq -cr '[.[] | select(.Maintainer != null)]')
fi
RESULTS=$(echo "${RESULTS}" | jq -cr ".[:${SEARCH_RESULTS}]")
# Break down every result in the results section of the entry.
RESULTS=$(
for RESULT in $(echo "${RESULTS}" | jq -cr '.[]'); do
# Apply installed and update marks.
LOCAL_STATUS=""
PACKAGE_NAME=$(echo "${RESULT}" | jq -cr '.Name')
if ! ${NO_MARK_INSTALLED} || ! ${NO_MARK_UPDATE}; then
INSTALLED_VERSION=$(pacman -Qi "${PACKAGE_NAME}" 2> /dev/null \
| grep -e "Version" | awk '{ print $3 }')
if [[ -n "${INSTALLED_VERSION}" ]]; then
if ! ${NO_MARK_INSTALLED}; then
LOCAL_STATUS="[installed]"
fi
if ! ${NO_MARK_UPDATE}; then
ONLINE_VERSION=$(echo "${RESULT}" | jq -r '.Version')
if [[ "${INSTALLED_VERSION}" != "${ONLINE_VERSION}" ]]; then
LOCAL_STATUS="[update]"
fi
fi
fi
fi
echo "${RESULT}" | jq -cr --arg LOCAL_STATUS "${LOCAL_STATUS}" '.LocalStatus = $LOCAL_STATUS'
done | jq -sc
)
# Print entry with modified results section.
echo "${ENTRY}" | jq -cr --argjson RESULTS "${RESULTS}" '.results = $RESULTS'
done | jq -sc
}
print_aur_data() {
local AUR_DATA="${*}"
declare -a PACKAGES_NOT_FOUND
case "${OUTPUT}" in
json )
echo "${AUR_DATA}"
;;
json-lines )
echo "${AUR_DATA}" | jq -crM ".[]"
;;
formatted )
local IFS=$'\n'
for ENTRY in $(echo "${AUR_DATA}" | jq -cr '.[]'); do
if [[ $(echo "${ENTRY}" | jq -cr '.resultcount') -eq 0 ]]; then
PACKAGES_NOT_FOUND+=( "$(echo "${ENTRY}" | jq -cr '.searchedkeyword')" )
fi
done
echo "${AUR_DATA}" \
| jq -crM ".[] | .results[] | \"\(.Maintainer)/\(.Name) \(.Version): \(.NumVotes) Votes, \(.Popularity) Popularity \(.LocalStatus) \n\t\(.Description)\""
if [[ ${#PACKAGES_NOT_FOUND[@]} -gt 0 ]]; then
print_error 76
fi
;;
* )
print_error 75
exit 75
;;
esac
}
# Tier 2 functions.
install_aur_package() {
local TARGET_PACKAGE="${1}"
if ${VERIFY_VERSIONS}; then
compare_versions "${TARGET_PACKAGE}" || return 0
fi
if [[ -d "${SOURCE_PATH}"/"${TARGET_PACKAGE}" ]]; then
if ${WIPE_EXISTING}; then
rm -rf "${SOURCE_PATH:?SOURCE_PATH not defined.}"/"${TARGET_PACKAGE}" || return 10
elif ${OVERWRITE_EXISTING} && [[ "${COMPARISON_CRITERIA}" == "rpc" ]]; then
pull_git_repo "${TARGET_PACKAGE}" || return 11
fi
fi
if [[ ! -d "${SOURCE_PATH}"/"${TARGET_PACKAGE}" ]]; then
clone_git_repo "${TARGET_PACKAGE}" || return 12
fi
if ${DOWNLOAD_ONLY}; then
return 0
fi
if build_makepkg_package "${TARGET_PACKAGE}"; then
if ${CLEANUP}; then
rm -rf "${SOURCE_PATH:?SOURCE_PATH not defined.}"/"${TARGET_PACKAGE}" || return 10
fi
else
if ${CLEAN_OPERATION}; then
rm -rf "${SOURCE_PATH:?SOURCE_PATH not defined.}"/"${TARGET_PACKAGE}" || return 10
fi
return 13
fi
write_package_list "${TARGET_PACKAGE}" || return 14
return 0
}
remove_aur_package() {
local TARGET_PACKAGE="${1}"
remove_from_system "${TARGET_PACKAGE}" || return 20
remove_from_package_list "${TARGET_PACKAGE}" || return 21
return 0
}
search_aur_packages() {
local TARGET_KEYWORDS="${*}"
AUR_DATA=$(gather_aur_data "${TARGET_KEYWORDS}") || return 30
AUR_DATA=$(filter_aur_data "${AUR_DATA}") || return 31
print_aur_data "${AUR_DATA}" || return 32
}
suggest_aur_package() {
local TARGET_KEYWORD="${1}"
aur_rpc_suggest "${TARGET_KEYWORD}" || return 40
}
# Tier 3 functions.
process_pseudofunctions() {
case "${CURRENT_OPERATION}" in
update )
SOURCE_PATH="${TMP_PATH?TMP_PATH not defined.}"
VERIFY_VERSIONS=true
if ! ${KEEP_SOURCES}; then
CLEANUP=true
fi
if ! ${KEEP_FAILED_SOURCES}; then
CLEAN_OPERATION=true
fi
if ! ${BLOCK_OVERWRITE}; then
OVERWRITE_EXISTING=true
fi
CURRENT_OPERATION="install"
;;
list )
ALL=true
SEARCH_RESULTS=1
CURRENT_OPERATION="search"
SEARCH_CRITERIA="provides"
;;
* )
;;
esac
}
launch_execution() {
case "${CURRENT_OPERATION}" in
install|remove|suggest )
for SELECTED_PACKAGE in "${TARGET_PACKAGES[@]}"; do
"${CURRENT_OPERATION}"_aur_package "${SELECTED_PACKAGE}" 1> "${STDOUT_DESTINATION}" 2> "${STDERR_DESTINATION}"
ERROR_CODE=${?}
case ${ERROR_CODE} in
0 )
;;
10|11|12|13|14|20|21|40 )
print_error "${ERROR_CODE}"
;;
* )
print_error 61
exit "${ERROR_CODE}"
;;
esac
done
;;
search )
search_aur_packages "${TARGET_PACKAGES[@]}" 1> "${STDOUT_DESTINATION}" 2> "${STDERR_DESTINATION}"
ERROR_CODE=${?}
case ${ERROR_CODE} in
0 )
;;
30|31|32 )
print_error "${ERROR_CODE}"
exit "${ERROR_CODE}"
;;
* )
print_error 61
exit "${ERROR_CODE}"
;;
esac
;;
completion )
COMPLETION_TYPE="${TARGET_PACKAGES[0]}"
if [[ "${AVAILABLE_COMPLETIONS[*]}" =~ ${COMPLETION_TYPE} ]]; then
aurx_completion "${COMPLETION_TYPE}"
exit 0
else
print_error 62
exit 62
fi
;;
* )
print_error 71
exit 71
;;
esac
}
# Tier 4 functions.
execute_script() {
load_config "$(generate_config_json)"
load_env_vars
load_explicit_opts "${@}"
load_piped_packages
[[ -n "${CONFIG}" ]] && load_config "${CONFIG}"
launch_sanity_checks
launch_system_checks
process_pseudofunctions
apply_all_opt
[[ -z "${TARGET_PACKAGES[*]}" ]] && print_error 56 && exit 56
launch_execution
}
# Metadata.
declare -a METADATA_VARIABLES
declare -a METADATA_ARRAYS
METADATA_VARIABLES=("INTERNAL_VERSION")
METADATA_ARRAYS=("INTERNAL_VARIABLES" "INTERNAL_ARRAYS" "POSSIBLE_OPERATIONS" "GENERAL_OPTIONS" "INSTALL_OPTIONS" \
"REMOVE_OPTIONS" "UPDATE_OPTIONS" "SEARCH_OPTIONS" "SUGGEST_OPTIONS" "COMPLETION_OPTIONS" "LIST_OPTIONS" "AVAILABLE_COMPLETIONS" \
"COMPARISON_CRITERIA_VALUES" "OUTPUT_VALUES" "OUTPUT_SUGGEST_VALUES" "ORDER_BY_VALUES" "SEARCH_CRITERIA_VALUES" "SORT_BY_VALUES")
declare "${METADATA_VARIABLES[@]}"
declare -a "${METADATA_ARRAYS[@]}"
INTERNAL_VERSION="1.0.7-1"
INTERNAL_VARIABLES=("ALL" "BLOCK_OVERWRITE" "CLEAN_OPERATION" "CLEANUP" "COMPARISON_CRITERIA" \
"DOWNLOAD_ONLY" "EXECUTABLE_NAME" "FORCE" "CONFIG" "KEEP_FAILED_SOURCES" "KEEP_SOURCES" \
"MAINTAINED" "NO_MARK_INSTALLED" "NO_MARK_UPDATE" "NO_OUT_OF_DATE" "ORDER_BY" "OUTPUT" "OVERWRITE_EXISTING" \
"PARALLEL" "PERSISTENT_PATH" "SEARCH_CRITERIA" "SEARCH_RESULTS" "SORT_BY" "SOURCE_PATH" "TMP_PATH" \
"VERBOSITY" "VERIFY_VERSIONS" "WIPE_EXISTING")
INTERNAL_ARRAYS=("CURL_OPTS" "GIT_OPTS" "MAKEPKG_OPTS" "REMOVE_OPTS")
POSSIBLE_OPERATIONS=("install" "remove" "update" "search" "completion" "list" "suggest")
GENERAL_OPTIONS=("-a" "--all" "-c" "--config" "-f" "--force" "-h" "--help" "--persistent-path" "-t" "--tmp-path" "--verbosity" "-v" "--version")
INSTALL_OPTIONS=("--cleanup" "--clean-operation" "-x" "--comparison-criteria" "-d" "--download-only" "-G" \
"--git-opts" "-M" "--makepkg-opts" "--overwrite-existing" "--source-path" "-V" "--verify-versions" "--wipe-existing")
REMOVE_OPTIONS=("-R" "--remove-opts")
UPDATE_OPTIONS=("--block-overwrite" "-x" "--comparison-criteria" "-C" "--curl-opts" "--keep-sources" \
"--keep-failed-sources" "-M" "--makepkg-opts")
SEARCH_OPTIONS=("-C" "--curl-opts" "--maintained" "--no-out-of-date" "--no-mark-installed" "--no-mark-update" \
"-p" "--parallel" "--search-results" "--search-criteria" "--sort-by" "--order-by" "-o" "--output")
SUGGEST_OPTIONS=("-C" "--curl-opts" "--search-results" "--order-by" "-o" "--output")
COMPLETION_OPTIONS=("-e" "--executable-name")
LIST_OPTIONS=("--no-mark-update" "-p" "--parallel" "--no-mark-installed")
AVAILABLE_COMPLETIONS=("bash")
COMPARISON_CRITERIA_VALUES=("rpc" "pkgbuild")
OUTPUT_VALUES=("formatted" "json" "json-lines")
OUTPUT_SUGGEST_VALUES=("formatted" "json-lines")
ORDER_BY_VALUES=("ascending" "descending")
SEARCH_CRITERIA_VALUES=("name" "name-desc" "depends" "checkdepends" "optdepends" "makedepends" "maintainer" \
"submitter" "provides" "conflicts" "replaces" "keywords" "groups" "comaintainers")
SORT_BY_VALUES=("firstsubmitted" "lastmodified" "votes" "popularity")
declare "${INTERNAL_VARIABLES[@]}"
declare -a "${INTERNAL_ARRAYS[@]}"
execute_script "${@}"
|