Code

Removing build directory after creating distribution
[nagiosplug.git] / tools / update_coreutils
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
6 function die { echo $1; exit 1; }
8 function copy_if_newer { [[ $1 -nt $2 ]] && cp $1 $2; }
10 coreutils_dir=$1
12 [[ -z $coreutils_dir ]] && die "Please specify coreutils directory"
14 cwd=`pwd`
16 [[ ${cwd##*/} != "lib" ]] && die "Must be run in lib directory"
18 # Get list of files from EXTRA_DIST in Makefile.am
19 # Need \\\ because the perl needs \\ but one is escaped
20 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`"
22 for i in $files ; do
23         if [[ -e $coreutils_dir/lib/$i ]] ; then
24                 copy_if_newer $coreutils_dir/lib/$i ./$i
25         elif [[ -e $coreutils_dir/m4/$i ]] ; then
26                 copy_if_newer $coreutils_dir/m4/$i ./$i
27         else
28                 echo "Not found: $i"
29         fi
30 done