diff --git a/.gitignore b/.gitignore index 1c7c406..2d48ec2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ filesystem/opt/groomer/pdfbox-app-*.jar filesystem/etc +tests/content* +tests/*vfat +deb/ + +*img + diff --git a/copy_force_shell.sh b/copy_force_shell.sh new file mode 100755 index 0000000..e219332 --- /dev/null +++ b/copy_force_shell.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e +set -x + +if [ -z "$1" ]; then + echo "Path to the mounted image needed." + exit +fi + +CHROOT_PATH=${1} + +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# prepare fs archive +tar -cvpzf backup.tar.gz -C fs_shell/ . +tar -xzf backup.tar.gz -C ${CHROOT_PATH}/ diff --git a/fs_shell/etc/fstab b/fs_shell/etc/fstab new file mode 100755 index 0000000..280c980 --- /dev/null +++ b/fs_shell/etc/fstab @@ -0,0 +1,5 @@ +proc /proc proc defaults 0 0 +/dev/mmcblk0p1 /boot vfat rw,defaults 0 0 +/dev/mmcblk0p2 / ext4 rw,defaults,noatime 0 0 +tmpfs /tmp tmpfs rw,size=64M,noexec,nodev,nosuid,mode=1777 0 0 +# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that diff --git a/fs_shell/etc/rc.local b/fs_shell/etc/rc.local new file mode 100755 index 0000000..32efadf --- /dev/null +++ b/fs_shell/etc/rc.local @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +cleanup(){ + apt-get autoremove -y + apt-get autoclean -y + apt-get clean -y + + /sbin/shutdown -h now +} + + +trap TERM EXIT + +apt-get update -y +apt-get dist-upgrade + + +/bin/bash + + + diff --git a/get_shell.sh b/get_shell.sh new file mode 100755 index 0000000..3cd22be --- /dev/null +++ b/get_shell.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/ + +IMAGE='2014-01-07-wheezy-raspbian.img' +OFFSET_ROOTFS=$((122880 * 512)) + +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +set -e +set -x + +./mount_image.sh ./copy_force_shell.sh + +SETUP_DIR="setup" + +clean(){ + mount -o loop,offset=${OFFSET_ROOTFS} ${IMAGE} ${SETUP_DIR} + mv ${SETUP_DIR}/etc/ld.so.preload_bkp ${SETUP_DIR}/etc/ld.so.preload + umount ${SETUP_DIR} + rm -rf ${SETUP_DIR} + ./mount_image.sh ./copy_to_final.sh +} + +trap clean EXIT TERM INT + +mkdir -p ${SETUP_DIR} + +# make the CIRCLean image compatible with qemu +mount -o loop,offset=${OFFSET_ROOTFS} ${IMAGE} ${SETUP_DIR} +mv ${SETUP_DIR}/etc/ld.so.preload ${SETUP_DIR}/etc/ld.so.preload_bkp +umount ${SETUP_DIR} + +qemu-system-arm -kernel tests/kernel-qemu -cpu arm1176 -m 256 -M versatilepb \ + -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw console=ttyAMA0 console=ttyS0" \ + -drive file=${IMAGE},index=0,media=disk \ + -nographic + + diff --git a/run_tests.sh b/run_tests.sh index a306a57..cff3c18 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,7 +2,7 @@ set -e -./update_scripts.sh +./mount_image.sh ./copy_to_final.sh pushd tests/ diff --git a/update_scripts.sh b/update_scripts.sh deleted file mode 100755 index 7d9f8a6..0000000 --- a/update_scripts.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./mount_image.sh ./copy_to_final.sh