Putting together a couple of tools to make testing faster

A few bash scripts that will hopefully make doing some especially repetitive things faster, except for I am bad at bash.

This first thing is a basic script that uses bdsync to reduce the amount of writes (and therefore wear) when flashing sd card. Be careful as it may do strange things if you have done a lot since initially flashing. If this is a concern, change old.img in line 2 to $2.

usage is sdmodify

bdsync "bdsync -s" $1 $HOME/.sdcardwrite/old.img | sudo bdsync --diffsize=minsize --patch=$2
cp $1 $HOME/.sdcardwrite/old.img

<wip> image builder chroot script thing

some things are stolen from other people like the package list from the docker example

requires root so the docker from the other post probably works best for most people

install dependencies:

create chroot script and install basics:


sudo debootstrap --components=main,restricted,universe --include=sudo,tzdata,vim,pkg-config,build-essential,ninja-build,automake,autoconf,libtool,wget,curl,git,gcc,libssl-dev,bc,slib,squashfs-tools,android-sdk-libsparse-utils,jq,python3-distutils,scons,parallel,tree,python3-dev,python3-pip,device-tree-compiler,ssh,cpio,fakeroot,libncurses5,flex,bison,libncurses5-dev,genext2fs,rsync,unzip,dosfstools,mtools,tcl,android-sdk-ext4-utils focal ubuntu/ http://archive.ubuntu.com/ubuntu

cd ubuntu

sudo mount -t proc /proc proc/

sudo mount -t sysfs /sys sys/

sudo mount --bind /dev dev/

sudo mount -t devpts devpts dev/pts

sudo mount --bind /run run/

sudo mount --bind /run/user/1000 run/user/1000

sudo mount -t tmpfs tmpfs tmp/

sudo cp -r /usr/share/terminfo/ usr/share/terminfo/

#chroot and install other things like the git repo
sudo chroot ./ /bin/bash <<END

#theres a weird backspace thing idk
export TERM=linux

su -l

git clone https://github.com/milkv-duo/duo-buildroot-sdk

cd duo-buildroot-sdk

#literally stolen from the repo, is here to make copying easier down the road

if [ ! -d host-tools ]; then
    #print_info "Toolchain does not exist, download it now..."

    echo "toolchain_url: ${toolchain_url}"
    echo "toolchain_file: ${toolchain_file}"

    wget ${toolchain_url} -O ${toolchain_file}
    if [ $? -ne 0 ]; then
      print_err "Failed to download ${toolchain_url} !"
      exit 1

    if [ ! -f ${toolchain_file} ]; then
      print_err "${toolchain_file} not found!"
      exit 1

    #print_info "Extracting ${toolchain_file}..."
    tar -xf ${toolchain_file}
    if [ $? -ne 0 ]; then
      print_err "Extract ${toolchain_file} failed!"
      exit 1

    [ -f ${toolchain_file} ] && rm -rf ${toolchain_file}


#more stuff stolen from the docker tutorial

wget -P /home https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh

chmod +x /home/cmake-3.26.4-linux-x86_64.sh

sh /home/cmake-3.26.4-linux-x86_64.sh --skip-license --prefix=/usr/




cd ..

sudo cp ubuntu/root/duo-buildroot-sdk/build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig kernelconfig

actual script to build things:

-modify image build scripts to compile new kernel without creating whole new image
-modify image build scripts to allow easily creating with different rootfs
-add argument in the form of a template rootfs whose files are added to/replace those in the rootfs to be added to make patching arch linux images easier.