author | Olivier Brunel
<jjk@jjacky.com> 2023-07-07 06:14:46 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-07-07 17:07:37 UTC |
parent | f864068341f2075942969678f0555eb8711f7caf |
getdeps | +32 | -32 |
diff --git a/getdeps b/getdeps index 1f3b966..b73aae6 100755 --- a/getdeps +++ b/getdeps @@ -8,16 +8,13 @@ usage() shift cat <<EOF -usage: $0 [ACTION] - - default Clone repo of components & "internal" dependencies +usage: $0 [-n] ACTION list List all components and dependencies - cpnt Clone repo of components only - intdeps Clone repo of "internal" dependencies only - deps Clone repo of all dependencies - dep NAME Clone repo of dependency NAME + cpnt Clone repo of components + deps Clone repo of dependencies + dep NAME [..] Clone repo of dependencies NAME [..] help Show this help screen and exit EOF @@ -60,12 +57,20 @@ list() foreach deps $nb_deps showdep } +mbrun() +{ + if test $dryrun -eq 0; then + run "$@" + else + echo "dry-run: $@" + fi +} + getdep() { local dep=$2 local depname="${dep##*/}" - local intonly=$3 - local rec=$4 + local rec=$3 local cpnt=0 test -e "$dep/cpnt" && cpnt=1 if test $cpnt -eq 1; then @@ -77,19 +82,18 @@ getdep() else dst="deps" fi - if test $intonly -eq 1 && test $cpnt -eq 0 && test ! -e "$dep/files"; then return; fi echo "getting $depname..." if ! test -e "deps"; then run mkdir "deps"; fi if test -e "$dst/$depname"; then warn "cannot clone: '$dst/$depname' already exists" else - run git clone "$(cat $dep/git)" "$dst/$depname" + mbrun git clone "$(cat $dep/git)" "$dst/$depname" local ref="$(cat $dep/ref 2>/dev/null)" if test -z "$ref"; then ref="$(cat $dep/version)"; fi - run git -C "deps/$depname" checkout -b "$prjname" "$ref" + mbrun git -C "$dst/$depname" checkout -b "for-$prjname-$version" "$ref" fi if test $cpnt -eq 1 && ! test -e "$dst/deps/$depname"; then - run ln -s "../$depname" "$dst/deps/$depname" + mbrun ln -s "../$depname" "$dst/deps/$depname" fi # recursive lila dependency @@ -98,10 +102,7 @@ getdep() if ! test -d "deps/$depname/deps"; then run mkdir "deps/$depname/deps"; fi for d in "deps/$depname/meta/deps/"*; do if ! test -d "$d"; then continue; fi - local int=$intonly - if test -e "$d/cpnt"; then int=0; fi - getdep 0 "$d" "$int" "../$rec" - if test "$int" -eq 1 && ! test -e "$d/files"; then continue; fi + getdep 0 "$d" "../$rec" local n="${d##*/}" local p="$(realpath "deps/$n")" if test -e "$d/cpnt"; then @@ -110,7 +111,7 @@ getdep() n="deps/$depname/deps/$n" fi if ! test -e "$n"; then - run ln -s "$p" "$n" + mbrun ln -s "$p" "$n" fi done } @@ -118,31 +119,30 @@ getdep() loadoptions loaddeps +if test $# -eq 0; then usage 0; fi + isdep=0 +dryrun=0 for arg ; do if test $isdep -eq 1; then - if test ! -d meta/deps/$arg; then error 2 "unknown dependency '$arg'"; fi - getdep 0 meta/deps/$arg 0 + if test ! -d meta/deps/$arg; then + warn "unknown dependency '$arg'" + else + getdep 0 meta/deps/$arg + fi continue fi case "$arg" in list) list ;; - cpnt) foreach cpnt $nb_cpnt getdep 0;; - intdeps) foreach deps $nb_deps getdep 1;; - deps) foreach deps $nb_deps getdep 0;; + + cpnt) foreach cpnt $nb_cpnt getdep;; + deps) foreach deps $nb_deps getdep;; dep) isdep=1 ;; - all) ;; + -n|--dry-run) dryrun=1 ;; -h|--help|help) usage 0 ;; - *) error 1 "unknown action '$arg'" ;; + *) dief 1 "unknown action '$arg'" ;; esac done -if test -z "$arg" || test "$arg" = "all"; then - foreach cpnt $nb_cpnt getdep 0 - intonly=1 - test "$arg" = "all" && intonly=0 - foreach deps $nb_deps getdep $intonly -fi - echo "done."