set -e


date=$(date -R)
time=$(date +%s -d"$date")
build=build-area/$time

cd /home/jak/toshiba-ac100/kernel-deb/

if [ ! -d build-area ]; then
    mkdir build-area
fi

mkdir $build

commit="$(cd marvin24s-kernel; git show HEAD --pretty=oneline)"


( cd marvin24s-kernel; git archive HEAD | tar -C ../$build -x; )
( cd marvin24s-kernel; git archive HEAD | tar -C ../$build -x; )
( cd linux-2.6-ac100; git archive HEAD | tar -C ../$build -x; )

cd $build

sed -i "s/gcc-4.5/gcc-4.4/g" debian/config/defines
dch -l "~${time}" "Test Build for ${date} using GCC 4.4 Cross compiler"
dch -a "Commit $commit"
debian/rules clean || true
DEB_BUILD_OPTIONS=parallel=4 debuild -b -us -uc -aarmel
