Skip to content

Commit bc4e612

Browse files
committed
port to dune, upgrade opam metadata, build with dune-release
use modern ppx_cstruct as well, which fixes building in a duniverse
1 parent d5a6a29 commit bc4e612

22 files changed

+138
-144
lines changed

.gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
_build/
2-
parse_test.native
3-
empty
4-
tar-format.install
52
*.install
63
*.merlin
4+
.*.swp
5+
empty

.travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ env:
99
- PACKAGE="tar"
1010
- PINS="tar:. tar-unix:. tar-mirage:."
1111
matrix:
12-
- DISTRO="alpine" OCAML_VERSION="4.03.0" PACKAGE="tar-unix"
13-
- DISTRO="alpine" OCAML_VERSION="4.04.2" PACKAGE="tar-mirage"
14-
- DISTRO="alpine" OCAML_VERSION="4.05.0" PACKAGE="tar-mirage"
15-
- DISTRO="alpine" OCAML_VERSION="4.06.0" PACKAGE="tar-unix"
16-
- DISTRO="alpine" OCAML_VERSION="4.06.0" PACKAGE="tar-mirage"
12+
- DISTRO="alpine" OCAML_VERSION="4.03" PACKAGE="tar-unix"
13+
- DISTRO="alpine" OCAML_VERSION="4.04" PACKAGE="tar-mirage"
14+
- DISTRO="alpine" OCAML_VERSION="4.05" PACKAGE="tar-mirage"
15+
- DISTRO="alpine" OCAML_VERSION="4.06" PACKAGE="tar-unix"
16+
- DISTRO="alpine" OCAML_VERSION="4.07" PACKAGE="tar-mirage"

