From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sahitihi Subject: Re: Fwd: Re: Patch file for colorize module Date: Thu, 7 Jun 2018 02:50:46 +0530 Message-ID: References: <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net> <87a7suwtp7.fsf@elephly.net> <149bfb8c-22b5-797d-e88a-ca4077b0a4cc@swecha.net> <87d0xmok8e.fsf@elephly.net> <87k1rsb9ex.fsf@elephly.net> <3e099b0b-e3ec-2bbb-6d10-5b7e48c4dff6@swecha.net> <300fd917-6742-3ef1-044d-4b0f38a44250@swecha.net> <87a7sm4v5j.fsf@elephly.net> <3d5eca09-7730-bd38-265b-7942d0ea16ed@swecha.net> <878t864i59.fsf@elephly.net> <87o9gwpcmx.fsf@elephly.net> <2f71be8d-c672-c66a-0b16-bc3abc748754@swecha.net> <877enjpquf.fsf@elephly.net> <557b30de-5aa2-113f-7e90-a4a23e86bb07@swecha.net> <87602zbrcc.fsf@elephly.net> <328742c6-f96f-74b8-68ef-3b165a6199aa@swecha.net> <87zi0a3m3t.fsf@elephly.net> <07c93c07-2172-6bf1-6188-88830c1d8b4c@swecha.net> <87o9gpyq4t.fsf@elephly.net> <91773c8b-3072-2a82-dca3-cbeb5adf826d@swecha.net> <87fu1zznl3.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------5B73D65643B4350E7DFB4086" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQfrW-0002ie-Oy for guix-devel@gnu.org; Wed, 06 Jun 2018 17:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQfrQ-0001u8-Vz for guix-devel@gnu.org; Wed, 06 Jun 2018 17:20:58 -0400 In-Reply-To: <87fu1zznl3.fsf@elephly.net> Content-Language: en-US List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel This is a multi-part message in MIME format. --------------5B73D65643B4350E7DFB4086 Content-Type: multipart/alternative; boundary="------------54D4E0650F864EE0EC177A8C" --------------54D4E0650F864EE0EC177A8C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 SGkgUmljYXJkbywKClBhdGNoIGZpbGUgaXMgYXR0YWNoZWQgd2l0aCBjaGFuZ2VzLgoKSSBt b2RpZmllZCBndWl4L3NjcmlwdHMvYnVpbGQuc2NtCsKgwqDCoMKgwqDCoMKgLyhwYXJhbWV0 ZXJpemUgKChjdXJyZW50LWJ1aWxkLW91dHB1dC1wb3J0IChpZiBxdWlldD8vLwovL8KgwqDC oMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDC oMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgICglbWFrZS12 b2lkLXBvcnQKInciKS8vCi8vwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKg wqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKg wqDCoMKgwqDCoMKgwqDCoAooY3VycmVudC1lcnJvci1wb3J0KSkpKS8vCi8KdG8gYnkgUkVQ TEFDSU5HIHRoaXMgdG8gdXNlIGNvbG9yZWQgb3V0cHV0CgrCoMKgwqDCoMKgwqAvKHBhcmFt ZXRlcml6ZSAoKGN1cnJlbnQtYnVpbGQtb3V0cHV0LXBvcnTCoApjb2xvcmZ1bC1idWlsZC1v dXRwdXQtcG9ydCkpLwoKClVJLnNjbSBoYWQgdGhlIG5lY2Vzc2FyeSBjaGFuZ2VzLgoKCkkg YW0gZ2V0dGluZyB0aGUgZm9sbG93aW5nIGVycm9yIHdoZW4gYn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8 Content-Transfer-Encoding: 8bit

Hi Ricardo,

Patch file is attached with changes.

