- use release revision and ocaml-calendar.patch

OBS-URL: https://build.opensuse.org/package/show/devel:languages:ocaml/ocaml-calendar?expand=0&rev=25
This commit is contained in:
Olaf Hering 2021-01-28 20:57:24 +00:00 committed by Git OBS Bridge
parent 8180b19f24
commit 3b238da72f
6 changed files with 277 additions and 19 deletions

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<package>testsuite</package>
</multibuild>

View File

@ -1,11 +1,10 @@
<services>
<service name="tar_scm" mode="disabled">
<param name="url">https://github.com/anuragsoni/calendar.git</param>
<param name="scm">git</param>
<param name="versionformat">2.04</param>
<!-- 1.6 -->
<param name="revision">pervasives-deprecated-408</param>
<param name="filename">ocaml-calendar</param>
<param name="revision">7f7ba9196f6018c8365ac5c6ef4a60891c4da761</param>
<param name="scm">git</param>
<param name="url">https://github.com/ocaml-community/calendar.git</param>
<param name="versionformat">2.04</param>
</service>
<service name="recompress" mode="disabled">
<param name="file">*.tar</param>

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:48db0ea40ae83fca502435f71eb2276e9c21e945e18bb697e5b84578ef31cae6
size 76496
oid sha256:b246712e6d024a5a1e1103c9d74ff498cf28d57b284292526e5dfabddec94905
size 78452

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu Jan 21 21:21:21 UTC 2021 - ohering@suse.de
- use release revision and ocaml-calendar.patch
-------------------------------------------------------------------
Thu Feb 20 20:20:20 UTC 2020 - ohering@suse.de

232
ocaml-calendar.patch Normal file
View File

