Date: Thursday, October 24, 2013 @ 19:17:21 Author: dreisner Revision: 197243
archrelease: copy trunk to testing-x86_64, testing-i686 Added: sysvinit-tools/repos/testing-i686/0001-simplify-writelog.patch (from rev 197242, sysvinit-tools/trunk/0001-simplify-writelog.patch) sysvinit-tools/repos/testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch (from rev 197242, sysvinit-tools/trunk/0002-remove-ansi-escape-codes-from-log-file.patch) sysvinit-tools/repos/testing-i686/PKGBUILD (from rev 197242, sysvinit-tools/trunk/PKGBUILD) sysvinit-tools/repos/testing-x86_64/0001-simplify-writelog.patch (from rev 197242, sysvinit-tools/trunk/0001-simplify-writelog.patch) sysvinit-tools/repos/testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch (from rev 197242, sysvinit-tools/trunk/0002-remove-ansi-escape-codes-from-log-file.patch) sysvinit-tools/repos/testing-x86_64/PKGBUILD (from rev 197242, sysvinit-tools/trunk/PKGBUILD) Deleted: sysvinit-tools/repos/testing-i686/0001-simplify-writelog.patch sysvinit-tools/repos/testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch sysvinit-tools/repos/testing-i686/PKGBUILD sysvinit-tools/repos/testing-x86_64/0001-simplify-writelog.patch sysvinit-tools/repos/testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch sysvinit-tools/repos/testing-x86_64/PKGBUILD ------------------------------------------------------------------+ /0001-simplify-writelog.patch | 252 ++++++++++ /0002-remove-ansi-escape-codes-from-log-file.patch | 160 ++++++ /PKGBUILD | 84 +++ testing-i686/0001-simplify-writelog.patch | 126 ----- testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch | 80 --- testing-i686/PKGBUILD | 52 -- testing-x86_64/0001-simplify-writelog.patch | 126 ----- testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch | 80 --- testing-x86_64/PKGBUILD | 52 -- 9 files changed, 496 insertions(+), 516 deletions(-) Deleted: testing-i686/0001-simplify-writelog.patch =================================================================== --- testing-i686/0001-simplify-writelog.patch 2013-10-24 17:16:28 UTC (rev 197242) +++ testing-i686/0001-simplify-writelog.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -1,126 +0,0 @@ -From 5577552eb1344ddd661893564b1e628f8edcf13d Mon Sep 17 00:00:00 2001 -From: Florian Pritz <bluew...@xinu.at> -Date: Fri, 15 Jun 2012 16:41:52 +0200 -Subject: [PATCH 1/2] simplify writelog() - -All we do is prepend the date and remove \r. We don't handle color -codes, but the user can just cat the log file in a terminal and it will -interpret the codes correctly. - -Signed-off-by: Florian Pritz <bluew...@xinu.at> ---- - bootlogd.c | 76 +++++++++++++++++------------------------------------------- - 1 file changed, 21 insertions(+), 55 deletions(-) - -diff --git a/bootlogd.c b/bootlogd.c -index 570d382..e36e261 100644 ---- a/bootlogd.c -+++ b/bootlogd.c -@@ -68,11 +68,6 @@ int didnl = 1; - int createlogfile = 0; - int syncalot = 0; - --struct line { -- char buf[256]; -- int pos; --} line; -- - /* - * Console devices as listed on the kernel command line and - * the mapping to actual devices in /dev -@@ -351,63 +346,34 @@ int consolename(char *res, int rlen) - */ - void writelog(FILE *fp, unsigned char *ptr, int len) - { -- time_t t; -- char *s; -- char tmp[8]; -- int olen = len; -- int dosync = 0; -- int tlen; -- -- while (len > 0) { -- tmp[0] = 0; -- if (didnl) { -+ int dosync = 0; -+ int i; -+ static int first_run = 1; -+ -+ for (i = 0; i < len; i++) { -+ int ignore = 0; -+ -+ /* prepend date to every line */ -+ if (*(ptr-1) == '\n' || first_run) { -+ time_t t; -+ char *s; - time(&t); - s = ctime(&t); - fprintf(fp, "%.24s: ", s); -- didnl = 0; -+ dosync = 1; -+ first_run = 0; - } -- switch (*ptr) { -- case 27: /* ESC */ -- strcpy(tmp, "^["); -- break; -- case '\r': -- line.pos = 0; -- break; -- case 8: /* ^H */ -- if (line.pos > 0) line.pos--; -- break; -- case '\n': -- didnl = 1; -- dosync = 1; -- break; -- case '\t': -- line.pos += (line.pos / 8 + 1) * 8; -- if (line.pos >= (int)sizeof(line.buf)) -- line.pos = sizeof(line.buf) - 1; -- break; -- case 32 ... 127: -- case 161 ... 255: -- tmp[0] = *ptr; -- tmp[1] = 0; -- break; -- default: -- sprintf(tmp, "\\%03o", *ptr); -- break; -- } -- ptr++; -- len--; - -- tlen = strlen(tmp); -- if (tlen && (line.pos + tlen < (int)sizeof(line.buf))) { -- memcpy(line.buf + line.pos, tmp, tlen); -- line.pos += tlen; -+ if (*ptr == '\r') { -+ ignore = 1; - } -- if (didnl) { -- fprintf(fp, "%s\n", line.buf); -- memset(&line, 0, sizeof(line)); -+ -+ if (!ignore) { -+ fwrite(ptr, sizeof(char), 1, fp); - } -- } - -+ ptr++; -+ } - if (dosync) { - fflush(fp); - if (syncalot) { -@@ -415,7 +381,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) - } - } - -- outptr += olen; -+ outptr += len; - if (outptr >= endptr) - outptr = ringbuf; - --- -1.7.10.4 - Copied: sysvinit-tools/repos/testing-i686/0001-simplify-writelog.patch (from rev 197242, sysvinit-tools/trunk/0001-simplify-writelog.patch) =================================================================== --- testing-i686/0001-simplify-writelog.patch (rev 0) +++ testing-i686/0001-simplify-writelog.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -0,0 +1,126 @@ +From 5577552eb1344ddd661893564b1e628f8edcf13d Mon Sep 17 00:00:00 2001 +From: Florian Pritz <bluew...@xinu.at> +Date: Fri, 15 Jun 2012 16:41:52 +0200 +Subject: [PATCH 1/2] simplify writelog() + +All we do is prepend the date and remove \r. We don't handle color +codes, but the user can just cat the log file in a terminal and it will +interpret the codes correctly. + +Signed-off-by: Florian Pritz <bluew...@xinu.at> +--- + bootlogd.c | 76 +++++++++++++++++------------------------------------------- + 1 file changed, 21 insertions(+), 55 deletions(-) + +diff --git a/bootlogd.c b/bootlogd.c +index 570d382..e36e261 100644 +--- a/bootlogd.c ++++ b/bootlogd.c +@@ -68,11 +68,6 @@ int didnl = 1; + int createlogfile = 0; + int syncalot = 0; + +-struct line { +- char buf[256]; +- int pos; +-} line; +- + /* + * Console devices as listed on the kernel command line and + * the mapping to actual devices in /dev +@@ -351,63 +346,34 @@ int consolename(char *res, int rlen) + */ + void writelog(FILE *fp, unsigned char *ptr, int len) + { +- time_t t; +- char *s; +- char tmp[8]; +- int olen = len; +- int dosync = 0; +- int tlen; +- +- while (len > 0) { +- tmp[0] = 0; +- if (didnl) { ++ int dosync = 0; ++ int i; ++ static int first_run = 1; ++ ++ for (i = 0; i < len; i++) { ++ int ignore = 0; ++ ++ /* prepend date to every line */ ++ if (*(ptr-1) == '\n' || first_run) { ++ time_t t; ++ char *s; + time(&t); + s = ctime(&t); + fprintf(fp, "%.24s: ", s); +- didnl = 0; ++ dosync = 1; ++ first_run = 0; + } +- switch (*ptr) { +- case 27: /* ESC */ +- strcpy(tmp, "^["); +- break; +- case '\r': +- line.pos = 0; +- break; +- case 8: /* ^H */ +- if (line.pos > 0) line.pos--; +- break; +- case '\n': +- didnl = 1; +- dosync = 1; +- break; +- case '\t': +- line.pos += (line.pos / 8 + 1) * 8; +- if (line.pos >= (int)sizeof(line.buf)) +- line.pos = sizeof(line.buf) - 1; +- break; +- case 32 ... 127: +- case 161 ... 255: +- tmp[0] = *ptr; +- tmp[1] = 0; +- break; +- default: +- sprintf(tmp, "\\%03o", *ptr); +- break; +- } +- ptr++; +- len--; + +- tlen = strlen(tmp); +- if (tlen && (line.pos + tlen < (int)sizeof(line.buf))) { +- memcpy(line.buf + line.pos, tmp, tlen); +- line.pos += tlen; ++ if (*ptr == '\r') { ++ ignore = 1; + } +- if (didnl) { +- fprintf(fp, "%s\n", line.buf); +- memset(&line, 0, sizeof(line)); ++ ++ if (!ignore) { ++ fwrite(ptr, sizeof(char), 1, fp); + } +- } + ++ ptr++; ++ } + if (dosync) { + fflush(fp); + if (syncalot) { +@@ -415,7 +381,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) + } + } + +- outptr += olen; ++ outptr += len; + if (outptr >= endptr) + outptr = ringbuf; + +-- +1.7.10.4 + Deleted: testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch =================================================================== --- testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch 2013-10-24 17:16:28 UTC (rev 197242) +++ testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -1,80 +0,0 @@ -From 8d0022d9540112a92ce8d88c91c4ac10bad8c9ef Mon Sep 17 00:00:00 2001 -From: Florian Pritz <bluew...@xinu.at> -Date: Sun, 24 Jun 2012 15:49:51 +0200 -Subject: [PATCH 2/2] remove ansi escape codes from log file - -References: https://en.wikipedia.org/wiki/ANSI_escape_code - -Signed-off-by: Florian Pritz <bluew...@xinu.at> ---- - bootlogd.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 43 insertions(+), 2 deletions(-) - -diff --git a/bootlogd.c b/bootlogd.c -index e36e261..88e610d 100644 ---- a/bootlogd.c -+++ b/bootlogd.c -@@ -349,6 +349,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) - int dosync = 0; - int i; - static int first_run = 1; -+ static int inside_esc = 0; - - for (i = 0; i < len; i++) { - int ignore = 0; -@@ -364,10 +365,50 @@ void writelog(FILE *fp, unsigned char *ptr, int len) - first_run = 0; - } - -- if (*ptr == '\r') { -- ignore = 1; -+ /* remove escape sequences, but do it in a way that allows us to stop -+ * in the middle in case the string was cut off */ -+ if (inside_esc == 1) { -+ /* first '[' is special because if we encounter it again, it should be considered the final byte */ -+ if (*ptr == '[') { -+ /* multi char sequence */ -+ ignore = 1; -+ inside_esc = 2; -+ } else { -+ /* single char sequence */ -+ if (*ptr >= 64 && *ptr <= 95) { -+ ignore = 1; -+ } -+ inside_esc = 0; -+ } -+ } else if (inside_esc == 2) { -+ switch (*ptr) { -+ case '0' ... '9': /* intermediate chars of escape sequence */ -+ case ';': -+ case 32 ... 47: -+ if (inside_esc) { -+ ignore = 1; -+ } -+ break; -+ case 64 ... 126: /* final char of escape sequence */ -+ if (inside_esc) { -+ ignore = 1; -+ inside_esc = 0; -+ } -+ break; -+ } -+ } else { -+ switch (*ptr) { -+ case '\r': -+ ignore = 1; -+ break; -+ case 27: /* ESC */ -+ ignore = 1; -+ inside_esc = 1; -+ break; -+ } - } - -+ - if (!ignore) { - fwrite(ptr, sizeof(char), 1, fp); - } --- -1.7.10.4 - Copied: sysvinit-tools/repos/testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch (from rev 197242, sysvinit-tools/trunk/0002-remove-ansi-escape-codes-from-log-file.patch) =================================================================== --- testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch (rev 0) +++ testing-i686/0002-remove-ansi-escape-codes-from-log-file.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -0,0 +1,80 @@ +From 8d0022d9540112a92ce8d88c91c4ac10bad8c9ef Mon Sep 17 00:00:00 2001 +From: Florian Pritz <bluew...@xinu.at> +Date: Sun, 24 Jun 2012 15:49:51 +0200 +Subject: [PATCH 2/2] remove ansi escape codes from log file + +References: https://en.wikipedia.org/wiki/ANSI_escape_code + +Signed-off-by: Florian Pritz <bluew...@xinu.at> +--- + bootlogd.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 43 insertions(+), 2 deletions(-) + +diff --git a/bootlogd.c b/bootlogd.c +index e36e261..88e610d 100644 +--- a/bootlogd.c ++++ b/bootlogd.c +@@ -349,6 +349,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) + int dosync = 0; + int i; + static int first_run = 1; ++ static int inside_esc = 0; + + for (i = 0; i < len; i++) { + int ignore = 0; +@@ -364,10 +365,50 @@ void writelog(FILE *fp, unsigned char *ptr, int len) + first_run = 0; + } + +- if (*ptr == '\r') { +- ignore = 1; ++ /* remove escape sequences, but do it in a way that allows us to stop ++ * in the middle in case the string was cut off */ ++ if (inside_esc == 1) { ++ /* first '[' is special because if we encounter it again, it should be considered the final byte */ ++ if (*ptr == '[') { ++ /* multi char sequence */ ++ ignore = 1; ++ inside_esc = 2; ++ } else { ++ /* single char sequence */ ++ if (*ptr >= 64 && *ptr <= 95) { ++ ignore = 1; ++ } ++ inside_esc = 0; ++ } ++ } else if (inside_esc == 2) { ++ switch (*ptr) { ++ case '0' ... '9': /* intermediate chars of escape sequence */ ++ case ';': ++ case 32 ... 47: ++ if (inside_esc) { ++ ignore = 1; ++ } ++ break; ++ case 64 ... 126: /* final char of escape sequence */ ++ if (inside_esc) { ++ ignore = 1; ++ inside_esc = 0; ++ } ++ break; ++ } ++ } else { ++ switch (*ptr) { ++ case '\r': ++ ignore = 1; ++ break; ++ case 27: /* ESC */ ++ ignore = 1; ++ inside_esc = 1; ++ break; ++ } + } + ++ + if (!ignore) { + fwrite(ptr, sizeof(char), 1, fp); + } +-- +1.7.10.4 + Deleted: testing-i686/PKGBUILD =================================================================== --- testing-i686/PKGBUILD 2013-10-24 17:16:28 UTC (rev 197242) +++ testing-i686/PKGBUILD 2013-10-24 17:17:21 UTC (rev 197243) @@ -1,52 +0,0 @@ -# $Id$ -# Maintainer: Tom Gundersen <t...@jklm.no> -# Maintainer: Eric Belanger <e...@archlinux.org> - -pkgname=sysvinit-tools -pkgver=2.88 -pkgrel=12 -arch=('i686' 'x86_64') -url="http://savannah.nongnu.org/projects/sysvinit" -license=('GPL') -depends=('glibc') -source=(http://download.savannah.gnu.org/releases/sysvinit/sysvinit-${pkgver}dsf.tar.bz2 - "0001-simplify-writelog.patch" - "0002-remove-ansi-escape-codes-from-log-file.patch") -sha1sums=('f2ca149df1314a91f3007cccd7a0aa47d990de26' - '326112c8a9bd24cb45bd4bb2f958a25f0ac4773d' - 'bbecfa7dfa45ac7c37ed8ac59fb53f6a85064b32') - -build() { - cd "${srcdir}/sysvinit-${pkgver}dsf" - - # FS#30005 - patch -p1 -d "src" -i "${srcdir}/0001-simplify-writelog.patch" - patch -p1 -d "src" -i "${srcdir}/0002-remove-ansi-escape-codes-from-log-file.patch" - - make -} - -package() { - pkgdesc="Linux System V Init Tools" - - cd "${srcdir}/sysvinit-${pkgver}dsf" - make ROOT="${pkgdir}" install - - cd "${pkgdir}" - ### drop the stuff provided by systemd-sysvcompat and util-linux - rm -r usr/share/man/man[15] - rm -r usr/include - rm bin/mountpoint - rm sbin/{halt,init,poweroff,reboot,runlevel,shutdown,telinit,sulogin} - rm usr/bin/{mesg,utmpdump,wall,last{,b}} - rm usr/share/man/man8/{halt,init,poweroff,reboot,runlevel,shutdown,telinit,sulogin}.8 - ### usrmerge - mv sbin/* usr/bin/ - rm -r sbin - mv bin/* usr/bin/ - rm -r bin - - # recreate pidof symlink so it points to the "right" place - rm "$pkgdir/usr/bin/pidof" - ln -s killall5 "$pkgdir/usr/bin/pidof" -} Copied: sysvinit-tools/repos/testing-i686/PKGBUILD (from rev 197242, sysvinit-tools/trunk/PKGBUILD) =================================================================== --- testing-i686/PKGBUILD (rev 0) +++ testing-i686/PKGBUILD 2013-10-24 17:17:21 UTC (rev 197243) @@ -0,0 +1,42 @@ +# $Id$ +# Maintainer: Tom Gundersen <t...@jklm.no> +# Maintainer: Eric Belanger <e...@archlinux.org> + +pkgname=sysvinit-tools +pkgdesc="Linux System V Init Tools" +pkgver=2.88 +pkgrel=12 +arch=('i686' 'x86_64') +url="http://savannah.nongnu.org/projects/sysvinit" +license=('GPL') +depends=('glibc') +source=(http://download.savannah.gnu.org/releases/sysvinit/sysvinit-${pkgver}dsf.tar.bz2 + "0001-simplify-writelog.patch" + "0002-remove-ansi-escape-codes-from-log-file.patch") +sha1sums=('f2ca149df1314a91f3007cccd7a0aa47d990de26' + '326112c8a9bd24cb45bd4bb2f958a25f0ac4773d' + 'bbecfa7dfa45ac7c37ed8ac59fb53f6a85064b32') + +build() { + cd "$srcdir/sysvinit-${pkgver}dsf" + + # FS#30005 + patch -p1 -d "src" -i "${srcdir}/0001-simplify-writelog.patch" + patch -p1 -d "src" -i "${srcdir}/0002-remove-ansi-escape-codes-from-log-file.patch" + + # only build what we need... + make -C src fstab-decode killall5 bootlogd +} + +package() { + cd "$srcdir/sysvinit-${pkgver}dsf" + + install -dm755 "$pkgdir/usr/bin" "$pkgdir/usr/share/man/man8" + + # binaries + install -m755 src/{fstab-decode,killall5,bootlogd} "$pkgdir/usr/bin" + ln -s killall5 "$pkgdir/usr/bin/pidof" + + # manpages + install -m644 man/{bootlogd,pidof,killall5,fstab-decode}.8 "$pkgdir/usr/share/man/man8" +} Deleted: testing-x86_64/0001-simplify-writelog.patch =================================================================== --- testing-x86_64/0001-simplify-writelog.patch 2013-10-24 17:16:28 UTC (rev 197242) +++ testing-x86_64/0001-simplify-writelog.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -1,126 +0,0 @@ -From 5577552eb1344ddd661893564b1e628f8edcf13d Mon Sep 17 00:00:00 2001 -From: Florian Pritz <bluew...@xinu.at> -Date: Fri, 15 Jun 2012 16:41:52 +0200 -Subject: [PATCH 1/2] simplify writelog() - -All we do is prepend the date and remove \r. We don't handle color -codes, but the user can just cat the log file in a terminal and it will -interpret the codes correctly. - -Signed-off-by: Florian Pritz <bluew...@xinu.at> ---- - bootlogd.c | 76 +++++++++++++++++------------------------------------------- - 1 file changed, 21 insertions(+), 55 deletions(-) - -diff --git a/bootlogd.c b/bootlogd.c -index 570d382..e36e261 100644 ---- a/bootlogd.c -+++ b/bootlogd.c -@@ -68,11 +68,6 @@ int didnl = 1; - int createlogfile = 0; - int syncalot = 0; - --struct line { -- char buf[256]; -- int pos; --} line; -- - /* - * Console devices as listed on the kernel command line and - * the mapping to actual devices in /dev -@@ -351,63 +346,34 @@ int consolename(char *res, int rlen) - */ - void writelog(FILE *fp, unsigned char *ptr, int len) - { -- time_t t; -- char *s; -- char tmp[8]; -- int olen = len; -- int dosync = 0; -- int tlen; -- -- while (len > 0) { -- tmp[0] = 0; -- if (didnl) { -+ int dosync = 0; -+ int i; -+ static int first_run = 1; -+ -+ for (i = 0; i < len; i++) { -+ int ignore = 0; -+ -+ /* prepend date to every line */ -+ if (*(ptr-1) == '\n' || first_run) { -+ time_t t; -+ char *s; - time(&t); - s = ctime(&t); - fprintf(fp, "%.24s: ", s); -- didnl = 0; -+ dosync = 1; -+ first_run = 0; - } -- switch (*ptr) { -- case 27: /* ESC */ -- strcpy(tmp, "^["); -- break; -- case '\r': -- line.pos = 0; -- break; -- case 8: /* ^H */ -- if (line.pos > 0) line.pos--; -- break; -- case '\n': -- didnl = 1; -- dosync = 1; -- break; -- case '\t': -- line.pos += (line.pos / 8 + 1) * 8; -- if (line.pos >= (int)sizeof(line.buf)) -- line.pos = sizeof(line.buf) - 1; -- break; -- case 32 ... 127: -- case 161 ... 255: -- tmp[0] = *ptr; -- tmp[1] = 0; -- break; -- default: -- sprintf(tmp, "\\%03o", *ptr); -- break; -- } -- ptr++; -- len--; - -- tlen = strlen(tmp); -- if (tlen && (line.pos + tlen < (int)sizeof(line.buf))) { -- memcpy(line.buf + line.pos, tmp, tlen); -- line.pos += tlen; -+ if (*ptr == '\r') { -+ ignore = 1; - } -- if (didnl) { -- fprintf(fp, "%s\n", line.buf); -- memset(&line, 0, sizeof(line)); -+ -+ if (!ignore) { -+ fwrite(ptr, sizeof(char), 1, fp); - } -- } - -+ ptr++; -+ } - if (dosync) { - fflush(fp); - if (syncalot) { -@@ -415,7 +381,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) - } - } - -- outptr += olen; -+ outptr += len; - if (outptr >= endptr) - outptr = ringbuf; - --- -1.7.10.4 - Copied: sysvinit-tools/repos/testing-x86_64/0001-simplify-writelog.patch (from rev 197242, sysvinit-tools/trunk/0001-simplify-writelog.patch) =================================================================== --- testing-x86_64/0001-simplify-writelog.patch (rev 0) +++ testing-x86_64/0001-simplify-writelog.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -0,0 +1,126 @@ +From 5577552eb1344ddd661893564b1e628f8edcf13d Mon Sep 17 00:00:00 2001 +From: Florian Pritz <bluew...@xinu.at> +Date: Fri, 15 Jun 2012 16:41:52 +0200 +Subject: [PATCH 1/2] simplify writelog() + +All we do is prepend the date and remove \r. We don't handle color +codes, but the user can just cat the log file in a terminal and it will +interpret the codes correctly. + +Signed-off-by: Florian Pritz <bluew...@xinu.at> +--- + bootlogd.c | 76 +++++++++++++++++------------------------------------------- + 1 file changed, 21 insertions(+), 55 deletions(-) + +diff --git a/bootlogd.c b/bootlogd.c +index 570d382..e36e261 100644 +--- a/bootlogd.c ++++ b/bootlogd.c +@@ -68,11 +68,6 @@ int didnl = 1; + int createlogfile = 0; + int syncalot = 0; + +-struct line { +- char buf[256]; +- int pos; +-} line; +- + /* + * Console devices as listed on the kernel command line and + * the mapping to actual devices in /dev +@@ -351,63 +346,34 @@ int consolename(char *res, int rlen) + */ + void writelog(FILE *fp, unsigned char *ptr, int len) + { +- time_t t; +- char *s; +- char tmp[8]; +- int olen = len; +- int dosync = 0; +- int tlen; +- +- while (len > 0) { +- tmp[0] = 0; +- if (didnl) { ++ int dosync = 0; ++ int i; ++ static int first_run = 1; ++ ++ for (i = 0; i < len; i++) { ++ int ignore = 0; ++ ++ /* prepend date to every line */ ++ if (*(ptr-1) == '\n' || first_run) { ++ time_t t; ++ char *s; + time(&t); + s = ctime(&t); + fprintf(fp, "%.24s: ", s); +- didnl = 0; ++ dosync = 1; ++ first_run = 0; + } +- switch (*ptr) { +- case 27: /* ESC */ +- strcpy(tmp, "^["); +- break; +- case '\r': +- line.pos = 0; +- break; +- case 8: /* ^H */ +- if (line.pos > 0) line.pos--; +- break; +- case '\n': +- didnl = 1; +- dosync = 1; +- break; +- case '\t': +- line.pos += (line.pos / 8 + 1) * 8; +- if (line.pos >= (int)sizeof(line.buf)) +- line.pos = sizeof(line.buf) - 1; +- break; +- case 32 ... 127: +- case 161 ... 255: +- tmp[0] = *ptr; +- tmp[1] = 0; +- break; +- default: +- sprintf(tmp, "\\%03o", *ptr); +- break; +- } +- ptr++; +- len--; + +- tlen = strlen(tmp); +- if (tlen && (line.pos + tlen < (int)sizeof(line.buf))) { +- memcpy(line.buf + line.pos, tmp, tlen); +- line.pos += tlen; ++ if (*ptr == '\r') { ++ ignore = 1; + } +- if (didnl) { +- fprintf(fp, "%s\n", line.buf); +- memset(&line, 0, sizeof(line)); ++ ++ if (!ignore) { ++ fwrite(ptr, sizeof(char), 1, fp); + } +- } + ++ ptr++; ++ } + if (dosync) { + fflush(fp); + if (syncalot) { +@@ -415,7 +381,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) + } + } + +- outptr += olen; ++ outptr += len; + if (outptr >= endptr) + outptr = ringbuf; + +-- +1.7.10.4 + Deleted: testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch =================================================================== --- testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch 2013-10-24 17:16:28 UTC (rev 197242) +++ testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -1,80 +0,0 @@ -From 8d0022d9540112a92ce8d88c91c4ac10bad8c9ef Mon Sep 17 00:00:00 2001 -From: Florian Pritz <bluew...@xinu.at> -Date: Sun, 24 Jun 2012 15:49:51 +0200 -Subject: [PATCH 2/2] remove ansi escape codes from log file - -References: https://en.wikipedia.org/wiki/ANSI_escape_code - -Signed-off-by: Florian Pritz <bluew...@xinu.at> ---- - bootlogd.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 43 insertions(+), 2 deletions(-) - -diff --git a/bootlogd.c b/bootlogd.c -index e36e261..88e610d 100644 ---- a/bootlogd.c -+++ b/bootlogd.c -@@ -349,6 +349,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) - int dosync = 0; - int i; - static int first_run = 1; -+ static int inside_esc = 0; - - for (i = 0; i < len; i++) { - int ignore = 0; -@@ -364,10 +365,50 @@ void writelog(FILE *fp, unsigned char *ptr, int len) - first_run = 0; - } - -- if (*ptr == '\r') { -- ignore = 1; -+ /* remove escape sequences, but do it in a way that allows us to stop -+ * in the middle in case the string was cut off */ -+ if (inside_esc == 1) { -+ /* first '[' is special because if we encounter it again, it should be considered the final byte */ -+ if (*ptr == '[') { -+ /* multi char sequence */ -+ ignore = 1; -+ inside_esc = 2; -+ } else { -+ /* single char sequence */ -+ if (*ptr >= 64 && *ptr <= 95) { -+ ignore = 1; -+ } -+ inside_esc = 0; -+ } -+ } else if (inside_esc == 2) { -+ switch (*ptr) { -+ case '0' ... '9': /* intermediate chars of escape sequence */ -+ case ';': -+ case 32 ... 47: -+ if (inside_esc) { -+ ignore = 1; -+ } -+ break; -+ case 64 ... 126: /* final char of escape sequence */ -+ if (inside_esc) { -+ ignore = 1; -+ inside_esc = 0; -+ } -+ break; -+ } -+ } else { -+ switch (*ptr) { -+ case '\r': -+ ignore = 1; -+ break; -+ case 27: /* ESC */ -+ ignore = 1; -+ inside_esc = 1; -+ break; -+ } - } - -+ - if (!ignore) { - fwrite(ptr, sizeof(char), 1, fp); - } --- -1.7.10.4 - Copied: sysvinit-tools/repos/testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch (from rev 197242, sysvinit-tools/trunk/0002-remove-ansi-escape-codes-from-log-file.patch) =================================================================== --- testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch (rev 0) +++ testing-x86_64/0002-remove-ansi-escape-codes-from-log-file.patch 2013-10-24 17:17:21 UTC (rev 197243) @@ -0,0 +1,80 @@ +From 8d0022d9540112a92ce8d88c91c4ac10bad8c9ef Mon Sep 17 00:00:00 2001 +From: Florian Pritz <bluew...@xinu.at> +Date: Sun, 24 Jun 2012 15:49:51 +0200 +Subject: [PATCH 2/2] remove ansi escape codes from log file + +References: https://en.wikipedia.org/wiki/ANSI_escape_code + +Signed-off-by: Florian Pritz <bluew...@xinu.at> +--- + bootlogd.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 43 insertions(+), 2 deletions(-) + +diff --git a/bootlogd.c b/bootlogd.c +index e36e261..88e610d 100644 +--- a/bootlogd.c ++++ b/bootlogd.c +@@ -349,6 +349,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) + int dosync = 0; + int i; + static int first_run = 1; ++ static int inside_esc = 0; + + for (i = 0; i < len; i++) { + int ignore = 0; +@@ -364,10 +365,50 @@ void writelog(FILE *fp, unsigned char *ptr, int len) + first_run = 0; + } + +- if (*ptr == '\r') { +- ignore = 1; ++ /* remove escape sequences, but do it in a way that allows us to stop ++ * in the middle in case the string was cut off */ ++ if (inside_esc == 1) { ++ /* first '[' is special because if we encounter it again, it should be considered the final byte */ ++ if (*ptr == '[') { ++ /* multi char sequence */ ++ ignore = 1; ++ inside_esc = 2; ++ } else { ++ /* single char sequence */ ++ if (*ptr >= 64 && *ptr <= 95) { ++ ignore = 1; ++ } ++ inside_esc = 0; ++ } ++ } else if (inside_esc == 2) { ++ switch (*ptr) { ++ case '0' ... '9': /* intermediate chars of escape sequence */ ++ case ';': ++ case 32 ... 47: ++ if (inside_esc) { ++ ignore = 1; ++ } ++ break; ++ case 64 ... 126: /* final char of escape sequence */ ++ if (inside_esc) { ++ ignore = 1; ++ inside_esc = 0; ++ } ++ break; ++ } ++ } else { ++ switch (*ptr) { ++ case '\r': ++ ignore = 1; ++ break; ++ case 27: /* ESC */ ++ ignore = 1; ++ inside_esc = 1; ++ break; ++ } + } + ++ + if (!ignore) { + fwrite(ptr, sizeof(char), 1, fp); + } +-- +1.7.10.4 + Deleted: testing-x86_64/PKGBUILD =================================================================== --- testing-x86_64/PKGBUILD 2013-10-24 17:16:28 UTC (rev 197242) +++ testing-x86_64/PKGBUILD 2013-10-24 17:17:21 UTC (rev 197243) @@ -1,52 +0,0 @@ -# $Id$ -# Maintainer: Tom Gundersen <t...@jklm.no> -# Maintainer: Eric Belanger <e...@archlinux.org> - -pkgname=sysvinit-tools -pkgver=2.88 -pkgrel=12 -arch=('i686' 'x86_64') -url="http://savannah.nongnu.org/projects/sysvinit" -license=('GPL') -depends=('glibc') -source=(http://download.savannah.gnu.org/releases/sysvinit/sysvinit-${pkgver}dsf.tar.bz2 - "0001-simplify-writelog.patch" - "0002-remove-ansi-escape-codes-from-log-file.patch") -sha1sums=('f2ca149df1314a91f3007cccd7a0aa47d990de26' - '326112c8a9bd24cb45bd4bb2f958a25f0ac4773d' - 'bbecfa7dfa45ac7c37ed8ac59fb53f6a85064b32') - -build() { - cd "${srcdir}/sysvinit-${pkgver}dsf" - - # FS#30005 - patch -p1 -d "src" -i "${srcdir}/0001-simplify-writelog.patch" - patch -p1 -d "src" -i "${srcdir}/0002-remove-ansi-escape-codes-from-log-file.patch" - - make -} - -package() { - pkgdesc="Linux System V Init Tools" - - cd "${srcdir}/sysvinit-${pkgver}dsf" - make ROOT="${pkgdir}" install - - cd "${pkgdir}" - ### drop the stuff provided by systemd-sysvcompat and util-linux - rm -r usr/share/man/man[15] - rm -r usr/include - rm bin/mountpoint - rm sbin/{halt,init,poweroff,reboot,runlevel,shutdown,telinit,sulogin} - rm usr/bin/{mesg,utmpdump,wall,last{,b}} - rm usr/share/man/man8/{halt,init,poweroff,reboot,runlevel,shutdown,telinit,sulogin}.8 - ### usrmerge - mv sbin/* usr/bin/ - rm -r sbin - mv bin/* usr/bin/ - rm -r bin - - # recreate pidof symlink so it points to the "right" place - rm "$pkgdir/usr/bin/pidof" - ln -s killall5 "$pkgdir/usr/bin/pidof" -} Copied: sysvinit-tools/repos/testing-x86_64/PKGBUILD (from rev 197242, sysvinit-tools/trunk/PKGBUILD) =================================================================== --- testing-x86_64/PKGBUILD (rev 0) +++ testing-x86_64/PKGBUILD 2013-10-24 17:17:21 UTC (rev 197243) @@ -0,0 +1,42 @@ +# $Id$ +# Maintainer: Tom Gundersen <t...@jklm.no> +# Maintainer: Eric Belanger <e...@archlinux.org> + +pkgname=sysvinit-tools +pkgdesc="Linux System V Init Tools" +pkgver=2.88 +pkgrel=12 +arch=('i686' 'x86_64') +url="http://savannah.nongnu.org/projects/sysvinit" +license=('GPL') +depends=('glibc') +source=(http://download.savannah.gnu.org/releases/sysvinit/sysvinit-${pkgver}dsf.tar.bz2 + "0001-simplify-writelog.patch" + "0002-remove-ansi-escape-codes-from-log-file.patch") +sha1sums=('f2ca149df1314a91f3007cccd7a0aa47d990de26' + '326112c8a9bd24cb45bd4bb2f958a25f0ac4773d' + 'bbecfa7dfa45ac7c37ed8ac59fb53f6a85064b32') + +build() { + cd "$srcdir/sysvinit-${pkgver}dsf" + + # FS#30005 + patch -p1 -d "src" -i "${srcdir}/0001-simplify-writelog.patch" + patch -p1 -d "src" -i "${srcdir}/0002-remove-ansi-escape-codes-from-log-file.patch" + + # only build what we need... + make -C src fstab-decode killall5 bootlogd +} + +package() { + cd "$srcdir/sysvinit-${pkgver}dsf" + + install -dm755 "$pkgdir/usr/bin" "$pkgdir/usr/share/man/man8" + + # binaries + install -m755 src/{fstab-decode,killall5,bootlogd} "$pkgdir/usr/bin" + ln -s killall5 "$pkgdir/usr/bin/pidof" + + # manpages + install -m644 man/{bootlogd,pidof,killall5,fstab-decode}.8 "$pkgdir/usr/share/man/man8" +}