diff options
-rw-r--r-- | src/chroot-tools/Makefile | 2 | ||||
-rwxr-xr-x | src/chroot-tools/indent | 33 | ||||
-rwxr-xr-x | src/chroot-tools/libremakepkg | 3 |
3 files changed, 36 insertions, 2 deletions
diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile index b42d28d..d08775e 100644 --- a/src/chroot-tools/Makefile +++ b/src/chroot-tools/Makefile @@ -1,7 +1,7 @@ # These files are coming from devtools copy_files = makechrootpkg.sh.in mkarchroot.in arch-nspawn.in # These are programs that we will use internally, but shouldn't be in PATH -libexecs = mkarchroot arch-nspawn distcc-tool chcleanup +libexecs = mkarchroot arch-nspawn distcc-tool chcleanup indent no-progs = $(libexecs) # These are the shell libraries we will use libs = makechrootpkg.sh $(wildcard hooks-*.sh) diff --git a/src/chroot-tools/indent b/src/chroot-tools/indent new file mode 100755 index 0000000..5a7f654 --- /dev/null +++ b/src/chroot-tools/indent @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +use warnings; +use strict; +use constant BUFFER_SIZE => 40; +binmode(STDIN); +binmode(STDOUT); + +exit(1) if ($#ARGV != 0); +my $indent = $ARGV[0]; + +my $print_indent = 1; +my $buffer; +my $size; +my $c; +while (1) { + $size = sysread(STDIN, $buffer, BUFFER_SIZE); + last if ($size < 1); + for (0..$size-1) { + $c = substr($buffer, $_, 1); + if ($c eq "\n") { + syswrite(STDOUT, $indent) if ($print_indent); + syswrite(STDOUT, $c, 1); + $print_indent = 1; + } elsif ($c eq "\r") { + syswrite(STDOUT, $c, 1); + $print_indent = 1; + } else { + syswrite(STDOUT, $indent) if ($print_indent); + syswrite(STDOUT, $c, 1); + $print_indent = 0; + } + } +} diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index df4cd07..f808070 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -30,6 +30,7 @@ shopt -s nullglob umask 0022 # Global variables: +readonly _indent="$(librelib chroot/indent)" readonly INCHROOT=$([[ -f /.arch-chroot ]] && echo true || echo false) NONET=true # can be changed with the -N flag # {SRC,LOG,PKG}DEST set at runtime by makepkg.conf @@ -50,7 +51,7 @@ hook_check_pkg=(:) # Boring/mundane functions ##################################################### indent() { - sed 's/^/ | /' + "$_indent" ' | ' } # Usage: exit_copy $copydir $src_owner |