build.sh 1.79 KB
Newer Older
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
#!/bin/bash

set -e

# XXX adjust this to flavor
kernel_work=~/rcn/kernel	# your checkout of rcn-ee kernel build repo
armhf_compile="ccache arm-linux-gnueabihf-"

kernel_dir="$kernel_work/KERNEL"
deploy_dir="$kernel_work/deploy"

if [[ ! -f "$kernel_dir/include/generated/utsrelease.h" ]]; then
	echo "Not found: $kernel_dir/include/generated/utsrelease.h" >&2
	exit 1
fi
uname_r="$(grep -oP '(?<=")[^\s"]+(?=")' \
		"$kernel_dir/include/generated/utsrelease.h")"

_make() {
	make -C eurasia_km/eurasiacon/build/linux2/omap_linux \
		ARCH=arm CROSS_COMPILE="$armhf_compile" \
		KERNELDIR="$kernel_dir" \
		TARGET_PRODUCT=ti335x \
		KERNEL_COMPONENTS="srvkm" \
		"$@"
}

_make clean
_make

build_output=eurasia_km/eurasiacon/binary2_omap_linux_release/target/kbuild
modules=( pvrsrvkm.ko )

Matthijs van Duin's avatar
Matthijs van Duin committed
34
install_dir="tmp/lib/modules/$uname_r/extra"
35 36 37 38

mkdir -vp "$install_dir"
cp "${modules[@]/#/"$build_output/"}" "$install_dir"

Matthijs van Duin's avatar
Matthijs van Duin committed
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
mkdir -p tmp/DEBIAN
cat >tmp/DEBIAN/control <<END
Package: sgx-modules-$uname_r
Version: 1cross
Section: base
Priority: optional
Architecture: armhf
Depends: linux-image-$uname_r
Recommends: sgx-userspace-1.14.3699939
Maintainer: Matthijs van Duin <matthijsvanduin@gmail.com>
Description: sgx kernel modules for linux $uname_r
END

cat >tmp/DEBIAN/postinst <<END
#!/bin/sh
depmod $uname_r
END
chmod a+x tmp/DEBIAN/postinst

cat >tmp/DEBIAN/postrm <<END
#!/bin/sh
if [[ -d /lib/modules/$uname_r ]]; then
	depmod $uname_r
fi
END
chmod a+x tmp/DEBIAN/postrm

chmod -R g=rX,o=rX tmp


#echo ""
#echo "creating $deploy_dir/sgx-335x-$uname_r.tar.xz"
#tar cavf "$deploy_dir/sgx-335x-$uname_r.tar.xz" \
#	--owner=root --group=root --mode="g=rX,o=rX" \
#	"${modules[@]/#/"$install_dir/"}"

75
echo ""
Matthijs van Duin's avatar
Matthijs van Duin committed
76 77 78 79
echo "creating $deploy_dir/sgx-modules-$uname_r.deb"
fakeroot dpkg-deb --build tmp "$deploy_dir/sgx-modules-$uname_r.deb"

rm -rf tmp