diff --git a/packages/devel/glib/package.mk b/packages/devel/glib/package.mk
index 3e69553c6c..3c554a9e8f 100644
--- a/packages/devel/glib/package.mk
+++ b/packages/devel/glib/package.mk
@@ -1,6 +1,7 @@
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
+# Copyright (C) 2016- Team LibreELEC
#
# OpenELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -33,6 +34,7 @@ PKG_LONGDESC="GLib is a library which includes support routines for C such as li
PKG_IS_ADDON="no"
PKG_AUTORECONF="yes"
+PKG_CONFIGURE_OPTS_HOST="--enable-static --disable-shared"
PKG_CONFIGURE_OPTS_TARGET="ac_cv_func_mmap_fixed_mapped=yes \
ac_cv_func_posix_getpwuid_r=yes \
ac_cv_func_posix_getgrgid_r=yes \
diff --git a/packages/tools/qemu/package.mk b/packages/tools/qemu/package.mk
new file mode 100644
index 0000000000..024d99da4b
--- /dev/null
+++ b/packages/tools/qemu/package.mk
@@ -0,0 +1,49 @@
+################################################################################
+# This file is part of LibreELEC - http://www.libreelec.tv
+# Copyright (C) 2016- Team LibreELEC
+#
+# LibreELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# LibreELEC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LibreELEC. If not, see .
+################################################################################
+
+PKG_NAME="qemu"
+PKG_VERSION="2.5.1"
+PKG_REV="1"
+PKG_ARCH="any"
+PKG_LICENSE="GPL"
+PKG_SITE="http://wiki.qemu.org"
+PKG_URL="http://wiki.qemu-project.org/download/qemu-$PKG_VERSION.tar.bz2"
+PKG_DEPENDS_HOST="toolchain Python:host zlib:host glib:host"
+PKG_PRIORITY="optional"
+PKG_SECTION="tools"
+PKG_SHORTDESC="QEMU is a generic and open source machine emulator and virtualizer."
+PKG_LONGDESC="QEMU is a generic and open source machine emulator and virtualizer."
+
+PKG_IS_ADDON="no"
+PKG_AUTORECONF="no"
+
+HOST_CONFIGURE_OPTS="--prefix=$ROOT/$TOOLCHAIN \
+ --bindir=$ROOT/$TOOLCHAIN/bin \
+ --sbindir=$ROOT/$TOOLCHAIN/sbin \
+ --sysconfdir=$ROOT/$TOOLCHAIN/etc \
+ --libexecdir=$ROOT/$TOOLCHAIN/lib \
+ --localstatedir=$ROOT/$TOOLCHAIN/var \
+ --extra-cflags=-I$ROOT/$TOOLCHAIN/include \
+ --extra-ldflags=-L$ROOT/$TOOLCHAIN/lib \
+ --static \
+ --disable-vnc \
+ --disable-werror \
+ --disable-blobs \
+ --disable-system \
+ --disable-user \
+ --disable-docs"
diff --git a/packages/virtual/virtual/package.mk b/packages/virtual/virtual/package.mk
new file mode 100644
index 0000000000..f078f71cca
--- /dev/null
+++ b/packages/virtual/virtual/package.mk
@@ -0,0 +1,33 @@
+################################################################################
+# This file is part of LibreELEC - http://www.libreelec.tv
+# Copyright (C) 2016- Team LibreELEC
+#
+# LibreELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# LibreELEC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LibreELEC. If not, see .
+################################################################################
+
+PKG_NAME="virtual"
+PKG_VERSION=""
+PKG_REV="1"
+PKG_ARCH="any"
+PKG_LICENSE="GPL"
+PKG_SITE="http://www.libreelec.tv"
+PKG_URL=""
+PKG_DEPENDS_TARGET="qemu:host"
+PKG_PRIORITY="optional"
+PKG_SECTION="virtual"
+PKG_SHORTDESC="virtual: Meta package to install Virtual project extra deps"
+PKG_LONGDESC="virtual is a Meta package to install Virtual project extra dependencies"
+
+PKG_IS_ADDON="no"
+PKG_AUTORECONF="no"
diff --git a/projects/Virtual/config/ovf.template b/projects/Virtual/config/ovf.template
new file mode 100644
index 0000000000..51f4baba68
--- /dev/null
+++ b/projects/Virtual/config/ovf.template
@@ -0,0 +1,120 @@
+
+
+
+
+
+ Virtual disk information
+
+
+
+ The list of logical networks
+
+ The bridged network
+
+
+
+ A virtual machine
+ @DISTRO@
+
+ Meta-information about the installed software
+ LibreELEC
+ LibreELEC
+ http://libreelec.tv
+ http://libreelec.tv
+
+
+ A human-readable annotation
+ LibreELEC is ‘Just enough OS’ for Kodi, a Linux distribution built to run Kodi on current and popular mediacentre hardware. We are an evolution of the popular OpenELEC project.
+
+
+ The kind of installed guest operating system
+
+ Virtual hardware requirements
+
+ Virtual Hardware Family
+ 0
+ LibreELEC
+ vmx-09
+
+ -
+ hertz * 10^6
+ Number of Virtual CPUs
+ 1 virtual CPU(s)
+ 1
+ 3
+ 1
+
+ -
+ byte * 2^20
+ Memory Size
+ 512MB of memory
+ 2
+ 4
+ 512
+
+ -
+ 0
+ USB Controller (EHCI)
+ usb
+ 3
+ vmware.usb.ehci
+ 23
+
+
+ -
+ 0
+ IDE Controller
+ ideController0
+ 4
+ 5
+
+ -
+ 0
+ disk0
+ ovf:/disk/disk
+ 5
+ 4
+ 17
+
+ -
+ 1
+ true
+ bridged
+ E1000 ethernet adapter on "bridged"
+ ethernet0
+ 6
+ E1000
+ 10
+
+
+ -
+ false
+ sound
+ 7
+ vmware.soundcard.hdaudio
+ 1
+
+ -
+ false
+ video
+ 8
+ 24
+
+
+ -
+ false
+ vmci
+ 9
+ vmware.vmci
+ 1
+
+
+
+
+
+
+
+
+
diff --git a/scripts/image b/scripts/image
index 3539e0683e..73c77fbce4 100755
--- a/scripts/image
+++ b/scripts/image
@@ -177,6 +177,9 @@ fi
# LCD support
[ ! "$LCD_DRIVER" = "none" ] && $SCRIPTS/install lcdproc
+# Virtual image creation support
+ [ "$PROJECT" = Virtual ] && $SCRIPTS/install virtual
+
# Installer support
[ "$INSTALLER_SUPPORT" = "yes" ] && $SCRIPTS/install installer
@@ -367,6 +370,9 @@ fi
PATH="$PATH:/sbin" \
ROOT="$ROOT" \
TOOLCHAIN="$TOOLCHAIN" \
+ PROJECT_DIR="$PROJECT_DIR" \
+ PROJECT="$PROJECT" \
+ DISTRO="$DISTRO" \
TARGET_IMG="$TARGET_IMG" \
IMAGE_NAME="$IMAGE_NAME" \
BOOTLOADER="$BOOTLOADER" \
diff --git a/scripts/mkimage b/scripts/mkimage
index c765dbbb88..2fe06335e0 100755
--- a/scripts/mkimage
+++ b/scripts/mkimage
@@ -108,7 +108,7 @@ fi
HEADS=4
TRACKS=32
SECTORS=$(( $SYSTEM_SIZE * 1024 * 1024 / 512 / $HEADS / $TRACKS ))
-
+
shopt -s expand_aliases # enables alias expansion in script
alias mformat="mformat -i $DISK@@$OFFSET -h $HEADS -t $TRACKS -s $SECTORS"
alias mcopy="mcopy -i $DISK@@$OFFSET"
@@ -139,6 +139,18 @@ LABEL live
APPEND boot=UUID=$UUID_SYSTEM live quiet tty vga=current
EOF
+ if [ "$PROJECT" = Virtual ]; then
+ cat << EOF > "$OE_TMP"/syslinux.cfg
+DEFAULT virtual
+TIMEOUT 50
+PROMPT 0
+
+LABEL virtual
+ KERNEL /$KERNEL_NAME
+ APPEND boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE quiet tty vga=current
+EOF
+ fi
+
mcopy "$OE_TMP/syslinux.cfg" ::
# install extlinux
@@ -255,7 +267,7 @@ fi # bootloader
sync
# add resize mark
- if [ "$BOOTLOADER" != "syslinux" ]; then
+ if [ "$BOOTLOADER" != "syslinux" -o "$PROJECT" = Virtual ]; then
mkdir "$OE_TMP/part2.fs"
touch "$OE_TMP/part2.fs/.please_resize_me"
echo "image: populating filesystem on part2..."
@@ -268,6 +280,7 @@ fi # bootloader
echo "image: merging part2 back to image..."
dd if="$OE_TMP/part2.ext4" of="$DISK" bs=512 seek="$STORAGE_PART_START" conv=fsync,notrunc >"$SAVE_ERROR" 2>&1 || show_error
+
# extract part1 from image to run fsck
echo "image: extracting part1 from image..."
SYSTEM_PART_COUNT=$(( $SYSTEM_PART_END - $SYSTEM_PART_START + 1 ))
@@ -276,6 +289,17 @@ fi # bootloader
echo "image: checking filesystem on part1..."
fsck -n $OE_TMP/part1.fat >"$SAVE_ERROR" 2>&1 || show_error
+# create virtual images
+ if [ "$PROJECT" = Virtual ]; then
+ echo "image: creating open virtual appliance..."
+ qemu-img convert -O vmdk -o subformat=streamOptimized "$DISK" "$DISK.vmdk"
+ sed -e "s,@DISTRO@,$DISTRO,g" -e "s,@DISK@,$(basename $DISK),g" -e "s,@DISK_SIZE@,$(ls -l $DISK.vmdk | awk '{print $5}'),g" $PROJECT_DIR/$PROJECT/config/ovf.template > $DISK.ovf
+ tar -C $TARGET_IMG -cf $DISK.ova $(basename $DISK).ovf $(basename $DISK).vmdk
+ echo "image: cleaning up..."
+ rm $DISK.vmdk $DISK.ovf
+ [ -n "$SUDO_USER" ] && chown $SUDO_USER: $DISK.ova
+ fi
+
# gzip
echo "image: compressing..."
gzip $DISK