Micron Document
ducktape

I want something lighter than github to watch and build some projects on change. I'm going to call it ducktape. It's a bash script that will have an array of projects. It will have a configurable delay. It will loop over all the projects, fetch from upstream, and if there is a change fetched, it will merge and build.

First Pass

For this to work, any project it watches must have a T383838Makefile. And some standard targets.

Since it wont completely use a fresh repo on each run (I'm bandwidth constrained) each project must have a T383838clean target.

Since my note repo has a T383838publish target, I'll make that required, too.

And then a default target is needed, which will be used to determine if the T383838publish target is called.

Well, that sounds easy enough.

First pass is done. Embedding a copy here...

T282828
T8b949e#!/bin/env bash

Te6edf3DELAYTff7b72=T79c0ff600 T8b949e# how long to wait before fetching updates and building again
Te6edf3REPOSTff7b72=Tff7b72(
T8b949e#add URI's here
Tff7b72)

get_new_reposTff7b72(Tff7b72)Tff7b72{
Tff7b72for REPO Tff7b72in Ta5d6ff"Tffd700${Te6edf3REPOSTb4b4b4[@]Tffd700}Ta5d6ff" Tb4b4b4; Tff7b72do
T79c0ff2>/dev/null git clone Ta5d6ff"Tffd700${Te6edf3REPOTffd700}Ta5d6ff" Tff7b72|| Tff7b72continue
Tff7b72done
Tff7b72}

build_and_publishTff7b72(Tff7b72)Tff7b72{
Tffa657local Te6edf3REPOTff7b72=Tffd700${Te6edf31Tff7b72:-Tffd700}
Tff7b72if Tff7b72[ -z Ta5d6ff"Tffd700${Te6edf3REPOTffd700}Ta5d6ff" Tff7b72] Tb4b4b4; Tff7b72then
Tffa657echo Ta5d6ff"Need a repo dir in order to build, failing..."
Tff7b72return T79c0ff1
Tff7b72fi
Tff7b72(
Tffa657set -e
Tffa657cd Ta5d6ff"Tffd700${Te6edf3REPOTffd700}Ta5d6ff" Tff7b72|| Tffa657exit T79c0ff1
git log -n1
Tffa657echo Ta5d6ff"Ta5d6ffAttempting to build Tff7b72$(git remoteTff7b72)Ta5d6ff"
Tff7b72if Tff7b72[ -f Ta5d6ff"shell.nix" Tff7b72] Tff7b72&& Tff7b72[ -f Ta5d6ff"Makefile" Tff7b72] Tb4b4b4; Tff7b72then
nix-shell Ta5d6ff"shell.nix" --run Ta5d6ff"make clean"
nix-shell Ta5d6ff"shell.nix" --run Ta5d6ff"make"
nix-shell Ta5d6ff"shell.nix" --run Ta5d6ff"make publish"
Tff7b72fi
Tff7b72) Tff7b72|| Tff7b72(
Tffa657echo Ta5d6ff"There was a problem building, skipping this commit:"
Tff7b72(Tffa657cd Ta5d6ff"Te6edf3$REPOTa5d6ff" Tb4b4b4; git log -n1Tff7b72)
Tff7b72)
Tff7b72}

update_existing_reposTff7b72(Tff7b72)Tff7b72{
Tffa657local DIR
Tffa657local DIFFS
Tffa657local DIRS
Tffa657local LOG
Te6edf3DIRSTff7b72=Tff7b72( */ Tff7b72)
Tff7b72for DIR Tff7b72in Ta5d6ff"Tffd700${Te6edf3DIRSTb4b4b4[@]Tffd700}Ta5d6ff" Tb4b4b4; Tff7b72do
Te6edf3DIFFSTff7b72=Tff7b72$(
T79c0ff1>/dev/null Tffa657cd Ta5d6ff"Tffd700${Te6edf3DIRTffd700}Ta5d6ff" Tff7b72|| Tffa657exit T79c0ff1
T79c0ff1>/dev/null git fetch
git diff origin Tb4b4b4| wc Tb4b4b4| awk Ta5d6ff'{print $1}'
Tff7b72)
Te6edf3LOGTff7b72=Ta5d6ff"Ta5d6ffrun-Tffd700${Te6edf3DIRTb4b4b4%/Tffd700}Ta5d6ff-Tff7b72$(date Ta5d6ff"+%Y-%m-%d-%H-%M-%S"Tff7b72)Ta5d6ff.logTa5d6ff"
Tff7b72if Tff7b72(Tff7b72(DIFFS>0Tff7b72)Tff7b72) Tb4b4b4; Tff7b72then
Tffa657echo Ta5d6ff"Ta5d6ffChanges in Tffd700${Te6edf3REPOTffd700}Ta5d6ff, attempting to run...Ta5d6ff"
Tff7b72(Tffa657cd Ta5d6ff"Tffd700${Te6edf3DIRTb4b4b4%/Tffd700}Ta5d6ff"Tb4b4b4; git merge originTff7b72)
build_and_publish Ta5d6ff"Tffd700${Te6edf3DIRTffd700}Ta5d6ff" Tb4b4b4|Tb4b4b4& tee Ta5d6ff"Tffd700${Te6edf3LOGTffd700}Ta5d6ff"
Tff7b72fi
Tff7b72done
Tff7b72}

get_new_repos
Tff7b72while Tffa657true Tb4b4b4; Tff7b72do
update_existing_repos
sleep Ta5d6ff"Tffd700${Te6edf3DELAYTffd700}Ta5d6ff"
Tff7b72done


Second Pass

For my second pass, I want to use containers that use an overlay on the existing checkout and build everything in place in the clean environment. Or at least, I certainly want to experiment with that. It would be nice to use NixOS containers instead of docker containers, just to see how those work.

Actually, I should make use of NixOS to get the dependencies and such as well.

Tags: cli

Tags
Navigation
Backlinks


created: 2024-07-07

(re)generated: 2026-07-17