Skip to content

Commit

Permalink
[script] clean up crankshaft script
Browse files Browse the repository at this point in the history
  • Loading branch information
htruong committed Apr 7, 2018
1 parent b13030a commit f68eab6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
52 changes: 34 additions & 18 deletions make-crankshaft.sh → crankshaft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
IMAGE_FILE=2018-03-13-raspbian-stretch-lite.zip
IMAGE_FILE_UNZIPPED=2018-03-13-raspbian-stretch-lite.img
TODAY_EXT=$(date +"%Y-%m-%d")
IMAGE_FILE_CUSTOMIZED=crankshaft-${TODAY_EXT}.img
IMAGE_FILE_CUSTOMIZED=${IMAGE:-"crankshaft-${TODAY_EXT}.img"}
IMAGE_URL=http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2018-03-13/2018-03-13-raspbian-stretch-lite.zip
IMAGE_SIZE_RAW=1858076672
IMAGE_ROOTPART_START=98304
TEMP_CHROOT_DIR=/mnt/raspbian-temp
DROP_IN=${DROP_IN:-0}
CUSTOM_SCRIPT=${CUSTOM_SCRIPT:-""}


#########################################################
Expand Down Expand Up @@ -119,33 +121,47 @@ set_up_loopdevs() {
e2fsck -f ${LOOPDEVPARTS}p2

mount_chroot_dirs ${LOOPDEVPARTS} ${LOOPPARTSID}

# now we should have a


# ld.so.preload fix
sed -i 's/^/#CHROOT /g' ${TEMP_CHROOT_DIR}/etc/ld.so.preload

# copy qemu binary
cp `which qemu-arm-static` ${TEMP_CHROOT_DIR}/usr/bin/

# extract libQt5
tar -xvf prebuilt/libQt5_OpenGLES2.tar.xz -C ${TEMP_CHROOT_DIR}/
if [[ ${DROP_IN} -ne 0 ]]; then

# copy rest of CS stuff to the root home directory
cp -a crankshaft/. ${TEMP_CHROOT_DIR}/root/
echo -e "Dropping you in the chroot shell."
chroot ${TEMP_CHROOT_DIR} /bin/bash

sync
sleep 1

# phew, customize it
chroot ${TEMP_CHROOT_DIR} /bin/bash /root/scripts/customize-image-pi.sh
else

echo -e "Dropping you on the chroot shell."
echo -e "You need to do whatever you need to do, then I will make it RO.\n\n\n"
chroot ${TEMP_CHROOT_DIR} /bin/bash
if [[ -n "${CUSTOM_SCRIPT}" ]]; then

chroot ${TEMP_CHROOT_DIR} /bin/bash /root/scripts/read-only-fs.sh

# eval the custom script

eval ${CUSTOM_SCRIPT}

else

# make the image

# extract libQt5
tar -xvf prebuilt/libQt5_OpenGLES2.tar.xz -C ${TEMP_CHROOT_DIR}/

# copy rest of CS stuff to the root home directory
cp -a crankshaft/. ${TEMP_CHROOT_DIR}/root/

sync
sleep 1

# phew, customize it
chroot ${TEMP_CHROOT_DIR} /bin/bash /root/scripts/customize-image-pi.sh

chroot ${TEMP_CHROOT_DIR} /bin/bash /root/scripts/read-only-fs.sh

fi

fi
# undo ld.so.preload fix
sed -i 's/^#CHROOT //g' ${TEMP_CHROOT_DIR}/etc/ld.so.preload

Expand Down
10 changes: 5 additions & 5 deletions crankshaft/scripts/customize-image-pi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

print_banner() {
echo "---- WELCOME TO THE RASPBERRY PI IMAGE CUSTOMIZER --------------"
echo " Congratulations, we have gone a long way."
echo " I will prepare some software for you, sit tight."
echo ""
echo ""
Expand All @@ -19,7 +18,7 @@ print_banner() {

get_deps() {
apt update
#apt upgrade

apt install --no-install-recommends -y \
libprotobuf10 libpulse0 libboost-log1.62.0 libboost-test1.62.0 \
libboost-thread1.62.0 libboost-date-time1.62.0 libboost-chrono1.62.0 \
Expand All @@ -30,10 +29,11 @@ get_deps() {
xinit xserver-xorg-video-fbdev xserver-xorg-legacy xserver-xorg-input-libinput xserver-xorg-input-mouse libgl1-mesa-dri xserver-xorg-input-evdev \
wiringpi

apt clean
rm -rf /var/cache/apt/
apt -y upgrade
apt autoremove --purge

#update raspi firmware
SKIP_WARNING=1 SKIP_BACKUP=1 rpi-update
# SKIP_WARNING=1 SKIP_BACKUP=1 rpi-update
}

mark_script_run() {
Expand Down
3 changes: 3 additions & 0 deletions crankshaft/scripts/read-only-fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ mkdir /tmp/.local
ln -s /tmp/.config /home/pi/
ln -s /tmp/.local /home/pi/

apt clean
rm -rf /var/cache/apt/

# Change spool permissions in var.conf (rondie/Margaret fix)
replace /usr/lib/tmpfiles.d/var.conf "spool\s*0755" "spool 1777"

Expand Down

0 comments on commit f68eab6

Please sign in to comment.