[Pkg-ocaml-maint-commits] r1730 - in
trunk/packages/findlib/trunk/debian: . bash_completion patches
Stefano Zacchiroli
zack at costa.debian.org
Thu Sep 1 10:24:03 UTC 2005
Author: zack
Date: 2005-09-01 10:24:02 +0000 (Thu, 01 Sep 2005)
New Revision: 1730
Added:
trunk/packages/findlib/trunk/debian/bash_completion/
trunk/packages/findlib/trunk/debian/bash_completion/ocamlfind
trunk/packages/findlib/trunk/debian/patches/23_include.dpatch
Modified:
trunk/packages/findlib/trunk/debian/changelog
trunk/packages/findlib/trunk/debian/ocaml-findlib.dirs
trunk/packages/findlib/trunk/debian/ocaml-findlib.install
trunk/packages/findlib/trunk/debian/patches/00list
Log:
- bash completion
- include patch
Added: trunk/packages/findlib/trunk/debian/bash_completion/ocamlfind
===================================================================
--- trunk/packages/findlib/trunk/debian/bash_completion/ocamlfind 2005-09-01 06:06:32 UTC (rev 1729)
+++ trunk/packages/findlib/trunk/debian/bash_completion/ocamlfind 2005-09-01 10:24:02 UTC (rev 1730)
@@ -0,0 +1,92 @@
+# Debian GNU/Linux ocamlfind(1) completion
+# Copyright 2005
+# Stefano Zacchiroli <zack at debian.org>
+# License: GNU GPL v2 or later
+
+# inter function communication is achieved via the $_ocamlfind_reply environment
+# variable, it will be unset each time the completion is used
+
+have ocamlfind &&
+_ocamlfind_add()
+{
+ _ocamlfind_reply="$_ocamlfind_reply $1"
+}
+
+[ "$have" ] &&
+_ocamlfind_flags()
+{
+ local cmd res
+ cmd="$1"
+ res="$( ocamlfind $cmd --help 2>/dev/null | \
+ grep '^ -' | sed 's/ *//;s/ .*//' )"
+ _ocamlfind_add "$res"
+}
+
+[ "$have" ] &&
+_ocamlfind_packages()
+{
+ local pkglist oldpkglist res
+ oldpkglist="$1"
+ pkglist=$( ocamlfind list | cut -f 1 -d' ' )
+ if echo "$oldpkglist" | grep -q ','; then
+ oldpkglist=$(echo $oldpkglist | sed 's/\(.*,\).*/\1/')
+ res=""
+ for pkg in $pkglist; do
+ res="$res $oldpkglist$pkg"
+ done
+ else
+ res="$pkglist"
+ fi
+ _ocamlfind_add "$res"
+}
+
+[ "$have" ] &&
+_ocamlfind()
+{
+ local cmd cur prev
+
+ COMPREPLY=()
+ cmd=${COMP_WORDS[1]}
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+ _ocamlfind_reply=""
+
+ if [ $COMP_CWORD -eq 1 ]; then
+ _ocamlfind_add "query ocamlc ocamlcp ocamlmktop ocamlopt ocamldep \
+ ocamlbrowser ocamldoc install remove printconf list opt --help"
+ # TODO missing "pkg/cmd arg ..." completion
+ elif [ $COMP_CWORD -gt 1 ]; then
+ [ "$prev" = "-package" ] || _ocamlfind_flags "$cmd"
+ case "$cmd" in
+ ocamlc|ocamlcp|ocamlmktop|ocamlopt|ocamldep|ocamldoc|opt)
+ if [ "$prev" = "-package" ]; then
+ _ocamlfind_packages "$cur"
+ fi
+ ;;
+ esac
+ case "$cmd" in
+ ocamlc|ocamlcp)
+ _ocamlfind_add "$( ls *.mli *.ml *.cmo *.cma *.c *.o *.a 2> /dev/null )"
+ ;;
+ ocamlopt|opt)
+ _ocamlfind_add "$( ls *.mli *.ml *.cmx *.cmxa *.c *.o *.a 2> /dev/null )"
+ ;;
+ ocamlmktop)
+ _ocamlfind_add "$( ls *.cmo *.cma *.o *.a 2> /dev/null )"
+ ;;
+ esac
+ if [ "$cmd" = "query" ]; then _ocamlfind_packages ""; fi
+ if [ "$cmd" = "printconf" -a $COMP_CWORD -eq 2 ]; then
+ _ocamlfind_add "$( ocamlfind printconf --help | grep '|' | \
+ sed 's/.*(//;s/)//;s/|/ /g' )"
+ fi
+ fi
+ COMPREPLY=( $(compgen -W "$_ocamlfind_reply" -- $cur) )
+ unset _ocamlfind_reply
+ return 0
+}
+
+[ "$have" ] &&
+complete -F _ocamlfind ocamlfind
+
+# vim:set ft=sh:
Modified: trunk/packages/findlib/trunk/debian/changelog
===================================================================
--- trunk/packages/findlib/trunk/debian/changelog 2005-09-01 06:06:32 UTC (rev 1729)
+++ trunk/packages/findlib/trunk/debian/changelog 2005-09-01 10:24:02 UTC (rev 1730)
@@ -1,3 +1,15 @@
+findlib (1.0.4-4) UNRELEASED; urgency=low
+
+ * debian/patches/23_include.dpatch
+ - added support for including configuration files stored in
+ /usr/share/ocaml-findlib/
+ * debian/bash_completion/ocamlfind
+ debian/ocamlfind.install
+ - added ocamlfind bash completion for bash, it gets installed under
+ /etc/bash_completion.d/
+
+ -- Stefano Zacchiroli <zack at debian.org> Thu, 1 Sep 2005 08:13:10 +0200
+
findlib (1.0.4-3) unstable; urgency=medium
* rebuilt against ocaml 3.08.3, changed dependencies and destdir
Modified: trunk/packages/findlib/trunk/debian/ocaml-findlib.dirs
===================================================================
--- trunk/packages/findlib/trunk/debian/ocaml-findlib.dirs 2005-09-01 06:06:32 UTC (rev 1729)
+++ trunk/packages/findlib/trunk/debian/ocaml-findlib.dirs 2005-09-01 10:24:02 UTC (rev 1730)
@@ -1 +1,2 @@
usr/lib/ocaml/3.08.3/METAS
+usr/share/ocaml-findlib
Modified: trunk/packages/findlib/trunk/debian/ocaml-findlib.install
===================================================================
--- trunk/packages/findlib/trunk/debian/ocaml-findlib.install 2005-09-01 06:06:32 UTC (rev 1729)
+++ trunk/packages/findlib/trunk/debian/ocaml-findlib.install 2005-09-01 10:24:02 UTC (rev 1730)
@@ -1 +1,2 @@
-debian/tmp/* /
+debian/tmp/* /
+debian/bash_completion/* /etc/bash_completion.d/
Modified: trunk/packages/findlib/trunk/debian/patches/00list
===================================================================
--- trunk/packages/findlib/trunk/debian/patches/00list 2005-09-01 06:06:32 UTC (rev 1729)
+++ trunk/packages/findlib/trunk/debian/patches/00list 2005-09-01 10:24:02 UTC (rev 1730)
@@ -1,2 +1,3 @@
17_stddirs
19_site_lib_metas
+23_include
Added: trunk/packages/findlib/trunk/debian/patches/23_include.dpatch
===================================================================
--- trunk/packages/findlib/trunk/debian/patches/23_include.dpatch 2005-09-01 06:06:32 UTC (rev 1729)
+++ trunk/packages/findlib/trunk/debian/patches/23_include.dpatch 2005-09-01 10:24:02 UTC (rev 1730)
@@ -0,0 +1,145 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 23_include.dpatch by Stefano Zacchiroli <zack at debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: adds support for 'include="<dir>"' in ocamlfind.conf, if dir is found,
+## DP: all files .conf are read at startup as additional configuration file,
+## DP: with the same syntax as /etc/ocamlfind.conf. Also, modifies debian
+## DP: findlib configuration so that /usr/share/ocaml-findlib/ is included.
+
+ at DPATCH@
+diff -urNad --exclude=CVS --exclude=.svn ./findlib.conf.in /tmp/dpep-work.SKU5zn/findlib-1.0.4/findlib.conf.in
+--- ./findlib.conf.in 2005-08-23 10:05:43.000000000 +0200
++++ /tmp/dpep-work.SKU5zn/findlib-1.0.4/findlib.conf.in 2005-08-23 10:05:43.000000000 +0200
+@@ -1,2 +1,3 @@
+ destdir="/usr/local/lib/ocaml/3.08.3"
+ path="/usr/local/lib/ocaml/3.08.3:@SITELIB@:@SITELIB@/METAS"
++include="/usr/share/ocaml-findlib/"
+diff -urNad --exclude=CVS --exclude=.svn ./src/findlib/findlib.ml /tmp/dpep-work.SKU5zn/findlib-1.0.4/src/findlib/findlib.ml
+--- ./src/findlib/findlib.ml 2005-08-23 10:05:42.000000000 +0200
++++ /tmp/dpep-work.SKU5zn/findlib-1.0.4/src/findlib/findlib.ml 2005-08-23 10:05:43.000000000 +0200
+@@ -82,6 +82,30 @@
+ []
+ ;;
+
++let normalize_dir s =
++ try
++ if s.[String.length s - 1] = '/' then s else s ^ "/"
++ with Invalid_argument _ -> failwith ("Invalid directory \"" ^ s ^ "\"")
++
++ (** @return absolute paths of regular file contained in directory <path> *)
++let ls_conf path =
++ let dir_handle = Unix.opendir path in
++ let is_regular fname = (Unix.stat fname).Unix.st_kind = Unix.S_REG in
++ let is_conf fname =
++ is_regular fname && Filename.check_suffix fname ".conf"
++ && (Filename.basename fname).[0] <> '.'
++ in
++ let entries = ref [] in
++ try
++ while true do
++ let entry = path ^ Unix.readdir dir_handle in
++ if is_conf entry then entries := entry :: !entries
++ done;
++ [] (* dummy *)
++ with End_of_file ->
++ Unix.closedir dir_handle;
++ List.fast_sort Pervasives.compare !entries
++
+ let init
+ ?env_ocamlpath ?env_ocamlfind_destdir ?env_ocamlfind_metadir
+ ?env_ocamlfind_commands ?env_camllib ?env_ldconf
+@@ -100,33 +124,39 @@
+ sys_ocamlbrowser, sys_ocamldoc,
+ sys_search_path, sys_destdir, sys_metadir, sys_stdlib, sys_ldconf = begin
+ if Sys.file_exists config_file then begin
+- let ch = open_in config_file in
+- try
++ let rec vars_of_file fname =
++ let ch = open_in fname in
+ let vars = (Fl_metascanner.parse ch).Fl_metascanner.pkg_defs in
+- let lookup name default =
+- try Fl_metascanner.lookup name [] vars
+- with Not_found -> default
+- in
+- let tuple =
+- ( (lookup "ocamlc" ocamlc_default),
+- (lookup "ocamlopt" ocamlopt_default),
+- (lookup "ocamlcp" ocamlcp_default),
+- (lookup "ocamlmktop" ocamlmktop_default),
+- (lookup "ocamldep" ocamldep_default),
+- (lookup "ocamlbrowser" ocamlbrowser_default),
+- (lookup "ocamldoc" ocamldoc_default),
+- Fl_split.path (lookup "path" ""),
+- (lookup "destdir" ""),
+- (lookup "metadir" "none"),
+- (lookup "stdlib" Findlib_config.ocaml_stdlib),
+- (lookup "ldconf" Findlib_config.ocaml_ldconf)
+- )
+- in
+- close_in ch;
+- tuple
+- with
+- exc ->
+- close_in ch; raise exc
++ close_in ch;
++ List.flatten
++ (List.map
++ (fun var ->
++ if var.Fl_metascanner.def_var = "include" then
++ let dirname = normalize_dir var.Fl_metascanner.def_value in
++ if Sys.file_exists dirname then
++ List.flatten (List.map vars_of_file (ls_conf dirname))
++ else []
++ else [var])
++ vars)
++ in
++ let vars = vars_of_file config_file in
++ let lookup name default =
++ try Fl_metascanner.lookup name [] vars
++ with Not_found -> default
++ in
++ ( (lookup "ocamlc" ocamlc_default),
++ (lookup "ocamlopt" ocamlopt_default),
++ (lookup "ocamlcp" ocamlcp_default),
++ (lookup "ocamlmktop" ocamlmktop_default),
++ (lookup "ocamldep" ocamldep_default),
++ (lookup "ocamlbrowser" ocamlbrowser_default),
++ (lookup "ocamldoc" ocamldoc_default),
++ Fl_split.path (lookup "path" ""),
++ (lookup "destdir" ""),
++ (lookup "metadir" "none"),
++ (lookup "stdlib" Findlib_config.ocaml_stdlib),
++ (lookup "ldconf" Findlib_config.ocaml_ldconf)
++ )
+ end
+ else
+ ( ocamlc_default, ocamlopt_default, ocamlcp_default, ocamlmktop_default,
+diff -urNad --exclude=CVS --exclude=.svn ./src/findlib/Makefile /tmp/dpep-work.SKU5zn/findlib-1.0.4/src/findlib/Makefile
+--- ./src/findlib/Makefile 2005-08-23 10:05:42.000000000 +0200
++++ /tmp/dpep-work.SKU5zn/findlib-1.0.4/src/findlib/Makefile 2005-08-23 10:05:43.000000000 +0200
+@@ -36,11 +36,11 @@
+ opt: ocamlfind_opt$(EXEC_SUFFIX) findlib.cmxa topfind
+
+ ocamlfind$(EXEC_SUFFIX): findlib.cma $(OCAMLFIND_OBJECTS)
+- $(OCAMLC) -custom -o ocamlfind$(EXEC_SUFFIX) findlib.cma unix.cma \
++ $(OCAMLC) -custom -o ocamlfind$(EXEC_SUFFIX) unix.cma findlib.cma \
+ $(OCAMLFIND_OBJECTS)
+
+ ocamlfind_opt$(EXEC_SUFFIX): findlib.cmxa $(OCAMLFIND_XOBJECTS)
+- $(OCAMLOPT) -o ocamlfind_opt$(EXEC_SUFFIX) findlib.cmxa unix.cmxa \
++ $(OCAMLOPT) -o ocamlfind_opt$(EXEC_SUFFIX) unix.cmxa findlib.cmxa \
+ $(OCAMLFIND_XOBJECTS)
+
+ findlib.cma: $(OBJECTS)
+diff -urNad --exclude=CVS --exclude=.svn ./src/findlib/topfind.p /tmp/dpep-work.SKU5zn/findlib-1.0.4/src/findlib/topfind.p
+--- ./src/findlib/topfind.p 2004-04-04 13:42:40.000000000 +0200
++++ /tmp/dpep-work.SKU5zn/findlib-1.0.4/src/findlib/topfind.p 2005-08-23 10:08:57.000000000 +0200
+@@ -4,6 +4,7 @@
+ * working findlib toploop.
+ *)
+
++#load "unix.cma";;
+
+ (* First test whether findlib_top is already loaded. If not, load it now.
+ * The test works by executing the toplevel phrase "Topfind.reset" and
More information about the Pkg-ocaml-maint-commits
mailing list