Skip to content

Instantly share code, notes, and snippets.

@Phate6660
Last active January 26, 2022 15:15
Show Gist options
  • Save Phate6660/ce6bc3455ca72ab39b7364a22c28da75 to your computer and use it in GitHub Desktop.
Save Phate6660/ce6bc3455ca72ab39b7364a22c28da75 to your computer and use it in GitHub Desktop.
Modified version check script for LFS to make output a bit easier to read. WIP.
#!/bin/bash
## Simple script to list version numbers of critical development tools
## Original by LFS team / contributor(s), modified by Phate6660.
## Startup
export LC_ALL=C
## Aliases
bash_version="$(bash --version | head -n1 | cut -d" " -f2-4)"
binutils_version="$(ld --version | head -n1 | cut -d" " -f3-)"
bison_version="$(bison --version | head -n1)"
bzip2_version="$(bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-)"
coreutils_version="$(chown --version | head -n1 | cut -d")" -f2)"
diff_version="$(diff --version | head -n1)"
find_version="$(find --version | head -n1)"
gawk_version="$(gawk --version | head -n1)"
gcc_version="$(gcc --version | head -n1)"
gccplusplus_version="$(g++ --version | head -n1)"
glibc_version="$(ldd --version | head -n1 | cut -d" " -f2-)"
grep_version="$(grep --version | head -n1)"
gzip_version="$(gzip --version | head -n1)"
system_info="$(cat /proc/version)"
m4_version="$(m4 --version | head -n1)"
make_version="$(make --version | head -n1)"
patch_version="$(patch --version | head -n1)"
perl_version="$(perl -V:version)"
python_version="$(python3 --version)"
sed_version="$(sed --version | head -n1)"
tar_version="$(tar --version | head -n1)"
makeinfo_version="$(makeinfo --version | head -n1)"
xz_version="$(xz --version | head -n1)"
## Functions
shell_version() {
MYSH=$(readlink -f /bin/sh)
if echo $MYSH | grep -q bash; then
shell_version="/bin/sh -> $MYSH"
else
shell_version="ERROR: /bin/sh does not point to bash, please fix that."
fi
unset MYSH
}
yacc_version() {
if [ -h /usr/bin/yacc ]; then
yacc_version="/usr/bin/yacc -> $(readlink -f /usr/bin/yacc)"
elif [ -x /usr/bin/yacc ]; then
yacc_version="$(/usr/bin/yacc --version | head -n1)"
else
yacc_version="Not installed or not found."
fi
}
awk_version() {
if [ -h /usr/bin/awk ]; then
awk_version="/usr/bin/awk -> $(readlink -f /usr/bin/awk)";
elif [ -x /usr/bin/awk ]; then
awk_version="$(/usr/bin/awk --version | head -n1)"
else
awk_version="awk not found"
fi
}
gccplusplus_complilation_test() {
echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]; then
gccplusplus_complilation_test="g++ compilation OK"
else
gccplusplus_complilation_test="g++ compilation failed"
fi
rm -f dummy.c dummy
}
main() {
echo "
awk = $awk_version
bash = $bash_version
binutils = $binutils_version
bison = $bison_version
bzip2 = $bzip2_version
coreutils = $coreutils_version
diff = $diff_version
find = $find_version
gawk = $gawk_version
gcc = $gcc_version
g++ = $gccplusplus_version
g++ compilation test = $gccplusplus_complilation_test
glibc = $glibc_version
grep = $grep_version
gzip = $gzip_version
system info = $system_info
m4 = $m4_version
make = $make_version
patch = $patch_version
perl = $perl_version
python = $python_version
sed = $sed_version
shell = $shell_version
tar = $tar_version
makeinfo = $makeinfo_version
xz = $xz_version
yacc = $yacc_version
"
}
## Run
awk_version
gccplusplus_complilation_test
shell_version
yacc_version
main
@Phate6660
Copy link
Author

Phate6660 commented Apr 25, 2020

Example output:


awk                   =  /usr/bin/awk -> /usr/bin/gawk
bash                  =  bash, version 4.4.23(1)-release       
binutils              =  (Gentoo 2.33.1 p2) 2.33.1   
bison                 =  bison (GNU Bison) 3.1      
bzip2                 =  bzip2,  Version 1.0.6, 6-Sept-2010.      
coreutils             =   8.31  
diff                  =  diff (GNU diffutils) 3.6       
find                  =  find (GNU findutils) 4.7.0       
gawk                  =  GNU Awk 4.2.1, API: 2.0       
gcc                   =  gcc (Gentoo 9.3.0 p2) 9.3.0        
g++                   =  g++ (Gentoo 9.3.0 p2) 9.3.0
g++ compilation test  =  g++ compilation OK
glibc                 =  (Gentoo 2.29-r7 p8) 2.29      
grep                  =  grep (GNU grep) 3.3       
gzip                  =  gzip 1.9       
system info           =  Linux version 5.4.31-ck-valley (root@gentoo) (gcc version 9.2.0 (Gentoo 9.2.0-r2 p3)) #1 SMP PREEMPT Mon Apr 20 06:39:08 EDT 2020        
m4                    =  m4 (GNU M4) 1.4.18         
make                  =  GNU Make 4.2.1       
patch                 =  GNU patch 2.7.6      
perl                  =  version='5.30.1';       
python                =  Python 3.6.10     
sed                   =  sed (GNU sed) 4.7        
shell                 =  /bin/sh -> /bin/bash
tar                   =  tar (GNU tar) 1.32        
makeinfo              =  texi2any (GNU texinfo) 6.6   
xz                    =  xz (XZ Utils) 5.2.4         
yacc                  =  /usr/bin/yacc -> /usr/bin/yacc.bison

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment