+# Add a build user with the same ID as the current build user, who can
+# then cross-mount their home directory into the image and build MyPLC
+# in their home directory.
+echo "* myplc-devel: Adding build user"
+uid=${SUDO_UID:-2000}
+gid=${SUDO_GID:-2000}
+if ! grep -q "Automated Build" devel/root/etc/passwd ; then
+ chroot devel/root sh -c "groupadd -o -g $gid build; \
+useradd -o -c 'Automated Build' -u $uid -g $gid -n -d /data/build -M -s /bin/bash build; \
+exit 0"
+fi
+
+# Copy build scripts to build home directory
+mkdir -p devel/data/build
+rsync -a $srcdir/build/ devel/data/build/
+
+# Allow build user to build certain RPMs as root
+cat >devel/root/etc/sudoers <<EOF
+root ALL=(ALL) ALL
+build ALL=(root) NOPASSWD: /usr/bin/rpmbuild
+EOF
+