From 9d6868f20c2f307f70ffef807f896ca8a79d242d Mon Sep 17 00:00:00 2001 From: marcsello Date: Mon, 19 Jul 2021 15:09:34 +0200 Subject: [PATCH] Initial commit --- build.sh | 8 ++++++++ input/image.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100755 build.sh create mode 100755 input/image.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b868ed8 --- /dev/null +++ b/build.sh @@ -0,0 +1,8 @@ +docker run --rm -it \ + -v $PWD/output:/output -v $PWD/input:/input \ + -e "DEFAULT_KERNEL_MODULES=*" \ + -e "SIZE_ROOT_PART=750M" \ + -e "SIZE_ROOT_FS=700M" \ + -e "DEFAULT_TIMEZONE=Europe/Budapest" \ + builder # <- don't forgetti to build this + diff --git a/input/image.sh b/input/image.sh new file mode 100755 index 0000000..58441e3 --- /dev/null +++ b/input/image.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +VERSION="1" +RUNTIME_PACKAGES="python3 udev alsa-utils alsa-utils-doc alsa-lib alsaconf py3-rpigpio" +BUILD_PACKAGES="alsa-lib-dev gcc g++ python3-dev musl-dev" + +# put back the resolv.conf to keep apk working +rm ${ROOTFS_PATH}/etc/resolv.conf # remove symlink +cp /etc/resolv.conf ${ROOTFS_PATH}/etc/resolv.conf + +# install things +chroot_exec apk add $RUNTIME_PACKAGES $BUILD_PACKAGES + + +# setup udev +chroot_exec rc-update add udev sysinit +chroot_exec rc-update add udev-trigger default +chroot_exec rc-update add udev-settle default +# udev_postmount's purpose is to write stuff to / which is not possible now + +# make audio work +echo "snd_bcm2835" >> ${ROOTFS_PATH}/etc/modules # Actually this is also loaded by udev, but it wouldn't hurt +echo "dtparam=audio=on" >> ${BOOTFS_PATH}/config.txt +echo "hdmi_drive=1" >> ${BOOTFS_PATH}/config.txt # disable HDMI audio +chroot_exec addgroup root audio +sed -i -e "s/^defaults.ctl.card [0-9]*$/defaults.ctl.card 0/" ${ROOTFS_PATH}/usr/share/alsa/alsa.conf +sed -i -e "s/^defaults.pcm.card [0-9]*$/defaults.pcm.card 0/" ${ROOTFS_PATH}/usr/share/alsa/alsa.conf +chroot_exec rc-update add alsa default +sed -i -e "s%alsastatedir=/var/lib/alsa%alsastatedir=/data/var/lib/alsa%" ${ROOTFS_PATH}/etc/init.d/alsa +mkdir -p ${DATAFS_PATH}/var/lib/alsa + +# make serial work +sed -i -e 's%#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100%ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100%' ${ROOTFS_PATH}/etc/inittab + +# mark this version +echo "Version: ${VERSION}\nBuild: $(date)\nUpdate: " > ${ROOTFS_PATH}/version + +# install things +mkdir -p ${ROOTFS_PATH}/opt/ + +for repo in iot-platform-raspberry iot-logic; do + archive="${repo}.tar.gz" + wget https://git.kmlabz.com/birbnetes/$repo/archive/master.tar.gz -O "${archive}" + tar xvf "${archive}" -C ${ROOTFS_PATH}/opt/ +done + +chroot_exec pip3 install /opt/iot-platform-raspberry/ +chroot_exec pip3 install -r /opt/iot-logic/requirements.txt + +# clean build dependencies +chroot_exec apk del $BUILD_PACKAGES + +# Put back resolv.conf where it was +rm ${ROOTFS_PATH}/etc/resolv.conf +ln -fs /data/etc/resolv.conf ${ROOTFS_PATH}/etc/resolv.conf +