2 # OCaml-specific "find-provides" for RPM.
3 # By Richard W.M. Jones <rjones@redhat.com>
4 # $Id: ocaml-find-provides.sh,v 1.2 2007/09/06 11:49:59 rjones Exp $
9 # (1) If you don't want the module to depend on the exact compiler
10 # version then use ocaml-find-requires.sh -c, but this is not something
11 # you should do normally.
13 # (2) For any modules which you want to ignore, use '-i Modulename'.
15 OCAMLOBJINFO=ocamlobjinfo
16 TEMP=`getopt -o i:f: -n ocaml-find-provides.sh -- "$@"`
17 if [ $? != 0 ]; then echo "ocaml-find-provides.sh: failed" >&2; exit 1; fi
20 ignore_modules=nOTREAL
24 -i) ignore_modules="$2 $ignore_modules"; shift 2;;
25 -f) OCAMLOBJINFO="$2"; shift 2;;
27 *) echo "ocaml-find-provides.sh: option error at $1"; exit 1;;
31 # Get the list of files.
32 files=`sed "s/['\"]/\\\&/g"`
34 # Get list of .cmi, .cmo and .cma files.
35 files=`echo $files | tr '[:blank:]' '\n' | grep '\.cm[ioa]$'`
37 if [ -z "$files" ]; then exit 0; fi
39 # Get the list of modules exported by the files.
40 modules=`$OCAMLOBJINFO $files |
41 grep -E '(Unit|Module) name: ' |
44 # Turn list of modules into a regexp that matches the module names.
45 modules_re=`echo $modules | sed 's/ /|/g'`
46 ignore_modules_re=`echo $ignore_modules | sed 's/ /|/g'`
48 # Get a list of the modules these file(s) provide.
49 $OCAMLOBJINFO $files |
50 grep -Eo '[0-9a-f]{32}[[:space:]]+[A-Za-z0-9_]+' |
51 grep -E '[0-9a-f]{32}[[:space:]]+'"($modules_re)\$" |
52 while read md5sum module; do
53 echo "ocaml($module) = $md5sum"
55 grep -Ev "$ignore_modules_re" |