mirror of
https://github.com/wahyd4/gvm.git
synced 2026-08-09 04:46:19 +10:00
While replacing pakcageset name with "--local", the packageset information will be managed under some/local/repo/.gvm_local folder, and add the root path of repository as the first path in GOPATH and PATH. This makes the repository more portable since we don't store all the go-installed package files under $HOME/.gvm . The repository root path for gvm is definded as $PWD while "pkgset create --local" . When "pkgset list" under some configured local repository, it will list the root path as the first packageset, and marked with "L".
43 lines
1.6 KiB
Bash
Executable File
43 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
. $GVM_ROOT/scripts/functions
|
|
|
|
[[ $1 != "" ]] ||
|
|
display_fatal "Please specifiy the name"
|
|
|
|
target_top=$GVM_ROOT
|
|
target_set_name=$1
|
|
target_set_name_str=$1
|
|
add_gopath="$GVM_ROOT/pkgsets/$gvm_go_name/$1"
|
|
add_path="$GVM_ROOT/pkgsets/$gvm_go_name/$1/bin"
|
|
|
|
if [[ $1 == "--local" ]]; then
|
|
LOCAL_TOP=$(find_local_pkgset)
|
|
if [[ ! -d LOCAL_TOP ]]; then
|
|
LOCAL_TOP=$PWD
|
|
fi
|
|
target_top=$LOCAL_TOP/.gvm_local
|
|
target_set_name="local"
|
|
target_set_name_str="__local__"
|
|
add_gopath="$target_top/pkgsets/$gvm_go_name/$target_set_name"
|
|
add_gopath="$LOCAL_TOP:$add_gopath"
|
|
add_path="$target_top/pkgsets/$gvm_go_name/$target_set_name/bin"
|
|
add_path="$LOCAL_TOP/bin:$add_path"
|
|
fi
|
|
|
|
[[ ! -f "$target_top/environments/$gvm_go_name@$target_set_name" ]] ||
|
|
display_fatal "Packageset already exists!"
|
|
|
|
mkdir -p $target_top/environments ||
|
|
display_fatal "Could not create environments folder"
|
|
mkdir -p $target_top/pkgsets/$gvm_go_name/$target_set_name ||
|
|
display_fatal "Could not create packageset folder"
|
|
cp $GVM_ROOT/environments/$gvm_go_name $target_top/environments/$gvm_go_name@$target_set_name ||
|
|
display_fatal "Could copy environment"
|
|
echo "export gvm_pkgset_name=\"$target_set_name_str\"" >> $target_top/environments/$gvm_go_name@$target_set_name ||
|
|
display_fatal "Could not extend environment"
|
|
echo "export GOPATH; GOPATH=\"$add_gopath:\$GOPATH\"" >> $target_top/environments/$gvm_go_name@$target_set_name ||
|
|
display_fatal "Could not extend environment"
|
|
echo "export PATH; PATH=\"$add_path:\$PATH\"" >> $target_top/environments/$gvm_go_name@$target_set_name ||
|
|
display_fatal "Could not extend environment"
|
|
|