I modified guix/scripts/build.scm
        (parameterize ((current-build-output-port (if quiet?
                                                     (%make-void-port "w")
                                                      (current-error-port))))

to by REPLACING this to use colored output

       (parameterize ((current-build-output-port  colorful-build-output-port))


UI.scm had the necessary changes.


I am getting the following error when building a package

In ice-9/boot-9.scm:
    837:9  6 (catch _ _ #<procedure 7f6bc6a0c468 at guix/ui.scm:589?> ?)
    837:9  5 (catch _ _ #<procedure 7f6bc6a0c480 at guix/ui.scm:697?> ?)
In guix/scripts/build.scm:
   781:24  4 (_)
In guix/store.scm:
   936:15  3 (_ #<build-daemon 256.97 919e60> _ _)
   620:13  2 (process-stderr _ _)
In unknown file:
           1 (display "@ build-started /gnu/store/gxv20gis2i4xk8nmn?" ?)
           0 (display "@ build-started /gnu/store/gxv20gis2i4xk8nmn?" ?)

ERROR: In procedure display:
ERROR: In procedure display: Wrong type argument in position 2: #«parameter> 870600 proc: #<procedure 779340 at ice-9/boot-9.scm:1419:15 () | (x)»
--------------54D4E0650F864EE0EC177A8C-- --------------5B73D65643B4350E7DFB4086 Content-Type: text/x-patch; name="0001-guix-Add-coloring-soft-port.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-guix-Add-coloring-soft-port.patch" =46rom 3b74ea60a13fef3141f4bedb52f9e8131aaec101 Mon Sep 17 00:00:00 2001 From: Sahithi Yarlagadda Date: Tue, 5 Jun 2018 00:08:32 +0530 Subject: [PATCH] guix: Add coloring soft port. * guix/ui.scm (handle-string): New procedures. (colorful-build-output-port): New variable. guix: Added colorful-build-output-port to build.scm instead of default --- guix/scripts/build.scm | 5 +---- guix/ui.scm | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) mode change 100644 =3D> 100755 guix/scripts/build.scm mode change 100644 =3D> 100755 guix/ui.scm diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm old mode 100644 new mode 100755 index 4dd4fbccd..be457443b --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -732,10 +732,7 @@ needed." (with-store store ;; Set the build options before we do anything else. (set-build-options-from-command-line store opts) - - (parameterize ((current-build-output-port (if quiet? - (%make-void-port "= w") - (current-error-por= t)))) +(parameterize ((current-build-output-port colorful-build-output-port)) (let* ((mode (assoc-ref opts 'build-mode)) (drv (options->derivations store opts)) (urls (map (cut string-append <> "/log") diff --git a/guix/ui.scm b/guix/ui.scm old mode 100644 new mode 100755 index 80f1a4d77..7774cf78c --- a/guix/ui.scm +++ b/guix/ui.scm @@ -109,7 +109,7 @@ warning info guix-main - colorize-string)) + colorful-build-output-port)) =20 ;;; Commentary: ;;; @@ -1631,4 +1631,44 @@ be reset such that subsequent output will not have= any colors in effect." str (color 'RESET))) =20 +=20 +(define (handle-string str) + (let ((message (or (and=3D> (string-match "^(starting phase)(.*)" s= tr) + (lambda (m) + (string-append + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN))))) + + (and=3D> (string-match "^(phase) (.*) (succeeded after) (.*) (sec= onds)" str) + (lambda (m) + (string-append + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(BLUE)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(BLUE))))) + + (and=3D> (string-match "^(phase)(.*) (failed after) (.*) (seconds= )" str) + (lambda (m) + (string-append + (colorize-string (match:substring m 1) '(RED)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(RED)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(RED))))) + + ;; Didn=E2=80=99t match, so return unmodified string. + str))) + (display message (current-error-port)))) + +(define colorful-build-output-port + (make-soft-port + (vector + (lambda (c) (write c current-error-port)) + handle-string + (lambda () (display "." current-error-port)) + (lambda () (char-upcase (read-char))) + (lambda () (display "@" current-error-port))) + "rw")) + ;;; ui.scm ends here --=20 2.11.0 --------------5B73D65643B4350E7DFB4086--