Blob Blame History Raw
#!/bin/bash -e

# Based on avi's scripts/make-release from kvm-userspace.git

usage()
{
    echo "usage: make-release name kernel-dir kernel-commit user-dir user-commit"
    exit 1
}

[ $# -eq 5 ] || usage

name="$1"
kdir="$2"
kcommit="$3"
udir="$4"
ucommit="$5"
archs=(x86 ia64)

release_dir=$(mktemp -d)

tarball="$(pwd)/$name.tar.gz"

cd "${release_dir}"
(cd "$udir";  git archive --format=tar --prefix="$name"/ "$ucommit") | tar x
cd "$name"
cat <<EOF > SOURCES
kernel:    $(cd "$kdir"; git rev-parse "$kcommit")
userspace: $(cd "$udir"; git rev-parse "$ucommit")
EOF

paths=(drivers/kvm virt/kvm)
files=(kvm.h kvm_host.h kvm_para.h kvm_types.h kvm_x86_emulate.h virtext.h svm.h vmx.h)
for file in "${files[@]}"; do
    for arch in "${archs[@]}"; do
	for variant in include/asm-"$arch" arch/"$arch"/include/asm; do
	    paths+=("$variant"/"$file")
	done
    done
    paths+=(include/linux/"$file")
done
for arch in "${archs[@]}"; do
    paths+=(arch/"$arch"/kvm)
done

(cd "$kdir"; git archive --format=tar --prefix=linux/ "$kcommit" "${paths[@]}") | tar x

touch kernel/config.kbuild
echo ARCH=ia64 > config.mak
make -C kernel sync LINUX=../linux version="$name" >/dev/null
echo ARCH=x86_64 > config.mak
make -C kernel sync LINUX=../linux version="$name" >/dev/null
rm -rf config.mak linux kernel/config.kbuild
#rm -rf kernel/include/asm kernel/include-compat/asm
sed -i "s/kvm-devel/$name/" qemu/configure

cd ..

tar czf "$tarball" "$name"

cd $(dirname "$tarball")
md5sum $(basename "$tarball")

rm -rf "${release_dir}"