feat: custom hosted packages via ssh+git; fix #464

Use git to install packages hosted in a custom server
via ssh using a URL like: owner@host.xz:path/to/repo
This commit is contained in:
Jorge Bucaran 2018-10-13 02:05:46 +09:00
parent da792f6887
commit 4d953fa72e
No known key found for this signature in database
GPG key ID: E54BA3C0E646DB30

View file

@ -203,34 +203,31 @@ function _fisher_pkg_fetch_all
echo "cannot install \"$id\" -- is this a valid file?" >&2 echo "cannot install \"$id\" -- is this a valid file?" >&2
end end
continue continue
case https://\* ssh://\* {github,gitlab}.com/\* bitbucket.org/\*
case \*/\*
set id "github.com/$id"
case \*
echo "cannot install \"$id\" without a prefix -- should be <owner>/$id" >&2
continue
end end
echo $id | command awk '{ command awk -v ID=$id -v FS=/ 'BEGIN {
split($0, tmp, /@/) if (split(ID, tmp, /@+|:/) > 2) {
if (tmp[4]) sub("@"tmp[4], "", ID)
pkg = tmp[1] print ID "\t" tmp[2]"/"tmp[1]"/"tmp[3] "\t" (tmp[4] ? tmp[4] : "master")
tag = tmp[2] ? tmp[2] : "master" } else {
name = tmp[split(pkg, tmp, "/")] pkg = split(ID, _, "/") <= 2 ? "github.com/"tmp[1] : tmp[1]
tag = tmp[2] ? tmp[2] : "master"
print (\ print (\
pkg ~ /^github\.com/ ? "https://codeload."pkg"/tar.gz/"tag : \ pkg ~ /^github/ ? "https://codeload."pkg"/tar.gz/"tag : \
pkg ~ /^gitlab\.com/ ? "https://"pkg"/-/archive/"tag"/"name"-"tag".tar.gz" : \ pkg ~ /^gitlab/ ? "https://"pkg"/-/archive/"tag"/"tmp[split(pkg, tmp, "/")]"-"tag".tar.gz" : \
pkg ~ /^bitbucket\.org/ ? "https://"pkg"/get/"tag".tar.gz" : pkg \ pkg ~ /^bitbucket/ ? "https://"pkg"/get/"tag".tar.gz" : pkg \
) "\t" pkg ) "\t" pkg
}' | read -l url pkg }
}' | read -l url pkg tag
if test ! -d "$fisher_config/$pkg" if test ! -d "$fisher_config/$pkg"
fish -c " fish -c "
echo fetching $url >&2 echo fetching $url >&2
command mkdir -p \"$fisher_config/$pkg\" command mkdir -p \"$fisher_config/$pkg\"
if test ! -z \"$tag\"
if curl -Ss $url 2>&1 | tar -xzf- -C \"$fisher_config/$pkg\" --strip-components=1 2>/dev/null command git clone $url \"$fisher_config/$pkg\" --branch $tag --depth 1 2>/dev/null
or echo cannot clone \"$url\" -- is this a valid url\? >&2
else if curl -Ss $url 2>&1 | tar -xzf- -C \"$fisher_config/$pkg\" --strip-components=1 2>/dev/null
command mkdir -p \"$fisher_cache/$pkg\" command mkdir -p \"$fisher_cache/$pkg\"
command cp -Rf \"$fisher_config/$pkg\" \"$fisher_cache/$pkg/..\" command cp -Rf \"$fisher_config/$pkg\" \"$fisher_cache/$pkg/..\"
else if test -d \"$fisher_cache/$pkg\" else if test -d \"$fisher_cache/$pkg\"
@ -385,8 +382,7 @@ function _fisher_fishfile_format -a pkgs
return s return s
} }
function get_pkg_id(s) { function get_pkg_id(s) {
n = split(s, tmp, "@+") return (split(s, tmp, /@+|:/) > 2) ? tmp[2]"/"tmp[1]"/"tmp[3] : tmp[1]
return (s ~ /.+@.+\..+:.+/) ? tmp[1]tmp[2] : tmp[1]
} }
' '
end end