Package Details: kube-ps1 0.7.0-2

Git Clone URL: https://aur.archlinux.org/kube-ps1.git (read-only, click to copy)
Package Base: kube-ps1
Description: A script that lets you add the current Kubernetes context and namespace configured on kubectl to your Bash/Zsh prompt
Upstream URL: https://github.com/jonmosco/kube-ps1
Keywords: kube kubectl ps1
Licenses: Apache
Submitter: gde.satrigraha
Maintainer: gde.satrigraha
Last Packager: gde.satrigraha
Votes: 0
Popularity: 0.000000
First Submitted: 2019-04-02 19:44 (UTC)
Last Updated: 2019-04-02 19:55 (UTC)

Latest Comments

VannTen commented on 2020-12-09 10:50 (UTC) (edited on 2020-12-09 10:50 (UTC) by VannTen)

A few problems with the package :

  • The install script try to modify the user .bashrc (or .zshrc) but it's executed in root context (sudo pacman -S) so it will not work. Better to leave an informative message and leave it to the users
  • There is png / gif which are packaged with the script, wasting some space
  • The script should be in /usr/share (like for example bash-completions)

Here is a patch that fix those (applicable with git am):

From acd72d65f52900fb08d814a25427b14aad4bd966 Mon Sep 17 00:00:00 2001
From: Max Gautier <mg+archlinux@max.gautier.name>
Date: Wed, 9 Dec 2020 11:40:41 +0100
Subject: [PATCH] Remove .bashrc modif in install script

- The .bashrc modif is executed in root context, so it would not achieve
  the intended purpose
- Put the script in /usr/share/ , like bash completions
- Get rid of unneeded images which were packaged (examples image from
  the source).
---
 PKGBUILD        |  6 ++----
 kube-ps1.pacman | 47 +++--------------------------------------------
 2 files changed, 5 insertions(+), 48 deletions(-)

diff --git a/PKGBUILD b/PKGBUILD
index 4f5023a..f3da02f 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -13,9 +13,7 @@ md5sums=('4cfab48cf524132b97d7b9255ac21f42')
 install="${pkgname}.pacman"

 package() {
-   KUBE_PS1_PATH="$pkgdir/opt/$pkgname"
+   cd "$pkgname-$pkgver"

-   mkdir -p "$KUBE_PS1_PATH"
-   cp -rf "$pkgname-$pkgver"/* "$KUBE_PS1_PATH"
-   chmod a+r "${KUBE_PS1_PATH}/kube-ps1.sh"
+   install -Dm 644 kube-ps1.sh "$pkgdir/usr/share/kube-ps1/kube-ps1.sh"
 }
diff --git a/kube-ps1.pacman b/kube-ps1.pacman
index 08892f4..308d266 100644
--- a/kube-ps1.pacman
+++ b/kube-ps1.pacman
@@ -1,60 +1,19 @@
-KUBE_PS1_PATH="/opt/kube-ps1"
-BASHRC_FILE="$HOME/.bashrc"
-ZSHRC_FILE="$HOME/.zshrc"
+KUBE_PS1_PATH="/usr/share/kube-ps1"

 LINE_SOURCE="source '$KUBE_PS1_PATH/kube-ps1.sh'"
 LINE_PS1_BASH="PS1='[\u@\h \W "'$(kube_ps1)'"]\$ '"
 LINE_PS1_ZSH="PROMPT='"'$(kube_ps1)'"'"'$PROMPT'

 post_install() {
-   echo '################################################################################'
-
-   if [ -f "$BASHRC_FILE" ]; then
-       TMP_FILE=$(mktemp)
-       grep -vF "$LINE_SOURCE" "$BASHRC_FILE" | grep -vF "$LINE_PS1_BASH" > "$TMP_FILE"
-
-       echo "$LINE_SOURCE" >> "$TMP_FILE"
-       echo "$LINE_PS1_BASH" >> "$TMP_FILE"
-
-       mv "$TMP_FILE" "$BASHRC_FILE"
-
-       echo "$BASHRC_FILE file has been modified."
-   fi
-
-   if [ -f "$ZSHRC_FILE" ]; then
-       TMP_FILE=$(mktemp)
-       grep -vF "$LINE_SOURCE" "$ZSHRC_FILE" | grep -vF "$LINE_PS1_ZSH" > "$TMP_FILE"
-
-       echo "$LINE_SOURCE" >> "$TMP_FILE"
-       echo "$LINE_PS1_ZSH" >> "$TMP_FILE"
-
-       mv "$TMP_FILE" "$ZSHRC_FILE"
-
-       echo "$ZSHRC_FILE file has been modified."=
-   fi

    echo 'More information at https://github.com/jonmosco/kube-ps1'
    echo '################################################################################'
-   echo "Add the following lines to another user's bashrc file if needed:"
+   echo "Add the following lines to users' bashrc file if needed:"
    echo "$LINE_SOURCE"
    echo "$LINE_PS1_BASH"
    echo '################################################################################'
-   echo "Add the following lines to another user's zshrc file if needed:"
+   echo "Add the following lines to users' zshrc file if needed:"
    echo "$LINE_SOURCE"
    echo "$LINE_PS1_ZSH"
    echo '################################################################################'
 }
-
-post_remove() {
-   if [ -f "$BASHRC_FILE" ]; then
-       TMP_FILE=$(mktemp)
-       grep -vF "$LINE_SOURCE" "$BASHRC_FILE" | grep -vF "$LINE_PS1_BASH" > "$TMP_FILE"
-       mv "$TMP_FILE" "$BASHRC_FILE"
-   fi
-
-   if [ -f "$ZSHRC_FILE" ]; then
-       TMP_FILE=$(mktemp)
-       grep -vF "$LINE_SOURCE" "$ZSHRC_FILE" | grep -vF "$LINE_PS1_ZSH" > "$TMP_FILE"
-       mv "$TMP_FILE" "$ZSHRC_FILE"
-   fi
-}
-- 
2.29.2

<deleted-account> commented on 2019-10-18 12:55 (UTC)

why on /opt?