Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/tests/frontend/lua.sh
2645 views
1
#! /usr/bin/env atf-sh
2
3
. $(atf_get_srcdir)/test_environment.sh
4
5
tests_init \
6
script_basic \
7
script_message \
8
script_rooteddir \
9
script_remove \
10
script_execute \
11
script_rename \
12
script_upgrade \
13
script_filecmp \
14
script_filecmp_symlink \
15
script_copy \
16
script_copy_symlink \
17
script_sample_not_exists \
18
script_sample_not_exists_symlink \
19
script_sample_not_exists_two_files \
20
script_sample_exists \
21
script_stat \
22
script_arguments \
23
script_metalog_add
24
25
script_arguments_body() {
26
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
27
cat << EOF >> test.ucl
28
lua_scripts: {
29
post-install: [
30
"-- args: plop\nprint(arg[1])"
31
]
32
}
33
EOF
34
atf_check \
35
-o empty \
36
-e empty \
37
-s exit:0 \
38
pkg create -M test.ucl
39
40
mkdir ${TMPDIR}/target
41
atf_check \
42
-o inline:"plop\n" \
43
-e empty \
44
-s exit:0 \
45
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
46
47
}
48
49
script_basic_body() {
50
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
51
cat << EOF >> test.ucl
52
lua_scripts: {
53
post-install: [
54
'print("this is post install1")',
55
'print("this is post install2")',
56
]
57
}
58
EOF
59
60
atf_check \
61
-o empty \
62
-e empty \
63
-s exit:0 \
64
pkg create -M test.ucl
65
66
mkdir ${TMPDIR}/target
67
atf_check \
68
-o inline:"this is post install1\nthis is post install2\n" \
69
-e empty \
70
-s exit:0 \
71
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
72
73
}
74
75
script_message_body() {
76
# The message should be the last thing planned
77
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
78
cat << EOF >> test.ucl
79
lua_scripts: {
80
post-install: [
81
"print(\"this is post install1\")\npkg.print_msg(\"this is a message\")",
82
'print("this is post install2")',
83
]
84
}
85
EOF
86
87
atf_check \
88
-o empty \
89
-e empty \
90
-s exit:0 \
91
pkg create -M test.ucl
92
93
mkdir ${TMPDIR}/target
94
atf_check \
95
-o inline:"this is post install1\nthis is post install2\nthis is a message\n" \
96
-e empty \
97
-s exit:0 \
98
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
99
100
}
101
102
script_rooteddir_body() {
103
# The message should be the last thing planned
104
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
105
cat << EOF >> test.ucl
106
lua_scripts: {
107
post-install: [ <<EOS
108
test = io.open("/file.txt", "w+")
109
test:write("test\n")
110
io.close(test)
111
EOS
112
,
113
]
114
}
115
EOF
116
117
atf_check \
118
-o empty \
119
-e empty \
120
-s exit:0 \
121
pkg create -M test.ucl
122
123
mkdir ${TMPDIR}/target
124
atf_check \
125
-e empty \
126
-s exit:0 \
127
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
128
[ -f ${TMPDIR}/target/file.txt ] || atf_fail "File not created in the rootdir"
129
# test the mode
130
atf_check -o match:"^-rw-r--r--" ls -l ${TMPDIR}/target/file.txt
131
atf_check \
132
-e empty \
133
-o inline:"test\n" \
134
-s exit:0 \
135
cat ${TMPDIR}/target/file.txt
136
137
}
138
139
script_remove_body() {
140
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
141
cat << EOF >> test.ucl
142
lua_scripts: {
143
post-install: [ <<EOS
144
os.remove("/file")
145
EOS
146
,
147
]
148
}
149
EOF
150
151
atf_check \
152
-o empty \
153
-e empty \
154
-s exit:0 \
155
pkg create -M test.ucl
156
157
mkdir -p ${TMPDIR}/target/file
158
atf_check \
159
-e empty \
160
-s exit:0 \
161
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
162
test -d ${TMPDIR}/target/file && atf_fail "directory not removed"
163
164
touch ${TMPDIR}/target/file
165
atf_check \
166
-e empty \
167
-s exit:0 \
168
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
169
test -f ${TMPDIR}/target/file && atf_fail "file not removed"
170
return 0
171
}
172
173
script_rename_body() {
174
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
175
cat << EOF >> test.ucl
176
lua_scripts: {
177
post-install: [ <<EOS
178
os.rename("/file","/plop")
179
EOS
180
,
181
]
182
}
183
EOF
184
185
atf_check \
186
-o empty \
187
-e empty \
188
-s exit:0 \
189
pkg create -M test.ucl
190
mkdir -p ${TMPDIR}/target
191
touch ${TMPDIR}/target/file
192
atf_check \
193
-e inline:"${ERR}" \
194
-s exit:0 \
195
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
196
test -f ${TMPDIR}/target/file && atf_fail "File not renamed"
197
test -f ${TMPDIR}/target/plop || atf_fail "File not renamed"
198
return 0
199
}
200
201
script_execute_body() {
202
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
203
cat << EOF >> test.ucl
204
lua_scripts: {
205
post-install: [ <<EOS
206
os.execute("echo yeah")
207
EOS
208
,
209
]
210
}
211
EOF
212
213
ERR="pkg: Failed to execute lua script: [string \"os.execute(\"echo yeah\")\"]:1: os.execute not available
214
pkg: lua script failed\n"
215
216
217
atf_check \
218
-o empty \
219
-e empty \
220
-s exit:0 \
221
pkg create -M test.ucl
222
mkdir -p ${TMPDIR}/target
223
atf_check \
224
-e inline:"${ERR}" \
225
-s exit:0 \
226
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
227
}
228
229
script_upgrade_body() {
230
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
231
cat << EOF >> test.ucl
232
lua_scripts: {
233
post-install: [ <<EOS
234
if pkg_upgrade then
235
pkg.print_msg("upgrade : ".. tostring(pkg_upgrade))
236
end
237
EOS
238
,
239
]
240
}
241
EOF
242
243
244
atf_check \
245
-o empty \
246
-e empty \
247
-s exit:0 \
248
pkg create -M test.ucl
249
mkdir -p ${TMPDIR}/target
250
atf_check \
251
-e empty \
252
-o empty \
253
-s exit:0 \
254
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
255
256
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "2" "/"
257
cat << EOF >> test.ucl
258
lua_scripts: {
259
post-install: [ <<EOS
260
if pkg_upgrade then
261
pkg.print_msg("upgrade:".. tostring(pkg_upgrade))
262
end
263
EOS
264
,
265
]
266
}
267
EOF
268
269
rm ${TMPDIR}/test-1.pkg
270
atf_check \
271
-o empty \
272
-e empty \
273
-s exit:0 \
274
pkg create -M test.ucl
275
mkdir -p ${TMPDIR}/target
276
atf_check \
277
-o ignore \
278
-e empty \
279
-s exit:0 \
280
pkg repo .
281
mkdir reposconf
282
cat <<EOF >> reposconf/repo.conf
283
local: {
284
url: file:///${TMPDIR},
285
enabled: true
286
}
287
EOF
288
atf_check \
289
-e empty \
290
-o match:"upgrade:true" \
291
-s exit:0 \
292
pkg -o REPOS_DIR="${TMPDIR}/reposconf" -r ${TMPDIR}/target upgrade -y
293
}
294
295
script_filecmp_body() {
296
echo "sametext" > a
297
echo "sametext" > b
298
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
299
cat << EOF >> test.ucl
300
files: {
301
${TMPDIR}/a: ""
302
${TMPDIR}/b: ""
303
}
304
lua_scripts: {
305
post-install: [ <<EOS
306
if pkg.filecmp("${TMPDIR}/a", "${TMPDIR}/b") == 0 then
307
pkg.print_msg("same")
308
else
309
pkg.print_msg("different")
310
end
311
EOS
312
, ]
313
}
314
EOF
315
316
atf_check \
317
-o empty \
318
-e empty \
319
-s exit:0 \
320
pkg create -M test.ucl
321
322
mkdir ${TMPDIR}/target
323
atf_check \
324
-o inline:"same\n" \
325
-e empty \
326
-s exit:0 \
327
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
328
329
# Cleanup
330
atf_check \
331
-o empty \
332
-e empty \
333
-s exit:0 \
334
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target delete -qfy test-1
335
rm -rf ${TMPDIR}/target
336
337
echo "sametext" > a
338
echo "differenttext" > b
339
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
340
cat << EOF >> test.ucl
341
files: {
342
${TMPDIR}/a: ""
343
${TMPDIR}/b: ""
344
}
345
lua_scripts: {
346
post-install: [ <<EOS
347
if pkg.filecmp("${TMPDIR}/a", "${TMPDIR}/b") == 0 then
348
pkg.print_msg("same")
349
else
350
pkg.print_msg("different")
351
end
352
EOS
353
, ]
354
}
355
EOF
356
357
atf_check \
358
-o empty \
359
-e empty \
360
-s exit:0 \
361
pkg create -M test.ucl
362
363
mkdir ${TMPDIR}/target
364
atf_check \
365
-o inline:"different\n" \
366
-e empty \
367
-s exit:0 \
368
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
369
}
370
371
script_filecmp_symlink_body() {
372
echo "sametext" > a
373
echo "sametext" > b
374
ln -s a c
375
ln -s b d
376
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
377
cat << EOF >> test.ucl
378
files: {
379
${TMPDIR}/a: ""
380
${TMPDIR}/b: ""
381
${TMPDIR}/c: ""
382
${TMPDIR}/d: ""
383
}
384
lua_scripts: {
385
post-install: [ <<EOS
386
if pkg.filecmp("${TMPDIR}/c", "${TMPDIR}/d") == 0 then
387
pkg.print_msg("same")
388
else
389
pkg.print_msg("different")
390
end
391
EOS
392
, ]
393
}
394
EOF
395
396
atf_check \
397
-o empty \
398
-e empty \
399
-s exit:0 \
400
pkg create -M test.ucl
401
402
mkdir ${TMPDIR}/target
403
atf_check \
404
-o inline:"same\n" \
405
-e empty \
406
-s exit:0 \
407
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
408
409
# Cleanup
410
atf_check \
411
-o empty \
412
-e empty \
413
-s exit:0 \
414
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target delete -qfy test-1
415
rm -rf ${TMPDIR}/target
416
rm a b c d
417
418
echo "sametext" > a
419
echo "differenttext" > b
420
ln -s a c
421
ln -s b d
422
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
423
cat << EOF >> test.ucl
424
files: {
425
${TMPDIR}/a: ""
426
${TMPDIR}/b: ""
427
${TMPDIR}/c: ""
428
${TMPDIR}/d: ""
429
}
430
lua_scripts: {
431
post-install: [ <<EOS
432
if pkg.filecmp("${TMPDIR}/c", "${TMPDIR}/d") == 0 then
433
pkg.print_msg("same")
434
else
435
pkg.print_msg("different")
436
end
437
EOS
438
, ]
439
}
440
EOF
441
442
atf_check \
443
-o empty \
444
-e empty \
445
-s exit:0 \
446
pkg create -M test.ucl
447
448
mkdir ${TMPDIR}/target
449
atf_check \
450
-o inline:"different\n" \
451
-e empty \
452
-s exit:0 \
453
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
454
}
455
456
script_copy_body() {
457
echo "sample text" > a.sample
458
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
459
cat << EOF >> test.ucl
460
files: {
461
${TMPDIR}/a.sample: ""
462
}
463
lua_scripts: {
464
post-install: [ <<EOS
465
pkg.copy("${TMPDIR}/a.sample", "${TMPDIR}/a")
466
EOS
467
, ]
468
}
469
EOF
470
471
atf_check \
472
-o empty \
473
-e empty \
474
-s exit:0 \
475
pkg create -M test.ucl
476
477
mkdir ${TMPDIR}/target
478
atf_check \
479
-o empty \
480
-e empty \
481
-s exit:0 \
482
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
483
484
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a.sample
485
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a
486
atf_check \
487
-o empty \
488
-e empty \
489
-s exit:0 \
490
cmp -s ${TMPDIR}/target${TMPDIR}/a.sample ${TMPDIR}/target${TMPDIR}/a
491
}
492
493
script_copy_symlink_body() {
494
echo "sample text" > a.sample
495
ln -s a.sample b
496
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
497
cat << EOF >> test.ucl
498
files: {
499
${TMPDIR}/a.sample: ""
500
${TMPDIR}/b: ""
501
}
502
lua_scripts: {
503
post-install: [ <<EOS
504
pkg.copy("${TMPDIR}/b", "${TMPDIR}/a")
505
EOS
506
, ]
507
}
508
EOF
509
510
atf_check \
511
-o empty \
512
-e empty \
513
-s exit:0 \
514
pkg create -M test.ucl
515
516
mkdir ${TMPDIR}/target
517
atf_check \
518
-o empty \
519
-e empty \
520
-s exit:0 \
521
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
522
523
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a.sample
524
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/b
525
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a
526
atf_check \
527
-o empty \
528
-e empty \
529
-s exit:0 \
530
cmp -s ${TMPDIR}/target${TMPDIR}/a.sample ${TMPDIR}/target${TMPDIR}/a
531
atf_check \
532
-o empty \
533
-e empty \
534
-s exit:0 \
535
cmp -s ${TMPDIR}/target${TMPDIR}/b ${TMPDIR}/target${TMPDIR}/a
536
}
537
538
script_sample_not_exists_body() {
539
echo "sample text" > a.sample
540
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
541
cat << EOF >> test.ucl
542
files: {
543
${TMPDIR}/a.sample: ""
544
}
545
lua_scripts: {
546
post-install: [ <<EOS
547
-- args: a.sample
548
sample_file = pkg.prefixed_path(arg[1])
549
if arg[2] == nil then
550
target_file = string.gsub(sample_file,'%.sample$', "")
551
else
552
target_file = pkg.prefixed_path(arg[2])
553
end
554
if not pkg.stat(target_file) then
555
pkg.copy(sample_file, target_file)
556
end
557
EOS
558
, ]
559
}
560
EOF
561
562
atf_check \
563
-o empty \
564
-e empty \
565
-s exit:0 \
566
pkg create -M test.ucl
567
568
mkdir ${TMPDIR}/target
569
atf_check \
570
-o empty \
571
-e empty \
572
-s exit:0 \
573
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
574
575
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a.sample
576
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a
577
atf_check \
578
-o empty \
579
-e empty \
580
-s exit:0 \
581
cmp -s ${TMPDIR}/target${TMPDIR}/a.sample ${TMPDIR}/target${TMPDIR}/a
582
}
583
584
script_sample_not_exists_symlink_body() {
585
echo "sample text" > a
586
ln -s a b.sample
587
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
588
cat << EOF >> test.ucl
589
files: {
590
${TMPDIR}/a: ""
591
${TMPDIR}/b.sample: ""
592
}
593
lua_scripts: {
594
post-install: [ <<EOS
595
-- args: b.sample
596
sample_file = pkg.prefixed_path(arg[1])
597
if arg[2] == nil then
598
target_file = string.gsub(sample_file,'%.sample$', "")
599
else
600
target_file = pkg.prefixed_path(arg[2])
601
end
602
if not pkg.stat(target_file) then
603
pkg.copy(sample_file, target_file)
604
end
605
EOS
606
, ]
607
}
608
EOF
609
610
atf_check \
611
-o empty \
612
-e empty \
613
-s exit:0 \
614
pkg create -M test.ucl
615
616
mkdir ${TMPDIR}/target
617
atf_check \
618
-o empty \
619
-e empty \
620
-s exit:0 \
621
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
622
623
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a
624
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/b.sample
625
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/b
626
atf_check \
627
-o empty \
628
-e empty \
629
-s exit:0 \
630
cmp -s ${TMPDIR}/target${TMPDIR}/b.sample ${TMPDIR}/target${TMPDIR}/b
631
}
632
633
script_sample_not_exists_two_files_body() {
634
echo "sample text" > a
635
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
636
cat << EOF >> test.ucl
637
files: {
638
${TMPDIR}/a: ""
639
}
640
lua_scripts: {
641
post-install: [ <<EOS
642
-- args: a b
643
sample_file = pkg.prefixed_path(arg[1])
644
if arg[2] == nil then
645
target_file = string.gsub(sample_file,'%.sample$', "")
646
else
647
target_file = pkg.prefixed_path(arg[2])
648
end
649
if not pkg.stat(target_file) then
650
pkg.copy(sample_file, target_file)
651
end
652
EOS
653
, ]
654
}
655
EOF
656
657
atf_check \
658
-o empty \
659
-e empty \
660
-s exit:0 \
661
pkg create -M test.ucl
662
663
mkdir ${TMPDIR}/target
664
atf_check \
665
-o empty \
666
-e empty \
667
-s exit:0 \
668
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
669
670
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/a
671
atf_check -o inline:"sample text\n" cat ${TMPDIR}/target${TMPDIR}/b
672
atf_check \
673
-o empty \
674
-e empty \
675
-s exit:0 \
676
cmp -s ${TMPDIR}/target${TMPDIR}/a ${TMPDIR}/target${TMPDIR}/b
677
}
678
679
script_sample_exists_body() {
680
echo "sample text" > a.sample
681
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
682
cat << EOF >> test.ucl
683
files: {
684
${TMPDIR}/a.sample: ""
685
}
686
lua_scripts: {
687
post-install: [ <<EOS
688
-- args: a.sample
689
sample_file = pkg.prefixed_path(arg[1])
690
if arg[2] == nil then
691
target_file = string.gsub(sample_file,'%.sample$', "")
692
else
693
target_file = pkg.prefixed_path(arg[2])
694
end
695
if not pkg.stat(target_file) then
696
pkg.copy(sample_file, target_file)
697
end
698
EOS
699
, ]
700
}
701
EOF
702
703
mkdir -p ${TMPDIR}/target${TMPDIR}
704
echo "text modified" > ${TMPDIR}/target${TMPDIR}/a
705
atf_check \
706
-o empty \
707
-e empty \
708
-s exit:0 \
709
pkg create -M test.ucl
710
711
atf_check \
712
-o empty \
713
-e empty \
714
-s exit:0 \
715
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
716
717
atf_check \
718
-o empty \
719
-e empty \
720
-s exit:1 \
721
cmp -s ${TMPDIR}/target${TMPDIR}/a.sample ${TMPDIR}/target${TMPDIR}/a
722
}
723
724
script_stat_body() {
725
touch plop
726
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
727
cat << EOF >> test.ucl
728
files: {
729
${TMPDIR}/plop: ""
730
}
731
lua_scripts: {
732
post-install: [ <<EOS
733
local st = pkg.stat("${TMPDIR}/plop")
734
if st.size == 0 then
735
pkg.print_msg("zero")
736
end
737
pkg.print_msg(st.type)
738
EOS
739
, ]
740
}
741
EOF
742
atf_check \
743
-o empty \
744
-e empty \
745
-s exit:0 \
746
pkg create -M test.ucl
747
mkdir ${TMPDIR}/target
748
atf_check \
749
-o inline:"zero\nreg\n" \
750
-e empty \
751
-s exit:0 \
752
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
753
}
754
755
script_metalog_add_body()
756
{
757
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
758
touch plop
759
echo "@(root,wheel,440) /plop" > test.plist
760
cat << EOF >> test.ucl
761
lua_scripts: {
762
post-install: [ <<EOS
763
assert(pkg.metalog_copy("/plop", "/meh"))
764
EOS
765
, ]
766
}
767
EOF
768
769
OUTPUT="./plop type=file uname=root gname=wheel mode=440
770
./meh type=file uname=root gname=wheel mode=440
771
"
772
atf_check -o ignore pkg create -M test.ucl -p test.plist -r .
773
mkdir ${TMPDIR}/target
774
atf_check -s exit:0 \
775
pkg \
776
-o REPOS_DIR=/dev/null \
777
-o METALOG=${TMPDIR}/METALOG \
778
-r ${TMPDIR}/target \
779
install \
780
-qfy ${TMPDIR}/test-1.pkg
781
atf_check -o inline:"${OUTPUT}" cat METALOG
782
}
783
784