[Pkg-ocaml-maint-commits] [SCM] oasis2debian project branch, master, updated. a85c25dc2305eccf3507acf59d7cbbc09b4201dc

Sylvain Le Gall gildor at debian.org
Wed Feb 9 15:58:51 UTC 2011


The following commit has been merged in the master branch:
commit 440d02f6655a5fbbc8e0f4ed3b85a10096b794b8
Author: Sylvain Le Gall <gildor at debian.org>
Date:   Wed Feb 9 10:58:20 2011 +0000

    Separate action update/init/get from main

diff --git a/.gitignore b/.gitignore
index 74d517a..3af9222 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 Main.byte
+test.byte
 _build
 setup.log
 setup.data
diff --git a/_oasis b/_oasis
index b1149d7..682629a 100644
--- a/_oasis
+++ b/_oasis
@@ -12,14 +12,26 @@ FilesAB:     src/Version.ml.ab
 Executable oasis2debian
   Path:         src
   MainIs:       Main.ml
-  BuildDepends: oasis (>= 0.2.0), xstrp4, fileutils (>= 0.4.2), pcre, 
-                oasis.base
+  BuildDepends: oasis (>= 0.2.0), oasis.base, 
+                xstrp4 (>= 1.8), 
+                fileutils (>= 0.4.2), 
+                pcre, 
+                debian-formats (>= 0.0.1), 
+                xdg-basedir (>= 0.0.1), 
+                inifiles (>= 1.2)
   
 Executable test
   Path:         test
   MainIs:       test.ml
+  Install:      false
   BuildDepends: oUnit (>= 1.1.0), fileutils (>= 0.4.2), unix
 
 Test main
   Command: $test -exec $oasis2debian
   TestTools: oasis2debian, test
+  Run: false
+
+Test "ocaml-sqlexpr"
+  Command: $oasis2debian update
+  TestTools: oasis2debian
+  WorkingDirectory: /home/gildor/debian/pkg-ocaml-maint/packages/ocaml-sqlexpr
diff --git a/_tags b/_tags
index 29376cd..447cff5 100644
--- a/_tags
+++ b/_tags
@@ -24,7 +24,7 @@
 # Executable oasis2debian
 # OASIS_STOP
 
-"src/Main.ml": syntax_camlp4o
+"src/ActInit.ml": syntax_camlp4o
 "src/Control.ml": syntax_camlp4o
 "src/Copyright.ml": syntax_camlp4o
 "src/Rules.ml": syntax_camlp4o
diff --git a/src/ActGet.ml b/src/ActGet.ml
new file mode 100644
index 0000000..343b902
--- /dev/null
+++ b/src/ActGet.ml
@@ -0,0 +1,3 @@
+
+let run ~ctxt args =
+  ()
diff --git a/src/ActHelp.ml b/src/ActHelp.ml
new file mode 100644
index 0000000..b88516a
--- /dev/null
+++ b/src/ActHelp.ml
@@ -0,0 +1,9 @@
+
+(** Display help 
+  *)
+
+let run ~ctxt args = 
+  prerr_endline "Help"
+
+let display ~ctxt _ = 
+  prerr_endline "Coucou"
diff --git a/src/ActInit.ml b/src/ActInit.ml
new file mode 100644
index 0000000..11e7249
--- /dev/null
+++ b/src/ActInit.ml
@@ -0,0 +1,86 @@
+
+(** Init action 
+  *)
+
+open OASISTypes
+open OASISMessage
+open FileUtil
+open Common
+
+let itp =
+  Conf.create
+    ~cli:"--itp"
+    "Bug number of the ITP for the package"
+    Conf.ShortInput
+
+let bts_query =
+  Conf.create_full 
+    ~cli:"--bts-query"
+    bool_of_string
+    "Query the BTS for ITP (true/false)"
+    (Conf.Value true)
+
+let dh_compat = "7"
+
+let run ~ctxt args = 
+
+  let t = 
+    Load.load ~ctxt args
+  in
+
+  (* Create debian/ and debian/compat *)
+  let () = 
+    debian_with_fn "compat"
+      (fun chn -> output_string chn (dh_compat^"\n"))
+  in
+
+  (* Create debian/gbp.conf *)
+  let () = 
+    debian_with_fn "gbp.conf"
+      (fun chn ->
+         output_string chn
+           "[DEFAULT]\n\
+            pristine-tar = True\n\
+            cleaner = debuild clean && dh_quilt_unpatch && dh_clean\n")
+  in
+
+  (* Create debian/source *)
+  let () = 
+    debian_with_fn "source/format"
+      (output_content "3.0 (quilt)")
+  in
+
+  (* Create debian/changelog *)
+  let () = 
+    let pkg_version = 
+      OASISVersion.string_of_version t.pkg.version
+    in
+
+    if debian_not_exist "changelog" then
+      begin
+        let itp = 
+          Conf.get ~ctxt itp 
+        in
+        let opts =
+          ""
+        in
+        let opts =
+          if Conf.get ~ctxt bts_query then
+            opts
+          else
+            opts^" --no-query"
+        in
+          assert_command ~ctxt  
+            (interpolate 
+               "dch --create --package $t.deb_name --newversion $pkg_version-1 --closes $itp $opts")
+      end
+  in
+
+  let () = 
+    Control.create t;
+    Copyright.create ~ctxt t;
+    Rules.create t;
+    DhFiles.create ~ctxt t
+  in 
+
+    ()
diff --git a/src/ActUpdate.ml b/src/ActUpdate.ml
new file mode 100644
index 0000000..bdb93fa
--- /dev/null
+++ b/src/ActUpdate.ml
@@ -0,0 +1,38 @@
+
+(** Update action 
+  *)
+
+open DebianFormats
+open Common
+
+let run ~ctxt args = 
+
+  let t = 
+    Load.load ~ctxt args
+  in
+
+  let ctl_source, ctl_binaries = 
+    let chn = 
+      open_in "debian/control"
+    in
+      try 
+        let res =
+          Control.parse (IO.input_channel chn)
+        in
+          close_in chn;
+          res
+      with e ->
+        close_in chn;
+        raise e
+  in
+  let ctl_build_depends =
+    List.map 
+      (function
+         | ((pkg, None), _) :: _ -> pkg
+         | ((pkg, Some (op, ver)), _) :: _ -> pkg^" ("^op^" "^ver^")"
+         | [] -> "<unknown>")
+      ctl_source.Control.build_depends
+  in
+
+    prerr_endline ("oasis: "^(String.concat ", " t.build_depends));
+    prerr_endline ("control: "^(String.concat ", " ctl_build_depends))
diff --git a/src/Load.ml b/src/Load.ml
new file mode 100644
index 0000000..f6503b2
--- /dev/null
+++ b/src/Load.ml
@@ -0,0 +1,121 @@
+
+
+(** Create a [Common.t] datastructure, using available data
+  *)
+
+open OASISMessage
+open OASISTypes
+open Common
+open FileUtil
+
+let description = 
+  Conf.create 
+    ~cli:"--description"
+    "Long description of the package"
+    Conf.LongInput
+
+let homepage =
+  Conf.create 
+    ~cli:"--homepage"
+    "Homepage of the package"
+    Conf.ShortInput
+
+let uploader =
+  Conf.create 
+    ~cli:"--uploader"
+    "Uploader of the package"
+    (Conf.Fun
+       (fun () ->
+          try 
+            Printf.sprintf 
+              "%s <%s>"
+              (Sys.getenv "DEBFULLNAME")
+              (Sys.getenv "DEBEMAIL")
+          with _ ->
+            failwith "Unable to guess uploader"))
+
+let deb_name =
+  Conf.create 
+    ~cli:"--debian-name"
+    "Source package name in Debian (e.g. extunix becomes ocaml-extunix)"
+    Conf.ShortInput
+
+
+let load ~ctxt args = 
+
+  let pkg = 
+    OASISParse.from_file
+      ~ctxt
+      "_oasis"
+  in
+                 
+  let expr = 
+    Expr.create ~ctxt pkg
+  in
+
+  let pkg_generic =
+    PkgGeneric.create ~ctxt expr pkg
+  in
+
+  let dflt r x =
+    match x, Conf.is_set r with 
+      | Some e, false -> 
+          Conf.set r e
+      | _ ->
+          ()
+  in
+
+  let () = 
+    dflt description pkg.OASISTypes.description;
+    dflt homepage    pkg.OASISTypes.homepage
+  in
+
+  let () = 
+    let cur_dn = FilePath.basename (pwd ()) in
+    let pkg_nm = pkg.OASISTypes.name in
+      if pkg_nm = cur_dn then
+        Conf.set deb_name cur_dn
+      else
+        warning ~ctxt 
+          "OASIS name (%s) and directory name (%s) are not the same, \
+           cannot set Debian name"
+          pkg_nm cur_dn
+  in
+
+  let () = 
+    Arg.parse_argv
+      ~current:(ref 0)
+      args
+      (Arg.align !Conf.all_args)
+      (fun s -> 
+         failwith 
+           (Printf.sprintf
+              "Don't know what to do with '%s'"
+              s))
+      (Printf.sprintf 
+         "oasis2debian v%s by Sylvain Le Gall"
+         Version.ver)
+  in
+
+  let t = 
+    {
+      build_depends = BuildDepends.get ~ctxt pkg [];
+      description   = Conf.get ~ctxt description;
+      homepage      = Conf.get ~ctxt homepage;
+      uploader      = Conf.get ~ctxt uploader;
+      deb_name      = Conf.get ~ctxt deb_name;
+      pkg           = pkg;
+      pkg_generic   = pkg_generic;
+      expr          = expr;
+      deb_exec      = None;
+      deb_dev       = None;
+      deb_doc       = None;
+    }
+  in
+
+  let t = 
+    (* Fix package generated *)
+    GenPkg.set ~ctxt t
+  in
+
+    t
diff --git a/src/Main.ml b/src/Main.ml
index 416eb0a..684fdb7 100644
--- a/src/Main.ml
+++ b/src/Main.ml
@@ -19,57 +19,8 @@
 (*  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA               *)
 (********************************************************************************)
 