@ -0,0 +1,232 @@
--- /dev/null
+++ b/calendar.opam
@@ -0,0 +1,25 @@
+opam-version: "2.0"
+version: "dev"
+author: "Julien Signoles"
+maintainer: "ocaml-community"
+license: "LGPL-2.1 with OCaml linking exception"
+synopsis: "Library for handling dates and times in your program"
+build: [
+ ["dune" "build" "-p" name]
+ ["dune" "build" "@doc" "-p" name] {with-doc}
+ ["dune" "runtest" "-p" name] {with-test}
+]
+depends: [
+ "re"
+ "dune" {build}
+ "odoc" {with-doc}
+ "alcotest" {with-test}
+]
+tags: [ "calendar" "date" "time" "datetime" ]
+homepage: "https://github.com/ocaml-community/calendar"
+doc: "https://ocaml-community.github.io/calendar/"
+bug-reports: "https://github.com/ocaml-community/calendar/issues"
+dev-repo: "git+https://github.com/ocaml-community/calendar"
+description:"""
+Calendar is a library for handling dates and times in your program.
+"""
--- /dev/null
+++ b/dune-project
@@ -0,0 +1 @@
+(lang dune 1.0)
--- a/src/date.ml
+++ b/src/date.ml
@@ -70,7 +70,7 @@ let hash = Utils.Int.hash
(* Constructors. *)
let lt (d1 : int * int * int) (d2 : int * int * int) =
- Pervasives.compare d1 d2 < 0
+ Stdlib.compare d1 d2 < 0
(* [date_ok] returns [true] is the date belongs to the Julian period;
[false] otherwise. *)
@@ -249,10 +249,10 @@ module Period = struct
let sub x y = { m = x.m - y.m; d = x.d - y.d }
let opp x = { m = - x.m; d = - x.d }
- (* exactly equivalent to [Pervasives.compare] but more flexible typing *)
+ (* exactly equivalent to [Stdlib.compare] but more flexible typing *)
let compare x y =
- let n = Pervasives.compare x.m y.m in
- if n = 0 then Pervasives.compare x.d y.d else n
+ let n = Stdlib.compare x.m y.m in
+ if n = 0 then Stdlib.compare x.d y.d else n
let equal x y = compare x y = 0
let hash = Hashtbl.hash
@@ -337,7 +337,7 @@ let weeks_in_year y =
| _ -> 52
let week_first_last w y =
- let d = make y 1 1 in
+ let d = make y 1 4 in (* January 4th must be in the first week (ISO 8601) *)
let d = d - d mod 7 in
let b = d + 7 * (w - 1) in
b, 6 + b
--- /dev/null
+++ b/src/dune
@@ -0,0 +1,16 @@
+(library
+ (name calendarLib)
+ (public_name calendar)
+ (libraries re unix)
+ (modules_without_implementation calendar_sig date_sig period time_sig)
+ (flags :standard -warn-error -32 -safe-string))
+
+(rule
+ (targets version.ml)
+ (action
+ (with-stdout-to %{targets}
+ (progn
+ (echo "let version = String.trim \"" %{version:calendar} "\"\n")
+ (echo "let date = String.trim \"")
+ (echo "\"\n")))))
+
--- a/src/printer.ml
+++ b/src/printer.ml
@@ -121,7 +121,7 @@ let gen_day_of_name f fmt name =
let day_of_name = gen_day_of_name name_of_day "%a"
let day_of_short_name = gen_day_of_name short_name_of_day "%A"
-let word_regexp = ref (Str.regexp "[a-zA-Z]+")
+let word_regexp = ref (Re.Str.regexp "[a-zA-Z]+")
let set_word_regexp r = word_regexp := r
@@ -181,7 +181,7 @@ struct
let print_int pad k n = print_number fmt pad k (Lazy.force n) in
let print_string pad s =
let pad s = match pad with
- | Uppercase -> String.uppercase s
+ | Uppercase -> String.uppercase_ascii s
| Empty | Zero | Blank -> s
in
Format.pp_print_string fmt (pad (Lazy.force s))
@@ -236,7 +236,7 @@ struct
| 'n' -> print_char '\n'
| 'p' -> print_string pad apm
| 'P' ->
- Format.pp_print_string fmt (String.lowercase (Lazy.force apm))
+ Format.pp_print_string fmt (String.lowercase_ascii (Lazy.force apm))
| 'r' ->
print_time pad shour;
print_char ' ';
@@ -259,10 +259,10 @@ struct
print_number fmt Zero 10 0
| ':' ->
let idx =
- try Str.search_forward (Str.regexp "z\\|:z\\|::z") f (i+1)
+ try Re.Str.search_forward (Re.Str.regexp "z\\|:z\\|::z") f (i+1)
with Not_found -> bad_format f
in
- let next = Str.matched_string f in
+ let next = Re.Str.matched_string f in
if idx <> i+1 then bad_format f;
if Lazy.force tz >= 0 then print_char '+';
print_int pad 10 tz;
@@ -352,15 +352,15 @@ struct
in
let read_word ?(regexp=(!word_regexp)) () =
let jn =
- try Str.search_forward regexp s !j with Not_found -> not_match f s
+ try Re.Str.search_forward regexp s !j with Not_found -> not_match f s
in
if jn <> !j then not_match f s;
- let w = Str.matched_string s in
+ let w = Re.Str.matched_string s in
j := jn + String.length w;
w
in
let read_float =
- let regexp = Str.regexp "[0-9][0-9]\\(\\.[0-9]*\\)?" in
+ let regexp = Re.Str.regexp "[0-9][0-9]\\(\\.[0-9]*\\)?" in
fun () ->
try float_of_string (read_word ~regexp ())
with Failure _ -> not_match f s
@@ -390,7 +390,7 @@ struct
let parse_y () = year := read_number 2 + 1900 in
let parse_Y () = year := read_number 4 in
let parse_tz () =
- let sign = match read_word ~regexp:(Str.regexp "[\\+-]") () with
+ let sign = match read_word ~regexp:(Re.Str.regexp "[\\+-]") () with
| "+" -> -1
| "-" -> 1
| _ -> assert false
--- a/src/printer.mli
+++ b/src/printer.mli
@@ -125,7 +125,7 @@ val short_name_of_month : Date.month ->
[name_of_month d].
Used by the specifier [%b]. *)
-val set_word_regexp: Str.regexp -> unit
+val set_word_regexp: Re.Str.regexp -> unit
(** Set the regular expression used to recognize words in
[from_fstring]. Default is [[a-zA-Z]*].
@since 1.10 *)
--- a/src/time_Zone.ml
+++ b/src/time_Zone.ml
@@ -44,7 +44,6 @@ let gap_gmt_local =
let current () = !tz
let change = function
- | UTC_Plus x when out_of_bounds x -> invalid_arg "Not a valid time zone"
| _ as t -> tz := t
let gap t1 t2 =
--- a/src/utils.ml
+++ b/src/utils.ml
@@ -29,8 +29,8 @@ end
module Int = struct
type t = int
- let equal = Pervasives.(=)
- let compare = Pervasives.compare
+ let equal = Stdlib.(=)
+ let compare = Stdlib.compare
let hash = Hashtbl.hash
end
@@ -38,7 +38,7 @@ module Float = struct
type t = float
- let precision = ref 1e-3
+ let precision = ref 1e-8
let set_precision f = precision := f
--- a/src/utils.mli
+++ b/src/utils.mli
@@ -58,8 +58,8 @@ module Float: sig
val set_precision: float -> unit
(** Set the precision of [equal] and [compare] for float.
If the precision is [p], then the floats [x] and [y] are equal iff
- [abs(x-y) < p]. By default, the precision is [1e-3] (that is one
- millisecond if floats represents seconds). *)
+ [abs(x-y) < p]. By default, the precision is [1e-8] (that is 0.864
+ milliseconds if floats represent days). *)
val round: t -> int
(** Round a float to the nearest integer. *)
--- /dev/null
+++ b/tests/dune
@@ -0,0 +1,8 @@
+(executable
+ (name test)
+ (libraries calendar))
+
+(alias
+ (name runtest)
+ (deps test.exe)
+ (action (run ./test.exe -e)))
--- a/tests/test_timezone.ml
+++ b/tests/test_timezone.ml
@@ -29,6 +29,7 @@ open Time_Zone;;
include Gen_test;;
reset ();;
+change UTC;;
test (current () = UTC) "current () = UTC";;
change Local;;
test (current () = Local) "current () = Local";;

