forked from OpenXT/openxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_build.sh
executable file
·1633 lines (1334 loc) · 45 KB
/
do_build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/bash -e
set -o pipefail
STEPS="setupoe,initramfs,stubinitramfs,dom0,uivm,ndvm,syncvm,sysroot,installer,installer2,syncui,source,sdk,license,sourceinfo,ship"
# Additional steps:
# copy: Copies the build output to a web/pxe server. See do_copy() for more details.
# Requires a valid BUILD_RSYNC_DESTINATION in .config
# extra_pkgs: Builds a bunch of extra OpenEmbedded packages, that will be installable separately.
# Combined with packages_tree, this allows easy debugging on the target.
# For example, on an OpenXT machine: # rw ; opkg update ; opkg install gdb surfman-dbg; ro
# packages_tree: Adds the built packages to an OpenEmbedded repository pool.
# Packages tree can use hardlinks to save disk space, if $SYNC_CACHE_OE/oe-archives is populated
# Requires a valid SYNC_CACHE_OE, BUILD_RSYNC_DESTINATION and NETBOOT_HTTP_URL in .config
TOPDIR=`pwd`
OUTPUT_DIR="$TOPDIR/build-output"
CMD="$0"
CMD_DIR=`dirname "$CMD"`
NAME=""
ENV=0
VERBOSE=0
SOURCE=0
BUILD_USER="`whoami`"
OE_BB_THREADS="8"
CACHE_DIR="$TOPDIR/build/cache"
OE_BUILD_CACHE="$TOPDIR/build"
BRANCH=master
BUILD_UID=`id -u`
export BUILD_UID
# TODO: move some of the above definitions into common-config
source ${CMD_DIR}/common-config
source ${CMD_DIR}/build_helpers.sh
create_ramdisk()
{
local path="$1"
local type="$2"
if [ $type -eq 0 ]; then
return
fi
mkdir -p "$path"
if [ $type -eq 1 ]; then
#tmpfs ramfs
local fstype="`df -T "$path" | tail -n1 | awk '{print $2}'`"
if [ "$fstype" != "tmpfs" ]; then
echo "Create ramfs ($path)"
sudo mount -t tmpfs -o size=20G tmpfs "$path"
fi
fi
if [ $type -eq 2 ]; then
#ext2 on ramdisk
local dev="`df -T "$path" | tail -n1 | awk '{print $1}'`"
if [ "$dev" != "/dev/ram0" ]; then
echo "Create ram disk on ($path)"
dev="/dev/ram0"
sudo modprobe brd rd_size=$[20 * 1024 * 1024]
sudo mke2fs -b 4096 "$dev"
sudo tune2fs -m 0 -i 0 -c 0 "$dev"
sudo mount "$dev" "$path"
sudo chmod 1777 "$path"
fi
fi
}
do_make()
{
local rule="$1"
local output="$2"
(
set +x
< /dev/null make $rule 2>&1 | \
while read l; do echo "$(date "+[%H:%M:%S.%N]"): $l"; done | tee "$output";
)
}
do_sim()
{
local path="$1"
local dom0rootfs="$OUTPUT_DIR/$NAME/raw/dom0-rootfs.i686.ext3.gz"
mkdir -p "$path"
pushd "$path"
git_clone "xc-test" "$OPENXT_GIT_PROTOCOL://$OPENXT_GIT_MIRROR/xc-test.git" "$BRANCH" "$ALLOW_SWITCH_BRANCH_FAIL"
pushd "xc-test/xc-sim"
do_make "BUILDNO=${ID} ID=${ID} ROOTFS=${dom0rootfs} xc-sim" "build.log"
popd
popd
}
do_oe_log()
{
(
set +x
while read l; do echo "`date "+[%H:%M:%S.%N]"`: $l"; done
)
}
do_oe_setup()
{
local path="$1"
local branch="$BRANCH"
mkdir -p "$path"
pushd "$path" > /dev/null
echo "*:$BRANCH" > "manifest"
if [ ! -f "local.settings" ]; then
cat > local.settings <<EOF
META_SELINUX_REPO=$OPENXT_GIT_PROTOCOL://$OPENXT_GIT_MIRROR/meta-selinux.git
EXTRA_REPO=$OPENXT_GIT_PROTOCOL://$OPENXT_GIT_MIRROR/xenclient-oe-extra.git
EXTRA_DIR=extra
EXTRA_TAG="$BRANCH"
XENCLIENT_REPO=$OPENXT_GIT_PROTOCOL://$OPENXT_GIT_MIRROR/xenclient-oe.git
XENCLIENT_TAG="$BRANCH"
EOF
if [ "$OE_GIT_MIRROR" ] ; then
cat >> local.settings <<EOF
BITBAKE_REPO=$OE_GIT_MIRROR/bitbake.git
OE_CORE_REPO=$OE_GIT_MIRROR/openembedded-core.git
META_OE_REPO=$OE_GIT_MIRROR/meta-openembedded.git
META_JAVA_REPO=$OE_GIT_MIRROR/meta-java.git
EOF
fi
fi
if [ -z "$REPO_PROD_CACERT" ] ; then
echo "Error: REPO_PROD_CACERT must be set in .config." >&2
exit 1
fi
if [ -z "$REPO_DEV_CACERT" ] ; then
echo "Error: REPO_DEV_CACERT must be set in .config." >&2
exit 1
fi
local REPO_PROD_CACERT_PATH="$(resolve_path "$TOPDIR" "$REPO_PROD_CACERT")"
local REPO_DEV_CACERT_PATH="$(resolve_path "$TOPDIR" "$REPO_DEV_CACERT")"
check_repo_signing_file "$REPO_PROD_CACERT_PATH" \
"Production repository-signing CA certificate"
check_repo_signing_file "$REPO_DEV_CACERT_PATH" \
"Development repository-signing CA certificate"
[ "x$ORIGIN_BRANCH" != "x" ] && branch="$ORIGIN_BRANCH"
oedl="$OE_BUILD_CACHE/downloads"
[ "x$OE_BUILD_CACHE_DL" != "x" ] && oedl="$OE_BUILD_CACHE_DL"
EXTRA_CLASSES=""
[ "x$INHIBIT_RMWORK" == "x" ] && EXTRA_CLASSES="rm_work $EXTRA_CLASSES"
if [ ! -e conf ]; then
mkdir -p conf
fi
if [ ! -f "conf/local.conf" ]; then
cp conf/local.conf-dist conf/local.conf
if [ ! -z "${OE_TARBALL_MIRROR}" ] ; then
cat >> conf/local.conf <<EOF
# Tarball mirror
PREMIRRORS = "(ftp|https?)$://.*/.*/ ${OE_TARBALL_MIRROR}"
EOF
fi
cat >> conf/local.conf <<EOF
# Distribution feed
XENCLIENT_PACKAGE_FEED_URI="${NETBOOT_HTTP_URL}/${ORIGIN_BRANCH}/${NAME}/packages/ipk"
# Local generated configuration for build $ID
INHERIT += "$EXTRA_CLASSES"
SSTATE_DIR = "$OE_BUILD_CACHE/sstate-cache/$branch"
DL_DIR = "$oedl"
export CCACHE_DIR = "${CACHE_DIR}"
CCACHE_TARGET_DIR="$CACHE_DIR"
PARALLEL_MAKE = "-j 8"
BB_NUMBER_THREADS = "$OE_BB_THREADS"
OPENXT_MIRROR="$OPENXT_MIRROR"
OPENXT_GIT_MIRROR="$OPENXT_GIT_MIRROR"
OPENXT_GIT_PROTOCOL="$OPENXT_GIT_PROTOCOL"
OPENXT_BRANCH="$ORIGIN_BRANCH"
OPENXT_TAG="$BRANCH"
require conf/xenclient-extra.conf
EOF
if [ "x$ID" != "x" ]; then
echo "XENCLIENT_BUILD = \"$ID\"" >> conf/local.conf
else
echo "XENCLIENT_BUILD = \"$NAME\"" >> conf/local.conf
fi
cat >> conf/local.conf <<EOF
XENCLIENT_BUILD_DATE = "`date +'%T %D'`"
XENCLIENT_BUILD_BRANCH = "${ORIGIN_BRANCH}"
XENCLIENT_VERSION = "$VERSION"
XENCLIENT_RELEASE = "$RELEASE"
XENCLIENT_TOOLS = "$XENCLIENT_TOOLS"
# dir for generated deb packages
XCT_DEB_PKGS_DIR := "${OE_BUILD_CACHE}/xct_deb_packages"
# xen version and source
XEN_VERSION="${XEN_VERSION}"
XEN_SRC_URI="${XEN_SRC_URI}"
XEN_SRC_MD5SUM="${XEN_SRC_MD5SUM}"
XEN_SRC_SHA256SUM="${XEN_SRC_SHA256SUM}"
EOF
cat >> conf/local.conf <<EOF
# Production and development repository-signing CA certificates
REPO_PROD_CACERT="$REPO_PROD_CACERT_PATH"
REPO_DEV_CACERT="$REPO_DEV_CACERT_PATH"
EOF
if [ $SOURCE -eq 1 ]
then
cat >> conf/local.conf <<EOF
XENCLIENT_BUILD_SRC_PACKAGES = "1"
XENCLIENT_COLLECT_SRC_INFO = "1"
EOF
fi
if [ "x$FREEZE_URIS" = "xyes" ]
then
cat >> conf/local.conf <<EOF
INHERIT += "freezer"
EOF
fi
fi
if [ $VERBOSE -eq 1 ]
then
echo "Generated config is:"
cat conf/local.conf
fi
if [ $VERBOSE -eq 1 ]
then
OPTS="-v"
else
OPTS=""
fi
${TOPDIR}/setup_build $OPTS
popd > /dev/null
}
check_repo_signing_file()
{
local FILE="$1"
local DESC="$2"
# TODO: Add script to generate set of production/development CA
# certificates and signing certificates and refer to it in this
# error message.
if [ ! -e "$FILE" ] ; then
cat <<EOF >&2
Error: $DESC '$FILE' not found.
EOF
false
fi
}
do_oe_check_cpp()
{
local path="$1"
pushd "$path"
cat <<- EOF > fish.cpp
#include <stdio.h>
int main(int argc, char *argv[]) { printf("fish\n"); }
EOF
export MACHINE="xenclient-dom0"
build/cross/i686core2/bin/i686-angstrom-linux-gcc -c -o fish.o fish.cpp | do_oe_log
rm -rf fish.o fish.cpp
popd
}
do_oe()
{
local path="$1"
local machine="$2"
local image="$3"
local log_path="${OUTPUT_DIR}/${NAME}/logs"
local dont_get_log="$4"
pushd "$path"
export MACHINE="$machine"
if [ "x$FREEZE_URIS" = "xyes" ]; then
echo "Running URI freezer"
< /dev/null ./bb --disable-wrapper -c freezeall "$image" | do_oe_log
# kill the cache
rm -fr tmp-eglibc/cache
fi
if [ $VERBOSE -eq 1 ]
then
BBFLAGS="-v"
else
BBFLAGS=""
fi
echo "STARTING OE BUILD $image $machine, started at" `date -u +'%H:%M:%S UTC'`
< /dev/null ./bb $BBFLAGS "$image" | do_oe_log
popd
if [ -z "${dont_get_log}" -a -z "${NEVER_GET_LOG}" ] ; then
mkdir -p "${log_path}"
echo "Collecting build logs..." | do_oe_log
find $path/tmp-eglibc/work/*/*/temp -name "log.do_*" | tar -cjf "${log_path}/$machine-$image.tar.bz2" --files-from=- | do_oe_log
echo "Done" | do_oe_log
echo "Collecting sigdata..." | do_oe_log
find "$path/tmp-eglibc/stamps" -name "*.sigdata.*" | tar -cjf "${log_path}/sigdata-$machine-$image.tar.bz2" --files-from=- | do_oe_log
echo "Done" | do_oe_log
echo "Collecting buildstats..." | do_oe_log
tar -cjf "${log_path}/buildstats-$machine-$image.tar.bz2" "$path/tmp-eglibc/buildstats" | do_oe_log
echo "Done" | do_oe_log
fi
}
do_oe_copy()
{
local path="$1"
local name="$2"
local image="$3"
local machine="$4"
local binaries="tmp-eglibc/deploy/images"
local t=""
local unhappy=1
pushd "$path"
# Copy OE
mkdir -p "$OUTPUT_DIR/$NAME/raw"
for t in cpio cpio.gz cpio.bz2 \
tar tar.gz tar.bz2 \
ext3 ext3.gz ext3.bz2 \
ext3.vhd ext3.vhd.gz ext3.vhd.bz2 \
xc.ext3 xc.ext3.gz xc.ext3.bz2 \
xc.ext3.vhd xc.ext3.vhd.gz xc.ext3.vhd.bz2 \
xc.ext3.bvhd xc.ext3.bvhd.gz xc.ext3.bvhd.bz2
do
if [ -f "$binaries/$image-image-$machine.$t" ]; then
echo "$name image type: $t"
cp "$binaries/$image-image-$machine.$t" "$OUTPUT_DIR/$NAME/raw/$name-rootfs.i686.$t"
unhappy=0
fi
done
if [ "$unhappy" -eq "1" ]; then
echo "$name image not found" 1>&2
popd
exit 1
fi
popd
}
do_oe_extra_pkgs()
{
local path="$1"
do_oe "$path" "xenclient-dom0" "task-xenclient-extra" "true"
do_oe "$path" "xenclient-dom0" "package-index"
}
do_oe_uivm_copy()
{
local path="$1"
do_oe_copy "$path" "uivm" "xenclient-uivm" "xenclient-uivm"
}
do_oe_uivm()
{
local path="$1"
do_oe "$path" "xenclient-uivm" "xenclient-uivm-image"
do_oe_uivm_copy $path
}
do_oe_ndvm_copy()
{
local path="$1"
do_oe_copy "$path" "ndvm" "xenclient-ndvm" "xenclient-ndvm"
}
do_oe_ndvm()
{
local path="$1"
do_oe "$path" "xenclient-ndvm" "xenclient-ndvm-image"
do_oe_ndvm_copy $path
}
do_oe_nilfvm_copy()
{
local path="$1"
do_oe_copy "$path" "nilfvm" "xenclient-nilfvm" "xenclient-nilfvm"
local binaries="tmp-eglibc/deploy/images"
pushd "$path"
cp "$binaries/service-nilfvm" "$OUTPUT_DIR/$NAME/raw/service-nilfvm"
popd
}
do_oe_nilfvm()
{
local path="$1"
echo This step is now useless, everything we need should be built as part of the tools.
return
do_oe "$path" "xenclient-nilfvm" "xenclient-nilfvm-image"
do_oe_nilfvm_copy $path
}
do_oe_syncvm_copy()
{
local path="$1"
do_oe_copy "$path" "syncvm" "xenclient-syncvm" "xenclient-syncvm"
}
do_oe_syncvm()
{
local path="$1"
do_oe "$path" "xenclient-syncvm" "xenclient-syncvm-image"
do_oe_syncvm_copy $path
}
do_oe_syncui_copy()
{
local path="$1"
pushd "$path"
mkdir -p "$OUTPUT_DIR/$NAME/raw"
cp tmp-eglibc/deploy/tar/sync-wui-0+git*.tar.gz "$OUTPUT_DIR/$NAME/raw/sync-wui-${RELEASE}.tar.gz"
cp tmp-eglibc/deploy/tar/sync-wui-sources-0+git*.tar.gz "$OUTPUT_DIR/$NAME/raw/sync-wui-sources-${RELEASE}.tar.gz"
popd
}
do_oe_syncui()
{
local path="$1"
do_oe "$path" "xenclient-syncui" "sync-wui"
do_oe_syncui_copy "$path"
}
do_oe_dom0_copy()
{
local path="$1"
do_oe_copy "$path" "dom0" "xenclient-dom0" "xenclient-dom0"
}
do_oe_dom0()
{
local path="$1"
do_oe "$path" "xenclient-dom0" "xenclient-dom0-image"
do_oe_dom0_copy $path
}
do_oe_sysroot_copy()
{
local path="$1"
do_oe_copy "$path" "sysroot" "xenclient-sysroot" "xenclient-dom0"
}
do_oe_sysroot()
{
local path="$1"
do_oe "$path" "xenclient-dom0" "xenclient-sysroot-image"
do_oe_sysroot_copy $path
}
do_oe_installer_copy()
{
local path="$1"
local binaries="tmp-eglibc/deploy/images"
pushd "$path"
mkdir -p "$OUTPUT_DIR/$NAME/raw/installer"
# Copy installer
cp "$binaries/xenclient-installer-image-xenclient-dom0.cpio.gz" "$OUTPUT_DIR/$NAME/raw/installer/rootfs.i686.cpio.gz"
# Copy extra installer files
rm -rf "$OUTPUT_DIR/$NAME/raw/installer/iso"
cp -r "$binaries/xenclient-installer-image-xenclient-dom0/iso" \
"$OUTPUT_DIR/$NAME/raw/installer/iso"
rm -rf "$OUTPUT_DIR/$NAME/raw/installer/netboot"
cp -r "$binaries/xenclient-installer-image-xenclient-dom0/netboot" \
"$OUTPUT_DIR/$NAME/raw/installer/netboot"
cp "$binaries/vmlinuz-xenclient-dom0.bin" \
"$OUTPUT_DIR/$NAME/raw/installer/vmlinuz"
cp "$binaries/xen.gz" \
"$OUTPUT_DIR/$NAME/raw/installer/xen.gz"
cp "$binaries/tboot.gz" \
"$OUTPUT_DIR/$NAME/raw/installer/tboot.gz"
cp "$binaries"/*.acm \
"$OUTPUT_DIR/$NAME/raw/installer/"
popd
}
do_oe_installer()
{
local path="$1"
do_oe "$path" "xenclient-dom0" "xenclient-installer-image"
do_oe_installer_copy $path
}
do_oe_installer_part2_copy()
{
local path="$1"
local binaries="tmp-eglibc/deploy/images"
pushd "$path"
mkdir -p "$OUTPUT_DIR/$NAME/raw"
cp "$binaries/xenclient-installer-part2-image-xenclient-dom0.tar.bz2" "$OUTPUT_DIR/$NAME/raw/control.tar.bz2"
popd
}
do_oe_installer_part2()
{
local path="$1"
do_oe "$path" "xenclient-dom0" "xenclient-installer-part2-image"
do_oe_installer_part2_copy $path
}
do_oe_source_shrink()
{
local path="$1"
local sum file last_sum last_file
find "$path" -type f |
xargs md5sum |
sort |
uniq -D -w32 |
while read sum file
do
if [ "$sum" = "$last_sum" ]
then
rm "$file"
ln "$last_file" "$file"
fi
last_sum="$sum"
last_file="$file"
done
}
do_oe_source_copy()
{
local path="$1"
local rootfs="tmp-eglibc/deploy/images/xenclient-source-image-xenclient-dom0.raw"
pushd "$path" > /dev/null
if [ "$SOURCE" -eq 0 ]
then
echo "Skipping 'source' step: '-S' option was not specified"
return
fi
if [ ! -d "$rootfs" ] ; then
echo "Source image not found ($rootfs)" >&2
exit 1
fi
rm -rf "$OUTPUT_DIR/$NAME/raw/source"
cp -Lr "$(pwd)/$rootfs" "$OUTPUT_DIR/$NAME/raw/source"
do_oe_source_shrink "$OUTPUT_DIR/$NAME/raw/source"
popd > /dev/null
}
do_oe_source()
{
local path="$1"
if [ "$SOURCE" -eq 0 ]
then
echo "Skipping 'source' step: '-S' option was not specified"
return
fi
do_oe "$path" "xenclient-dom0" "xenclient-source-image"
do_oe_source_copy "$path"
}
do_oe_packages_tree()
{
local path="$1"
local dest="$BUILD_RSYNC_DESTINATION/$ORIGIN_BRANCH/$NAME"
# Create a separate package tree populated with symlinks for stuffs that didn't change
# rsync seems to delegate non-remote operations to another program, ignoring --rsync-path
# If the destination is not remote, we have to run the --rsync-path command hack manualy
( echo $BUILD_RSYNC_DESTINATION | grep ':' > /dev/null 2>&1) || mkdir -p "$dest"
rsync -altvzr --exclude "morgue" --link-dest="$SYNC_CACHE_OE/oe-archive/" \
--rsync-path="mkdir -p \"$dest\" && rsync" \
"$path/tmp-eglibc/deploy/ipk" "$dest/packages"
}
do_oe_copy_licenses()
{
local path="$1"
local binaries="tmp-eglibc/deploy/images"
pushd "$path"
# Copy list of packages and licences for each image
local licences="$OUTPUT_DIR/$NAME/raw/licences"
rm -rf "$licences"
mkdir -p "$OUTPUT_DIR/$NAME/raw/licences"
for i in "$binaries"/*-image-licences.csv ; do
local target="$(basename "$i" |
sed 's/[^-]*-\(.*-\)image-\(licences.csv\)$/\1\2/')"
cp "$i" "$licences/$target"
done
# Verify that dom0 licences were copied
[ -e "$licences/dom0-licences.csv" ]
popd
}
do_oe_merge_src_info()
{
local path="$1"
if [ "$SOURCE" -eq 0 ]
then
echo "Skipping 'sourceinfo' step: '-S' option was not specified"
return
fi
mkdir -p "$OUTPUT_DIR/$NAME/raw"
"${CMD_DIR}/merge_src_info.py" \
"$path/oe/tmp-eglibc/deploy/src-info" \
"$OUTPUT_DIR/$NAME/raw/source-info.json"
}
do_sync_cache()
{
set +o pipefail
mkdir -p "$OE_BUILD_CACHE"
if [ $VERBOSE -eq 1 ]
then
OPTS="-ltvzr --progress"
else
OPTS="-ltzr"
fi
[ "x$SYNC_CACHE_OE" != "x" ] && \
rsync $OPTS -u --exclude ".*" "$SYNC_CACHE_OE/downloads" "$OE_BUILD_CACHE"
# Get the last version of each package
# FIXME: We explicitely exclude obselete folders from the list, as they still exist $SYNC_CACHE_OE
# OIFS=$IFS
# IFS=$'\n'
# for i in `find $SYNC_CACHE_OE/oe-archive/$ORIGIN_BRANCH -name Packages | grep -v xenclient-iovm | grep -v xenclient-vpnvm`; do
# folder=`dirname $i | sed "s|^$SYNC_CACHE_OE/oe-archive/||"`
# grep "^Filename: " $i | sed "s|^Filename: |$folder/|"
# done | rsync -ltvvzru --no-whole-file --files-from=- "$SYNC_CACHE_OE/oe-archive/" "$OE_BUILD_CACHE/oe-archive"
# IFS=$OIFS
set -o pipefail
}
do_sync_cache_back()
{
set +o pipefail
if [ "x$SYNC_CACHE_OE" != "x" ]; then
rsync -ltzru --exclude "*[Oo]pen[Xx][Tt]*" "$OE_BUILD_CACHE/downloads" "$SYNC_CACHE_OE"
# sudo rsync -ltzru --no-whole-file --ignore-existing "$OE_BUILD_CACHE/oe-archive" "$SYNC_CACHE_OE"
#
# # Rsync the previously evicted package list files
# for i in `find $OE_BUILD_CACHE/oe-archive -name "Packages*"`; do
# echo $i | sed "s|^$OE_BUILD_CACHE/oe-archive/||"
# done | sudo rsync -ltvvzru --no-whole-file --files-from=- "$OE_BUILD_CACHE/oe-archive/" "$SYNC_CACHE_OE/oe-archive"
fi
set -o pipefail
}
do_cleanup()
{
set +o pipefail
local path="$1"
local ramdisk="$path/oe"
# Kill old process that could use this directory
lsof | grep "$(pwd)/$path/" | awk '{print $2}' | while read pid; do
[ "$$" != "$pid" ] && kill -9 "$pid" || true
done
local type="`df -T "$ramdisk" | tail -n1 | awk '{print $2}'`"
local dev="`df -T "$ramdisk" | tail -n1 | awk '{print $1}'`"
if [ "$type" == "tmpfs" ]; then
sudo umount "$ramdisk"
elif [ "$dev" == "/dev/ram0" ]; then
sudo umount "$ramdisk"
fi
sudo rm -rf "$ramdisk"
mkdir -p "$ramdisk"
sudo rm -rf "$path"
set -o pipefail
}
list_manifest_suffixes()
{
(
cd "$CMD_DIR"
find . -maxdepth 1 -name "manifest-*" | sort | \
sed 's/^\.\/manifest//'
)
}
repository_add()
{
local repository="$1"
local shortname="$2"
local format="$3"
local required="$4"
local filename="$5"
local unpackdir="$6"
(
cd "$repository"
local filesize=$( du -b $filename | awk '{print $1}' )
local sha256sum=$( sha256sum $filename | awk '{print $1}' )
echo "$shortname" "$filesize" "$sha256sum" "$format" \
"$required" "$filename" "$unpackdir" | tee -a XC-PACKAGES
)
}
# fills repository$1 according to manifest$1
generic_do_repository()
{
local suffix="$1"
local info="$2"
local repository="$OUTPUT_DIR/$NAME/repository$suffix/packages.main"
mkdir -p "$repository"
echo -n > "$repository/XC-PACKAGES"
# Format of the manifest file is
# name format optional/required source_filename dest_path
while read l
do
local name=`echo "$l" | awk '{print $1}'`
local format=`echo "$l" | awk '{print $2}'`
local opt_req=`echo "$l" | awk '{print $3}'`
local src=`echo "$l" | awk '{print $4}'`
local dest=`echo "$l" | awk '{print $5}'`
if [ ! -e "$OUTPUT_DIR/$NAME/raw/$src" ] ; then
if [ "$opt_req" = "required" ] ; then
echo "Error: Required file $src is missing"
exit 1
fi
echo "Optional file $src is missing: skipping"
break
fi
cp "$OUTPUT_DIR/$NAME/raw/$src" "$repository/$src"
repository_add "$repository" "$name" "$format" "$opt_req" \
"$src" "$dest"
done < "$CMD_DIR/manifest$suffix"
PACKAGES_SHA256SUM=$(sha256sum "$repository/XC-PACKAGES" |
awk '{print $1}')
set +o pipefail #fragile part
# Pad XC-REPOSITORY to 1 MB with blank lines. If this is changed, the
# repository-signing process will also need to change.
{
cat <<EOF
xc:main
pack:Base Pack
product:XenClient
build:${ID}
version:${VERSION}
release:${RELEASE}
upgrade-from:${UPGRADEABLE_RELEASES}
packages:${PACKAGES_SHA256SUM}
EOF
yes ""
} | head -c 1048576 > "$repository/XC-REPOSITORY"
set -o pipefail #end of fragile part
"${CMD_DIR}/sign_repo.sh" \
"$(resolve_path "$TOPDIR" "$REPO_DEV_SIGNING_CERT")" \
"$(resolve_path "$TOPDIR" "$REPO_DEV_SIGNING_KEY")" \
"$repository"
echo "repository$suffix: repository$suffix" >> "$info"
}
# fills each repository<suffix> according to manifest<suffix>
do_repositories()
{
(
local info_dir="$OUTPUT_DIR/$NAME/raw/info"
local info="$info_dir/repository"
mkdir -p "$info_dir"
rm -f "$info"
for suffix in "" `list_manifest_suffixes` ; do
echo "Repository$suffix:"
generic_do_repository "$suffix" "$info"
done
echo ""
)
}
# Resolve $2 as an absolute path, or a path relative to $1
resolve_path()
{
case "$2" in
/*) echo "$2" ;;
*) echo "$1/$2" ;;
esac
}
get_file_from_tar_or_cpio()
{
local tarball="$1"
local file="$2"
if [ -f "$1.tar.bz2" ]; then
tar -xOf "$1.tar.bz2" "./$file"
elif [ -f "$1.cpio.gz" ]; then
zcat "$1.cpio.gz" | cpio -i --to-stdout "$file"
elif [ -f "$1.cpio.bz2" ]; then
bzcat "$1.cpio.bz2" | cpio -i --to-stdout "$file"
else
false
fi
}
generic_do_update()
{
local suffix="$1"
local info="$2"
local update_name="update/update$suffix.tar"
echo "update$suffix:"
mkdir -p "$OUTPUT_DIR/$NAME/update"
tar -C "$OUTPUT_DIR/$NAME/repository$suffix" \
-cf "$OUTPUT_DIR/$NAME/$update_name" packages.main
echo "ota-update$suffix: $update_name" >> "$info"
}
do_updates()
{
local info_dir="$OUTPUT_DIR/$NAME/raw/info"
local info="$info_dir/update"
mkdir -p "$info_dir"
rm -f "$info"
for suffix in "" `list_manifest_suffixes`; do
generic_do_update "$suffix" "$info"
done
}
ACM_LIST="ivb_snb.acm gm45.acm duali.acm quadi.acm q35.acm q45q43.acm xeon56.acm xeone7.acm hsw.acm"
extract_acms()
{
local tarball="$1"
local src="$2"
local dst="$3"
for ACM in $ACM_LIST; do
echo " - extract $ACM"
if [ -f "$src/$ACM" ]; then
cp "$src/$ACM" "$dst/$ACM"
else
get_file_from_tar_or_cpio "$tarball" "boot/$ACM" > "$dst/$ACM"
fi
done
}
generic_do_netboot()
{
local suffix="$1"
local info="$2"
local path="$OUTPUT_DIR/$NAME/raw/installer"
local netboot="$OUTPUT_DIR/$NAME/netboot$suffix"
local tarball="$path/rootfs.i686"
echo "netboot$suffix:"
rm -rf "$netboot"
mkdir -p "$netboot"
cp "$path/netboot/"* "$netboot"
echo " - extract xen.gz"
if [ -f "$path/xen.gz" ]; then
cp "$path/xen.gz" "$netboot/xen.gz"
else
get_file_from_tar_or_cpio "$tarball" "boot/xen-3.4.1-xc.gz" > "$netboot/xen.gz"
fi
echo " - extract vmlinuz"
if [ -f "$path/vmlinuz" ]; then
cp "$path/vmlinuz" "$netboot/vmlinuz"
else
get_file_from_tar_or_cpio "$tarball" "boot/vmlinuz" > "$netboot/vmlinuz"
fi
echo " - extract tboot.gz"
if [ -f "$path/tboot.gz" ]; then
cp "$path/tboot.gz" "$netboot/tboot.gz"
else
get_file_from_tar_or_cpio "$tarball" "boot/tboot.gz" > "$netboot/tboot.gz"
fi
echo " - extract ACMs"
extract_acms "$tarball" "$path" "$netboot"
echo " - copy rootfs"
cp "$path/rootfs.i686.cpio.gz" "$netboot/rootfs.gz"
echo " - Create a tarball with netboot file"
tar cf "$netboot/netboot.tar" -C "$netboot" .
gzip -9 "$netboot/netboot.tar"
echo "netboot$suffix: netboot$suffix" >> "$info"
echo ""
}
do_netboots()
{
local info_dir="$OUTPUT_DIR/$NAME/raw/info"
local info="$info_dir/netboot"
mkdir -p "$info_dir"
rm -f "$info"
for suffix in "" `list_manifest_suffixes` ; do
generic_do_netboot "$suffix" "$info"
done
}
generic_do_installer_iso()
{
local suffix="$1"
local info="$2"
local path="$OUTPUT_DIR/$NAME/raw"
local repository="$OUTPUT_DIR/$NAME/repository$suffix"
local iso="$OUTPUT_DIR/$NAME/iso"
local iso_path="$iso/installer$suffix"
local tarball="$path/installer/rootfs.i686"
local OPENXT_VERSION="$VERSION"
local OPENXT_BUILD_ID="$ID"
local OPENXT_ISO_LABEL="OpenXT-${VERSION}"
echo "installer$suffix iso:"
rm -rf "$iso_path" "$iso_path.iso"
mkdir -p "$iso_path/isolinux"