[IMP] point_of_sale: migrate POSBox to Raspbian Jessie
The main reason for doing this is supporting the new Raspberry Pi 3. No functional changes where made. For Raspbian Wheezy we used to download the full image and strip it as best we could to obtain a reasonable image size for people to download. Since Raspbian Jessie the Raspberry Pi Foundation has started releasing an official minimal image (Raspbian Jessie Lite) which we will use from now on to build our image. One downside of this is that the minimal image is a 1.3 GiB image which is too small for our purposes so it has to be resized. Because Raspbian Jessie migrated to systemd we cannot rely on /etc/init.d/rcS to set up the ramdisks anymore. Jessie provides a compatibility layer so old SysVinit scripts still work but rcS does not block like it does in a SysVinit system, it is run in parallel with other startup services. In our case this is a bad thing as setting up the ramdisks has to be done before any other services are started. To accomplish this the rcS hack has been migrated to a systemd service running before basic.target and with DefaultDependencies=no. This has a similar effect as the rcS hack because normal systemd services (with DefaultDependencies=yes) all require basic.target by default.
This commit is contained in:
parent
46c5f93b6c
commit
5af1c085bf
|
@ -15,11 +15,10 @@ create_ramdisk () {
|
|||
mount --bind "${RAMDISK}" "${ORIGINAL}"
|
||||
}
|
||||
|
||||
# check /proc/cmdline
|
||||
|
||||
# bind mount / so that we can get to the real /var and /etc
|
||||
mount --bind / /root_bypass_ramdisks
|
||||
|
||||
echo "Creating ramdisks..."
|
||||
create_ramdisk "/var" "128M"
|
||||
create_ramdisk "/etc" "16M"
|
||||
create_ramdisk "/tmp" "16M"
|
||||
|
||||
# bind mount / so that we can get to the real /var and /etc
|
||||
mount --bind / /root_bypass_ramdisks
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# rcS
|
||||
#
|
||||
# Call all S??* scripts in /etc/rcS.d/ in numerical/alphabetical order
|
||||
#
|
||||
|
||||
/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh
|
||||
|
||||
exec /etc/init.d/rc S
|
|
@ -0,0 +1 @@
|
|||
/usr/lib/arm-linux-gnueabihf/libarmmem.so
|
|
@ -0,0 +1,5 @@
|
|||
proc /proc proc defaults 0 0
|
||||
#/dev/mmcblk0p1 /boot vfat defaults 0 2
|
||||
#/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
|
||||
# a swapfile is not a swap partition, no line here
|
||||
# use dphys-swapfile swap[on|off] for that
|
|
@ -11,37 +11,16 @@ __base="$(basename ${__file} .sh)"
|
|||
# Recommends: antiword, graphviz, ghostscript, postgresql, python-gevent, poppler-utils
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# GUI-related packages
|
||||
PKGS_TO_DELETE="xserver-xorg-video-fbdev xserver-xorg xinit gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-libav epiphany-browser lxde lxtask menu-xdg gksu xserver-xorg-video-fbturbo xpdf gtk2-engines alsa-utils netsurf-gtk zenity desktop-base lxpolkit weston omxplayer raspberrypi-artwork lightdm gnome-themes-standard-data gnome-icon-theme qt50-snapshot qt50-quick-particle-examples idle python-pygame python-tk idle3 python-serial python-picamera debian-reference-en dillo x2x scratch nuscratch raspberrypi-ui-mods timidity smartsim penguinspuzzle pistore sonic-pi python-pifacecommon python-pifacedigitalio oracle-java8-jdk minecraft-pi python-minecraftpi wolfram-engine raspi-config libgl1-mesa-dri libicu48 pypy-upstream lxde-icon-theme python3 avahi-daemon"
|
||||
INSTALLED_PKGS_TO_DELETE=""
|
||||
set +o errexit
|
||||
for CURRENT_PKG in $(echo $PKGS_TO_DELETE); do
|
||||
$(dpkg --status $CURRENT_PKG &> /dev/null)
|
||||
if [[ $? -eq 0 ]]; then
|
||||
INSTALLED_PKGS_TO_DELETE="$INSTALLED_PKGS_TO_DELETE $CURRENT_PKG"
|
||||
fi
|
||||
done
|
||||
set -o errexit
|
||||
|
||||
apt-get -y remove --purge ${INSTALLED_PKGS_TO_DELETE}
|
||||
|
||||
# Remove automatically installed dependency packages
|
||||
apt-get -y autoremove
|
||||
|
||||
apt-get update
|
||||
apt-get -y dist-upgrade
|
||||
|
||||
PKGS_TO_INSTALL="adduser postgresql-client python python-dateutil python-decorator python-docutils python-feedparser python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-werkzeug python-xlwt python-yaml postgresql python-gevent python-serial python-pip python-dev localepurge vim mc mg screen iw hostapd isc-dhcp-server"
|
||||
PKGS_TO_INSTALL="adduser postgresql-client python python-dateutil python-decorator python-docutils python-feedparser python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-werkzeug python-xlwt python-yaml postgresql python-gevent python-serial python-pip python-dev localepurge vim mc mg screen iw hostapd isc-dhcp-server git rsync console-data"
|
||||
|
||||
apt-get -y install ${PKGS_TO_INSTALL}
|
||||
|
||||
apt-get clean
|
||||
localepurge
|
||||
rm -rf /usr/share/doc
|
||||
rm -rf /home/pi/python_games
|
||||
|
||||
# remove raspi-config notice, it's not necessary and it's not installed anyway
|
||||
rm -f /etc/profile.d/raspi-config.sh
|
||||
|
||||
# python-usb in wheezy is too old
|
||||
# the latest pyusb from pip does not work either, usb.core.find() never returns
|
||||
|
@ -70,6 +49,10 @@ echo "* * * * * rm /var/run/odoo/sessions/*" | crontab -
|
|||
update-rc.d -f hostapd remove
|
||||
update-rc.d -f isc-dhcp-server remove
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable ramdisks.service
|
||||
systemctl disable dphys-swapfile.service
|
||||
|
||||
# https://www.raspberrypi.org/forums/viewtopic.php?p=79249
|
||||
# to not have "setting up console font and keymap" during boot take ages
|
||||
setupcon
|
||||
|
@ -81,6 +64,7 @@ create_ramdisk_dir () {
|
|||
|
||||
create_ramdisk_dir "/var"
|
||||
create_ramdisk_dir "/etc"
|
||||
create_ramdisk_dir "/tmp"
|
||||
mkdir /root_bypass_ramdisks
|
||||
|
||||
reboot
|
||||
|
|
|
@ -1 +1 @@
|
|||
#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
|
||||
#/usr/lib/arm-linux-gnueabihf/libarmmem.so
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=ramdisks
|
||||
DefaultDependencies=no
|
||||
After=sysinit.target local-fs.target
|
||||
Before=basic.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
|
@ -50,8 +50,29 @@ rm ngrok.zip
|
|||
cd "${__dir}"
|
||||
mv /tmp/ngrok "${USR_BIN}"
|
||||
|
||||
# zero pad the image to be around 3.5 GiB, by default the image is only ~1.3 GiB
|
||||
dd if=/dev/zero bs=1M count=2048 >> posbox.img
|
||||
|
||||
# resize partition table
|
||||
START_OF_ROOT_PARTITION=$(fdisk -l posbox.img | tail -n 1 | awk '{print $2}')
|
||||
(echo 'p'; # print
|
||||
echo 'd'; # delete
|
||||
echo '2'; # second partition
|
||||
echo 'n'; # create new partition
|
||||
echo 'p'; # primary
|
||||
echo '2'; # number 2
|
||||
echo "${START_OF_ROOT_PARTITION}"; # starting at previous offset
|
||||
echo ''; # ending at default (fdisk should propose max)
|
||||
echo 'p'; # print
|
||||
echo 'w') | fdisk posbox.img # write and quit
|
||||
|
||||
LOOP_MAPPER_PATH=$(kpartx -av posbox.img | tail -n 1 | cut -d ' ' -f 3)
|
||||
LOOP_MAPPER_PATH="/dev/mapper/${LOOP_MAPPER_PATH}"
|
||||
|
||||
# resize filesystem
|
||||
e2fsck -f "${LOOP_MAPPER_PATH}" # resize2fs requires clean fs
|
||||
resize2fs "${LOOP_MAPPER_PATH}"
|
||||
|
||||
mkdir "${MOUNT_POINT}"
|
||||
mount "${LOOP_MAPPER_PATH}" "${MOUNT_POINT}"
|
||||
|
||||
|
@ -70,7 +91,7 @@ umount "${MOUNT_POINT}"
|
|||
|
||||
# from http://paulscott.co.za/blog/full-raspberry-pi-raspbian-emulation-with-qemu/
|
||||
# ssh pi@localhost -p10022
|
||||
QEMU_OPTS=(-kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda posbox.img -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::18069-:8069 -net nic)
|
||||
QEMU_OPTS=(-kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append 'root=/dev/sda2 rootfstype=ext4 rw' -hda posbox.img -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::18069-:8069 -net nic)
|
||||
if [ -z ${DISPLAY:-} ] ; then
|
||||
QEMU_OPTS+=(-nographic)
|
||||
fi
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
wget 'http://downloads.raspberrypi.org/raspbian_latest' -O raspbian.img.zip
|
||||
wget 'https://downloads.raspberrypi.org/raspbian_lite_latest' -O raspbian.img.zip
|
||||
unzip raspbian.img.zip
|
||||
wget 'https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu'
|
||||
wget 'https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.1.13-jessie' -O kernel-qemu
|
||||
|
|
Loading…
Reference in New Issue