diff options
Diffstat (limited to 'src/chroot-tools')
-rwxr-xr-x | src/chroot-tools/libremakepkg | 67 |
1 files changed, 63 insertions, 4 deletions
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index d2ce222..f4fda83 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -52,7 +52,12 @@ run() ( local copydir=$1; shift local cmd="$*" - trap "rm -f -- '$copydir/chrootexec'" EXIT + if $HASNET; then + trap "rm -f -- '$copydir/chrootexec'" EXIT + else + distcc_start "$copydir" + trap "rm -f -- '$copydir/chrootexec'; distcc_stop '$copydir'" EXIT + fi cat >"$copydir/chrootexec" <<EOF #!/bin/bash @@ -74,6 +79,51 @@ EOF fi ) +distcc_start() { + local copydir=$1 + # Because /{,usr/}{,s}bin are all symlinked together for + # fileystem 2013.05-2 and up, I can take shortcuts when checking for + # existance of programs. + if [[ -f "$copydir/bin/socat" && -f "$copydir/bin/distcc" ]]; then + local home=$LIBREHOME + $INCHROOT || home="$copydir/build" + + cp -a "$(which distcc-tool)" "$copydir/distcc-tool" + + mkdir -p "$home/.ssh" + + printf '%s\n' \ + '/distcc-tool idaemon "$DISTCC_HOSTS" &' \ + 'DISTCC_HOSTS="$(/distcc-tool rewrite "$DISTCC_HOSTS")"' \ + > "$home/.makepkg.conf" + + printf '%s\n' \ + 'Host *' \ + ' ProxyCommand /distcc-tool client %h %p' \ + > "$home/.ssh/config" + + distcc-tool odaemon "$copydir" & + echo $! > "$copydir/distcc-tool.pid" + fi +} + +distcc_stop() { + local copydir=$1 + local home=$LIBREHOME + $INCHROOT || home="$copydir/build" + if [[ -f "$copydir/distcc-tool.pid" ]]; then + + odaemon=$(cat "$copydir/distcc-tool.pid") + kill -- $odaemon + + rm -f -- \ + "$copydir/distcc-tool" \ + "$home/.makepkg.conf" \ + "$home/.ssh/config" \ + "$copydir/distcc-tool.pid" + fi +} + # Usage: add_to_local_repo $copydir $pkgfiles... add_to_local_repo() ( set +euE @@ -217,9 +267,18 @@ usage() { echo "Usage: $cmd [options] [-- makepkg args]" echo 'This program will build your package.' echo '' - echo 'If run from outside of a chroot, this will set PKGDEST and' - echo "SRCDEST in the chroot's \`/etc/makepkg.conf', as well as making" - echo "whataver alterations to the chroot \`librechroot' makes." + echo 'If run from outside of a chroot, command will make the following' + echo 'configuration changes in the chroot:' + echo ' - whatever changes `librechroot` makes.' + echo ' - set `PKGDEST` and `SRCDEST` in `/etc/makepkg.conf`' + echo ' - (maybe) delete `/build/.makepkg.conf`' + echo ' - (maybe) delete `/build/.ssh/config`' + echo 'If run from inside of a chroot, this command will:' + echo ' - (maybe) delete `~/.makepkg.conf`' + echo ' - (maybe) delete `~/.ssh/config`' + echo "The above 'maybe's happen as part of the workarounds to make" + echo 'distcc work in a network-less environment. They will happen if' + echo 'both `socat` and `distcc` are installed in the chroot.' echo '' echo "The \`-n' and \`-l' options behave identically to librechroot," echo 'see the documentation there.' |