update_coreutils 893 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # Quick script to copy coreutil files into Nagios area
  3. # Pass $1 as top level of coreutils source dir
  4. # Expects to be run in the lib directory
  5. function die { echo $1; exit 1; }
  6. function copy_if_newer { [[ $1 -nt $2 ]] && cp $1 $2; }
  7. coreutils_dir=$1
  8. [[ -z $coreutils_dir ]] && die "Please specify coreutils directory"
  9. cwd=`pwd`
  10. [[ ${cwd##*/} != "lib" ]] && die "Must be run in lib directory"
  11. # Get list of files from EXTRA_DIST in Makefile.am
  12. # Need \\\ because the perl needs \\ but one is escaped
  13. files="`perl -ne '$a=1 if s/^EXTRA_DIST\s*=\s*|libnagiosplug_a_SOURCES\s*=\s*//; $a=0 if /^\s*$/; if ($a==1) {s/\\\//; print $_}' Makefile.am`"
  14. for i in $files ; do
  15. if [[ -e $coreutils_dir/lib/$i ]] ; then
  16. copy_if_newer $coreutils_dir/lib/$i ./$i
  17. elif [[ -e $coreutils_dir/m4/$i ]] ; then
  18. copy_if_newer $coreutils_dir/m4/$i ./$i
  19. else
  20. echo "Not found: $i"
  21. fi
  22. done