CHANGES.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v1.0.0 (2019-02-03)
2+
- port build to dune from builder (@avsm)
3+
- upgrade opam metadata to 2.0 (@avsm)
4+
- remove topkg in favour of dune-release (@avsm)
5+
- use modern `ppx_cstruct` instead of `cstruct.ppx` (#65 @avsm @djs55)
6+
- test with OCaml 4.07 as well (@avsm)
7+
18
## v0.9.0 (2017-11-25)
29

310
- preliminary support for Cstruct.t-backed tar processing (#54 by @hcarty)

Makefile

+6-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
1-
2-
.PHONY: build clean test
1+
.PHONY: build clean test install uninstall
32

43
build:
5-
jbuilder build @install
4+
dune build
65

76
test:
8-
jbuilder runtest
7+
dune runtest
98

109
install:
11-
jbuilder install
10+
dune install
1211

1312
uninstall:
14-
jbuilder uninstall
13+
dune uninstall
1514

1615
clean:
17-
rm -rf _build
18-
19-
REPO=../opam-repository
20-
PACKAGES=$(REPO)/packages
21-
# until we have https://github.com/ocaml/opam-publish/issues/38
22-
pkg-%:
23-
topkg opam pkg -n $*
24-
mkdir -p $(PACKAGES)/$*
25-
cp -r _build/$*.* $(PACKAGES)/$*/
26-
cd $(PACKAGES) && git add $*
27-
28-
PKGS=$(basename $(wildcard *.opam))
29-
opam-pkg:
30-
$(MAKE) $(PKGS:%=pkg-%)
16+
dune clean

doc/api.odocl

-4
This file was deleted.

dune-project

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(lang dune 1.0)
2+
(name tar)

lib/dune

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(library
2+
(name tar)
3+
(public_name tar)
4+
(wrapped false)
5+
(libraries result cstruct re.str)
6+
(flags :standard -safe-string)
7+
(preprocess (pps ppx_cstruct)))

lib/jbuild

-8
This file was deleted.

lib/tar.ml

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1616
*)
1717

18+
[@@@warning "-32"]
1819

1920
(** Process and create tar file headers *)
2021
module Header = struct
@@ -30,11 +31,11 @@ module Header = struct
3031
done;
3132
Bytes.to_string result
3233

33-
let trim regexp x = match Re_str.split regexp x with
34+
let trim regexp x = match Re.Str.split regexp x with
3435
| [] -> ""
3536
| x :: _ -> x
36-
let trim_numerical = trim (Re_str.regexp "[\000 ]+")
37-
let trim_string = trim (Re_str.regexp "[\000]+")
37+
let trim_numerical = trim (Re.Str.regexp "[\000 ]+")
38+
let trim_string = trim (Re.Str.regexp "[\000]+")
3839

3940
(** Unmarshal an integer field (stored as 0-padded octal) *)
4041
let unmarshal_int (x: string) : int =

lib_test/dune

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(executables
2+
(names parse_test)
3+
(flags :standard -safe-string)
4+
(libraries mirage-block-unix mirage-types-lwt oUnit lwt io-page-unix
5+
tar-unix tar-mirage))
6+
7+
(alias
8+
(name runtest)
9+
(deps
10+
(:< parse_test.exe))
11+
(action
12+
(run %{<})))

lib_test/jbuild

-10
This file was deleted.

lib_test/parse_test.ml

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
* GNU Lesser General Public License for more details.
1313
*)
14+
15+
[@@@warning "-3-27"] (* FIXME: deprecation from the tar library *)
16+
1417
open OUnit
1518
open Tar_lwt_unix
1619
open Lwt
@@ -167,7 +170,7 @@ module Block4096 = struct
167170
| [] -> []
168171
| b :: bs ->
169172
let b' = Cstruct.len b in
170-
for i = 0 to b' do Cstruct.set_uint8 b 0 0 done;
173+
for _ = 0 to b' do Cstruct.set_uint8 b 0 0 done;
171174
let to_drop = max 0 (len + b' - need_to_keep) in
172175
let to_keep = max 0 (b' - to_drop) in
173176
Cstruct.sub b 0 to_keep :: (trimmed (len + b') bs) in

mirage/dune

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(library
2+
(name tar_mirage)
3+
(public_name tar-mirage)
4+
(libraries tar io-page lwt mirage-types-lwt mirage-block mirage-block-lwt)
5+
(flags :standard -safe-string)
6+
(wrapped false))

mirage/jbuild

-7
This file was deleted.

mirage/tar_mirage.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module Make_KV_RO (BLOCK : Mirage_block_lwt.S) = struct
7777
let skip in_channel n =
7878
in_channel.offset <- Int64.(add in_channel.offset (of_int n));
7979
Lwt.return_unit
80-
let get_current_tar_sector in_channel = Int64.div in_channel.offset 512L
80+
let _get_current_tar_sector in_channel = Int64.div in_channel.offset 512L
8181

8282
end
8383
module HR = Tar.HeaderReader(Lwt)(Reader)
@@ -140,7 +140,7 @@ module Make_KV_RO (BLOCK : Mirage_block_lwt.S) = struct
140140
if not(StringMap.mem key t.map)
141141
then Lwt.return (Error (`Unknown_key key))
142142
else begin
143-
let hdr, start_sector = StringMap.find key t.map in
143+
let hdr, _start_sector = StringMap.find key t.map in
144144
Lwt.return (Ok hdr.Tar.Header.file_size)
145145
end
146146
end

pkg/pkg.ml

-8
This file was deleted.

tar-mirage.opam

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
opam-version: "1.2"
2-
maintainer: "[email protected]"
3-
authors: [ "Dave Scott" "Thomas Gazagnaire" "David Allsopp" ]
4-
tags: ["org:xapi-project" "org:mirage"]
5-
homepage: "https://github.com/mirage/ocaml-tar"
6-
bug-reports: "https://github.com/mirage/ocaml-tar/issues"
7-
dev-repo: "https://github.com/mirage/ocaml-tar.git"
8-
doc: "https://mirage.github.io/ocaml-tar/"
9-
10-
build: [
11-
["jbuilder" "subst" "-p" name "--name" name] {pinned}
12-
["jbuilder" "build" "-p" name "-j" jobs]
13-
]
14-
15-
build-test: [
16-
[ "jbuilder" "runtest" ]
17-
]
18-
1+
opam-version: "2.0"
2+
maintainer: "[email protected]"
3+
authors: ["Dave Scott" "Thomas Gazagnaire" "David Allsopp"]
4+
tags: ["org:xapi-project" "org:mirage"]
5+
homepage: "https://github.com/mirage/ocaml-tar"
6+
doc: "https://mirage.github.io/ocaml-tar/"
7+
bug-reports: "https://github.com/mirage/ocaml-tar/issues"
198
depends: [
20-
"jbuilder" {build & >="1.0+beta7"}
21-
"ocamlfind" {build}
9+
"ocaml" {>= "4.04.2"}
10+
"dune" {build & >= "1.0"}
2211
"tar"
23-
"cstruct" {>= "1.9.0"}
24-
"re"
12+
"cstruct" {>= "1.9.0"}
13+
"re" {>="1.7.2"}
2514
"result"
26-
"mirage-block-unix" {test & >= "2.5.0"}
27-
"mirage-types-lwt" {>= "3.0.0"}
15+
"mirage-block-unix" {with-test & >= "2.5.0"}
16+
"mirage-types-lwt" {>= "3.0.0"}
2817
"lwt"
2918
"io-page"
30-
"mirage-block-unix" {test}
31-
"io-page-unix" {test}
32-
"ounit" {test}
19+
"mirage-block-unix" {with-test}
20+
"io-page-unix" {with-test}
21+
"ounit" {with-test}
3322
]
3423
conflicts: [
3524
"mirage-types-lwt" {< "3.0.0"}
3625
]
37-
available: [ ocaml-version >= "4.04.2" ]
26+
build: [
27+
["dune" "subst"] {pinned}
28+
["dune" "build" "-p" name "-j" jobs]
29+
["dune" "runtest" "-p" name "-j" jobs] {with-test}
30+
]
31+
dev-repo: "git+https://github.com/mirage/ocaml-tar.git"
32+
synopsis: "Read and write tar format files via MirageOS interfaces"
33+
description: """
34+
tar is a simple library to read and write tar files with an emphasis on
35+
streaming. This library is functorised over external OS dependencies
36+
to facilitate embedding within MirageOS.
37+
"""

tar-unix.opam

+21-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
opam-version: "1.2"
2-
maintainer: "[email protected]"
3-
authors: [ "Dave Scott" "Thomas Gazagnaire" "David Allsopp" ]
4-
tags: ["org:xapi-project" "org:mirage"]
5-
homepage: "https://github.com/mirage/ocaml-tar"
6-
bug-reports: "https://github.com/mirage/ocaml-tar/issues"
7-
dev-repo: "https://github.com/mirage/ocaml-tar.git"
8-
doc: "https://mirage.github.io/ocaml-tar/"
9-
10-
build: [
11-
["jbuilder" "subst" "-p" name "--name" name] {pinned}
12-
["jbuilder" "build" "-p" name "-j" jobs]
13-
]
14-
1+
opam-version: "2.0"
2+
maintainer: "[email protected]"
3+
authors: ["Dave Scott" "Thomas Gazagnaire" "David Allsopp"]
4+
tags: ["org:xapi-project" "org:mirage"]
5+
homepage: "https://github.com/mirage/ocaml-tar"
6+
doc: "https://mirage.github.io/ocaml-tar/"
7+
bug-reports: "https://github.com/mirage/ocaml-tar/issues"
158
depends: [
16-
"jbuilder" {build & >="1.0+beta7"}
17-
"ocamlfind" {build}
9+
"ocaml" {>= "4.03.0"}
10+
"dune" {build & >= "1.0"}
11+
"ocamlfind" {build}
1812
"tar"
19-
"cstruct" {>= "1.9.0"}
13+
"cstruct" {>= "1.9.0"}
2014
"cstruct-lwt"
2115
"re"
2216
"result"
2317
"lwt"
2418
]
25-
available: [ ocaml-version >= "4.03.0" ]
19+
build: [
20+
["dune" "subst"] {pinned}
21+
["dune" "build" "-p" name "-j" jobs]
22+
]
23+
dev-repo: "git+https://github.com/mirage/ocaml-tar.git"
24+
synopsis: "Decode and encode tar format files from Unix"
25+
description: """
26+
tar is a simple library to read and write tar files with an emphasis on
27+
streaming. This library provides a Unix or Windows compatible interface.
28+
"""

tar.opam

+24-20
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
opam-version: "1.2"
2-
maintainer: "[email protected]"
3-
authors: [ "Dave Scott" "Thomas Gazagnaire" "David Allsopp" ]
4-
tags: ["org:xapi-project" "org:mirage"]
5-
homepage: "https://github.com/mirage/ocaml-tar"
6-
bug-reports: "https://github.com/mirage/ocaml-tar/issues"
7-
dev-repo: "https://github.com/mirage/ocaml-tar.git"
8-
doc: "https://mirage.github.io/ocaml-tar/"
9-
10-
build: [
11-
["jbuilder" "subst" "-p" name "--name" name] {pinned}
12-
["jbuilder" "build" "-p" name "-j" jobs]
13-
]
14-
1+
opam-version: "2.0"
2+
maintainer: "[email protected]"
3+
authors: ["Dave Scott" "Thomas Gazagnaire" "David Allsopp"]
4+
tags: ["org:xapi-project" "org:mirage"]
5+
homepage: "https://github.com/mirage/ocaml-tar"
6+
doc: "https://mirage.github.io/ocaml-tar/"
7+
bug-reports: "https://github.com/mirage/ocaml-tar/issues"
158
depends: [
16-
"jbuilder" {build & >="1.0+beta7"}
17-
"ocamlfind" {build}
18-
"ppx_tools" {build}
19-
"ppx_cstruct" {build}
20-
"cstruct" {>= "1.9.0"}
9+
"ocaml" {>= "4.03.0"}
10+
"dune" {build & >= "1.0"}
11+
"ppx_tools" {build}
12+
"ppx_cstruct" {>= "3.1.0"}
13+
"cstruct" {>= "1.9.0"}
2114
"re"
2215
"result"
2316
]
24-
available: [ ocaml-version >= "4.03.0" ]
17+
build: [
18+
["dune" "subst"] {pinned}
19+
["dune" "build" "-p" name "-j" jobs]
20+
]
21+
dev-repo: "git+https://github.com/mirage/ocaml-tar.git"
22+
synopsis: "Decode and encode tar format files in pure OCaml"
23+
description: """
24+
tar is a simple library to read and write tar files with an emphasis on
25+
streaming.
26+
27+
This is pure OCaml code, no C bindings.
28+
"""

unix/dune

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(library
2+
(name tar_unix)
3+
(public_name tar-unix)
4+
(libraries tar lwt cstruct.lwt)
5+
(flags :standard -safe-string)
6+
(wrapped false))

unix/jbuild

-7
This file was deleted.

unix/tar_unix.ml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1616
*)
1717

18+
[@@@warning "-3"] (* FIXME Tar.HeaderWriter needs to be used here *)
19+
1820
module Driver = struct
1921
type in_channel = Unix.file_descr
2022
type out_channel = Unix.file_descr

0 commit comments

Comments
 (0)