Skip to content

Instantly share code, notes, and snippets.

@hkoba
Last active January 8, 2022 02:23
Show Gist options
  • Save hkoba/61ba5c5bcbc3393f6dd8963a70d54012 to your computer and use it in GitHub Desktop.
Save hkoba/61ba5c5bcbc3393f6dd8963a70d54012 to your computer and use it in GitHub Desktop.
buildah unshare + tclsh
RUN buildah unshare tclsh << [list apply {{container} {
source ./utils.tcl
set mntDir [@RUN buildah mount $container]
set prefix sysroot
foreach dir [lgrep-match $prefix/* [git-submodule-list .]] {
set destDir $mntDir/[regsub ^$prefix $dir {}]
git-clone-submodule-as-workdir $dir $destDir
}
}} $container]
RUN buildah unshare tclsh << [list apply {{container} {
source ./utils.tcl
set mntDir [@RUN buildah mount $container]
set argv [list $mntDir]
source ./populate.tcl
}} $container]
@hkoba
Copy link
Author

hkoba commented Jan 8, 2022

# RUN emits stdout and stderr as-is
proc RUN args {
    puts [list RUNNING: $args]
    exec -ignorestderr {*}$args >@ stdout 2>@ stderr
}

# @RUN captures stdout and return it
proc @RUN args {
    puts [list RUNNING: $args]
    exec -ignorestderr {*}$args 2>@ stderr
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment