Browse Source

first commit

master
zapashcanon 3 years ago
commit
e19d64cff5
Signed by: zapashcanon GPG Key ID: 8981C3C62D1D28F1
  1. 3
      .gitignore
  2. 8
      LICENSE.md
  3. 37
      README.md
  4. 3
      dune-project
  5. 7
      scripts/build.sh
  6. 7
      scripts/clean.sh
  7. 8
      scripts/format.sh
  8. 3
      src/dune
  9. 41
      src/still_dep.ml

3
.gitignore

@ -0,0 +1,3 @@
_build
*.merlin
*.install

8
LICENSE.md

@ -0,0 +1,8 @@
The ISC License (ISC)
=====================
Copyright © 2019, Léo Andrès
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

37
README.md

@ -0,0 +1,37 @@
# still-dep
still-dep is a small tool to list all packages that *still* depends on a given package.
## Usage
```sh
./still_dep.exe oasis # will list all opam packages that still depends on oasis
```
## Build
To build the executable:
```sh
scripts/build.sh
```
To clean after building:
```sh
scripts/clean.sh
```
## Format
You can format the code using:
```sh
scripts/format.sh
```
## License
See [LICENSE].
[LICENSE]: ./LICENSE.md

3
dune-project

@ -0,0 +1,3 @@
(lang dune 1.11)
(name memo)
(explicit_js_mode)

7
scripts/build.sh

@ -0,0 +1,7 @@
#!/bin/sh
set -eu
( cd "$(dirname "$0")/../"
eval "$(opam env)"
dune build @all )

7
scripts/clean.sh

@ -0,0 +1,7 @@
#!/bin/sh
set -eu
( cd "$(dirname "$0")/../"
eval "$(opam env)"
dune clean )

8
scripts/format.sh

@ -0,0 +1,8 @@
#!/bin/sh
set -eu
( cd "$(dirname "$0")/../"
eval "$(opam env)"
ocamlformat -i src/*.ml )
# ocamlformat -i test/*.ml )

3
src/dune

@ -0,0 +1,3 @@
(executable
(name still_dep)
(libraries unix))

41
src/still_dep.ml

@ -0,0 +1,41 @@
;;
if Array.length Sys.argv <> 2 then (
Format.printf "usage: %s <package name>@." Sys.argv.(0);
exit 1
)
let pkg = Sys.argv.(1)
let chan =
Unix.open_process_in ("opam list --color=never --depopts --depends-on " ^ pkg ^ " -s")
let _ =
try
while true do
(* one rev-dep of pkg *)
let line = input_line chan in
(* the last version of this rev-dep *)
let last_ver =
input_line
(Unix.open_process_in
("opam show --color=never " ^ line ^ " -f version"))
in
let chan' =
Unix.open_process_in
( "opam list --color=never --depopts --required-by " ^ line ^ "." ^ last_ver
^ " -s" )
in
try
while true do
(* one dep of this rev-dep *)
let line' = input_line chan' in
(* if pkg is here, then this rev-dep still depends on pkg *)
if line' = pkg then (
print_endline line;
try Unix.kill (Unix.process_in_pid chan') Sys.sigkill with Sys_error _ -> ();
raise_notrace End_of_file
)
done
with End_of_file -> ignore(Unix.close_process_in chan')
done
with End_of_file -> ()
Loading…
Cancel
Save