#!/bin/bash -x

# Install dependencies
apt-get build-dep wpasupplicant || exit 1
aptitude install linux-backports-modules-karmic-generic-pae || exit 1

# Install the link to the configuration
/home/aaa/installvm.sh conflink

# Test build directive file
if ! [ -f /root/conf/wpasupplicant/build.config ]; then echo Missing build config file; exit 1; fi

# We need the radio emulation driver as well, check it was correctly installed.
modprobe mac80211_hwsim || exit 1

# Build wpa_supplicant
rm -rf /root/wpa_supplicant
cp -Rs /home/aaa/src/hostap /root/wpa_supplicant
ln -s /root/conf/wpasupplicant/build.config /root/wpa_supplicant/wpa_supplicant/.config
cd /root/wpa_supplicant/wpa_supplicant && make || exit 1