-open OASISTypes
-open OASISMessage
-open FileUtil
-open Common
-
-let dh_compat = "7"
-
-let description = 
-  Conf.create 
-    ~cli:"--description"
-    "Long description of the package"
-    Conf.LongInput
-
-let homepage =
-  Conf.create 
-    ~cli:"--homepage"
-    "Homepage of the package"
-    Conf.ShortInput
-
-let uploader =
-  Conf.create 
-    ~cli:"--uploader"
-    "Uploader of the package"
-    (Conf.Fun
-       (fun () ->
-          try 
-            Printf.sprintf 
-              "%s <%s>"
-              (Sys.getenv "DEBFULLNAME")
-              (Sys.getenv "DEBEMAIL")
-          with _ ->
-            failwith "Unable to guess uploader"))
-
-let deb_name =
-  Conf.create 
-    ~cli:"--debian-name"
-    "Source package name in Debian (e.g. extunix becomes ocaml-extunix)"
-    Conf.ShortInput
 
-let itp =
-  Conf.create
-    ~cli:"--itp"
-    "Bug number of the ITP for the package"
-    Conf.ShortInput
-
-let bts_query =
-  Conf.create_full 
-    ~cli:"--bts-query"
-    bool_of_string
-    "Query the BTS for ITP (true/false)"
-    (Conf.Value true)
+open OASISMessage
 
 let () = 
   let () = 
@@ -83,132 +34,32 @@ let () =
          OASISContext.ignore_plugins = true}
   in
 
