xref: /aosp_15_r20/external/bcc/scripts/build-deb.sh (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1*387f9dfdSAndroid Build Coastguard Worker#!/bin/bash
2*387f9dfdSAndroid Build Coastguard Worker
3*387f9dfdSAndroid Build Coastguard Worker# helper script to be invoked by jenkins/buildbot or github actions
4*387f9dfdSAndroid Build Coastguard Worker
5*387f9dfdSAndroid Build Coastguard Worker# $1 [optional]: the build type - release | nightly | test
6*387f9dfdSAndroid Build Coastguard Workerbuildtype=${1:-test}
7*387f9dfdSAndroid Build Coastguard Worker
8*387f9dfdSAndroid Build Coastguard Workerset -x
9*387f9dfdSAndroid Build Coastguard Workerset -e
10*387f9dfdSAndroid Build Coastguard Worker
11*387f9dfdSAndroid Build Coastguard WorkerPARALLEL=${PARALLEL:-1}
12*387f9dfdSAndroid Build Coastguard WorkerTMP=$(mktemp -d /tmp/debuild.XXXXXX)
13*387f9dfdSAndroid Build Coastguard Worker
14*387f9dfdSAndroid Build Coastguard Workerfunction cleanup() {
15*387f9dfdSAndroid Build Coastguard Worker  [[ -d $TMP ]] && rm -rf $TMP
16*387f9dfdSAndroid Build Coastguard Worker}
17*387f9dfdSAndroid Build Coastguard Workertrap cleanup EXIT
18*387f9dfdSAndroid Build Coastguard Worker
19*387f9dfdSAndroid Build Coastguard Worker# populate submodules
20*387f9dfdSAndroid Build Coastguard Workergit submodule update --init --recursive
21*387f9dfdSAndroid Build Coastguard Worker
22*387f9dfdSAndroid Build Coastguard Worker. scripts/git-tag.sh
23*387f9dfdSAndroid Build Coastguard Worker
24*387f9dfdSAndroid Build Coastguard Workergit archive HEAD --prefix=bcc/ --format=tar -o $TMP/bcc_$revision.orig.tar
25*387f9dfdSAndroid Build Coastguard Worker
26*387f9dfdSAndroid Build Coastguard Worker# archive submodules
27*387f9dfdSAndroid Build Coastguard Workerpushd src/cc/libbpf
28*387f9dfdSAndroid Build Coastguard Workergit archive HEAD --prefix=bcc/src/cc/libbpf/ --format=tar -o $TMP/bcc_libbpf_$revision.orig.tar
29*387f9dfdSAndroid Build Coastguard Workerpopd
30*387f9dfdSAndroid Build Coastguard Worker
31*387f9dfdSAndroid Build Coastguard Workerpushd $TMP
32*387f9dfdSAndroid Build Coastguard Worker
33*387f9dfdSAndroid Build Coastguard Worker# merge all archives into bcc_$revision.orig.tar.gz
34*387f9dfdSAndroid Build Coastguard Workertar -A -f bcc_$revision.orig.tar bcc_libbpf_$revision.orig.tar
35*387f9dfdSAndroid Build Coastguard Workergzip bcc_$revision.orig.tar
36*387f9dfdSAndroid Build Coastguard Worker
37*387f9dfdSAndroid Build Coastguard Workertar xf bcc_$revision.orig.tar.gz
38*387f9dfdSAndroid Build Coastguard Workercd bcc
39*387f9dfdSAndroid Build Coastguard Worker
40*387f9dfdSAndroid Build Coastguard Workerdebuild=debuild
41*387f9dfdSAndroid Build Coastguard Workerif [[ "$buildtype" = "test" ]]; then
42*387f9dfdSAndroid Build Coastguard Worker  # when testing, use faster compression options
43*387f9dfdSAndroid Build Coastguard Worker  debuild+=" --preserve-envvar PATH"
44*387f9dfdSAndroid Build Coastguard Worker  echo -e '#!/bin/bash\nexec /usr/bin/dpkg-deb -z1 "$@"' \
45*387f9dfdSAndroid Build Coastguard Worker    | sudo tee /usr/local/bin/dpkg-deb
46*387f9dfdSAndroid Build Coastguard Worker  sudo chmod +x /usr/local/bin/dpkg-deb
47*387f9dfdSAndroid Build Coastguard Worker  dch -b -v $revision-$release "$git_subject"
48*387f9dfdSAndroid Build Coastguard Workerfi
49*387f9dfdSAndroid Build Coastguard Workerif [[ "$buildtype" = "nightly" ]]; then
50*387f9dfdSAndroid Build Coastguard Worker  dch -v $revision-$release "$git_subject"
51*387f9dfdSAndroid Build Coastguard Workerfi
52*387f9dfdSAndroid Build Coastguard Worker
53*387f9dfdSAndroid Build Coastguard WorkerDEB_BUILD_OPTIONS="nocheck parallel=${PARALLEL}" $debuild -us -uc
54*387f9dfdSAndroid Build Coastguard Workerpopd
55*387f9dfdSAndroid Build Coastguard Worker
56*387f9dfdSAndroid Build Coastguard Workercp $TMP/*.deb .
57