xref: /aosp_15_r20/external/bcc/scripts/build-rpm.sh (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1*387f9dfdSAndroid Build Coastguard Worker#!/bin/bash
2*387f9dfdSAndroid Build Coastguard Worker
3*387f9dfdSAndroid Build Coastguard Workerset -x
4*387f9dfdSAndroid Build Coastguard Workerset -e
5*387f9dfdSAndroid Build Coastguard Worker
6*387f9dfdSAndroid Build Coastguard WorkerTMP=$(mktemp -d /tmp/rpmbuild.XXXXXX)
7*387f9dfdSAndroid Build Coastguard Worker
8*387f9dfdSAndroid Build Coastguard Workerfunction cleanup() {
9*387f9dfdSAndroid Build Coastguard Worker  [[ -d $TMP ]] && rm -rf $TMP
10*387f9dfdSAndroid Build Coastguard Worker}
11*387f9dfdSAndroid Build Coastguard Workertrap cleanup EXIT
12*387f9dfdSAndroid Build Coastguard Worker
13*387f9dfdSAndroid Build Coastguard Worker# install python dependencies for test
14*387f9dfdSAndroid Build Coastguard Workerif [ -f os-release ]; then
15*387f9dfdSAndroid Build Coastguard Worker    . os-release
16*387f9dfdSAndroid Build Coastguard Workerfi
17*387f9dfdSAndroid Build Coastguard Workerif [[ $VERSION_ID -lt 30 ]]; then
18*387f9dfdSAndroid Build Coastguard Worker  PKGS="python3-cachetools python-cachetools"
19*387f9dfdSAndroid Build Coastguard Workerelse
20*387f9dfdSAndroid Build Coastguard Worker  PKGS="python3-cachetools"
21*387f9dfdSAndroid Build Coastguard Workerfi
22*387f9dfdSAndroid Build Coastguard Workersudo dnf install -y $PKGS
23*387f9dfdSAndroid Build Coastguard Worker
24*387f9dfdSAndroid Build Coastguard Workermkdir $TMP/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
25*387f9dfdSAndroid Build Coastguard Worker
26*387f9dfdSAndroid Build Coastguard Workerllvmver=3.7.1
27*387f9dfdSAndroid Build Coastguard Worker
28*387f9dfdSAndroid Build Coastguard Worker# populate submodules
29*387f9dfdSAndroid Build Coastguard Workergit submodule update --init --recursive
30*387f9dfdSAndroid Build Coastguard Worker
31*387f9dfdSAndroid Build Coastguard Worker. scripts/git-tag.sh
32*387f9dfdSAndroid Build Coastguard Worker
33*387f9dfdSAndroid Build Coastguard Workergit archive HEAD --prefix=bcc/ --format=tar -o $TMP/SOURCES/bcc.tar
34*387f9dfdSAndroid Build Coastguard Worker
35*387f9dfdSAndroid Build Coastguard Worker# archive submodules
36*387f9dfdSAndroid Build Coastguard Workerpushd src/cc/libbpf
37*387f9dfdSAndroid Build Coastguard Workergit archive HEAD --prefix=bcc/src/cc/libbpf/ --format=tar -o $TMP/SOURCES/bcc_libbpf.tar
38*387f9dfdSAndroid Build Coastguard Workerpopd
39*387f9dfdSAndroid Build Coastguard Worker
40*387f9dfdSAndroid Build Coastguard Worker# merge all archives into bcc.tar.gz
41*387f9dfdSAndroid Build Coastguard Workerpushd $TMP/SOURCES
42*387f9dfdSAndroid Build Coastguard Workertar -A -f bcc.tar bcc_libbpf.tar
43*387f9dfdSAndroid Build Coastguard Workergzip bcc.tar
44*387f9dfdSAndroid Build Coastguard Workerpopd
45*387f9dfdSAndroid Build Coastguard Worker
46*387f9dfdSAndroid Build Coastguard Workersed \
47*387f9dfdSAndroid Build Coastguard Worker  -e "s/^\(Version:\s*\)@REVISION@/\1$revision/" \
48*387f9dfdSAndroid Build Coastguard Worker  -e "s/^\(Release:\s*\)@GIT_REV_COUNT@/\1$release/" \
49*387f9dfdSAndroid Build Coastguard Worker  SPECS/bcc.spec > $TMP/SPECS/bcc.spec
50*387f9dfdSAndroid Build Coastguard Worker
51*387f9dfdSAndroid Build Coastguard Workerpushd $TMP
52*387f9dfdSAndroid Build Coastguard Workerrpmbuild $RPM_WITH_OPTS --define "_topdir `pwd`" -ba SPECS/bcc.spec
53*387f9dfdSAndroid Build Coastguard Workerpopd
54*387f9dfdSAndroid Build Coastguard Worker
55*387f9dfdSAndroid Build Coastguard Workercp $TMP/RPMS/*/*.rpm .
56*387f9dfdSAndroid Build Coastguard Workercp $TMP/SRPMS/*.rpm .
57