mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 01:52:26 +08:00
Merge pull request #2321 from Kubuxu/feat/there-is-gx
Do not install gx if user explicitly didn't ask for it
This commit is contained in:
@ -13,7 +13,9 @@ env:
|
|||||||
- TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_go_expensive
|
- TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_go_expensive
|
||||||
- TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_sharness_expensive
|
- TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_sharness_expensive
|
||||||
|
|
||||||
install: make install
|
install:
|
||||||
|
- make toolkit_upgrade
|
||||||
|
- make install
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make $TEST_SUITE
|
- make $TEST_SUITE
|
||||||
|
15
Makefile
15
Makefile
@ -14,11 +14,19 @@ all: help
|
|||||||
godep:
|
godep:
|
||||||
go get github.com/tools/godep
|
go get github.com/tools/godep
|
||||||
|
|
||||||
gx:
|
toolkit_upgrade: gx_upgrade gxgo_upgrade
|
||||||
|
|
||||||
|
gx_upgrade:
|
||||||
go get -u github.com/whyrusleeping/gx
|
go get -u github.com/whyrusleeping/gx
|
||||||
|
|
||||||
|
gxgo_upgrade:
|
||||||
go get -u github.com/whyrusleeping/gx-go
|
go get -u github.com/whyrusleeping/gx-go
|
||||||
|
|
||||||
deps: gx
|
gx_check:
|
||||||
|
@bin/check_gx_program "gx" "0.3" 'Upgrade or install gx using your package manager or run `make gx_upgrade`'
|
||||||
|
@bin/check_gx_program "gx-go" "0.2" 'Upgrade or install gx-go using your package manager or run `make gxgo_upgrade`'
|
||||||
|
|
||||||
|
deps: gx_check
|
||||||
gx --verbose install --global
|
gx --verbose install --global
|
||||||
|
|
||||||
# saves/vendors third-party dependencies to Godeps/_workspace
|
# saves/vendors third-party dependencies to Godeps/_workspace
|
||||||
@ -42,7 +50,7 @@ clean:
|
|||||||
uninstall:
|
uninstall:
|
||||||
cd cmd/ipfs && go clean -i -ldflags=$(ldflags)
|
cd cmd/ipfs && go clean -i -ldflags=$(ldflags)
|
||||||
|
|
||||||
PHONY += all help godep install build nofuse clean uninstall
|
PHONY += all help godep toolkit_upgrade gx_upgrade gxgo_upgrade gx_check deps vendor install build nofuse clean uninstall
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
# tests targets
|
# tests targets
|
||||||
@ -98,6 +106,7 @@ PHONY += test test_short test_expensive
|
|||||||
help:
|
help:
|
||||||
@echo 'DEPENDENCY TARGETS:'
|
@echo 'DEPENDENCY TARGETS:'
|
||||||
@echo ''
|
@echo ''
|
||||||
|
@echo ' deps - Download dependencies using gx'
|
||||||
@echo ' vendor - Create a Godep workspace of 3rd party dependencies'
|
@echo ' vendor - Create a Godep workspace of 3rd party dependencies'
|
||||||
@echo ''
|
@echo ''
|
||||||
@echo 'BUILD TARGETS:'
|
@echo 'BUILD TARGETS:'
|
||||||
|
@ -40,7 +40,7 @@ install:
|
|||||||
# default file handles. Ensure a dummy file descriptor is opened with 'exec'.
|
# default file handles. Ensure a dummy file descriptor is opened with 'exec'.
|
||||||
#
|
#
|
||||||
build_script:
|
build_script:
|
||||||
- '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; export PATH=$GOPATH/bin:$PATH; make nofuse"'
|
- '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; export PATH=$GOPATH/bin:$PATH; make toolkit_upgrade; make nofuse"'
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; export PATH=$GOPATH/bin:$PATH; export GOFLAGS=''-tags nofuse''; export TEST_NO_FUSE=1; export TEST_VERBOSE=1; export TEST_SUITE=test_sharness_expensive; make $TEST_SUITE"'
|
- '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; export PATH=$GOPATH/bin:$PATH; export GOFLAGS=''-tags nofuse''; export TEST_NO_FUSE=1; export TEST_VERBOSE=1; export TEST_SUITE=test_sharness_expensive; make $TEST_SUITE"'
|
||||||
|
90
bin/check_gx_program
Executable file
90
bin/check_gx_program
Executable file
@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Check if a gx program is installed and if its version is at least
|
||||||
|
# equal to a minimum version number.
|
||||||
|
#
|
||||||
|
# Call it for example like this:
|
||||||
|
#
|
||||||
|
# $ check_gx_program "gx-go" "0.2.0" "Use 'make gx_upgrade' to install or upgrade gx-go."
|
||||||
|
#
|
||||||
|
# or:
|
||||||
|
#
|
||||||
|
# $ check_gx_program "gx" "0.3" "Use 'make gx_upgrade' to install or upgrade gx."
|
||||||
|
#
|
||||||
|
|
||||||
|
USAGE="$0 GX_PROGRAM_NAME GX_MIN_VERSION UPGRADE_MSG"
|
||||||
|
|
||||||
|
die() {
|
||||||
|
printf >&2 "fatal: %s\n" "$@"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get arguments
|
||||||
|
|
||||||
|
test "$#" -eq "3" || die "This program must be passed exactly 3 arguments" "Usage: $USAGE"
|
||||||
|
|
||||||
|
GX_PROGRAM_NAME="$1"
|
||||||
|
GX_MIN_VERSION="$2"
|
||||||
|
UPGRADE_MSG="$3"
|
||||||
|
|
||||||
|
die_upgrade() {
|
||||||
|
printf >&2 "fatal: %s\n" "$@"
|
||||||
|
printf >&2 "=> %s\n" "$UPGRADE_MSG"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
major_number() {
|
||||||
|
vers="$1"
|
||||||
|
|
||||||
|
# Hack around 'expr' exiting with code 1 when it outputs 0
|
||||||
|
case "$vers" in
|
||||||
|
0) echo "0" ;;
|
||||||
|
0.*) echo "0" ;;
|
||||||
|
*) expr "$vers" : "\([^.]*\).*" || return 1
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
check_at_least_version() {
|
||||||
|
MIN_VERS="$1"
|
||||||
|
CUR_VERS="$2"
|
||||||
|
PROG_NAME="$3"
|
||||||
|
|
||||||
|
# Get major, minor and fix numbers for each version
|
||||||
|
MIN_MAJ=$(major_number "$MIN_VERS") || die "No major version number in '$MIN_VERS' for '$PROG_NAME'"
|
||||||
|
CUR_MAJ=$(major_number "$CUR_VERS") || die "No major version number in '$CUR_VERS' for '$PROG_NAME'"
|
||||||
|
|
||||||
|
if MIN_MIN=$(expr "$MIN_VERS" : "[^.]*\.\([^.]*\).*"); then
|
||||||
|
MIN_FIX=$(expr "$MIN_VERS" : "[^.]*\.[^.]*\.\([^.]*\).*") || MIN_FIX="0"
|
||||||
|
else
|
||||||
|
MIN_MIN="0"
|
||||||
|
MIN_FIX="0"
|
||||||
|
fi
|
||||||
|
if CUR_MIN=$(expr "$CUR_VERS" : "[^.]*\.\([^.]*\).*"); then
|
||||||
|
CUR_FIX=$(expr "$CUR_VERS" : "[^.]*\.[^.]*\.\([^.]*\).*") || CUR_FIX="0"
|
||||||
|
else
|
||||||
|
CUR_MIN="0"
|
||||||
|
CUR_FIX="0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compare versions
|
||||||
|
VERS_LEAST="$PROG_NAME version '$CUR_VERS' should be at least '$MIN_VERS'"
|
||||||
|
test "$CUR_MAJ" -gt $(expr "$MIN_MAJ" - 1) || die_upgrade "$VERS_LEAST"
|
||||||
|
test "$CUR_MAJ" -gt "$MIN_MAJ" || {
|
||||||
|
test "$CUR_MIN" -gt $(expr "$MIN_MIN" - 1) || die_upgrade "$VERS_LEAST"
|
||||||
|
test "$CUR_MIN" -gt "$MIN_MIN" || {
|
||||||
|
test "$CUR_FIX" -ge "$MIN_FIX" || die_upgrade "$VERS_LEAST"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check that the gx program exists
|
||||||
|
|
||||||
|
type "$GX_PROGRAM_NAME" >/dev/null 2>&1 || die_upgrade "Program $GX_PROGRAM_NAME is not installed!"
|
||||||
|
|
||||||
|
# Check the gx program version
|
||||||
|
|
||||||
|
VERS_STR=$($GX_PROGRAM_NAME -v 2>&1) || die "'$GX_PROGRAM_NAME -v' failed with output: $VERS_STR"
|
||||||
|
|
||||||
|
GX_CUR_VERSION=$(expr "$VERS_STR" : ".*$GX_PROGRAM_NAME.* version \(.*\)") || die "Invalid '$GX_PROGRAM_NAME -v' output: $VERS_STR"
|
||||||
|
|
||||||
|
check_at_least_version "$GX_MIN_VERSION" "$GX_CUR_VERSION" "$GX_PROGRAM_NAME"
|
Reference in New Issue
Block a user