Commit aaf395e0 authored by pcy's avatar pcy
Browse files

add hacks to make go packages work

parent 319ddf77
#!/usr/bin/env bash
find local/ -type f -name "sspt*" | while read -r FILE; do
echo "==> $FILE"
shellcheck -s bash "$FILE"
done
......@@ -298,6 +298,7 @@ sspt_build() {
true
}
sspt_install() {
>&2 echo "NOTE: go doesn't honor \$SSPT_DEST_DIR"
npm install
}
sspt_clean() {
......@@ -576,6 +577,27 @@ sspt_clean() {
sspt_clean_config() {
true
}
EOF
elif [ -d ".git/" ] && ! [ -z "$GOPATH" ] && [[ "$(realpath "$(pwd)")" == "$GOPATH"* ]]; then
cat <<EOF
sspt_config() {
>&2 echo "NOTE: go doesn't honor \$SSPT_DEST_DIR but installs" \
"everything to \$GOPATH/bin"
}
sspt_build() {
go build -v -x
}
sspt_install() {
>&2 echo "NOTE: go doesn't honor \$SSPT_DEST_DIR but installs" \
"everything to \$GOPATH/bin"
go install -v -x
}
sspt_clean() {
go clean -v -x
}
sspt_clean_config() {
true
}
EOF
elif ! [ -z "$CHANGED_DIR" ]; then
# try top directory instead
......
......@@ -14,8 +14,11 @@ Usage: sspt pull [-h|-?|--help]
edit if autogeneration failed) and whether to build or install
the package afterwards (resp. -b and -i, default to false, -i
implies -b) can be specified.
Supported VCSes: git, hg, svn, cvs, bzr, mtn, darcs, http(s), rsync
(Those last two aren't VCSes, but you can get tarballs over them.)
Supported VCSes: git, hg, svn, cvs, bzr, mtn, darcs, go, http(s), rsync
(Those last two aren't VCSes, but you can get tarballs over them. Go
isn't one either, but the Go people are too backwards in package
management so workarounds are needed. Install go packages using the
fake go: uri scheme, eg.: 'go:githost.net/user/package'.)
EOF
}
......@@ -38,6 +41,10 @@ pull_with_vcs() {
fi
case "$1" in
"go") # special case for git
go get -v -x "$2" && \
ln -s -T "$GOPATH/src/${2:3}" "$SSPT_DL_DIR/$PKG_NAME"
;;
"git")
git clone --recursive "$2" "$SSPT_DL_DIR/$PKG_NAME"
;;
......@@ -62,9 +69,9 @@ pull_with_vcs() {
"http"|"https")
local TMP="$(temp_filename)"
if command -v "wget" >/dev/null 2>&1; then
wget "$2" -q -O "$TMP"
wget "$2" -q -O "$TMP" || return 1
elif command -v "curl" >/dev/null 2>&1; then
curl "$2" -S -o "$TMP"
curl "$2" -S -o "$TMP" || return 1
else
>&2 echo "wget nor curl are installed, but they are" \
"required to fetch data over HTTP(S)."
......@@ -78,7 +85,7 @@ pull_with_vcs() {
;;
"rsync")
local TMP="$(temp_filename)"
rsync "$1" "$TMP"
rsync "$1" "$TMP" || return 1
if ! [ -d "$SSPT_DL_DIR/$PKG_NAME" ]; then
mkdir -p "$SSPT_DL_DIR/$PKG_NAME"
fi
......@@ -135,6 +142,9 @@ main() {
"--"*)
pull_with_vcs "${1:2}" "$2"
;;
"go:"*)
pull_with_vcs go "$1" "$2"
;;
"git"*|*".git"|*"github"*|*"gitlab"*|*"git.savannah"*|*"gogs"*|"://git."*|":git."*)
pull_with_vcs git "$1" "$2"
;;
......@@ -180,10 +190,8 @@ main() {
DO_AUTOGEN='y'
fi
if [ "$DO_AUTOGEN" = "y" ]; then
if ! exec_subcommand autogen "$PKG_NAME"; then
DO_EDIT='y'
fi
if [ "$DO_AUTOGEN" = "y" ] && ! exec_subcommand autogen "$PKG_NAME"; then
DO_EDIT='y'
fi
if [ "$DO_EDIT" = "y" ]; then
......
......@@ -11,10 +11,11 @@ edit_the_conf() {
read -r -e -p "Edit the sspt.conf file? (Y/n) " edit_conf
if [ "$edit_conf" != "n" ] && [ "$edit_conf" != "N" ]; then
command -v "$EDITOR" >/dev/null 2>&1 && "$EDITOR" "$cfgfile" && return
command -v "nano" >/dev/null 2>&1 && "nano" "$cfgfile" && return
command -v "nvim" >/dev/null 2>&1 && "nvim" "$cfgfile" && return
command -v "vim" >/dev/null 2>&1 && "vim" "$cfgfile" && return
command -v "vi" >/dev/null 2>&1 && "vi" "$cfgfile" && return
command -v "nano" >/dev/null 2>&1 && "nano" "$cfgfile" && return
command -v "ed" >/dev/null 2>&1 && "ed" "$cfgfile" && return
fi
}
......
* update without upgrade
* aliases (sspt rm foo)
* bulk operations (pull pkg0 pkg1 pkg2 ...)
* aliases (sspt rm foo) -> symlinks?
* bulk operations (pull pkg0 pkg1 pkg2 ...): pull build clean install configure
* modularize sspt-autogen, sspt-pull for easier addition of other vcs
& build system types
* make it more portable
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment