aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xREADME.md4
-rwxr-xr-xbuild.sh12
-rwxr-xr-xexport-image/04-finalise/01-run.sh6
-rwxr-xr-xstage2/01-sys-tweaks/01-run.sh20
-rw-r--r--stage2/01-sys-tweaks/files/90-qemu.rules3
-rw-r--r--stage2/EXPORT_IMAGE3
-rw-r--r--stage4/EXPORT_IMAGE3
-rw-r--r--stage5/EXPORT_IMAGE3
8 files changed, 48 insertions, 6 deletions
diff --git a/README.md b/README.md
index 3a02095..f0a794d 100755
--- a/README.md
+++ b/README.md
@@ -66,6 +66,10 @@ The following environment variables are supported:
Output directory for target system images and NOOBS bundles.
+ * `USE_QEMU` (Default: `"0"`)
+
+ This enable the Qemu mode and set filesystem and image suffix if set to 1.
+
A simple example for building Raspbian:
diff --git a/build.sh b/build.sh
index 06d9abc..8b3c82e 100755
--- a/build.sh
+++ b/build.sh
@@ -119,6 +119,7 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
+
if [ -f config ]; then
source config
fi
@@ -128,6 +129,7 @@ if [ -z "${IMG_NAME}" ]; then
exit 1
fi
+export USE_QEMU=${USE_QEMU:-0}
export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"}
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -177,10 +179,12 @@ for EXPORT_DIR in ${EXPORT_DIRS}; do
source "${EXPORT_DIR}/EXPORT_IMAGE"
EXPORT_ROOTFS_DIR=${WORK_DIR}/$(basename ${EXPORT_DIR})/rootfs
run_stage
- if [ -e ${EXPORT_DIR}/EXPORT_NOOBS ]; then
- source ${EXPORT_DIR}/EXPORT_NOOBS
- STAGE_DIR=${BASE_DIR}/export-noobs
- run_stage
+ if [ "${USE_QEMU}" != "1" ]; then
+ if [ -e ${EXPORT_DIR}/EXPORT_NOOBS ]; then
+ source ${EXPORT_DIR}/EXPORT_NOOBS
+ STAGE_DIR=${BASE_DIR}/export-noobs
+ run_stage
+ fi
fi
done
diff --git a/export-image/04-finalise/01-run.sh b/export-image/04-finalise/01-run.sh
index fefed50..80fd954 100755
--- a/export-image/04-finalise/01-run.sh
+++ b/export-image/04-finalise/01-run.sh
@@ -15,8 +15,10 @@ fi
rm -f ${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache
rm -f ${ROOTFS_DIR}/usr/sbin/policy-rc.d
rm -f ${ROOTFS_DIR}/usr/bin/qemu-arm-static
-if [ -e ${ROOTFS_DIR}/etc/ld.so.preload.disabled ]; then
- mv ${ROOTFS_DIR}/etc/ld.so.preload.disabled ${ROOTFS_DIR}/etc/ld.so.preload
+if [ "${USE_QEMU}" != "1" ]; then
+ if [ -e ${ROOTFS_DIR}/etc/ld.so.preload.disabled ]; then
+ mv ${ROOTFS_DIR}/etc/ld.so.preload.disabled ${ROOTFS_DIR}/etc/ld.so.preload
+ fi
fi
rm -f ${ROOTFS_DIR}/etc/apt/sources.list~
diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh
index 4c72d85..b735f58 100755
--- a/stage2/01-sys-tweaks/01-run.sh
+++ b/stage2/01-sys-tweaks/01-run.sh
@@ -17,8 +17,28 @@ systemctl disable nfs-common
systemctl disable rpcbind
systemctl disable ssh
systemctl enable regenerate_ssh_host_keys
+EOF
+
+if [ "${USE_QEMU}" = "1" ]; then
+ echo "enter QEMU mode"
+ install -m 644 files/90-qemu.rules ${ROOTFS_DIR}/etc/udev/rules.d/
+ if [ -e ${ROOTFS_DIR}/etc/ld.so.preload.disabled ]; then
+ rm ${ROOTFS_DIR}/etc/ld.so.preload.disabled
+ touch ${ROOTFS_DIR}/etc/ld.so.preload.disabled
+ fi
+ if [ -e ${ROOTFS_DIR}/etc/ld.so.preload ]; then
+ rm ${ROOTFS_DIR}/etc/ld.so.preload
+ touch ${ROOTFS_DIR}/etc/ld.so.preload
+ fi
+ on_chroot << EOF
+systemctl disable resize2fs_once
+EOF
+ echo "leaving QEMU mode"
+else
+ on_chroot << EOF
systemctl enable resize2fs_once
EOF
+fi
on_chroot << \EOF
for GRP in input spi i2c gpio; do
diff --git a/stage2/01-sys-tweaks/files/90-qemu.rules b/stage2/01-sys-tweaks/files/90-qemu.rules
new file mode 100644
index 0000000..cfe8998
--- /dev/null
+++ b/stage2/01-sys-tweaks/files/90-qemu.rules
@@ -0,0 +1,3 @@
+KERNEL=="sda", SYMLINK+="mmcblk0"
+KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
+KERNEL=="sda2", SYMLINK+="root"
diff --git a/stage2/EXPORT_IMAGE b/stage2/EXPORT_IMAGE
index 8ef6ebe..aa8f936 100644
--- a/stage2/EXPORT_IMAGE
+++ b/stage2/EXPORT_IMAGE
@@ -1 +1,4 @@
IMG_SUFFIX="-lite"
+if [ "${USE_QEMU}" = "1" ]; then
+ export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
+fi
diff --git a/stage4/EXPORT_IMAGE b/stage4/EXPORT_IMAGE
index ee20363..1f1bd4f 100644
--- a/stage4/EXPORT_IMAGE
+++ b/stage4/EXPORT_IMAGE
@@ -1 +1,4 @@
IMG_SUFFIX="-4GB"
+if [ "${USE_QEMU}" = "1" ]; then
+ export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
+fi
diff --git a/stage5/EXPORT_IMAGE b/stage5/EXPORT_IMAGE
index 2b0f09d..79ec11a 100644
--- a/stage5/EXPORT_IMAGE
+++ b/stage5/EXPORT_IMAGE
@@ -1 +1,4 @@
IMG_SUFFIX=""
+if [ "${USE_QEMU}" = "1" ]; then
+ export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
+fi