summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-10-06 12:29:37 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-10-06 12:29:37 +0300
commit82e7dd702013d3679fda438333de30afdec17a4f (patch)
tree1db44eb07c21310e04e75b01b8b4ae2ef9d0dc8e /scripts
parent1c83af6e10302346a765e484d38cdac3ff619436 (diff)
downloadlibrpm-tizen-82e7dd702013d3679fda438333de30afdec17a4f.tar.gz
librpm-tizen-82e7dd702013d3679fda438333de30afdec17a4f.tar.bz2
librpm-tizen-82e7dd702013d3679fda438333de30afdec17a4f.zip
Add OCaml dependency generator scripts (Richard W.M. Jones)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am1
-rw-r--r--scripts/ocaml-find-provides.sh61
-rw-r--r--scripts/ocaml-find-requires.sh73
3 files changed, 135 insertions, 0 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 05df2ef13..8ced6c48c 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -32,6 +32,7 @@ rpmconfig_SCRIPTS = \
perl.prov perl.req perldeps.pl pythondeps.sh osgideps.pl \
mono-find-requires mono-find-provides \
pkgconfigdeps.sh libtooldeps.sh \
+ ocaml-find-requires.sh ocaml-find-provides.sh \
fontconfig.prov desktop-file.prov \
rpmdb_loadcvt rpmdiff rpm2cpio.sh tcl.req tgpg
diff --git a/scripts/ocaml-find-provides.sh b/scripts/ocaml-find-provides.sh
new file mode 100644
index 000000000..007b4ca29
--- /dev/null
+++ b/scripts/ocaml-find-provides.sh
@@ -0,0 +1,61 @@
+#!/bin/sh -
+# OCaml-specific "find-provides" for RPM.
+# By Richard W.M. Jones <rjones@redhat.com>
+# $Id: ocaml-find-provides.sh,v 1.2 2007/09/06 11:49:59 rjones Exp $
+
+#set -x
+
+# Usage:
+# (1) Add the following to the spec file:
+# %define _use_internal_dependency_generator 0
+# %define __find_requires /usr/lib/rpm/ocaml-find-requires.sh
+# %define __find_provides /usr/lib/rpm/ocaml-find-provides.sh
+#
+# (2) If you don't want the module to depend on the exact compiler
+# version then use ocaml-find-requires.sh -c, but this is not something
+# you should do normally.
+#
+# (3) For any modules which you want to ignore, use '-i Modulename'.
+
+OCAMLOBJINFO=ocamlobjinfo
+TEMP=`getopt -o i:f: -n ocaml-find-provides.sh -- "$@"`
+if [ $? != 0 ]; then echo "ocaml-find-provides.sh: failed" >&2; exit 1; fi
+eval set -- "$TEMP"
+
+ignore_modules=nOTREAL
+
+while true; do
+ case "$1" in
+ -i) ignore_modules="$2 $ignore_modules"; shift 2;;
+ -f) OCAMLOBJINFO="$2"; shift 2;;
+ --) shift; break;;
+ *) echo "ocaml-find-provides.sh: option error at $1"; exit 1;;
+ esac
+done
+
+# Get the list of files.
+files=`sed "s/['\"]/\\\&/g"`
+
+# Get list of .cmi, .cmo and .cma files.
+files=`echo $files | tr [:blank:] '\n' | grep '\.cm[ioa]$'`
+
+if [ -z "$files" ]; then exit 0; fi
+
+# Get the list of modules exported by the files.
+modules=`$OCAMLOBJINFO $files |
+ grep -E '(Unit|Module) name: ' |
+ awk '{print $3}'`
+
+# Turn list of modules into a regexp that matches the module names.
+modules_re=`echo $modules | sed 's/ /|/g'`
+ignore_modules_re=`echo $ignore_modules | sed 's/ /|/g'`
+
+# Get a list of the modules these file(s) provide.
+$OCAMLOBJINFO $files |
+grep -Eo '[0-9a-f]{32}[[:space:]]+[A-Za-z0-9_]+' |
+grep -E '[0-9a-f]{32}[[:space:]]+'"($modules_re)\$" |
+while read md5sum module; do
+ echo "ocaml($module) = $md5sum"
+done |
+grep -Ev "$ignore_modules_re" |
+sort -u
diff --git a/scripts/ocaml-find-requires.sh b/scripts/ocaml-find-requires.sh
new file mode 100644
index 000000000..654747f05
--- /dev/null
+++ b/scripts/ocaml-find-requires.sh
@@ -0,0 +1,73 @@
+#!/bin/sh -
+# OCaml-specific "find-requires" for RPM.
+# By Richard W.M. Jones <rjones@redhat.com>
+# $Id: ocaml-find-requires.sh,v 1.5 2009/10/04 22:34:51 rjones Exp $
+
+#set -x
+
+# Usage:
+# (1) Add the following to the spec file:
+# %define _use_internal_dependency_generator 0
+# %define __find_requires /usr/lib/rpm/ocaml-find-requires.sh
+# %define __find_provides /usr/lib/rpm/ocaml-find-provides.sh
+#
+# (2) If you don't want the module to depend on the exact compiler
+# version then use ocaml-find-requires.sh -c, but this is not something
+# you should do normally.
+#
+# (3) For any modules which you want to ignore, use '-i Modulename'.
+
+OCAMLOBJINFO=ocamlobjinfo
+TEMP=`getopt -o ci:f: -n ocaml-find-requires.sh -- "$@"`
+if [ $? != 0 ]; then echo "ocaml-find-requires.sh: failed" >&2; exit 1; fi
+eval set -- "$TEMP"
+
+emit_compiler_version=yes
+ignore_modules=nOTREAL
+
+while true; do
+ case "$1" in
+ -c) emit_compiler_version=; shift;;
+ -i) ignore_modules="$2 $ignore_modules"; shift 2;;
+ -f) OCAMLOBJINFO="$2"; shift 2;;
+ --) shift; break;;
+ *) echo "ocaml-find-requires.sh: option error at $1"; exit 1;;
+ esac
+done
+
+# Get the list of files.
+files=`sed "s/['\"]/\\\&/g"`
+
+# Use ordinary find-requires first.
+echo $files | tr [:blank:] '\n' | /usr/lib/rpm/find-requires
+
+# Get list of .cmi, .cmo and .cma files.
+files=`echo $files | tr [:blank:] '\n' | grep '\.cm[ioa]$'`
+
+if [ -z "$files" ]; then exit 0; fi
+
+# Get the list of modules exported by the file(s).
+modules=`$OCAMLOBJINFO $files |
+ grep -E '(Unit|Module) name: ' |
+ awk '{print $3}'`
+
+# Turn list of modules into a regexp that matches the module names.
+modules_re=`echo $modules | sed 's/ /|/g'`
+ignore_modules_re=`echo $ignore_modules | sed 's/ /|/g'`
+
+# Get a list of the modules these file(s) depend on.
+$OCAMLOBJINFO $files |
+grep -Eo '[0-9a-f]{32}[[:space:]]+[A-Za-z0-9_]+' |
+grep -Ev '[0-9a-f]{32}[[:space:]]+'"($modules_re)\$" |
+while read md5sum module; do
+ echo "ocaml($module) = $md5sum"
+done |
+grep -Ev "$ignore_modules_re" |
+grep -Ev "^ocaml\((Annot|Asttypes|Outcometree|Cmo_format|Parsetree)\) =" |
+sort -u
+
+if [ -n "$emit_compiler_version" ]; then
+ # Every OCaml program depends on the version of the
+ # runtime which was used to compile it.
+ echo "ocaml(runtime) = `ocamlrun -version | awk '{print $NF}' | sed 's/\+.*//'`"
+fi