Whamcloud - gitweb
LU-7421 utils: getparam_display() should reset popt
[fs/lustre-release.git] / build / gen_filelist.sh
1 #!/bin/sh
2
3 # Run this script after a package install and pre uninstall
4 usage()
5 {
6         echo "Usage: $0 <root_dir> <create|remove>"
7         exit 1
8 }
9
10 if [ $# -ne 2 ]; then usage; fi
11 if [ !  -d $1 ]; then usage; fi
12
13 NAME=$(basename "$0" .sh)
14 ROOT_DIR="$1"
15 FILELIST="$(dirname $ROOT_DIR)/$NAME.filelist"
16 MIC_LIST="$(micctrl --status | grep "mic[0-9]*:" | sed -ne 's/\(mic[0-9]*\):.*$/\1/gp')"
17 case "$2" in
18 create)
19         EXCLUDE="\(share\|include\|src\)"
20
21         # Create filelist for Intel(R) Xeon Phi(TM) infrastructure
22         for i in $(rpm -ql $NAME | grep $ROOT_DIR | grep -v $EXCLUDE); do
23                 find $ROOT_DIR -path $i -type f -printf "file /%P $(basename $ROOT_DIR)/%P %#m 0 0\n"
24                 dir=$(dirname $i)
25                 while [ "$dir" != "$ROOT_DIR" ]; do
26                         echo "dir $dir 0755 0 0" | sed -e "s#$ROOT_DIR##"
27                         dir=$(dirname $dir)
28                 done
29                 # Link scripts for autorun after boot (NOT READY YET)
30                 #if [ -n "$(echo $i | grep '/init.d/')" ]; then
31                 #       echo "slink /etc/rc3.d/S31$(basename $i) ../init.d/$(basename $i) 0755 0 0"
32                 #fi
33         done | sort -u > $FILELIST
34
35         micctrl --overlay=filelist --source=$(dirname $ROOT_DIR) --target=$FILELIST --state=on $MIC_LIST
36         ;;
37 remove)
38         micctrl --overlay=filelist --source=$(dirname $ROOT_DIR) --target=$FILELIST --state=delete $MIC_LIST
39         rm -f $FILELIST
40         ;;
41 *)
42         usage
43         ;;
44 esac
45 exit 0