Skip to content
Snippets Groups Projects

Checkupdates: Preserve pacman colors when printing the list of pending updates

Merged Robin Candau requested to merge antiz/pacman-contrib:checkupdates_colors into master
1 unresolved thread

The colors for the listing of pending updates are inherited from the "Color" option in /etc/pacman.conf (since it uses pacman -Qu to generate the list).

However, since the list is put into an array via a mapfile the colors are not preserved. Indeed, the "Color" option in /etc/pacman.conf correspond to the --color auto pacman flag which prints colors only when outputting onto in a TTY (which a mapfile/array is not :sweat_smile:) and the lack of coloring seems confusing for users (see #117 (closed) & #1 (closed)).

This commit makes checkupdates forcing the use of --color always during the pacman -Qu command in the mapfile to generate the list of pending updates with colors for users that have the "Color" option enabled in the pacman.conf.

Edited by Robin Candau

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • mentioned in issue #117 (closed)

  • Author Contributor

    Here's a PKGUILD to build a pacman-contrib package including this change for testing purposes:

    # Maintainer: Johannes Löthberg <johannes@kyriasis.com>
    # Maintainer: Daniel M. Capella <polyzen@archlinux.org>
    
    pkgname=pacman-contrib
    pkgver=1.10.1
    pkgrel=1
    pkgdesc='Contributed scripts and tools for pacman systems'
    arch=('x86_64')
    url=https://gitlab.archlinux.org/antiz/pacman-contrib
    license=('GPL')
    depends=('fakeroot' 'pacman' 'perl')
    makedepends=('asciidoc' 'git')
    optdepends=('diffutils: for pacdiff'
                'findutils: for pacdiff --find'
                'mlocate: for pacdiff --locate'
                'sudo: privilege elevation for several scripts'
                'vim: default merge program for pacdiff')
    source=("git+$url.git#branch=checkupdates_colors")
    b2sums=('SKIP')
    validpgpkeys=('04DC3FB1445FECA813C27EFAEA4F7B321A906AD9') # Daniel M. Capella <polyzen@archlinux.org>
    #             '5134EF9EAF65F95B6BB1608E50FB9B273A9D0BB5')  # Johannes Löthberg <johannes@kyriasis.com>
    
    prepare() {
      cd $pkgname
      ./autogen.sh
    }
    
    build() {
      cd $pkgname
      ./configure \
        --prefix=/usr \
        --sysconfdir=/etc \
        --localstatedir=/var
      make
    }
    
    check() {
      cd $pkgname
      make check
    }
    
    package() {
      cd $pkgname
      make DESTDIR="$pkgdir" install
    }
    
    # vim:set ts=2 sw=2 et:
  • Robin Candau changed the description

    changed the description

  • Robin Candau added 2 commits

    added 2 commits

    • efdf14a3 - Revert "Checkupdates: Preserve pacman colors when printing the list of pending updates"
    • 6aa3c15c - Force the updates array to keep pacman colors if the Color option is used in pacman.conf

    Compare with previous version

  • Robin Candau marked this merge request as draft

    marked this merge request as draft

  • Robin Candau added 1 commit

    added 1 commit

    Compare with previous version

  • Robin Candau added 1 commit

    added 1 commit

    • 9b1b52c9 - Use --color always as the mapfile isn't a TTY

    Compare with previous version

  • Robin Candau marked this merge request as ready

    marked this merge request as ready

  • Robin Candau changed the description

    changed the description

  • Robin Candau added 1 commit

    added 1 commit

    • f98efcc7 - Use `--color always` during the `pacman -Qu` command in the mapfile to...

    Compare with previous version

  • Robin Candau changed the description

    changed the description

    • I wonder if we should also replace --nocolor with --color=<always|never|auto> :thinking:

    • Author Contributor

      Eventually... If the aim for pacman-contrib is to stay close to pacman's way of handling such option, then maybe we should consider this indeed.
      Although, checkupdates isn't the only script with the --nocolor option so, if anything, it should be done globally in a separate MR IMO.

      PS: Thanks for the fixup commit. I wasn't sure if we wanted to link the color option from checkupdates to this (since it's actually another package's option) but I guess it makes sense that way!

      Edited by Robin Candau
    • Please register or sign in to reply
  • mentioned in commit 5472d4f7

Please register or sign in to reply
Loading