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
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
|
#! /usr/bin/env bash
# Usage: test.sh [test-options] [bpkg-common-options]
#
# Test options are:
#
# -v
# Run verbose. By default, this script runs bpkg quiet and suppresses
# error messages in the fail tests. Note that when this options is
# specified, bpkg is called with default verbosity level. If you want
# more bpkg diagnostics, add the --verbose N option.
#
# --remote
# Test using the remote repositories. Normally, you would first run the
# local test in order to create the repositories, then publish them (see
# pkg/publish.sh), and finally run the remote test.
#
# --valgrind
# Run under valgrind (takes forever).
#
# Some common bpkg use-cases worth testing:
#
# --fetch wget
# --fetch curl
# --fetch fetch --fetch-option --no-verify-peer
#
# --tar bsdtar
#
# --sha256 shasum
# --sha256 sha256-freebsd
#
trap 'exit 1' ERR
tmp_file=`mktemp`
# Remove temporary file on exit. Cover the case when exit due to an error.
#
trap 'rm -f $tmp_file' EXIT
function error ()
{
echo "$*" 1>&2
exit 1
}
bpkg="../bpkg/bpkg"
cfg=/tmp/conf
if [ "${MSYSTEM:0:5}" = "MINGW" -o "${MSYSTEM:0:4}" = "MSYS" ]; then
msys=y
fi
verbose=n
remote=n
options=
while [ $# -gt 0 ]; do
case $1 in
-v)
verbose=y
shift
;;
--remote)
remote=y
shift
;;
--valgrind)
bpkg="valgrind -q $bpkg"
shift
;;
*)
# If this is the --verbose bpkg option, switch to the verbose
# mode as well.
#
if [ "$1" == "--verbose" ]; then
verbose=y
fi
options="$options $1"
shift
;;
esac
done
if [ "$verbose" != "y" ]; then
options="$options -q"
fi
bpkg="$bpkg $options"
# Repository location and name prefixes. Note that the local path is carefully
# crafted so that we end up with the same repository names in both cases. This
# is necessary for the authentication tests to work in both cases.
#
if [ "$remote" = "y" ]; then
rep=https://build2.org/bpkg/1
repn=build2.org/
else
rep=pkg/1/build2.org
repn=build2.org/
fi
#
#
function test ()
{
local cmd=$1; shift
local ops=
if [ "$cmd" != "rep-create" -a \
"$cmd" != "rep-info" -a \
"$cmd" != "pkg-verify" ]; then
ops="-d $cfg"
fi
if [ "$cmd" = "cfg-fetch" -o \
"$cmd" = "rep-info" ]; then
ops="$ops --auth all"
fi
if [ -t 0 ]; then
$bpkg $cmd $ops $*
else
$bpkg $cmd $ops $* >$tmp_file
diff --strip-trailing-cr -u - $tmp_file
fi
if [ $? -ne 0 ]; then
error "failed: $bpkg $cmd $ops $*"
fi
}
function fail ()
{
local cmd=$1; shift
local ops=
if [ "$cmd" != "rep-create" -a \
"$cmd" != "rep-info" -a \
"$cmd" != "pkg-verify" ]; then
ops="-d $cfg"
fi
if [ "$cmd" = "cfg-fetch" -o \
"$cmd" = "rep-info" ]; then
ops="$ops --auth all"
fi
if [ "$verbose" = "y" ]; then
$bpkg $cmd $ops $*
else
$bpkg $cmd $ops $* 2>/dev/null
fi
if [ $? -eq 0 ]; then
error "succeeded: $bpkg $cmd $ops $*"
fi
return 0
}
# Verify package status.
#
function stat ()
{
local s=`$bpkg pkg-status -d $cfg $1`
if [ "$s" != "$2" ]; then
error "status $1: '"$s"', expected: '"$2"'"
fi
}
# Verify path is gone (no longer exists)
#
function gone ()
{
if [ -e "$1" ]; then
error "path $1 still exists"
fi
}
#if false; then
# Repository certificate fingerprint.
#
function rep_cert_fp ()
{
cat $1/repositories | \
sed -n '/^-----BEGIN CERTIFICATE-----$/,/^-----END CERTIFICATE-----$/p' | \
openssl x509 -sha256 -noout -fingerprint | \
sed -n 's/^SHA256 Fingerprint=\(.*\)$/\1/p'
}
# Edit file with sed.
#
function edit ()
{
local path=$1; shift
sed "$@" $path > $path.bak
mv $path.bak $path
}
# Repository absolute location from a relative path.
#
function location ()
{
if [ "$remote" = "y" ]; then
echo "$rep/$1"
elif [ "$msys" = "y" ]; then
# Convert Windows path like c:/abc/xyz to the c:\abc\xyz canonical form.
#
echo "`pwd -W`/$rep/$1" | sed 's%/%\\%g'
else
echo "`pwd`/$rep/$1"
fi
}
##
## Low-level commands.
##
##
## pkg-verify
##
fail pkg-verify # archive expected
fail pkg-verify ./no-such-file # archive does not exist
fail pkg-verify pkg/1/build2.org/common/not-a-package.tar.gz
fail pkg-verify --silent pkg/1/build2.org/common/not-a-package.tar.gz
test pkg-verify pkg/1/build2.org/common/hello/libhello-1.0.0+1.tar.gz
##
## rep-create
##
fail rep-create # no 'repositories' file
fail rep-create pkg/1/build2.org/satisfy # unexpected files
test rep-create pkg/1/build2.org/common/hello --key key.pem
test rep-create pkg/1/build2.org/common/foo/stable
test rep-create pkg/1/build2.org/common/foo/testing
test rep-create pkg/1/build2.org/common/bar/stable
test rep-create pkg/1/build2.org/common/bar/testing
test rep-create pkg/1/build2.org/common/bar/unstable
##
## rep-info
##
fail rep-info # repository location expected
test rep-info --trust-yes $rep/common/foo/testing <<EOF
${repn}common/foo/testing `location common/foo/testing`
complement ${repn}common/foo/stable `location common/foo/stable`
libfoo 1.1.0
EOF
test rep-info -m -r -n --trust-yes $rep/common/bar/unstable <<EOF
${repn}common/bar/unstable `location common/bar/unstable`
: 1
location: ../../foo/testing
:
location: ../testing
role: complement
:
EOF
test rep-info -m -p --trust-yes $rep/common/bar/unstable <<EOF
: 1
sha256sum: 3034b727288efbb52b7b6e41fe147b815e7b3aa704e8cef6c2ee8d7421ab5b72
:
name: libbar
version: 1.1.1
summary: libbar
license: MIT
description: \\
libbar is a very modern C++ XML parser.
It has an API that we believe should have already been in Boost or even in
the C++ standard library.
\\
changes: \\
* Applied upstream patch for critical bug bar.
* Applied upstream patch for critical bug foo.
\\
url: http://example.org
email: pkg@example.org
depends: libfoo >= 1.1.0
location: libbar-1.1.1.tar.gz
sha256sum: d09700602ff78ae405b6d4850e34660e939d27676e015a23b549884497c8bb45
EOF
hello_fp=`rep_cert_fp pkg/1/build2.org/common/hello`
test rep-info -m -p --trust $hello_fp $rep/common/hello <<EOF
: 1
sha256sum: 8d324fa7911038778b215d28805c6546e737e0092f79f7bd167cf2e28f4ad96f
:
name: libhello
version: 1.0.0+1
summary: The "Hello World" example library
license: MIT
tags: c++, hello, world, example
description: \\
A simple library that implements the "Hello World" example in C++. Its primary
goal is to show a canonical build2/bpkg project/package.
\\
url: http://www.example.org/libhello
email: hello-users@example.org
requires: c++11
location: libhello-1.0.0+1.tar.gz
sha256sum: ceff9f39dbff496ece817d6806ab3723b065dcdff1734683fe64a60c103f7f9b
EOF
##
## cfg-create
##
test cfg-create --wipe cxx config.install.root=/tmp/install
stat libfoo unknown
test cfg-create --wipe config.install.root=/tmp/install cxx
stat libfoo unknown
##
## cfg-add
##
test cfg-create --wipe
fail cfg-add # repository location expected
fail cfg-add stable # invalid location
fail cfg-add http:// # invalid location
# relative path
#
test cfg-add ./1/bar/stable
fail cfg-add ./1/../1/bar/stable # duplicate
# absolute path
#
test cfg-add /tmp/1/foo/stable
fail cfg-add /tmp/1/../1/foo/stable # duplicate
# remote URL
#
test cfg-add http://pkg.example.org/1/testing
fail cfg-add https://www.example.org/1/testing # duplicate
##
## cfg-fetch
##
test cfg-create --wipe
fail cfg-fetch # no repositories
# hello repository
#
test cfg-create --wipe
test cfg-add $rep/common/hello
test cfg-fetch --trust $hello_fp
test cfg-fetch
# bar/unstable repository
#
test cfg-create --wipe
test cfg-add $rep/common/bar/unstable
test cfg-fetch --trust-yes
test cfg-fetch
# both
#
test cfg-create --wipe
test cfg-add $rep/common/hello
test cfg-add $rep/common/bar/unstable
test cfg-fetch --trust-yes
test cfg-fetch
##
## pkg-fetch
##
test rep-create pkg/1/build2.org/fetch/t1
test cfg-create --wipe
fail pkg-fetch -e # archive expected
fail pkg-fetch -e ./no-such-file # archive does not exist
fail pkg-fetch # package name expected
fail pkg-fetch libfoo # package version expected
fail pkg-fetch libfoo/1/2/3 # invalid package version
fail pkg-fetch libfoo/1.0.0 # no repositories
test cfg-add $rep/fetch/t1
fail pkg-fetch libfoo/1.0.0 # no packages
test cfg-fetch --trust-yes
fail pkg-fetch libfoo/2+1.0.0 # not available
test cfg-create --wipe
test cfg-add $rep/fetch/t1
test cfg-fetch --trust-yes
test pkg-fetch libfoo/1.0.0
stat libfoo/1.0.0 fetched
fail pkg-fetch libfoo/1.0.0
fail pkg-fetch -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
test pkg-purge libfoo
test pkg-fetch -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
stat libfoo/1.0.0 fetched
test pkg-unpack libfoo
test pkg-fetch -r libfoo/1.1.0
stat libfoo/1.1.0 fetched
test pkg-unpack libfoo
test pkg-fetch -r -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
stat libfoo/1.0.0 fetched
test pkg-fetch -r libfoo/1.1.0
stat libfoo/1.1.0 fetched
test pkg-fetch -r -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
stat libfoo/1.0.0 fetched
test pkg-purge libfoo
# hello
#
test cfg-create --wipe
test cfg-add $rep/common/hello
test cfg-fetch --trust $hello_fp
test pkg-fetch libhello/1.0.0+1
test pkg-purge libhello
##
## pkg-unpack
##
test cfg-create --wipe
fail pkg-unpack -r # replace only with existing
fail pkg-unpack -e # package directory expected
fail pkg-unpack # package name expected
test cfg-add $rep/fetch/t1
test cfg-fetch --trust-yes
# existing
#
fail pkg-unpack -e ./no-such-dir # package directory does not exist
fail pkg-unpack -e ./pkg # not a package directory
test pkg-fetch libfoo/1.0.0
fail pkg-unpack -e pkg/1/build2.org/fetch/libfoo-1.1.0 # already exists
test pkg-purge libfoo
test pkg-unpack -e pkg/1/build2.org/fetch/libfoo-1.1.0
stat libfoo/1.1.0 unpacked
test pkg-purge libfoo
# existing & replace
#
test pkg-fetch libfoo/1.0.0
fail pkg-unpack -e pkg/1/build2.org/fetch/libfoo-1.1.0
test pkg-unpack -r -e pkg/1/build2.org/fetch/libfoo-1.1.0
stat libfoo/1.1.0 unpacked
test pkg-purge libfoo
test pkg-fetch libfoo/1.0.0
test pkg-unpack libfoo
fail pkg-unpack -e pkg/1/build2.org/fetch/libfoo-1.1.0
test pkg-unpack -r -e pkg/1/build2.org/fetch/libfoo-1.1.0
stat libfoo/1.1.0 unpacked
test pkg-purge libfoo
# package name
#
fail pkg-unpack libfoo # no such package in configuration
test pkg-unpack -e pkg/1/build2.org/fetch/libfoo-1.1.0
fail pkg-unpack libfoo # wrong package state
test pkg-purge libfoo
test pkg-fetch libfoo/1.0.0
stat libfoo/1.0.0 fetched
test pkg-unpack libfoo
stat libfoo/1.0.0 unpacked
test pkg-purge libfoo
# hello
#
test cfg-create --wipe
test cfg-add $rep/common/hello
test cfg-fetch --trust $hello_fp
test pkg-fetch libhello/1.0.0+1
test pkg-unpack libhello
test pkg-purge libhello
##
## pkg-purge
##
test cfg-create --wipe
fail pkg-purge # missing package name
fail pkg-purge libfoo # no such package
# purge fetched
#
test pkg-fetch -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
test pkg-purge libfoo
stat libfoo unknown
# --keep
#
test pkg-fetch -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
test pkg-purge -k libfoo
stat libfoo "fetched 1.0.0"
test pkg-purge libfoo
# archive and --purge
#
cp pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz $cfg/
test pkg-fetch -e -p $cfg/libfoo-1.0.0.tar.gz
test pkg-purge libfoo
stat libfoo unknown
gone $cfg/libfoo-1.0.0.tar.gz
# no archive but --keep
#
test pkg-unpack -e pkg/1/build2.org/fetch/libfoo-1.1.0
fail pkg-purge --keep libfoo
stat libfoo "unpacked 1.1.0"
test pkg-purge libfoo
# purge unpacked directory
#
test pkg-unpack -e pkg/1/build2.org/fetch/libfoo-1.1.0
test pkg-purge libfoo
stat libfoo unknown
# purge unpacked archive
#
test pkg-fetch -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
test pkg-unpack libfoo
test pkg-purge libfoo
stat libfoo unknown
gone $cfg/libfoo-1.0.0
# purge unpacked archive but --keep
#
test pkg-fetch -e pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz
test pkg-unpack libfoo
test pkg-purge --keep libfoo
stat libfoo "fetched 1.0.0"
gone $cfg/libfoo-1.0.0
test pkg-purge libfoo
stat libfoo unknown
# directory and --purge
#
cp -r pkg/1/build2.org/fetch/libfoo-1.1.0 $cfg/
test pkg-unpack -e -p $cfg/libfoo-1.1.0
test pkg-purge libfoo
stat libfoo unknown
gone $cfg/libfoo-1.1.0
# archive and --purge
#
cp pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz $cfg/
test pkg-fetch -e -p $cfg/libfoo-1.0.0.tar.gz
test pkg-unpack libfoo
test pkg-purge libfoo
stat libfoo unknown
gone $cfg/libfoo-1.0.0
gone $cfg/libfoo-1.0.0.tar.gz
# broken
#
cp pkg/1/build2.org/fetch/libfoo-1.0.0.tar.gz $cfg/
test pkg-fetch -e -p $cfg/libfoo-1.0.0.tar.gz
test pkg-unpack libfoo
chmod 000 $cfg/libfoo-1.0.0
fail pkg-purge libfoo
stat libfoo/1.0.0 broken
fail pkg-purge libfoo # need --force
fail pkg-purge -f -k libfoo # can't keep broken
fail pkg-purge -f libfoo # out directory still exists
chmod 755 $cfg/libfoo-1.0.0
rm -r $cfg/libfoo-1.0.0
fail pkg-purge -f libfoo # archive still exists
rm $cfg/libfoo-1.0.0.tar.gz
test pkg-purge -f libfoo
stat libfoo unknown
##
## pkg-configure/pkg-disfigure
##
test cfg-create --wipe
test cfg-add $rep/common/hello
test cfg-fetch --trust $hello_fp
fail pkg-configure # package name expected
fail pkg-configure config.dist.root=/tmp # ditto
fail pkg-configure libhello libhello # unexpected argument
fail pkg-configure libhello1 # no such package
fail pkg-disfigure # package name expected
fail pkg-disfigure libhello1 # no such package
test pkg-fetch libhello/1.0.0+1
fail pkg-configure libhello # wrong package state
fail pkg-disfigure libhello # wrong package state
test pkg-purge libhello
# src == out
#
test pkg-fetch libhello/1.0.0+1
test pkg-unpack libhello
test pkg-configure libhello
stat libhello "configured 1.0.0+1"
test pkg-disfigure libhello
stat libhello "unpacked 1.0.0+1"
test pkg-purge libhello
stat libhello/1.0.0 "available 1.0.0+1"
# src != out
#
test cfg-create --wipe
test pkg-unpack -e pkg/1/build2.org/common/libhello-1.0.0+1
test pkg-configure libhello
stat libhello "configured 1.0.0+1"
test pkg-disfigure libhello
stat libhello "unpacked 1.0.0+1"
test pkg-purge libhello
stat libhello unknown
gone $cfg/libhello-1.0.0+1
# out still exists after disfigure
#
test pkg-unpack -e pkg/1/build2.org/common/libhello-1.0.0+1
test pkg-configure libhello
touch $cfg/libhello-1.0.0+1/stray
fail pkg-disfigure libhello
stat libhello/1.0.0+1 broken
rm -r $cfg/libhello-1.0.0+1
test pkg-purge -f libhello
stat libhello unknown
# disfigure failed
#
test pkg-unpack -e pkg/1/build2.org/common/libhello-1.0.0+1
test pkg-configure libhello
chmod 555 $cfg/libhello-1.0.0+1
fail pkg-disfigure libhello
stat libhello/1.0.0+1 broken
chmod 755 $cfg/libhello-1.0.0+1
rm -r $cfg/libhello-1.0.0+1
test pkg-purge -f libhello
stat libhello unknown
# While it's forbidden to delete a directory with write permissions being
# revoked with the 'chmod 555' command in MSYS, it's still allowed to create
# subdirectories and files inside such a directory. This is why the following
# 'fail pkg-configure libhello' test cases undesirably succeed in MSYS.
#
if [ "$msys" != "y" ]; then
# configure failed but disfigure succeeds
#
test pkg-unpack -e pkg/1/build2.org/common/libhello-1.0.0+1
mkdir -p $cfg/libhello-1.0.0+1/build
chmod 555 $cfg/libhello-1.0.0+1/build
fail pkg-configure libhello
stat libhello "unpacked 1.0.0+1"
test pkg-purge libhello
stat libhello unknown
# configure and disfigure both failed
#
test pkg-unpack -e pkg/1/build2.org/common/libhello-1.0.0+1
mkdir -p $cfg/libhello-1.0.0+1/build
# Trip both con/dis.
#
chmod 555 $cfg/libhello-1.0.0+1 $cfg/libhello-1.0.0+1/build
fail pkg-configure libhello
stat libhello/1.0.0+1 broken
chmod 755 $cfg/libhello-1.0.0+1 $cfg/libhello-1.0.0+1/build
rm -r $cfg/libhello-1.0.0+1
test pkg-purge -f libhello
stat libhello unknown
fi
# dependency management
#
test rep-create pkg/1/build2.org/depend/stable
test cfg-create --wipe
test cfg-add $rep/depend/stable
test cfg-fetch --trust-yes
test pkg-fetch libbar/1.0.0
test pkg-unpack libbar
fail pkg-configure libbar # no libfoo
stat libbar/1.0.0 "unpacked"
test pkg-fetch libfoo/1.0.0
test pkg-unpack libfoo
fail pkg-configure libbar # libfoo not configured
test pkg-configure libfoo
test pkg-configure libbar
fail pkg-disfigure libfoo # libbar still depends on libfoo
test pkg-disfigure libbar
test pkg-disfigure libfoo
test pkg-purge libbar
test pkg-purge libfoo
test pkg-fetch libfoo/1.0.0
test pkg-unpack libfoo
test pkg-configure libfoo
test pkg-fetch libbar/1.1.0
test pkg-unpack libbar
fail pkg-configure libbar # libfoo >= 1.1.0
test pkg-disfigure libfoo
test pkg-purge libfoo
test pkg-fetch libfoo/1.1.0
test pkg-unpack libfoo
test pkg-configure libfoo
test pkg-configure libbar
test pkg-disfigure libbar
test pkg-disfigure libfoo
test pkg-purge libfoo
test pkg-purge libbar
test pkg-fetch libfoo/1.1.0
test pkg-unpack libfoo
test pkg-configure libfoo
test pkg-fetch libbar/1.2.0
test pkg-unpack libbar
fail pkg-configure libbar # libfoo >= 1.2.0
test pkg-disfigure libfoo
test pkg-purge libfoo
test pkg-fetch libfoo/1.2.0
test pkg-unpack libfoo
test pkg-configure libfoo
test pkg-configure libbar
fail pkg-disfigure libfoo # "package libbar on libfoo >= 1.2.0"
test pkg-disfigure libbar
test pkg-disfigure libfoo
test pkg-purge libfoo
test pkg-purge libbar
test pkg-fetch libfoo/1.1.0
test pkg-unpack libfoo
test pkg-configure libfoo
test pkg-fetch libbar/1.3.0
test pkg-unpack libbar
fail pkg-configure libbar # incompatible constraints
test pkg-disfigure libfoo
test pkg-purge libfoo
test pkg-purge libbar
##
## pkg-status (also tested in pkg-{fetch,unpack,configure,disfigure,purge})
##
test rep-create pkg/1/build2.org/status/stable
test rep-create pkg/1/build2.org/status/extra
test rep-create pkg/1/build2.org/status/testing
test rep-create pkg/1/build2.org/status/unstable
# basics
#
test cfg-create --wipe
stat libfoo/1.0.0 "unknown"
stat libfoo "unknown"
test cfg-add $rep/status/stable
test cfg-fetch --trust-yes
stat libfoo/1.0.0 "available"
stat libfoo "available 1.0.0"
test pkg-fetch libfoo/1.0.0
stat libfoo/1.0.0 "fetched"
stat libfoo "fetched 1.0.0"
# multiple versions/revisions
#
test cfg-create --wipe
test cfg-add $rep/status/extra
test cfg-fetch --trust-yes
stat libbar "available 1.1.0+1"
test cfg-add $rep/status/stable
test cfg-fetch --trust-yes
stat libbar "available 1.1.0+1 1.0.0"
test cfg-create --wipe
test cfg-add $rep/status/testing
test cfg-fetch --trust-yes
stat libbar "available 1.1.0 1.0.0+1 1.0.0"
test cfg-create --wipe
test cfg-add $rep/status/unstable
test cfg-fetch --trust-yes
stat libbar "available 2.0.0 1.1.0 1.0.0+1 1.0.0"
test pkg-fetch libbar/1.0.0+1
stat libbar "fetched 1.0.0+1; available 2.0.0 1.1.0"
test pkg-purge libbar
test pkg-fetch libbar/2.0.0
stat libbar "fetched 2.0.0"
##
## pkg-update
##
test cfg-create --wipe
test cfg-add $rep/common/hello
test cfg-fetch --trust $hello_fp
fail pkg-update # package name expected
fail pkg-update libhello # no such package
test pkg-fetch libhello/1.0.0+1
fail pkg-update libhello # wrong package state
test pkg-purge libhello
# src == out
#
test pkg-fetch libhello/1.0.0+1
test pkg-unpack libhello
test pkg-configure libhello
test pkg-update libhello
test pkg-update libhello
test pkg-disfigure libhello
test pkg-purge libhello
# src != out
#
test cfg-create --wipe
test pkg-unpack -e pkg/1/build2.org/common/libhello-1.0.0+1
test pkg-configure libhello
test pkg-update libhello
test pkg-update libhello
test pkg-disfigure libhello
test pkg-purge libhello
##
## pkg-clean
##
test cfg-create --wipe
test cfg-add $rep/common/hello
test cfg-fetch --trust $hello_fp
fail pkg-clean # package name expected
fail pkg-clean libhello # no such package
test pkg-fetch libhello/1.0.0+1
fail pkg-clean libhello # wrong package state
test pkg-purge libhello
# src == out
#
test pkg-fetch libhello/1.0.0+1
test pkg-unpack libhello
test pkg-configure libhello
test pkg-update libhello
test pkg-clean libhello
test pkg-clean libhello
test pkg-disfigure libhello
test pkg-purge libhello
# src != out
#
test cfg-create --wipe
test pkg-unpack -e pkg/1/build2.org/common/libhello-1.0.0+1
test pkg-configure libhello
test pkg-update libhello
test pkg-clean libhello
test pkg-clean libhello
test pkg-disfigure libhello
test pkg-purge libhello
##
## Low-level command scenarios.
##
# build and clean package
#
test cfg-create --wipe cxx
test cfg-add $rep/common/hello
test cfg-fetch --trust $hello_fp
test pkg-fetch libhello/1.0.0+1
test pkg-unpack libhello
test pkg-configure libhello
test pkg-update libhello
test pkg-clean libhello
test pkg-disfigure libhello
test pkg-purge libhello
##
## pkg-build
##
# 1 (libfoo)
#
test rep-create pkg/1/build2.org/satisfy/t1
test cfg-create --wipe
fail pkg-build -p # package name expected
fail pkg-build -p libfoo # unknown package
fail pkg-build -p libfoo/1.0.0 # unknown package
test pkg-build -p pkg/1/build2.org/satisfy/libfoo-1.1.0.tar.gz <<EOF
build libfoo 1.1.0
EOF
test pkg-build -p pkg/1/build2.org/satisfy/libfoo-1.1.0/ <<EOF
build libfoo 1.1.0
EOF
test pkg-unpack -e pkg/1/build2.org/satisfy/libfoo-1.1.0
test pkg-build -p libfoo <<< "build libfoo 1.1.0"
test pkg-build -p libfoo/1.1.0 <<< "build libfoo 1.1.0"
test pkg-build -p libfoo libfoo <<< "build libfoo 1.1.0"
test pkg-build -p libfoo libfoo/1.1.0 <<< "build libfoo 1.1.0"
test pkg-build -p libfoo/1.1.0 libfoo <<< "build libfoo 1.1.0"
test pkg-build -p libfoo/1.1.0 libfoo/1.1.0 <<< "build libfoo 1.1.0"
fail pkg-build -p libfoo/1.0.0
test pkg-purge libfoo
test cfg-add $rep/satisfy/t1
test cfg-fetch --trust-yes
test pkg-build -p libfoo <<< "build libfoo 1.0.0"
test pkg-build -p libfoo/1.0.0 <<< "build libfoo 1.0.0"
test pkg-build -p libfoo libfoo <<< "build libfoo 1.0.0"
test pkg-build -p libfoo libfoo/1.0.0 <<< "build libfoo 1.0.0"
test pkg-build -p libfoo/1.0.0 libfoo <<< "build libfoo 1.0.0"
test pkg-build -p libfoo/1.0.0 libfoo/1.0.0 <<< "build libfoo 1.0.0"
fail pkg-build -p libfoo/1.1.0
test pkg-unpack -e pkg/1/build2.org/satisfy/libfoo-1.1.0
test pkg-build -p libfoo <<< "build libfoo 1.1.0"
test pkg-build -p libfoo/1.0.0 <<< "downgrade libfoo 1.0.0"
fail pkg-build -p libfoo/0.0.0
test pkg-purge libfoo
test pkg-fetch -e pkg/1/build2.org/satisfy/libfoo-0.0.0.tar.gz
test pkg-unpack libfoo
test pkg-build -p libfoo <<< "upgrade libfoo 1.0.0"
test pkg-build -p libfoo/0.0.0 <<< "build libfoo 0.0.0"
fail pkg-build -p libfoo/1.1.0
test pkg-purge libfoo
# 2 (libbar depends on libfoo)
#
test rep-create pkg/1/build2.org/satisfy/t2
test cfg-create --wipe
fail pkg-build pkg/1/build2.org/satisfy/libbar-1.0.0.tar.gz
test cfg-add $rep/satisfy/t2
test cfg-fetch --trust-yes
test pkg-build -p libbar <<EOF
build libfoo 1.0.0 (required by libbar)
build libbar 1.0.0
EOF
test pkg-build -p libbar libfoo <<EOF
build libfoo 1.0.0
build libbar 1.0.0
EOF
test pkg-build -p libbar libfoo/1.0.0 <<EOF
build libfoo 1.0.0
build libbar 1.0.0
EOF
test pkg-build -p libbar libfoo libbar/1.0.0 <<EOF
build libfoo 1.0.0
build libbar 1.0.0
EOF
fail pkg-build -p libbar libfoo/1.1.0
test pkg-fetch -e pkg/1/build2.org/satisfy/libfoo-0.0.0.tar.gz
test pkg-unpack libfoo
test pkg-build -p libbar <<EOF
build libfoo 0.0.0 (required by libbar)
build libbar 1.0.0
EOF
test pkg-build -p libbar libfoo <<EOF
upgrade libfoo 1.0.0
build libbar 1.0.0
EOF
test pkg-build -p libbar libfoo/0.0.0 <<EOF
build libfoo 0.0.0
build libbar 1.0.0
EOF
test pkg-purge libfoo
test pkg-unpack -e pkg/1/build2.org/satisfy/libfoo-1.1.0
test pkg-build -p libbar <<EOF
build libfoo 1.1.0 (required by libbar)
build libbar 1.0.0
EOF
test pkg-build -p libbar libfoo <<EOF
build libfoo 1.1.0
build libbar 1.0.0
EOF
test pkg-build -p libbar libfoo/1.0.0 <<EOF
downgrade libfoo 1.0.0
build libbar 1.0.0
EOF
test pkg-purge libfoo
# 3 (libbaz depends on libbar; libbar in prerequisite repository)
#
test rep-create pkg/1/build2.org/satisfy/t3
test cfg-create --wipe
test cfg-add $rep/satisfy/t3
test cfg-fetch --trust-yes
# only in prerequisite repository
#
fail pkg-build -p libfoo
fail pkg-build -p libbar
fail pkg-build -p libbaz libbar
test pkg-build -p libbaz <<EOF
build libfoo 1.0.0 (required by libbar)
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test cfg-add $rep/satisfy/t2
test cfg-fetch
# order
#
test pkg-build -p libfox libfoo <<EOF
build libfox 1.0.0
build libfoo 1.0.0
EOF
test pkg-build -p libfoo libfox <<EOF
build libfoo 1.0.0
build libfox 1.0.0
EOF
test pkg-build -p libbaz libfoo <<EOF
build libfoo 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test pkg-build -p libfoo libbaz <<EOF
build libfoo 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test pkg-build -p libbaz libfox <<EOF
build libfoo 1.0.0 (required by libbar)
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
build libfox 1.0.0
EOF
test pkg-build -p libfox libbaz <<EOF
build libfox 1.0.0
build libfoo 1.0.0 (required by libbar)
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test pkg-build -p libfox libfoo libbaz <<EOF
build libfox 1.0.0
build libfoo 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test pkg-build -p libfox libbaz libfoo <<EOF
build libfox 1.0.0
build libfoo 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test pkg-build -p libfoo libfox libbaz <<EOF
build libfoo 1.0.0
build libfox 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test pkg-build -p libfoo libbaz libfox <<EOF
build libfoo 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
build libfox 1.0.0
EOF
# this one is contradictory: baz before fox but fox before foo
#
test pkg-build -p libbaz libfox libfoo <<EOF
build libfox 1.0.0
build libfoo 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
EOF
test pkg-build -p libbaz libfoo libfox <<EOF
build libfoo 1.0.0
build libbar 1.0.0 (required by libbaz)
build libbaz 1.0.0
build libfox 1.0.0
EOF
test pkg-build -p libbaz libfoo libbar <<EOF
build libfoo 1.0.0
build libbar 1.0.0
build libbaz 1.0.0
EOF
test pkg-build -p libbaz libbar libfoo <<EOF
build libfoo 1.0.0
build libbar 1.0.0
build libbaz 1.0.0
EOF
# 4 (libbaz depends on libfoo and libbar; libbar depends on libfoo >= 1.1.0)
#
test rep-create pkg/1/build2.org/satisfy/t4a
test rep-create pkg/1/build2.org/satisfy/t4b
test rep-create pkg/1/build2.org/satisfy/t4c
test rep-create pkg/1/build2.org/satisfy/t4d
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -p libbaz <<EOF
build libfoo 1.1.0 (required by libbar libbaz)
build libbar 1.1.0 (required by libbaz)
build libbaz 1.1.0
EOF
test pkg-build -p libfoo libbaz <<EOF
build libfoo 1.1.0
build libbar 1.1.0 (required by libbaz)
build libbaz 1.1.0
EOF
fail pkg-build -p libfoo/1.0.0 libbaz
fail pkg-build -p libfoo/1.1.0 libbaz
# upgrade warning
#
test pkg-fetch -e pkg/1/build2.org/satisfy/libfoo-0.0.0.tar.gz
test pkg-unpack libfoo
test pkg-build -p libbaz <<EOF
upgrade libfoo 1.1.0 (required by libbar libbaz)
build libbar 1.1.0 (required by libbaz)
build libbaz 1.1.0
EOF
test pkg-purge libfoo
# downgrade error
#
test pkg-fetch -e pkg/1/build2.org/satisfy/libfoo-1.2.0.tar.gz
test pkg-unpack libfoo
fail pkg-build -p libbaz
test cfg-add $rep/satisfy/t4a
test cfg-fetch --trust-yes
test pkg-build -p libfoo/1.1.0 libbaz <<EOF
downgrade libfoo 1.1.0
build libbar 1.1.0 (required by libbaz)
build libbaz 1.1.0
EOF
test pkg-purge libfoo
# dependent prevents upgrade/downgrade
#
test pkg-fetch libfoo/1.1.0
test pkg-unpack libfoo
test pkg-configure libfoo
test pkg-fetch libbar/1.1.0
test pkg-unpack libbar
test pkg-configure libbar
fail pkg-build -p pkg/1/build2.org/satisfy/libfoo-1.2.0.tar.gz
fail pkg-build -p libfoo/1.0.0
test pkg-build -p libfoo/1.1.0 <<< "build libfoo 1.1.0"
test pkg-disfigure libbar
test pkg-disfigure libfoo
test pkg-purge libbar
test pkg-purge libfoo
# dependent reconfigure
#
test cfg-create --wipe
test pkg-fetch -e pkg/1/build2.org/satisfy/libfoo-1.0.0.tar.gz
test pkg-unpack libfoo
test pkg-configure libfoo
test pkg-fetch -e pkg/1/build2.org/satisfy/libbar-1.0.0.tar.gz
test pkg-unpack libbar
test pkg-configure libbar
test pkg-fetch -e pkg/1/build2.org/satisfy/libbaz-1.1.0.tar.gz
test pkg-unpack libbaz
test pkg-configure libbaz
test cfg-add $rep/satisfy/t4a
test cfg-add $rep/satisfy/t4b
test cfg-fetch --trust-yes
test pkg-build -p libbar <<EOF
upgrade libfoo 1.1.0 (required by libbar libbaz)
upgrade libbar 1.1.0
reconfigure libbaz (required by libbar)
EOF
test pkg-build -p libfoo <<EOF
upgrade libfoo 1.1.0
reconfigure libbar (required by libfoo)
reconfigure libbaz (required by libbar)
EOF
test pkg-build -p libfoo libbar/1.0.0 <<EOF
upgrade libfoo 1.1.0
reconfigure/build libbar 1.0.0
reconfigure libbaz (required by libbar)
EOF
test pkg-build -p libbar/1.0.0 libfoo <<EOF
upgrade libfoo 1.1.0
reconfigure/build libbar 1.0.0
reconfigure libbaz (required by libbar)
EOF
test pkg-build -p libbaz libfoo <<EOF
upgrade libfoo 1.1.0
reconfigure libbar (required by libbaz libfoo)
reconfigure/build libbaz 1.1.0
EOF
test pkg-build -p libbaz libfoo/1.0.0 <<EOF
build libfoo 1.0.0
build libbaz 1.1.0
EOF
# actually build
#
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -y libbaz
stat libfoo/1.1.0 "configured"
stat libbar/1.1.0 "configured"
stat libbaz/1.1.0 "configured hold_package"
# hold
#
test cfg-create --wipe
test pkg-build -y pkg/1/build2.org/satisfy/libfoo-1.0.0.tar.gz
stat libfoo "configured 1.0.0 hold_package hold_version"
test pkg-build -y pkg/1/build2.org/satisfy/libfoo-1.1.0/
stat libfoo "configured 1.1.0 hold_package hold_version"
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -y libfoo
stat libfoo "configured 1.0.0 hold_package"
test pkg-build -y libfoo/1.0.0
stat libfoo "configured 1.0.0 hold_package hold_version"
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -y libfoo/1.0.0
stat libfoo "configured 1.0.0 hold_package hold_version"
test cfg-create --wipe
test pkg-fetch -e pkg/1/build2.org/satisfy/libfoo-1.0.0.tar.gz
test pkg-unpack libfoo
test pkg-configure libfoo
stat libfoo "configured 1.0.0"
test pkg-build -y libfoo
stat libfoo "configured 1.0.0 hold_package"
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -y libfoo
stat libfoo "configured 1.0.0 hold_package"
test pkg-build -y libbaz
stat libfoo "configured 1.1.0 hold_package"
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -y libfoo/1.0.0
stat libfoo "configured 1.0.0 hold_package hold_version"
fail pkg-build -y libbaz
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -y libbaz
stat libfoo "configured 1.1.0"
# drop prerequisites on downgrade
#
test rep-create pkg/1/build2.org/satisfy/t5
test cfg-create --wipe
test cfg-add $rep/satisfy/t2
test cfg-fetch --trust-yes
test pkg-build -y libbar
stat libfoo "configured 1.0.0"
stat libbar "configured 1.0.0 hold_package"
test cfg-add $rep/satisfy/t5
test cfg-fetch --trust-yes
test pkg-build -y libbar
stat libfoo "available 1.0.0"
stat libbar "configured 1.2.0 hold_package"
test pkg-build -y libbar/1.0.0 libfoo
stat libfoo "configured 1.0.0 hold_package"
stat libbar "configured 1.0.0 hold_package hold_version; available 1.2.0"
test pkg-build -y libbar
stat libfoo "configured 1.0.0 hold_package"
stat libbar "configured 1.2.0 hold_package"
##
## pkg-drop
##
test cfg-create --wipe
fail pkg-drop -p # package name expected
fail pkg-drop -p libfoo # unknown package
fail pkg-drop -p libfoo/1.0.0 # unknown package
test cfg-create --wipe
test cfg-add $rep/satisfy/t4c
test cfg-fetch --trust-yes
test pkg-build -y libbaz
test pkg-drop -p -y libfoo libbaz libbar <<EOF
drop libbaz
drop libbar
drop libfoo
EOF
# dependents
#
fail pkg-drop -y libfoo
fail pkg-drop -y libfoo libbar
fail pkg-drop -y libfoo libbaz
test pkg-drop -p -y --drop-dependent libfoo <<EOF
drop libbaz
drop libbar
drop libfoo
EOF
test pkg-drop -p --drop-dependent libfoo libbaz <<EOF
drop libbaz
drop libbar
drop libfoo
EOF
test pkg-drop -p --drop-dependent libbaz libfoo <<EOF
drop libbaz
drop libbar
drop libfoo
EOF
# prerequisites
#
test pkg-drop -p -y libbaz <<EOF
drop libbaz
drop libbar
drop libfoo
EOF
test pkg-drop -p -n libbaz <<EOF
drop libbaz
EOF
test pkg-drop -p -n libbar libbaz <<EOF
drop libbaz
drop libbar
EOF
test pkg-drop -p -n libbaz libbar <<EOF
drop libbaz
drop libbar
EOF
# prerequisites and dependents
#
test pkg-drop -p -y --drop-dependent libbar <<EOF
drop libbaz
drop libbar
drop libfoo
EOF
test cfg-create --wipe
test cfg-add $rep/satisfy/t4d
test cfg-fetch --trust-yes
test pkg-build -y libbiz
test pkg-drop -p -y libbiz <<EOF
drop libbiz
drop libbaz
drop libbar
drop libfoo
drop libfox
EOF
test pkg-drop -p -y libfox libbiz <<EOF
drop libbiz
drop libfox
drop libbaz
drop libbar
drop libfoo
EOF
test pkg-drop -p -y --drop-dependent libfox <<EOF
drop libbiz
drop libfox
drop libbaz
drop libbar
drop libfoo
EOF
test pkg-drop -p -y --drop-dependent libbaz <<EOF
drop libbiz
drop libbaz
drop libbar
drop libfoo
drop libfox
EOF
test pkg-drop -p -y --drop-dependent libbar <<EOF
drop libbiz
drop libbaz
drop libbar
drop libfoo
drop libfox
EOF
test pkg-drop -p -y --drop-dependent libfoo <<EOF
drop libbiz
drop libbaz
drop libbar
drop libfoo
drop libfox
EOF
test pkg-drop -p -n --drop-dependent libfox libbaz <<EOF
drop libbiz
drop libfox
drop libbaz
EOF
test pkg-drop -p -n --drop-dependent libbaz libfox <<EOF
drop libbiz
drop libbaz
drop libfox
EOF
test pkg-drop -p -n --drop-dependent libfox libbar <<EOF
drop libbiz
drop libfox
drop libbaz
drop libbar
EOF
test pkg-drop -p -n --drop-dependent libbar libfox <<EOF
drop libbiz
drop libbaz
drop libbar
drop libfox
EOF
# actually drop
#
test pkg-drop -y --drop-dependent libbar
stat libfox/1.0.0 "available"
stat libfoo/1.1.0 "unknown"
stat libbar/1.1.0 "unknown"
stat libbaz/1.1.0 "unknown"
stat libbiz/1.0.0 "available"
##
## auth
##
# rep-create
#
fail rep-create pkg/1/build2.org/auth/create-noemail --key key.pem
fail rep-create pkg/1/build2.org/auth/create-expired --key key.pem
fail rep-create pkg/1/build2.org/auth/signed # no --key option
test rep-create pkg/1/build2.org/auth/signed --key key.pem
test rep-create pkg/1/build2.org/auth/unsigned1
test rep-create pkg/1/build2.org/auth/unsigned2
test rep-create pkg/1/build2.org/auth/name-mismatch --key key.pem
test rep-create pkg/1/build2.org/auth/sha256sum-mismatch --key key.pem
# Tamper signature manifest's sha256sum value.
#
s=d374c59b36fdbdbd0d4468665061d94fda9c6c687863dfe72b0bcc34ff9d5fb4
edit pkg/1/build2.org/auth/sha256sum-mismatch/signature \
"s/^\(sha256sum: \).*\$/\1$s/"
test rep-create pkg/1/build2.org/auth/signature-mismatch --key key.pem
# Tamper signature manifest's signature value.
#
edit pkg/1/build2.org/auth/signature-mismatch/signature \
'/^signature: \\$/,/^\\$/d'
cat >> pkg/1/build2.org/auth/signature-mismatch/signature << EOF
signature: \\
XBjnmXXVHY0RqMI0gL/P4t/vuWwK9JJkLl4Qf2gMxq5k2WQ2CIE56DfG0RaGklgKcI3UxsQZvMQI
5PNtAHJDjteQ+BqY0io8A43KPX+2LKMU+I825sKmPRjCLYleGM3mNndDkWfYtAzYk5AmR2piqRz0
D7CLq9GIoQQZO4Fw44muaQDMCRcXy8Txx2jDnretQjx/C0ZQw4M/cd6/cKEKUmLITDkBig9oVlSh
tpxHqWz5NTbO3vm8ILc03AwiOJHwZweLb6ocJ6a467IJa+F/xUm9B09k8wFWMs+jHXXzHDE0syv7
lqWL7SvHSjVFrGVFKS6nx7lCj2b8XFiGlwWIwjY4m/VK/5QmbL/lC4f+ww5XT5NG5iYh/eMaCxCJ
zTg5iZsWNLhrx9uKNrL5xC4z0OONRVOwzu7gsqr0GLWewPyhH0AqJLgOSkw9N7FJwbv2IKNZ88YA
u2YMXNkXytcQvENLVQDX5oxvUMEurUJFOCuYB/SEnpcwkV5h9RtXzIFVy4OCTU2MhQHDEldI8s7w
Hga/ct4WupgE228gGdgwJLCbHx6AWBlS9iL10AdS8JkQ9LaZwTMHHz44f8y00X4MiT06gpgDeoQD
rUyP0KNG65tdWnVTMqg6Q/YXhtRZLHoD6+QbiYLlruR1phu4y4fDt7AKxoXfeme/a86A37UogZY=
\\
EOF
# cfg-fetch
#
signed_fp=`rep_cert_fp pkg/1/build2.org/auth/signed`
test cfg-create --wipe
test cfg-add $rep/auth/signed
test cfg-fetch --trust $signed_fp
test cfg-fetch
test cfg-create --wipe
test cfg-add $rep/auth/signed
test cfg-fetch --trust-no --trust $signed_fp
test cfg-fetch
test cfg-fetch --trust-no # certificate is already trusted
test cfg-create --wipe
test cfg-add $rep/auth/signed
test cfg-fetch --trust-yes
test cfg-fetch
test cfg-create --wipe
test cfg-add $rep/auth/signed
fail cfg-fetch --trust-no
test cfg-create --wipe
test cfg-add $rep/auth/signed
fail cfg-fetch --trust-yes --trust-no # inconsistent options
test cfg-create --wipe
test cfg-add $rep/auth/unsigned1
test cfg-fetch --trust-yes
test cfg-fetch
test cfg-add $rep/auth/unsigned2
test cfg-fetch
test cfg-fetch --trust-no # certificates are already trusted
test cfg-create --wipe
test cfg-add $rep/auth/unsigned1
fail cfg-fetch --trust-no
test cfg-create --wipe
test cfg-add $rep/auth/name-mismatch
fail cfg-fetch --trust-yes # certificate name mismatch
test cfg-create --wipe
test cfg-add $rep/auth/expired
fail cfg-fetch --trust-yes # certificate expired
test cfg-create --wipe
test cfg-add $rep/auth/sha256sum-mismatch
fail cfg-fetch --trust-yes # packages file checksum mismatch
test cfg-create --wipe
test cfg-add $rep/auth/signature-mismatch
fail cfg-fetch --trust-yes # packages file signature:mismatch
# rep-info
#
test cfg-create --wipe
test rep-info --trust-no --trust $signed_fp -d $cfg $rep/auth/signed <<EOF
${repn}auth/signed `location auth/signed`
libfoo 1.0.0
EOF
test rep-info --trust-no -d $cfg $rep/auth/signed <<EOF
${repn}auth/signed `location auth/signed`
libfoo 1.0.0
EOF
test cfg-create --wipe
test rep-info --trust-yes $rep/auth/signed <<EOF
${repn}auth/signed `location auth/signed`
libfoo 1.0.0
EOF
fail rep-info --trust-no $rep/auth/signed <<EOF
${repn}auth/signed `location auth/signed`
libfoo 1.0.0
EOF
test cfg-create --wipe
test rep-info --trust-yes -d $cfg $rep/auth/unsigned1 <<EOF
${repn}auth/unsigned1 `location auth/unsigned1`
libfoo 1.0.0
EOF
test rep-info --trust-no -d $cfg $rep/auth/unsigned2 <<EOF
${repn}auth/unsigned2 `location auth/unsigned2`
libfoo 1.0.0
EOF
test cfg-create --wipe
test rep-info --trust-yes $rep/auth/unsigned1 <<EOF
${repn}auth/unsigned1 `location auth/unsigned1`
libfoo 1.0.0
EOF
fail rep-info --trust-no $rep/auth/unsigned1 <<EOF
${repn}auth/unsigned1 `location auth/unsigned1`
libfoo 1.0.0
EOF
|