View File

@ -1,7 +1,7 @@
#
# spec file for package ocaml-calendar
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -16,23 +16,34 @@
#
%bcond_with ocaml_alcotest
Name: ocaml-calendar
%define build_flavor @BUILD_FLAVOR@%{nil}
%if "%{build_flavor}" == "testsuite"
%define nsuffix -testsuite
%else
%define nsuffix %{nil}
%endif
%define pkg ocaml-calendar
Name: %{pkg}%{nsuffix}
Version: 2.04
Release: 0
%{?ocaml_preserve_bytecode}
Summary: Objective Caml library for managing dates and times
License: LGPL-2.0
License: LGPL-2.0-only
Group: Development/Languages/OCaml
Url: https://github.com/ocaml-community/calendar
Source0: %{name}-%{version}.tar.xz
URL: https://opam.ocaml.org/packages/calendar
Source0: %{pkg}-%{version}.tar.xz
Patch0: ocaml-calendar.patch
BuildRequires: ocaml
BuildRequires: ocaml-dune
BuildRequires: ocaml-rpm-macros >= 20200220
BuildRequires: ocaml-rpm-macros >= 20210121
%if 1
BuildRequires: ocamlfind(re)
BuildRequires: ocamlfind(unix)
%if %{with ocaml_alcotest}
BuildRequires: ocamlfind(alcotest)
%endif
%if "%{build_flavor}" == "testsuite"
BuildRequires: ocamlfind(calendar)
%endif
%description
@ -48,25 +59,33 @@ The %{name}-devel package contains libraries and signature files for
developing applications that use %{name}.
%prep
%autosetup -p1
%autosetup -p1 -n %{pkg}-%{version}
%build
sed -i~ '/system date/d' src/dune
diff -u "$_"~ "$_" && exit 1
dune_release_pkgs='calendar'
%ocaml_dune_setup
%if "%{build_flavor}" == ""
%ocaml_dune_build
%ocaml_dune_test
%endif
%install
%if "%{build_flavor}" == ""
%ocaml_dune_install
%ocaml_create_file_list
%endif
%if "%{build_flavor}" == "testsuite"
%check
dune_test_tolerate_fail='dune_test_tolerate_fail'
%ocaml_dune_test
%endif
%if "%{build_flavor}" == ""
%files -f %{name}.files
%files devel -f %{name}.files.devel
%endif
%changelog