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) Add the following to the spec file:
10 # %define _use_internal_dependency_generator 0
11 # %define __find_requires /usr/lib/rpm/ocaml-find-requires.sh
12 # %define __find_provides /usr/lib/rpm/ocaml-find-provides.sh
14 # (2) If you don't want the module to depend on the exact compiler
15 # version then use ocaml-find-requires.sh -c, but this is not something
16 # you should do normally.
18 # (3) For any modules which you want to ignore, use '-i Modulename'.
20 OCAMLOBJINFO=ocamlobjinfo
21 TEMP=`getopt -o i:f: -n ocaml-find-provides.sh -- "$@"`
22 if [ $? != 0 ]; then echo "ocaml-find-provides.sh: failed" >&2; exit 1; fi
25 ignore_modules=nOTREAL
29 -i) ignore_modules="$2 $ignore_modules"; shift 2;;
30 -f) OCAMLOBJINFO="$2"; shift 2;;
32 *) echo "ocaml-find-provides.sh: option error at $1"; exit 1;;
36 # Get the list of files.
37 files=`sed "s/['\"]/\\\&/g"`
39 # Get list of .cmi, .cmo and .cma files.
40 files=`echo $files | tr [:blank:] '\n' | grep '\.cm[ioa]$'`
42 if [ -z "$files" ]; then exit 0; fi
44 # Get the list of modules exported by the files.
45 modules=`$OCAMLOBJINFO $files |
46 grep -E '(Unit|Module) name: ' |
49 # Turn list of modules into a regexp that matches the module names.
50 modules_re=`echo $modules | sed 's/ /|/g'`
51 ignore_modules_re=`echo $ignore_modules | sed 's/ /|/g'`
53 # Get a list of the modules these file(s) provide.
54 $OCAMLOBJINFO $files |
55 grep -Eo '[0-9a-f]{32}[[:space:]]+[A-Za-z0-9_]+' |
56 grep -E '[0-9a-f]{32}[[:space:]]+'"($modules_re)\$" |
57 while read md5sum module; do
58 echo "ocaml($module) = $md5sum"
60 grep -Ev "$ignore_modules_re" |