-  let pkg = 
-    OASISParse.from_file
-      ~ctxt
-      "_oasis"
-  in
-                 
-  let expr = 
-    Expr.create ~ctxt pkg
-  in
-
-  let pkg_generic =
-    PkgGeneric.create ~ctxt expr pkg
-  in
-
-  let dflt r x =
-    match x, Conf.is_set r with 
-      | Some e, false -> 
-          Conf.set r e
-      | _ ->
-          ()
-  in
-
-  let () = 
-    dflt description pkg.OASISTypes.description;
-    dflt homepage    pkg.OASISTypes.homepage
-  in
-
-  let () = 
-    let cur_dn = FilePath.basename (pwd ()) in
-    let pkg_nm = pkg.OASISTypes.name in
-      if pkg_nm = cur_dn then
-        Conf.set deb_name cur_dn
-      else
-        warning ~ctxt 
-          "OASIS name (%s) and directory name (%s) are not the same, \
-           cannot set Debian name"
-          pkg_nm cur_dn
-  in
-
-  let () = 
-    Arg.parse
-      (Arg.align !Conf.all_args)
-      (fun s -> 
-         failwith 
-           (Printf.sprintf
-              "Don't know what to do with '%s'"
-              s))
-      (Printf.sprintf 
-         "oasis2debian v%s by Sylvain Le Gall"
-         Version.ver)
-  in
-
-  let t = 
-    {
-      build_depends = BuildDepends.get ~ctxt pkg [];
-      description   = Conf.get ~ctxt description;
-      homepage      = Conf.get ~ctxt homepage;
-      uploader      = Conf.get ~ctxt uploader;
-      deb_name      = Conf.get ~ctxt deb_name;
-      pkg           = pkg;
-      pkg_generic   = pkg_generic;
-      expr          = expr;
-      deb_exec      = None;
-      deb_dev       = None;
-      deb_doc       = None;
-    }
-  in
-
-  let t = 
-    (* Fix package generated *)
-    GenPkg.set ~ctxt t
-  in
-
-  (* Create debian/ and debian/compat *)
-  let () = 
-    debian_with_fn "compat"
-      (fun chn -> output_string chn (dh_compat^"\n"))
-  in
-
-  (* Create debian/gbp.conf *)
-  let () = 
-    debian_with_fn "gbp.conf"
-      (fun chn ->
-         output_string chn
-           "[DEFAULT]\n\
-            pristine-tar = True\n\
-            cleaner = debuild clean && dh_quilt_unpatch && dh_clean\n")
-  in
-
-  (* Create debian/source *)
-  let () = 
-    debian_with_fn "source/format"
-      (output_content "3.0 (quilt)")
-  in
-
-  (* Create debian/changelog *)
-  let () = 
-    let pkg_version = 
-      OASISVersion.string_of_version t.pkg.version
-    in
-
-    if debian_not_exist "changelog" then
+    if Array.length Sys.argv >= 2 then
       begin
-        let itp = 
-          Conf.get ~ctxt itp 
-        in
-        let opts =
-          ""
+        let args = 
+          Array.sub Sys.argv 1 ((Array.length Sys.argv) - 1)
         in
-        let opts =
-          if Conf.get ~ctxt bts_query then
-            opts
-          else
-            opts^" --no-query"
+        let run =
+          match Sys.argv.(1) with 
+            | "init" ->
+                ActInit.run
+            | "get" ->
+                ActGet.run
+            | "update" ->
+                ActUpdate.run
+            | "help" ->
+                ActHelp.run
+            | str ->
+                ActHelp.display ~ctxt stderr;
+                error ~ctxt "No action %s defined" str;
+                exit 2
         in
-          assert_command ~ctxt  
-            (interpolate 
-               "dch --create --package $t.deb_name --newversion $pkg_version-1 --closes $itp $opts")
+          run ~ctxt args
+      end
+    else
+      begin
+        ActHelp.display ~ctxt stderr;
+        error ~ctxt "Not enough arguments";
+        exit 2
       end
-  in
-
-  let () = 
-    Control.create t;
-    Copyright.create ~ctxt t;
-    Rules.create t;
-    DhFiles.create ~ctxt t
-  in 
 
-    ()

-- 
oasis2debian project



More information about the Pkg-ocaml-maint-commits mailing list