0
guidol

tutorial show armbian-package versions in login motd

Recommended Posts

A while ago I did create  a armbian-package-information for at the motd of the login:

Now the line for the kernel does show 2 versions because there are "Version:" and "Config -Version:"

 

root@npi-neo2-24(192.168.6.24):~# dpkg -s linux-image-$BRANCH-$LINUXFAMILY|grep Version
Version: 5.96
Config-Version: 5.96

root@npi-neo2-24(192.168.6.24):~# dpkg -s linux-image-$BRANCH-$LINUXFAMILY|grep Version|cut -f 2 -d ' '
5.96
5.96

So I had to find another way/command to get the information once ;)
I did go back from "dpkg -s" to "dpkg -l" and greped there the version-info:

root@npi-neo2-24(192.168.6.24):~# dpkg -l | awk -v env_var="linux-image-$BRANCH-$LINUXFAMILY" '$2==env_var { print $3 }'
5.96

# end-part of /etc/update-motd.d/10-armbian-header
# NEW version
# ===============================================================================================================
ARMBIAN_bsp=$(more /etc/armbian-release|grep VERSION|cut -f 2 -d '=')
ARMBIAN_kernel=$(dpkg -l | awk -v env_var="linux-image-$BRANCH-$LINUXFAMILY" '$2==env_var { print $3 }')
ARMBIAN_uboot=$(dpkg -l | awk -v env_var="linux-u-boot-$BOARD-$BRANCH" '$2==env_var { print $3 }')
ARMBIAN_dtb=$(dpkg -l | awk -v env_var="linux-dtb-$BRANCH-$LINUXFAMILY" '$2==env_var { print $3 }')
ARMBIAN_firmware=$(dpkg -l | awk -v env_var="armbian-firmware" '$2==env_var { print $3 }')
ARMBIAN_config=$(dpkg -l | awk -v env_var="armbian-config" '$2==env_var { print $3 }')

printf 'package bsp-kernel[\e[0;91m%s\x1B[0m] u-boot[\e[0;91m%s\x1B[0m] dtb[\e[0;91m%s\x1B[0m] firmware[\e[0;91m%s\x1B[0m] config[\e[0;91m%s\x1B[0m]\n' "$ARMBIAN_kernel" "$ARMBIAN_uboot" "$ARMBIAN_dtb" "$ARMBIAN_firmware" "$ARMBIAN_config"
printf '\n'
# ===============================================================================================================

 

After successfully getting the kernel-version only once- I edited the other commands to the "dpkg -l" version - and the result is clear as before :)

 _   _ ____  _   _   _              ____
| \ | |  _ \(_) | \ | | ___  ___   |___ \
|  \| | |_) | | |  \| |/ _ \/ _ \    __) |
| |\  |  __/| | | |\  |  __/ (_) |  / __/
|_| \_|_|   |_| |_| \_|\___|\___/  |_____|

Welcome to Debian Buster with Armbian Linux 5.3.3-sunxi64
package bsp-kernel[5.98.191003] u-boot[5.96] dtb[5.98.191003] firmware[5.96] config[5.96]

The only drawback is, when you use a dev-kernel/-dtb on a next-installation (using other kernel via armbian-config) then $BRANCH is next and your kernel is dev :(

root@npi-neo2-24(192.168.6.24):~# dpkg -l|grep image
ii  linux-image-dev-sunxi64           5.98.191003                         arm64        Linux kernel, version 5.3.3-sunxi64
rc  linux-image-next-sunxi64          5.96                                arm64        Linux kernel, version 4.19.71-sunxi64

root@npi-neo2-24(192.168.6.24):~# dpkg -l|grep dtb
ii  linux-dtb-dev-sunxi64             5.98.191003                         arm64        Linux DTB, version 5.3.3-sunxi64


# ARMBIAN_kernel=$(dpkg -l | awk -v env_var="linux-image-$BRANCH-$LINUXFAMILY" '$2==env_var { print $3 }')
ARMBIAN_kernel=$(dpkg -l | awk -v env_var="linux-image-dev-$LINUXFAMILY" '$2==env_var { print $3 }')

# ARMBIAN_dtb=$(dpkg -l | awk -v env_var="linux-dtb-$BRANCH-$LINUXFAMILY" '$2==env_var { print $3 }')
ARMBIAN_dtb=$(dpkg -l | awk -v env_var="linux-dtb-dev-$LINUXFAMILY" '$2==env_var { print $3 }')

 

 

PS: I also did try - before this - the package apt-show-versions (lists available package versions with distribution)

but this takes much too long to resolve and needs this additionally package :(

 

 

package_info.jpg

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
0